/* ==========================================================================
   Linea — a sideways-scrolling monospace Ghost theme
   ========================================================================== */

/* 1. Tokens
   -------------------------------------------------------------------------- */
:root {
    --lx-bg: #ffffff;
    --lx-fg: #111111;
    --lx-muted: #707070;
    --lx-line: #dcdcdc;
    --lx-soft: #f4f4f4;
    --lx-accent: var(--ghost-accent-color, #e0301e);

    --lx-mono: var(--gh-font-heading, "Roboto Mono"), ui-monospace, SFMono-Regular, Menlo, monospace;
    --lx-sans: var(--gh-font-body, "Roboto"), system-ui, -apple-system, "Segoe UI", sans-serif;

    --lx-gutter: clamp(16px, 2.2vw, 40px);
    --lx-header-h: 76px;
    --lx-card-w: clamp(260px, 23vw, 400px);
    --lx-intro-w: clamp(320px, 34vw, 600px);
    --lx-ease: cubic-bezier(.2, .7, .2, 1);
}

html[data-scheme="dark"] {
    --lx-bg: #0d0d0d;
    --lx-fg: #ededed;
    --lx-muted: #8f8f8f;
    --lx-line: #2b2b2b;
    --lx-soft: #181818;
}

/* 2. Base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
    font-size: clamp(14px, .95vw, 18px);
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--lx-bg);
    color: var(--lx-fg);
    font-family: var(--lx-sans);
    font-weight: 300;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
h1, h2, h3, h4, h5, h6 { margin: 0; font-family: var(--lx-mono); font-weight: 400; letter-spacing: -.01em; line-height: 1.2; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }

:focus-visible { outline: 1px dashed var(--lx-accent); outline-offset: 3px; }

.lx-skip {
    position: absolute; left: -9999px; top: 8px; z-index: 100;
    padding: .5em 1em; background: var(--lx-fg); color: var(--lx-bg);
}
.lx-skip:focus { left: 8px; }

/* Interface text (titles, labels, nav) can be set in capitals */
.is-upper .lx-header,
.is-upper .lx-kicker,
.is-upper .lx-group-label,
.is-upper .lx-card-top,
.is-upper .lx-card-title,
.is-upper .lx-card-bottom,
.is-upper .lx-intro-title,
.is-upper .lx-ul,
.is-upper .lx-progress-label,
.is-upper .lx-article-meta,
.is-upper .lx-end,
.is-upper .lx-error,
.is-upper .lx-subscribe-input::placeholder { text-transform: uppercase; }

/* 3. Underline control — the theme's signature button/link
   A thin resting underline; on hover a second line sweeps across it.
   -------------------------------------------------------------------------- */
.lx-ul {
    --lx-ul-base: var(--lx-line);
    --lx-ul-hover: var(--lx-fg);
    display: inline-flex;
    align-items: center;
    gap: .5em;
    padding-bottom: .35em;
    font-family: var(--lx-mono);
    font-size: .82rem;
    letter-spacing: .04em;
    white-space: nowrap;
    background-image:
        linear-gradient(var(--lx-ul-hover), var(--lx-ul-hover)),
        linear-gradient(var(--lx-ul-base), var(--lx-ul-base));
    background-repeat: no-repeat;
    background-position: 0 100%, 0 100%;
    background-size: 0% 1px, 100% 1px;
    transition: background-size .35s var(--lx-ease), color .2s;
}
.lx-ul:hover,
.lx-ul:focus-visible { background-size: 100% 1px, 100% 1px; }
.lx-ul.is-solid { --lx-ul-base: var(--lx-fg); --lx-ul-hover: var(--lx-accent); }
.lx-ul.is-solid:hover { color: var(--lx-accent); }

/* Labels get a quiet static underline to match */
.lx-group-label,
.lx-kicker,
.lx-card-tags,
.lx-card-lock,
.lx-error-code {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: .4em;
}
.lx-group-label,
.lx-card-tags { text-decoration-color: var(--lx-line); }
.lx-card-lock { text-decoration-color: currentColor; }

/* 4. Header
   -------------------------------------------------------------------------- */
.lx-header {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 2rem;
    height: var(--lx-header-h);
    padding: 0 var(--lx-gutter);
    font-family: var(--lx-mono);
    font-size: .82rem;
    letter-spacing: .04em;
    background: linear-gradient(var(--lx-bg) 60%, transparent);
}

.lx-brand { flex-shrink: 0; display: flex; align-items: center; }
.lx-brand-logo { max-height: 28px; width: auto; }
.lx-brand-text { font-weight: 500; }
html[data-scheme="dark"] .lx-brand-logo { filter: invert(1); }

.lx-nav { margin-left: auto; }
.lx-nav .nav { display: flex; gap: 1.8rem; }
.lx-nav .nav a { position: relative; padding: .3em 0; }
.lx-nav .nav a::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
    background: currentColor; transform: scaleX(0); transform-origin: left;
    transition: transform .3s var(--lx-ease);
}
.lx-nav .nav a:hover::after,
.lx-nav .nav-current a::after { transform: scaleX(1); }

