/* ==========================================================================
   ThreadNotes — core design system
   Tokens, reset, primitives, chrome (header/footer), utilities.
   Every other stylesheet consumes from here.
   ========================================================================== */

/* --- Reset ---------------------------------------------------------------- */

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    scroll-padding-top: 6rem;
}

img,
svg,
canvas {
    display: block;
    max-width: 100%;
}

img {
    height: auto;
}

button,
input,
textarea,
select {
    font: inherit;
    color: inherit;
}

button {
    background: none;
    border: 0;
    cursor: pointer;
}

ul[class],
ol[class] {
    list-style: none;
}

a {
    color: inherit;
    text-decoration: none;
}

/* --- Tokens --------------------------------------------------------------- */

:root {
    /* Surfaces */
    --bg: oklch(13% 0.02 275);
    --bg-raise: oklch(17% 0.025 275);
    --surface: oklch(21% 0.03 275 / 0.6);
    --surface-solid: oklch(19% 0.028 275);
    --line: oklch(35% 0.03 275 / 0.5);
    --line-strong: oklch(45% 0.04 275 / 0.7);

    /* Ink */
    --text: oklch(97% 0.01 275);
    --text-dim: oklch(74% 0.02 275);
    --text-faint: oklch(58% 0.02 275);

    /* Accent */
    --violet: oklch(65% 0.24 295);
    --violet-soft: oklch(72% 0.18 295);
    --cyan: oklch(80% 0.16 205);
    --cyan-soft: oklch(85% 0.11 205);
    --grad: linear-gradient(110deg, var(--violet), var(--cyan));
    --grad-soft: linear-gradient(110deg, oklch(65% 0.24 295 / 0.16), oklch(80% 0.16 205 / 0.16));

    /* Status */
    --ok: oklch(78% 0.17 155);
    --warn: oklch(82% 0.16 85);
    --info: var(--cyan);

    /* Glow + elevation (valid colour syntax — the old hsl(oklch) tokens were dropped by the parser) */
    --glow-violet: 0 0 40px oklch(65% 0.24 295 / 0.35);
    --glow-cyan: 0 0 40px oklch(80% 0.16 205 / 0.3);
    --shadow-1: 0 1px 2px oklch(0% 0 0 / 0.4), 0 2px 6px oklch(0% 0 0 / 0.25);
    --shadow-2: 0 2px 4px oklch(0% 0 0 / 0.35), 0 8px 24px oklch(0% 0 0 / 0.35);
    --shadow-3: 0 4px 8px oklch(0% 0 0 / 0.35), 0 20px 50px oklch(0% 0 0 / 0.45);

    /* Type */
    --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-display: 'Space Grotesk', 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

    --step--1: clamp(0.83rem, 0.79rem + 0.2vw, 0.94rem);
    --step-0: clamp(1.0625rem, 1.02rem + 0.22vw, 1.125rem);
    --step-1: clamp(1.25rem, 1.16rem + 0.45vw, 1.5rem);
    --step-2: clamp(1.5rem, 1.32rem + 0.9vw, 2rem);
    --step-3: clamp(1.9rem, 1.55rem + 1.75vw, 2.9rem);
    --step-4: clamp(2.4rem, 1.7rem + 3.4vw, 4.2rem);
    --step-5: clamp(2.9rem, 1.75rem + 5.6vw, 5.6rem);

    /* Space */
    --gap-xs: 0.5rem;
    --gap-sm: 0.875rem;
    --gap: 1.25rem;
    --gap-lg: 2rem;
    --gap-xl: 3rem;
    --section-y: clamp(4rem, 9vw, 8.5rem);
    --gutter: clamp(1.15rem, 4vw, 3rem);
    --shell: 1200px;

    /* Shape */
    --r-sm: 10px;
    --r: 16px;
    --r-lg: 24px;
    --r-pill: 999px;

    /* Motion */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
    --dur-1: 180ms;
    --dur-2: 380ms;
    --dur-3: 700ms;

    --header-h: 4.5rem;
}

/* --- Base ----------------------------------------------------------------- */

