/*
 * Forethought Studio - shared design system.
 *
 * Single source of truth for every studio-level page (home, contact, privacy,
 * terms). Previously each page carried its own inline <style> block, which is
 * how the site ended up running two unrelated palettes at once: the home page
 * on #6b8afd and the legal pages on a #667eea/#764ba2 gradient. Linking one
 * stylesheet makes that drift impossible rather than merely discouraged.
 *
 * Voice: a terminal manifest. Monospace throughout, hairline rules, square
 * corners, one amber accent. No shadows, no blur, no gradients, no scroll
 * animation. Both themes are contrast-checked to WCAG AA for body text.
 *
 * Long-form legal prose is the one exception to the monospace rule: it sets in
 * the reading face (--font-read), because several thousand words of monospace
 * is a legibility cost with no identity benefit. Chrome, headings and metadata
 * on those pages stay mono, so the pages still read as part of the same site.
 */

/* ── Typeface ─────────────────────────────────────────────────────────────
   Self-hosted rather than loaded from the Google Fonts CDN: the CDN exposes
   visitor IP addresses to a third party on every page load, which is a
   needless GDPR liability for 42KB of font. Variable weight axis 100-800. */
@font-face {
    font-family: 'JetBrains Mono';
    src: url('assets/fonts/jetbrains-mono-latin.woff2') format('woff2');
    font-weight: 100 800;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
                   U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
                   U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'JetBrains Mono';
    src: url('assets/fonts/jetbrains-mono-latin-ext.woff2') format('woff2');
    font-weight: 100 800;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
                   U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF,
                   U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ── Tokens ───────────────────────────────────────────────────────────── */
:root {
    --bg:        #f7f5f0;
    --panel:     #efece4;
    --panel-alt: #eae6dc;
    --line:      #d8d3c6;
    --fg:        #1a1814;
    --fg-dim:    #6b6659;
    --accent:    #8a5a0b;
    --ok:        #3f6b28;
    --sel:       rgba(138, 90, 11, 0.16);

    --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
    --font-read: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

    --measure: 940px;
}

[data-theme="dark"] {
    --bg:        #100f0d;
    --panel:     #16150f;
    --panel-alt: #1a1813;
    --line:      #2c2a24;
    --fg:        #d6d1c4;
    --fg-dim:    #837e71;
    --accent:    #d8a02a;
    --ok:        #7fae5e;
    --sel:       rgba(216, 160, 42, 0.22);
}

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

html { scroll-behavior: smooth; }

body {
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

::selection { background: var(--sel); }

a { color: var(--fg); text-decoration: none; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.wrap {
    max-width: var(--measure);
    margin: 0 auto;
    padding: 0 32px;
}

.dim { color: var(--fg-dim); }
.accent { color: var(--accent); }

/* ── Masthead ─────────────────────────────────────────────────────────── */
.site-head { border-bottom: 1px solid var(--line); }

.bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    padding: 16px 0;
}

.bar .brand {
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--fg);
}
.bar .brand .sep { color: var(--accent); }

.bar-right { display: flex; align-items: center; gap: 20px; }

.nav-links { display: flex; gap: 20px; list-style: none; }
.nav-links a { color: var(--fg-dim); font-size: 12.5px; }
.nav-links a::before { content: '/'; color: var(--line); margin-right: 3px; }
.nav-links a:hover, .nav-links a:focus-visible { color: var(--accent); }

.theme-toggle {
    background: none;
    border: 1px solid var(--line);
    border-radius: 0;
    cursor: pointer;
    padding: 4px 12px;
    font-family: inherit;
    font-size: 12.5px;
    letter-spacing: 0.06em;
    text-transform: lowercase;
    color: var(--fg-dim);
    transition: color 0.12s linear, border-color 0.12s linear;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }

/* Hamburger: three rules, no rounding, no rotation gimmick. */
.hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 30px;
    height: 30px;
    background: none;
    border: 1px solid var(--line);
    cursor: pointer;
    padding: 0 6px;
}
.hamburger span { display: block; height: 1px; background: var(--fg-dim); }
.hamburger[aria-expanded="true"] span { background: var(--accent); }

/* ── Page head block ──────────────────────────────────────────────────── */
.head { padding: 76px 0 60px; border-bottom: 1px solid var(--line); }

.head h1 {
    font-size: clamp(1.5rem, 3.6vw, 2.45rem);
    font-weight: 700;
    line-height: 1.28;
    letter-spacing: -0.03em;
    max-width: 24ch;
}

/* Keeps the caret bound to the final word so it never wraps alone onto a
   line of its own at narrow widths. */
.head .nb { white-space: nowrap; }