.lx-actions { display: flex; align-items: center; gap: 1.4rem; padding-left: 1.4rem; border-left: 1px solid var(--lx-line); }
.lx-menu-toggle { display: none; }

/* 5. Horizontal layout (index, tag, author)
   -------------------------------------------------------------------------- */
.lx-main { position: relative; }

.lx-track {
    display: flex;
    flex-direction: column;
    padding-top: var(--lx-header-h);
}

.lx-panel,
.lx-group { position: relative; }

/* Intro panel */
.lx-intro {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 3rem;
    padding: 4rem var(--lx-gutter);
}
.lx-intro-body { display: flex; flex-direction: column; gap: 1.2rem; }
.lx-intro-title { font-size: clamp(2.2rem, 3.6vw, 4rem); font-weight: 300; }
.lx-intro-desc { max-width: 34ch; color: var(--lx-muted); font-size: 1.05rem; }
.lx-intro-image { margin: 0; aspect-ratio: 4 / 3; overflow: hidden; }
.lx-intro-image img { width: 100%; height: 100%; object-fit: cover; }
.lx-avatar { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; }
.lx-kicker { display: inline-block; font-family: var(--lx-mono); font-size: .78rem; letter-spacing: .06em; color: var(--lx-muted); }

.lx-social { display: flex; flex-wrap: wrap; gap: 1.2rem; margin-top: .6rem; }
.lx-meta-item { font-family: var(--lx-mono); font-size: .82rem; color: var(--lx-muted); }

/* Subscribe form */
.lx-subscribe { display: flex; flex-direction: column; gap: .8rem; max-width: 30rem; }
.lx-subscribe-label { font-size: .9rem; color: var(--lx-muted); }
.lx-subscribe-row { display: flex; align-items: flex-end; gap: 1.2rem; font-family: var(--lx-mono); }
.lx-subscribe-input {
    flex: 1; min-width: 0; padding: .5em 0;
    font: inherit; font-size: .9rem; letter-spacing: .04em; color: var(--lx-fg);
    border: 0; border-radius: 0; outline: none;
    background-color: transparent;
    background-image:
        linear-gradient(var(--lx-fg), var(--lx-fg)),
        linear-gradient(var(--lx-line), var(--lx-line));
    background-repeat: no-repeat;
    background-position: 0 100%, 0 100%;
    background-size: 0% 1px, 100% 1px;
    transition: background-size .35s var(--lx-ease);
}
.lx-subscribe-input:focus { background-size: 100% 1px, 100% 1px; }
.lx-subscribe-input::placeholder { color: var(--lx-muted); opacity: .7; }
.lx-subscribe-busy, .lx-subscribe-note { display: none; }
.lx-subscribe.loading .lx-subscribe-idle { display: none; }
.lx-subscribe.loading .lx-subscribe-busy { display: inline; }
.lx-subscribe.success .lx-subscribe-ok,
.lx-subscribe.error .lx-subscribe-err { display: block; font-size: .85rem; }
.lx-subscribe-ok { color: #2f9e44; }
.lx-subscribe-err { color: var(--lx-accent); }

/* Groups of cards */
.lx-group { padding: 2rem var(--lx-gutter) 4rem; }
.lx-group-label {
    margin-bottom: 2rem;
    font-size: .78rem;
    font-weight: 400;
    letter-spacing: .08em;
    color: var(--lx-muted);
}

.lx-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 3rem var(--lx-gutter);
}