body {
    font-family: var(--font-body);
    font-size: var(--step-0);
    line-height: 1.65;
    color: var(--text);
    background-color: var(--bg);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* Ambient field: two slow aurora blooms + fine grain. Fixed so it never scrolls. */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -2;
    background:
        radial-gradient(50rem 34rem at 18% -8%, oklch(65% 0.24 295 / 0.22), transparent 65%),
        radial-gradient(44rem 30rem at 88% 8%, oklch(80% 0.16 205 / 0.14), transparent 62%),
        radial-gradient(60rem 40rem at 50% 105%, oklch(65% 0.24 295 / 0.1), transparent 68%);
    animation: aurora 24s var(--ease-in-out) infinite alternate;
}

body::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: 0.035;
    background-image: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 400"%3E%3Cfilter id="n"%3E%3CfeTurbulence type="fractalNoise" baseFrequency="0.8" numOctaves="3"/%3E%3C/filter%3E%3Crect width="100%25" height="100%25" filter="url(%23n)"/%3E%3C/svg%3E');
}

@keyframes aurora {
    from { transform: translate3d(0, 0, 0) scale(1); }
    to { transform: translate3d(-2%, 1.5%, 0) scale(1.08); }
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.08;
    letter-spacing: -0.025em;
    text-wrap: balance;
}

h1 { font-size: var(--step-5); }
h2 { font-size: var(--step-4); }
h3 { font-size: var(--step-2); }
h4 { font-size: var(--step-1); }

p { text-wrap: pretty; }

::selection {
    background: oklch(65% 0.24 295 / 0.4);
    color: var(--text);
}

:focus-visible {
    outline: 2px solid var(--cyan);
    outline-offset: 3px;
    border-radius: 4px;
}

/* --- Layout primitives ---------------------------------------------------- */

.shell {
    width: 100%;
    max-width: var(--shell);
    margin-inline: auto;
    padding-inline: var(--gutter);
}

.shell--wide { max-width: 1440px; }
.shell--narrow { max-width: 780px; }

.section {
    padding-block: var(--section-y);
    position: relative;
}

/* Below-the-fold sections skip layout/paint until near the viewport. */
.section--defer {
    content-visibility: auto;
    contain-intrinsic-size: auto 700px;
}

.stack > * + * { margin-top: var(--gap); }

.section-head {
    max-width: 46rem;
    margin-bottom: clamp(2.5rem, 5vw, 4rem);
}

.section-head--center {
    margin-inline: auto;
    text-align: center;
}

.section-head p {
    margin-top: var(--gap);
    color: var(--text-dim);
    font-size: var(--step-1);
    line-height: 1.55;
}

/* --- Text utilities ------------------------------------------------------- */

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--cyan-soft);
    margin-bottom: var(--gap);
}

.eyebrow::before {
    content: '';
    width: 1.75rem;
    height: 1px;
    background: var(--grad);
}

.eyebrow--center::before { display: none; }

.grad-text {
    background: var(--grad);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    /* Gradient text can clip descenders in some engines. */
    padding-bottom: 0.08em;
}

.lead {
    font-size: var(--step-1);
    color: var(--text-dim);
    line-height: 1.55;
}

.dim { color: var(--text-dim); }

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translate(-50%, -150%);
    z-index: 200;
    padding: 0.75rem 1.5rem;
    background: var(--violet);
    color: oklch(100% 0 0);
    border-radius: 0 0 var(--r-sm) var(--r-sm);
    font-weight: 600;
    transition: transform var(--dur-1) var(--ease-out);
}

.skip-link:focus {
    transform: translate(-50%, 0);
}

/* --- Buttons -------------------------------------------------------------- */

.btn {
    --btn-bg: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    min-height: 2.875rem;
    padding: 0.75rem 1.6rem;
    border-radius: var(--r-pill);
    font-weight: 600;
    font-size: var(--step-0);
    letter-spacing: -0.01em;
    white-space: nowrap;
    position: relative;
    isolation: isolate;
    /* Clips the .btn--primary sheen sweep to the pill. */
    overflow: hidden;
    transition: transform var(--dur-1) var(--ease-out),
                box-shadow var(--dur-2) var(--ease-out),
                background-color var(--dur-1) var(--ease-out),
                border-color var(--dur-1) var(--ease-out);
}

.btn:active { transform: translateY(1px) scale(0.99); }

.btn--primary {
    color: oklch(14% 0.02 275);
    background: var(--grad);
    box-shadow: 0 6px 22px oklch(65% 0.24 295 / 0.32);
}