.head .cursor {
    display: inline-block;
    width: 0.56em;
    height: 1.02em;
    background: var(--accent);
    vertical-align: -0.16em;
    margin-left: 4px;
    animation: blink 1.15s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.head .standfirst {
    margin-top: 26px;
    max-width: 68ch;
    color: var(--fg-dim);
    font-size: 13.5px;
}
.head .standfirst .fg { color: var(--fg); }

.kv {
    margin-top: 34px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 34px;
    font-size: 12.5px;
}
.kv b { color: var(--fg-dim); font-weight: 400; }

/* ── Sections ─────────────────────────────────────────────────────────── */
.band { padding: 54px 0; border-bottom: 1px solid var(--line); }

.shead {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 26px;
    font-size: 12.5px;
    color: var(--fg-dim);
}
.shead::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.shead b { color: var(--accent); font-weight: 500; }

/* ── Manifest (the work) ──────────────────────────────────────────────── */
.manifest { border: 1px solid var(--line); }

.row {
    display: grid;
    grid-template-columns: 128px 108px 1fr 84px;
    gap: 20px;
    align-items: baseline;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
    transition: background-color 0.12s linear;
}
.row:last-child { border-bottom: none; }

.row-head {
    background: var(--panel);
    font-size: 12.5px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--fg-dim);
}

a.row:hover, a.row:focus-visible { background: var(--panel-alt); }
a.row:hover .nm, a.row:focus-visible .nm { color: var(--accent); }
a.row:hover .ds, a.row:focus-visible .ds { color: var(--fg); }

.row .nm { font-weight: 700; letter-spacing: -0.01em; }
.row .pf { color: var(--fg-dim); font-size: 12.5px; }
.row .ds { color: var(--fg-dim); font-size: 12.5px; transition: color 0.12s linear; }
.row .st { font-size: 12.5px; text-align: right; }

.st .live { color: var(--ok); white-space: nowrap; }
.st .live::before { content: '\25CF'; margin-right: 5px; font-size: 9px; vertical-align: 1px; }

.note { margin-top: 18px; font-size: 12.5px; color: var(--fg-dim); }
.note a { color: var(--fg); border-bottom: 1px solid var(--line); }
.note a:hover { color: var(--accent); border-color: var(--accent); }

/* ── Prose (short-form, stays mono) ───────────────────────────────────── */
.prose { max-width: 74ch; font-size: 13.5px; }
.prose p { color: var(--fg-dim); }
.prose p + p { margin-top: 16px; }
.prose .lead { color: var(--fg); font-size: 15px; }
.prose .arr { color: var(--accent); }
.prose code {
    color: var(--accent);
    background: var(--panel);
    border: 1px solid var(--line);
    padding: 1px 6px;
}

/* ── Link rows ────────────────────────────────────────────────────────── */
.link-rows a {
    display: block;
    padding: 13px 0;
    border-bottom: 1px solid var(--line);
    font-size: 13.5px;
    transition: color 0.12s linear, padding-left 0.12s linear;
}
.link-rows a:first-child { border-top: 1px solid var(--line); }
.link-rows a:hover, .link-rows a:focus-visible { color: var(--accent); padding-left: 8px; }
.link-rows a .idx { color: var(--fg-dim); margin-right: 14px; }

/* ── Footer ───────────────────────────────────────────────────────────── */
.site-foot {
    padding: 26px 0 48px;
    display: flex;
    justify-content: space-between;
    gap: 12px 20px;
    flex-wrap: wrap;
    font-size: 12.5px;
    color: var(--fg-dim);
}
.site-foot a { color: var(--fg-dim); }
.site-foot a:hover { color: var(--accent); }

/* ── Long-form documents (privacy, terms) ─────────────────────────────── */
.doc { padding: 56px 0 72px; }

.doc-back {
    display: inline-block;
    margin-bottom: 32px;
    font-size: 12.5px;
    color: var(--fg-dim);
}
.doc-back:hover { color: var(--accent); }

.doc-body { max-width: 76ch; }

.doc-body h1 {
    font-family: var(--font-mono);
    font-size: clamp(1.5rem, 3.4vw, 2.1rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.2;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--line);
}

.doc-body h2 {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--fg);
    margin: 40px 0 12px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
}
.doc-body h2::before { content: '# '; color: var(--accent); }

/* A section heading straight after the title would draw a second rule a few
   pixels below the title's own, framing an empty band. Only fires when nothing
   sits between them, so documents that open with a date or standfirst keep the
   normal separator. */
.doc-body h1 + h2 { border-top: none; padding-top: 0; margin-top: 30px; }

.doc-body h3 {
    font-family: var(--font-mono);
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--fg);
    margin: 24px 0 8px;
}
.doc-body h3::before { content: '## '; color: var(--fg-dim); }

/* The reading face: legal text runs to thousands of words and monospace
   would cost real legibility for no identity gain. */
.doc-body p,
.doc-body li {
    font-family: var(--font-read);
    font-size: 15px;
    line-height: 1.72;
    color: var(--fg-dim);
}
.doc-body p { margin-bottom: 14px; }
.doc-body ul, .doc-body ol { margin: 0 0 16px 0; padding-left: 22px; }
.doc-body li { margin-bottom: 6px; }
.doc-body strong { color: var(--fg); font-weight: 600; }
.doc-body em { color: var(--fg-dim); }
.doc-body a { color: var(--accent); border-bottom: 1px solid var(--line); }
.doc-body a:hover { border-color: var(--accent); }
.doc-body table { border-collapse: collapse; width: 100%; margin-bottom: 18px; font-size: 13px; }
.doc-body th, .doc-body td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; }
.doc-body th { background: var(--panel); font-weight: 700; color: var(--fg); }