/* Card */
.lx-card-link { display: flex; flex-direction: column; gap: .9rem; }
.lx-card-top { display: flex; flex-wrap: wrap; gap: .6em; font-family: var(--lx-mono); font-size: .74rem; letter-spacing: .05em; }
.lx-card-lock { color: var(--lx-accent); }
.lx-card-title {
    min-height: 2.4em;
    font-size: 1.05rem;
    font-weight: 300;
    line-height: 1.25;
    color: var(--lx-muted);
    transition: color .25s;
}
.lx-card-link:hover .lx-card-title { color: var(--lx-fg); }

.lx-card-media {
    position: relative;
    margin: 0;
    aspect-ratio: 4 / 5;
    overflow: hidden;
    background: var(--lx-soft);
}
.lx-card-media img {
    width: 100%; height: 100%; object-fit: cover;
    transition: transform .8s var(--lx-ease), filter .6s var(--lx-ease);
}
.is-grayscale .lx-card-media img { filter: grayscale(1) contrast(1.05); }
.lx-card-link:hover .lx-card-media img { transform: scale(1.04); filter: none; }

.lx-card-placeholder {
    position: absolute; inset: 0; display: flex; align-items: flex-end;
    padding: 1.4rem; font-size: .9rem; color: var(--lx-muted);
}

.lx-card-bottom {
    display: flex; justify-content: space-between; gap: 1rem;
    font-family: var(--lx-mono); font-size: .72rem; letter-spacing: .05em;
}
.lx-card-bottom time { color: var(--lx-muted); }

.lx-more-card {
    display: flex; align-items: center; justify-content: center;
    min-height: 12rem; border: 1px dashed var(--lx-line);
}

/* End panel */
.lx-end {
    display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 1.6rem;
    padding: 4rem var(--lx-gutter) 6rem;
    font-family: var(--lx-mono);
}
.lx-end-main { display: flex; flex-direction: column; align-items: flex-start; gap: 1.6rem; }
.lx-end-footer { display: none; }

/* Horizontal mode is active (set by main.js): the row is the whole page,
   so the footer moves into the end panel. The vertical scrollbar stays
   visible and drives the sideways movement. */
.lx-h-active body > .lx-footer { display: none; }
.lx-h-fits, .lx-h-fits body { height: 100%; overflow: hidden; }
.lx-h-active .lx-end { justify-content: space-between; }
.lx-h-active .lx-end-main { margin-top: auto; margin-bottom: auto; }
.lx-h-active .lx-end-footer {
    display: flex; flex-direction: column; gap: .6rem;
    padding-bottom: 3.2rem;
    font-size: .74rem; letter-spacing: .05em; color: var(--lx-muted);
}
.lx-h-active .lx-end-footer a:hover { color: var(--lx-fg); }
.lx-h-active .lx-end-footer .nav { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; margin-bottom: .6rem; color: var(--lx-fg); }
.lx-end-count { font-size: .82rem; color: var(--lx-muted); letter-spacing: .06em; }
.lx-end-links { display: flex; gap: 1.6rem; }
.lx-end-top { font-size: .78rem; color: var(--lx-muted); text-decoration: underline; text-underline-offset: 4px; }

/* Desktop: lay the track out in one long row */
@media (min-width: 900px) and (prefers-reduced-motion: no-preference) {
    .is-horizontal .lx-main { height: 100vh; overflow: hidden; }

    .is-horizontal .lx-track {
        flex-direction: row;
        align-items: stretch;
        width: 100%;
        height: 100vh;
        padding-top: 0;
        /* without JavaScript the row simply scrolls sideways */
        overflow-x: auto;
    }
    .lx-js .is-horizontal .lx-track { width: max-content; overflow: visible; }
    .is-horizontal .lx-track > * { flex-shrink: 0; }

    .is-horizontal .lx-intro {
        width: var(--lx-intro-w);
        padding: calc(var(--lx-header-h) + 8vh) var(--lx-gutter) 10vh;
        border-right: 1px dashed var(--lx-line);
    }
    .is-horizontal .lx-intro-image { max-width: 70%; }

    .is-horizontal .lx-group {
        display: flex;
        align-items: stretch;
        padding: 0 0 0 var(--lx-gutter);
        border-right: 1px dashed var(--lx-line);
    }
    .is-horizontal .lx-group-label {
        align-self: flex-start;
        margin: calc(var(--lx-header-h) + 2rem) calc(var(--lx-gutter) * 2) 0 0;
        writing-mode: vertical-rl;
        transform: rotate(180deg);
    }

    .is-horizontal .lx-cards {
        display: flex;
        align-items: flex-start;
        gap: var(--lx-gutter);
        padding: calc(var(--lx-header-h) + 6vh) var(--lx-gutter) 0 0;
    }
    .is-horizontal .lx-card { flex: 0 0 var(--lx-card-w); }
    /* stagger: every other card sits lower */
    .is-horizontal .lx-card:nth-child(even) { margin-top: 16vh; }
    .is-horizontal .lx-card-media { aspect-ratio: auto; height: 46vh; }
    .is-horizontal .lx-more-card { flex: 0 0 calc(var(--lx-card-w) * .7); align-self: center; height: 46vh; }

    .is-horizontal .lx-end {
        width: clamp(320px, 30vw, 520px);
        padding: var(--lx-header-h) var(--lx-gutter);
    }
}