/* Sheen that sweeps across on hover. */
.btn--primary::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: inherit;
    background: linear-gradient(110deg, transparent 20%, oklch(100% 0 0 / 0.45) 50%, transparent 80%);
    transform: translateX(-120%);
    transition: transform var(--dur-3) var(--ease-out);
}

.btn--ghost {
    color: var(--text);
    border: 1px solid var(--line-strong);
    background: oklch(100% 0 0 / 0.03);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.btn--lg {
    min-height: 3.375rem;
    padding: 0.95rem 2.1rem;
    font-size: var(--step-1);
}

.btn--sm {
    min-height: 2.5rem;
    padding: 0.5rem 1.1rem;
    font-size: var(--step--1);
}

.btn__arrow {
    transition: transform var(--dur-2) var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
    .btn--primary:not([aria-disabled='true']):hover {
        transform: translateY(-2px);
        box-shadow: 0 12px 34px oklch(65% 0.24 295 / 0.45);
    }

    .btn--primary:not([aria-disabled='true']):hover::after { transform: translateX(120%); }

    .btn--ghost:not([aria-disabled='true']):hover {
        border-color: var(--cyan);
        background: oklch(80% 0.16 205 / 0.1);
        transform: translateY(-2px);
    }

    .btn:not([aria-disabled='true']):hover .btn__arrow { transform: translateX(4px); }
}

/* --- Form fields ---------------------------------------------------------- */
/* Shared by the auth pages and the forum composer. */

.field {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.field label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dim);
    letter-spacing: 0.01em;
}

.field input {
    width: 100%;
    min-height: 3rem;
    padding: 0.75rem 1rem;
    border-radius: var(--r-sm);
    border: 1px solid var(--line-strong);
    background: oklch(11% 0.02 275 / 0.75);
    color: var(--text);
    font-size: 1rem;
    transition: border-color var(--dur-1) var(--ease-out),
                box-shadow var(--dur-1) var(--ease-out),
                background-color var(--dur-1) var(--ease-out);
}

.field input::placeholder { color: var(--text-faint); }

.field input:focus {
    outline: none;
    border-color: var(--cyan);
    background: oklch(13% 0.02 275);
    box-shadow: 0 0 0 3px oklch(80% 0.16 205 / 0.18);
}

/* Only flag a field once it has actually been marked invalid by JS. */
.field.is-invalid input {
    border-color: oklch(70% 0.19 25);
    box-shadow: 0 0 0 3px oklch(70% 0.19 25 / 0.16);
}

.field__hint {
    font-size: 0.8rem;
    color: var(--text-faint);
}

.field.is-invalid .field__hint { color: oklch(78% 0.16 25); }

/* --- Gated controls ------------------------------------------------------- */

/* Early access and sign-in are not open yet. These read as buttons but do
   nothing; aria-disabled (rather than the disabled attribute) keeps them
   focusable so keyboard users can reach the explanation too. */

.btn[aria-disabled='true'],
.locked {
    cursor: not-allowed;
    opacity: 0.55;
}

.btn[aria-disabled='true']:active { transform: none; }

/* Kill the sweeping sheen on a gated primary button. */
.btn--primary[aria-disabled='true'] {
    box-shadow: none;
}

.btn--primary[aria-disabled='true']::after { display: none; }

.locked {
    color: var(--text-faint);
    text-decoration: none;
}

/* Tooltip wrapper. It sits outside .btn because .btn is overflow:hidden (to
   clip the sheen) and .btn--primary already uses ::after. */
.tip {
    position: relative;
    display: inline-flex;
}

.tip::after {
    content: attr(data-tip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 0.6rem);
    z-index: 120;
    transform: translate(-50%, 0.3rem);
    padding: 0.45rem 0.8rem;
    border-radius: 8px;
    background: oklch(24% 0.03 275);
    border: 1px solid var(--line-strong);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 0.78rem;
    font-weight: 500;
    line-height: 1.3;
    letter-spacing: 0;
    text-transform: none;
    white-space: nowrap;
    box-shadow: var(--shadow-2);
}

.tip::before {
    content: '';
    position: absolute;
    left: 50%;
    bottom: calc(100% + 0.32rem);
    z-index: 121;
    width: 9px;
    height: 9px;
    transform: translate(-50%, 0.3rem) rotate(45deg);
    background: oklch(24% 0.03 275);
    border-right: 1px solid var(--line-strong);
    border-bottom: 1px solid var(--line-strong);
}