.doc-loading { color: var(--fg-dim); font-size: 13px; padding: 40px 0; }

/* French term of art restated beneath an English document title. It lives inside
   the h1 so it sits above the title's rule; as a sibling it would strand between
   that rule and the first h2's, reading as a section of its own. */
.doc-body h1 .doc-sub {
    display: block;
    margin-top: 10px;
    font-size: 12.5px;
    font-weight: 400;
    letter-spacing: 0;
    color: var(--fg-dim);
}

/* ── Forms ────────────────────────────────────────────────────────────── */
.field-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.field-grid .full { grid-column: 1 / -1; }

label { display: block; font-size: 12.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--fg-dim); margin-bottom: 6px; }

input[type="text"], input[type="email"], select, textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 0;
    padding: 10px 12px;
    font-family: inherit;
    font-size: 13.5px;
    color: var(--fg);
    transition: border-color 0.12s linear;
}
input[type="text"]:focus, input[type="email"]:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
}
textarea { min-height: 170px; resize: vertical; line-height: 1.6; }

.help { font-size: 12.5px; color: var(--fg-dim); margin-top: 6px; }

.submit-button {
    background: var(--accent);
    color: var(--bg);
    border: 1px solid var(--accent);
    border-radius: 0;
    padding: 11px 26px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: opacity 0.12s linear;
}
.submit-button:hover { opacity: 0.86; }
.submit-button:disabled { opacity: 0.5; cursor: not-allowed; }

.status { padding: 12px 14px; border: 1px solid var(--line); font-size: 13px; margin-bottom: 20px; }
.status.success { border-color: var(--ok); color: var(--ok); }
.status.error { border-color: #b3401b; color: #b3401b; }
[data-theme="dark"] .status.error { border-color: #e2703f; color: #e2703f; }
.status ul { margin: 0; padding-left: 18px; }

/* Honeypot: must stay reachable to bots parsing the DOM but never shown to a
   person, so it is moved off-canvas rather than display:none. */
.hidden-field {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

form > div + div { margin-top: 18px; }
.field-grid + div { margin-top: 18px; }

.checkbox-group { margin-top: 22px; display: grid; gap: 14px; }
.checkbox-option { display: grid; grid-template-columns: 16px 1fr; gap: 10px; align-items: start; }
.checkbox-option input { margin-top: 4px; accent-color: var(--accent); }
.checkbox-option label {
    font-size: 12.5px;
    letter-spacing: 0;
    text-transform: none;
    color: var(--fg-dim);
    margin-bottom: 0;
    line-height: 1.55;
}

.submit-row {
    margin-top: 26px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    flex-wrap: wrap;
}
.privacy-note { font-size: 12.5px; color: var(--fg-dim); margin: 0; }

.contact-layout { display: grid; grid-template-columns: 250px 1fr; gap: 48px; align-items: start; }

.meta-list { display: grid; }
.meta-item { padding: 14px 0; border-bottom: 1px solid var(--line); }
.meta-item:first-child { border-top: 1px solid var(--line); }
.meta-item strong { display: block; font-size: 12.5px; font-weight: 700; color: var(--fg); }
.meta-item span { display: block; margin-top: 4px; font-size: 12.5px; color: var(--fg-dim); line-height: 1.55; }

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 780px) {
    .wrap { padding: 0 18px; }

    .nav-links {
        position: fixed;
        top: 0;
        right: -100%;
        width: 260px;
        height: 100vh;
        background: var(--bg);
        border-left: 1px solid var(--line);
        flex-direction: column;
        gap: 0;
        padding: 72px 0 24px;
        transition: right 0.22s ease;
        z-index: 99;
    }
    .nav-links.open { right: 0; }
    .nav-links li { border-bottom: 1px solid var(--line); }
    .nav-links a { display: block; padding: 14px 22px; font-size: 14px; }

    .hamburger { display: flex; z-index: 101; }

    .nav-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 98; }
    .nav-overlay.open { display: block; }

    .head { padding: 52px 0 44px; }

    /* Explicit placement: the source order (name, target, does, status) does
       not auto-flow into a sensible two-column stack, so each cell is placed
       by hand. Name and status share the first line; target and description
       take a full-width line each. */
    .row { grid-template-columns: 1fr auto; gap: 4px 14px; padding: 16px 14px; }
    .row .nm { grid-column: 1; grid-row: 1; }
    .row .st { grid-column: 2; grid-row: 1; }
    .row .pf { grid-column: 1 / 3; grid-row: 2; }
    .row .ds { grid-column: 1 / 3; grid-row: 3; margin-top: 6px; }
    .row-head { display: none; }

    .field-grid { grid-template-columns: 1fr; }
    .contact-layout { grid-template-columns: 1fr; gap: 32px; }
    .submit-row { flex-direction: column; align-items: stretch; }
    .submit-button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .head .cursor { animation: none; }
    * { transition-duration: 0.01ms !important; }
}