/* 6. Progress line
   -------------------------------------------------------------------------- */
.lx-progress {
    position: fixed;
    left: var(--lx-gutter);
    right: var(--lx-gutter);
    bottom: 1.6rem;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 1.6rem;
    pointer-events: none;
}
.lx-progress-line { position: relative; flex: 1; height: 1px; background: var(--lx-line); }
.lx-progress-fill {
    position: absolute; inset: 0;
    background: var(--lx-accent);
    transform: scaleX(var(--lx-progress, 0));
    transform-origin: left;
}
.lx-progress-label {
    font-family: var(--lx-mono);
    font-size: .74rem;
    letter-spacing: .06em;
    white-space: nowrap;
}
.post-template .lx-progress-label,
.page-template .lx-progress-label,
.error-template .lx-progress { display: none; }

/* 7. Reading layout (post, page)
   -------------------------------------------------------------------------- */
.lx-reading { padding: calc(var(--lx-header-h) + 8vh) 0 10vh; }

.lx-canvas {
    display: grid;
    grid-template-columns:
        [full-start] minmax(var(--lx-gutter), 1fr)
        [wide-start] minmax(0, 12rem)
        [main-start] min(42rem, calc(100% - var(--lx-gutter) * 2))
        [main-end] minmax(0, 12rem)
        [wide-end] minmax(var(--lx-gutter), 1fr) [full-end];
}
.lx-canvas > * { grid-column: main; }
.lx-canvas > .kg-width-wide { grid-column: wide; }
.lx-canvas > .kg-width-full { grid-column: full; }
.lx-canvas > .kg-width-full img { width: 100%; }

.lx-article-head { row-gap: 1.2rem; margin-bottom: 3.5rem; }
.lx-article-title { font-size: clamp(2rem, 3.4vw, 3.4rem); font-weight: 300; }
.lx-article-excerpt { font-size: 1.25rem; color: var(--lx-muted); }
.lx-article-meta {
    display: flex; flex-wrap: wrap; gap: .4rem 1.4rem;
    padding-top: 1.2rem; border-top: 1px solid var(--lx-line);
    font-family: var(--lx-mono); font-size: .78rem; letter-spacing: .05em; color: var(--lx-muted);
}
.lx-article-meta a { color: var(--lx-fg); }

.lx-article-image { margin: 0 0 3.5rem; }
.lx-article-image img { grid-column: wide; width: 100%; }
.lx-article-image figcaption { grid-column: wide; }