.tip::after,
.tip::before {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--dur-1) var(--ease-out),
                transform var(--dur-1) var(--ease-out),
                visibility var(--dur-1);
}

.tip:hover::after,
.tip:focus-within::after {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
}

.tip:hover::before,
.tip:focus-within::before {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0) rotate(45deg);
}

/* Header buttons sit at the top of the page, so their tooltip drops down. */
.tip--below::after {
    bottom: auto;
    top: calc(100% + 0.6rem);
    transform: translate(-50%, -0.3rem);
}

.tip--below::before {
    bottom: auto;
    top: calc(100% + 0.32rem);
    transform: translate(-50%, -0.3rem) rotate(225deg);
}

.tip--below:hover::before,
.tip--below:focus-within::before {
    transform: translate(-50%, 0) rotate(225deg);
}

/* Where a button goes full width, its wrapper has to as well. */
.tip--block,
.tip--block > .btn { width: 100%; }

/* --- Cards ---------------------------------------------------------------- */

.card {
    position: relative;
    padding: clamp(1.4rem, 2.6vw, 2rem);
    border-radius: var(--r-lg);
    background: var(--surface);
    border: 1px solid var(--line);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    transition: transform var(--dur-2) var(--ease-out),
                border-color var(--dur-2) var(--ease-out),
                box-shadow var(--dur-2) var(--ease-out);
}

/* Gradient rim that lights up on hover, drawn as a masked pseudo-border. */
.card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: var(--grad);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity var(--dur-2) var(--ease-out);
    pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
    .card:hover {
        transform: translateY(-6px);
        box-shadow: var(--shadow-3);
    }

    .card:hover::before { opacity: 0.7; }
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.7rem;
    border-radius: var(--r-pill);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    border: 1px solid var(--line-strong);
    background: oklch(100% 0 0 / 0.04);
    color: var(--text-dim);
}

.pill__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* --- Header --------------------------------------------------------------- */

.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background-color var(--dur-2) var(--ease-out),
                border-color var(--dur-2) var(--ease-out),
                backdrop-filter var(--dur-2) var(--ease-out);
    border-bottom: 1px solid transparent;
}

.site-header.is-stuck {
    background: oklch(13% 0.02 275 / 0.72);
    border-bottom-color: var(--line);
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
}

.site-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--gap);
    height: var(--header-h);
    transition: height var(--dur-2) var(--ease-out);
}

.site-header.is-stuck .site-header__inner { height: 3.75rem; }

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    flex-shrink: 0;
}

.brand__mark {
    width: 1.85rem;
    height: 1.85rem;
    flex-shrink: 0;
}

.nav {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.nav__link {
    display: block;
    padding: 0.55rem 0.85rem;
    border-radius: var(--r-sm);
    color: var(--text-dim);
    font-size: 0.95rem;
    font-weight: 500;
    position: relative;
    transition: color var(--dur-1) var(--ease-out), background-color var(--dur-1) var(--ease-out);
}

.nav__link:hover { color: var(--text); }

.nav__link[aria-current='page'] { color: var(--text); }

.nav__link[aria-current='page']::after {
    content: '';
    position: absolute;
    left: 0.85rem;
    right: 0.85rem;
    bottom: 0.25rem;
    height: 2px;
    border-radius: 2px;
    background: var(--grad);
}

.nav__group { position: relative; }

.nav__toggle {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.nav__chev {
    transition: transform var(--dur-1) var(--ease-out);
}

.nav__menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 50%;
    min-width: 15rem;
    padding: 0.4rem;
    border-radius: var(--r);
    background: oklch(17% 0.025 275 / 0.96);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-3);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, -0.5rem);
    transition: opacity var(--dur-1) var(--ease-out),
                transform var(--dur-1) var(--ease-out),
                visibility var(--dur-1);
}

.nav__group:hover .nav__menu,
.nav__group:focus-within .nav__menu,
.nav__menu.is-open {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
}

.nav__group:hover .nav__chev,
.nav__group:focus-within .nav__chev { transform: rotate(180deg); }