/* Content */
.lx-content { font-size: 1.12rem; line-height: 1.75; font-weight: 300; }
.lx-content > * + * { margin-top: 1.6em; }
.lx-content > :is(h2, h3, h4) { margin-top: 2.4em; }
.lx-content > :is(h2, h3, h4) + * { margin-top: .8em; }
.lx-content h2 { font-size: 1.7rem; }
.lx-content h3 { font-size: 1.35rem; }
.lx-content h4 { font-size: 1.1rem; }
.lx-content a { text-decoration: underline; text-decoration-color: var(--lx-accent); text-underline-offset: 3px; }
.lx-content strong { font-weight: 500; }
.lx-content :is(ul, ol) { padding-left: 1.4em; }
.lx-content ul { list-style: square; }
.lx-content ol { list-style: decimal; }
.lx-content li + li { margin-top: .5em; }
.lx-content blockquote:not([class]) {
    margin-left: 0; margin-right: 0; padding-left: 1.4rem;
    border-left: 2px solid var(--lx-accent);
    font-family: var(--lx-mono); font-size: 1.1rem; line-height: 1.6;
}
.lx-content blockquote.kg-blockquote-alt { font-size: 1.6rem; text-align: center; font-family: var(--lx-mono); color: var(--lx-muted); }
.lx-content hr { width: 100%; height: 0; border: 0; border-top: 1px dashed var(--lx-line); margin: 3em 0; }
.lx-content code:not(pre code) {
    padding: .1em .35em; font-family: var(--lx-mono); font-size: .88em;
    background: var(--lx-soft); border-radius: 3px;
}
.lx-content pre {
    overflow-x: auto; padding: 1.4rem; font-family: var(--lx-mono); font-size: .88rem; line-height: 1.6;
    background: #111; color: #eee; border-radius: 4px;
}
.lx-content table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.lx-content :is(th, td) { padding: .6em .8em; border-bottom: 1px solid var(--lx-line); text-align: left; }
.lx-content figcaption,
.lx-article-image figcaption {
    margin-top: .8rem; font-family: var(--lx-mono); font-size: .76rem; letter-spacing: .03em; color: var(--lx-muted); text-align: center;
}
.lx-content .kg-card { margin-top: 2.2em; }
.lx-content .kg-image { margin: 0 auto; }

.lx-comments { margin-top: 5rem; }

/* Related */
.lx-related { margin-top: 8rem; padding: 4rem var(--lx-gutter) 0; border-top: 1px dashed var(--lx-line); }
.lx-group-label.is-flat { writing-mode: horizontal-tb; transform: none; }
.lx-related-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--lx-gutter); }
.lx-related .lx-card:nth-child(2) { margin-top: 4rem; }

/* 8. Error
   -------------------------------------------------------------------------- */
.lx-error {
    min-height: 100vh;
    display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 1.6rem;
    padding: var(--lx-header-h) var(--lx-gutter);
}
.lx-error-code { font-family: var(--lx-mono); color: var(--lx-accent); letter-spacing: .08em; }
.lx-error-title { font-size: clamp(2rem, 5vw, 4.4rem); font-weight: 300; }

/* 9. Footer
   -------------------------------------------------------------------------- */
.lx-footer {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem 2rem;
    padding: 3rem var(--lx-gutter) 5rem;
    border-top: 1px solid var(--lx-line);
    font-family: var(--lx-mono); font-size: .76rem; letter-spacing: .05em; color: var(--lx-muted);
}
.lx-footer-nav .nav { display: flex; flex-wrap: wrap; gap: 1.4rem; }
.lx-footer a:hover { color: var(--lx-fg); }

/* 10. Small screens
   -------------------------------------------------------------------------- */
@media (max-width: 899px) {
    :root { --lx-header-h: 64px; }

    .lx-header { gap: 1rem; }
    .lx-actions { margin-left: auto; padding-left: 0; border-left: 0; gap: 1rem; }
    .lx-hide-sm { display: none; }
    .lx-menu-toggle { display: inline-flex; }

    .lx-nav {
        position: fixed;
        inset: var(--lx-header-h) 0 0 0;
        margin: 0;
        padding: 2rem var(--lx-gutter);
        background: var(--lx-bg);
        opacity: 0;
        visibility: hidden;
        transform: translateY(-8px);
        transition: opacity .25s, transform .25s var(--lx-ease), visibility 0s .25s;
    }
    .lx-nav .nav { flex-direction: column; gap: 1.2rem; font-size: 1.4rem; }
    .lx-menu-open .lx-nav { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
    .lx-menu-open { overflow: hidden; }

    .lx-intro { padding-top: 3rem; padding-bottom: 3rem; }
    .lx-progress { display: none; }

    .lx-cards { grid-template-columns: 1fr 1fr; gap: 2.4rem 1rem; }
    .lx-cards .lx-card:nth-child(even) { margin-top: 3rem; }
    .lx-card-title { font-size: .95rem; }

    .lx-related-grid { grid-template-columns: 1fr; }
    .lx-related .lx-card:nth-child(2) { margin-top: 0; }
}

@media (max-width: 520px) {
    .lx-cards { grid-template-columns: 1fr; }
    .lx-cards .lx-card:nth-child(even) { margin-top: 0; }
    .lx-card-bottom { font-size: .68rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; }
}