.nav__menu a {
    display: block;
    padding: 0.6rem 0.75rem;
    border-radius: var(--r-sm);
    color: var(--text-dim);
    font-size: 0.9rem;
    transition: background-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out);
}

.nav__menu a:hover {
    background: oklch(100% 0 0 / 0.06);
    color: var(--text);
}

.nav__menu small {
    display: block;
    font-size: 0.75rem;
    color: var(--text-faint);
}

.nav__menu .locked {
    display: block;
    padding: 0.6rem 0.75rem;
    border-radius: var(--r-sm);
    font-size: 0.9rem;
}

.drawer__locked {
    display: block;
    padding: 0.9rem 0.75rem;
    border-bottom: 1px solid var(--line);
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 600;
    opacity: 0;
    transform: translateX(1rem);
}

.drawer.is-visible .drawer__locked {
    animation: drawer-in var(--dur-2) var(--ease-out) forwards;
    animation-delay: calc(var(--i, 0) * 45ms + 80ms);
}

.drawer__locked em {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-style: normal;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-faint);
    margin-left: 0.4rem;
    vertical-align: middle;
}

.header__actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-shrink: 0;
}

.burger {
    display: none;
    width: 2.75rem;
    height: 2.75rem;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-sm);
    border: 1px solid var(--line-strong);
    background: oklch(100% 0 0 / 0.03);
}

.burger__box {
    display: block;
    width: 1.15rem;
    height: 0.7rem;
    position: relative;
}

.burger__box span {
    position: absolute;
    left: 0;
    width: 100%;
    height: 1.5px;
    border-radius: 2px;
    background: var(--text);
    transition: transform var(--dur-2) var(--ease-out), opacity var(--dur-1) var(--ease-out);
}

.burger__box span:nth-child(1) { top: 0; }
.burger__box span:nth-child(2) { top: 50%; transform: translateY(-50%); }
.burger__box span:nth-child(3) { bottom: 0; }

.burger[aria-expanded='true'] .burger__box span:nth-child(1) {
    transform: translateY(0.335rem) rotate(45deg);
}

.burger[aria-expanded='true'] .burger__box span:nth-child(2) { opacity: 0; }

.burger[aria-expanded='true'] .burger__box span:nth-child(3) {
    transform: translateY(-0.335rem) rotate(-45deg);
}

/* --- Mobile drawer -------------------------------------------------------- */

.drawer {
    position: fixed;
    inset: 0;
    z-index: 150;
    display: none;
}

.drawer.is-open { display: block; }

.drawer__scrim {
    position: absolute;
    inset: 0;
    background: oklch(8% 0.02 275 / 0.72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    transition: opacity var(--dur-2) var(--ease-out);
}

.drawer.is-visible .drawer__scrim { opacity: 1; }

.drawer__panel {
    position: absolute;
    inset-block: 0;
    right: 0;
    width: min(22rem, 88vw);
    padding: 1.25rem var(--gutter) 2rem;
    background: oklch(15% 0.025 275);
    border-left: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: var(--gap-lg);
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: translateX(100%);
    transition: transform var(--dur-2) var(--ease-out);
}

.drawer.is-visible .drawer__panel { transform: translateX(0); }

.drawer__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 2.75rem;
}

.drawer__close {
    width: 2.75rem;
    height: 2.75rem;
    display: grid;
    place-items: center;
    border-radius: var(--r-sm);
    border: 1px solid var(--line-strong);
    color: var(--text-dim);
}

.drawer__nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.drawer__nav a {
    display: block;
    padding: 0.9rem 0.75rem;
    border-radius: var(--r-sm);
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-dim);
    border-bottom: 1px solid var(--line);
    opacity: 0;
    transform: translateX(1rem);
}

.drawer.is-visible .drawer__nav a {
    animation: drawer-in var(--dur-2) var(--ease-out) forwards;
    animation-delay: calc(var(--i, 0) * 45ms + 80ms);
}

.drawer__nav a[aria-current='page'] { color: var(--cyan); }

.drawer__label {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-faint);
    padding: 1rem 0.75rem 0.35rem;
}

@keyframes drawer-in {
    to { opacity: 1; transform: translateX(0); }
}

.drawer__cta { margin-top: auto; }
.drawer__cta .btn { width: 100%; }

/* --- Footer --------------------------------------------------------------- */

.site-footer {
    position: relative;
    padding-block: clamp(3rem, 6vw, 5rem) 2rem;
    border-top: 1px solid var(--line);
    background: oklch(11% 0.02 275 / 0.6);
}

.site-footer::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: min(60rem, 90%);
    height: 1px;
    background: var(--grad);
    opacity: 0.55;
}

.footer__grid {
    display: grid;
    grid-template-columns: 1.5fr repeat(3, 1fr);
    gap: var(--gap-xl) var(--gap-lg);
    margin-bottom: var(--gap-xl);
}

.footer__tagline {
    margin-top: 0.75rem;
    color: var(--text-dim);
    font-size: 0.95rem;
    max-width: 24rem;
}

.footer__col h4 {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-faint);
    margin-bottom: 1rem;
}

.footer__col ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.footer__col a {
    display: inline-block;
    color: var(--text-dim);
    font-size: 0.95rem;
    transition: color var(--dur-1) var(--ease-out);
}

/* Standalone nav links need a comfortable touch target; inline links inside a
   sentence are exempt (WCAG 2.5.8) and stay as they are. */
@media (pointer: coarse) {
    .footer__col ul { gap: 0.15rem; }

    .footer__col a {
        padding-block: 0.6rem;
        min-height: 44px;
    }
}

.footer__col a:hover { color: var(--cyan); }

.footer__bottom {
    display: flex;
    flex-wrap: wrap;
    gap: var(--gap);
    align-items: center;
    justify-content: space-between;
    padding-top: 1.75rem;
    border-top: 1px solid var(--line);
    color: var(--text-faint);
    font-size: 0.875rem;
}

.footer__social {
    display: flex;
    gap: 0.5rem;
}

.footer__social a {
    width: 2.5rem;
    height: 2.5rem;
    display: grid;
    place-items: center;
    border-radius: var(--r-sm);
    border: 1px solid var(--line);
    color: var(--text-dim);
    transition: color var(--dur-1) var(--ease-out),
                border-color var(--dur-1) var(--ease-out),
                transform var(--dur-1) var(--ease-out);
}

.footer__social a:hover {
    color: var(--cyan);
    border-color: var(--cyan);
    transform: translateY(-2px);
}

/* --- Backdrop-filter fallback ---------------------------------------------- */

/* Where blur is unavailable the translucent surfaces let text show through.
   Fall back to opaque backgrounds so contrast holds. */
@supports not ((backdrop-filter: blur(4px)) or (-webkit-backdrop-filter: blur(4px))) {
    .site-header.is-stuck { background: oklch(13% 0.02 275 / 0.97); }
    .card,
    .panel,
    .post,
    .legal__toc,
    .faq details { background: var(--surface-solid); }
    .nav__menu { background: oklch(17% 0.025 275); }
    .drawer__scrim { background: oklch(8% 0.02 275 / 0.92); }
    .btn--ghost { background: oklch(20% 0.025 275); }
}

/* --- Scroll reveal (driven by js/reveal.js) -------------------------------- */

[data-reveal] {
    opacity: 0;
    transform: translateY(1.75rem);
    transition: opacity var(--dur-3) var(--ease-out), transform var(--dur-3) var(--ease-out);
    transition-delay: var(--reveal-delay, 0ms);
}

[data-reveal='left'] { transform: translateX(-1.75rem); }
[data-reveal='right'] { transform: translateX(1.75rem); }
[data-reveal='scale'] { transform: scale(0.94); }

[data-reveal].is-revealed {
    opacity: 1;
    transform: none;
}

/* --- Responsive ----------------------------------------------------------- */

@media (max-width: 900px) {
    .footer__grid { grid-template-columns: 1fr 1fr; }
    .footer__col:first-child { grid-column: 1 / -1; }
}

@media (max-width: 860px) {
    .nav,
    .header__actions .btn,
    /* The wrapper has to go too: its tooltip is absolutely positioned, and a
       hidden absolute box still counts toward scrollable overflow. */
    .header__actions .tip { display: none; }

    .burger { display: inline-flex; }
}

@media (max-width: 560px) {
    .footer__grid { grid-template-columns: 1fr; gap: var(--gap-lg); }
    .footer__bottom { justify-content: center; text-align: center; }
}

/* --- Reduced motion ------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    [data-reveal] {
        opacity: 1 !important;
        transform: none !important;
    }
}
