/* CABIN design tokens — docs/design.md §2.
 *
 * The ONLY stylesheet allowed to contain a colour literal (§6.3). Light ("studio")
 * is defined on bare :root; dark ("graphite") is defined twice with identical
 * declarations — once under the system preference (guarded so an explicit
 * data-theme="light" wins) and once under data-theme="dark". No preprocessor:
 * the two dark blocks are kept in sync by hand (§5.1).
 */

/* ── Light theme ("studio") ───────────────────────────────────────── */
:root {
    color-scheme: light;

    /* Tones — paper < surface < raised */
    --paper: #ECECEC;
    --surface: #F6F6F6;
    --surface-raised: #FFFFFF;

    /* Text */
    --ink: #1A1A1A;
    --ink-2: #474747;
    --muted: #616161;
    --faint: #8C8C8C;             /* non-text only */

    /* Lines */
    --rule: #D9D9D9;
    --rule-2: #BDBDBD;
    --edge-control: #7A7A7A;

    /* Accent — one accent, one job: the current thing (selection, focus, playhead, primary) */
    --accent: #2F5FE0;            /* marks only: playhead, selection edge, tab underline, focus, unsaved dot */
    --accent-text: #2A55C9;
    --accent-fill: #2F5FE0;
    --accent-hover: #2449B5;
    --accent-ink: #FFFFFF;

    /* Status */
    --ok: #1B7346;
    --warn: #8A5A00;
    --err: #B8352D;
    --ok-tint: rgba(27, 115, 70, .10);
    --warn-tint: rgba(138, 90, 0, .10);
    --err-tint: rgba(184, 53, 45, .10);
    --err-fill: #B8352D;          /* solid red behind white marks, both themes (white 5.86:1; the dark --err is a text colour) */
    --err-ink: #FFFFFF;           /* marks on --err-fill */

    /* Fills */
    --sel: #DDE6FA;
    --hover: #EFEFEF;
    --tl-bg: #E2E2E2;
    --tl-fg: #4F4F4F;
    --wave: #707070;
    --tl-shot: #B07A1E;      /* shot-change hairlines on the timeline waveform */
    --stage: #0B0B0B;
    --code-bg: #E4E4E4;

    /* The review page's panel frame (docs/design.md §0.2, "panel suite"): the
       shell and the gutters between the workspace's panels sit one step below
       the panels; --panel-edge is the panels' 1 px outline */
    --frame: #E1E1E1;
    --panel-edge: #D2D2D2;

    /* Focus, scrim, elevation */
    --focus: #2F5FE0;
    --focus-halo: rgba(47, 95, 224, .35);
    --scrim: rgba(20, 20, 20, .40);
    --shadow-pop: 0 2px 8px rgba(20, 20, 20, .12);

    /* Speakers — muted data hues (never the accent); 1–6 cycle by first appearance.
       --spk-stage-N are for text on the always-dark stage (caption overlay). */
    --spk-1: #1A6E67;
    --spk-2: #6A55B8;
    --spk-3: #A8466A;
    --spk-4: #5F6B12;
    --spk-5: #8A5F2E;
    --spk-6: #4E6378;
    --spk-stage-1: #4FB3A9;
    --spk-stage-2: #A08DDB;
    --spk-stage-3: #D0839A;
    --spk-stage-4: #A3B05A;
    --spk-stage-5: #C8A27A;
    --spk-stage-6: #8EA2B8;

    /* Caption overlay (theme-independent) */
    --caption-ink: #FFFFFF;
    --caption-band: rgba(0, 0, 0, .60);

    /* Stage tones (theme-independent): the features page's hero is a screening
       room in both themes, so its chrome never follows the theme (features.css) */
    --stage-raised: #141414;
    --stage-well: #101010;
    --stage-ink: #E8E8E8;
    --stage-ink-2: #BDBDBD;
    --stage-muted: #9A9A9A;
    --stage-rule: #262626;
    --stage-rule-2: #3A3A3A;
    --stage-hover: #222222;
    --stage-accent: #4C7DFF;
    --stage-shot: #D9A441;
    --stage-wave: #5A5A5A;
    /* The hero's drawn scene: a door opening onto a rainy porch */
    --scene-wall: #0F1012;
    --scene-floor: #151619;
    --scene-door: #1B1C20;
    --scene-frame: #34302A;
    --scene-light: #E8B65A;
    --scene-figure: #070708;

    /* Type tracking for sizes < 13px */
    --track-small: 0;

    /* Select chevron (stroke = --ink-2) */
    --icon-chevron: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23474747' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><path d='m3.5 6 4.5 4.5L12.5 6'/></svg>");
}

/* ── Dark theme ("graphite") — system preference, unless the user chose light ── */
/* keep in sync */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;

        /* Tones — paper < surface < raised (lighter as they rise) */
        --paper: #1A1A1A;
        --surface: #212121;
        --surface-raised: #2A2A2A;

        /* Text */
        --ink: #E8E8E8;
        --ink-2: #BDBDBD;
        --muted: #9A9A9A;
        --faint: #6E6E6E;             /* non-text only */

        /* Lines */
        --rule: #303030;
        --rule-2: #3D3D3D;
        --edge-control: #737373;

        /* Accent */
        --accent: #4C7DFF;
        --accent-text: #8AA9FF;
        --accent-fill: #3563E9;
        --accent-hover: #4170F0;
        --accent-ink: #FFFFFF;        /* white on --accent-fill 5.11:1; --accent itself is a mark (3.69:1 with white) */

        /* Status */
        --ok: #3FB27F;
        --warn: #E0A030;
        --err: #EF6B5B;
        --ok-tint: rgba(63, 178, 127, .12);
        --warn-tint: rgba(224, 160, 48, .12);
        --err-tint: rgba(239, 107, 91, .12);

        /* Fills */
        --sel: #22314F;
        --hover: #2E2E2E;
        --tl-bg: #121212;
        --tl-fg: #9A9A9A;
        --wave: #7A7A7A;
        --tl-shot: #D9A441;
        --stage: #0B0B0B;
        --code-bg: #121212;

        /* panel frame (§0.2): the shell below the panels, a lit 1 px panel edge */
        --frame: #151515;
        --panel-edge: #2D2D2D;

        /* Focus, scrim, elevation — no shadows in dark, ever */
        --focus: #4C7DFF;
        --focus-halo: rgba(76, 125, 255, .40);
        --scrim: rgba(0, 0, 0, .60);
        --shadow-pop: none;

        /* Speakers (same hues as the stage set) */
        --spk-1: #4FB3A9;
        --spk-2: #A08DDB;
        --spk-3: #D0839A;
        --spk-4: #A3B05A;
        --spk-5: #C8A27A;
        --spk-6: #8EA2B8;

        /* Caption overlay (identical to light) */
        --caption-ink: #FFFFFF;
        --caption-band: rgba(0, 0, 0, .60);

        /* Counter dark-theme thinning below 13px */
        --track-small: 0.005em;

        /* Select chevron (stroke = --ink-2) */
        --icon-chevron: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23BDBDBD' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><path d='m3.5 6 4.5 4.5L12.5 6'/></svg>");
    }
}

/* ── Dark theme ("graphite") — explicit choice ────────────────────── */
/* keep in sync */
:root[data-theme="dark"] {
    color-scheme: dark;

    /* Tones — paper < surface < raised (lighter as they rise) */
    --paper: #1A1A1A;
    --surface: #212121;
    --surface-raised: #2A2A2A;

    /* Text */
    --ink: #E8E8E8;
    --ink-2: #BDBDBD;
    --muted: #9A9A9A;
    --faint: #6E6E6E;             /* non-text only */

    /* Lines */
    --rule: #303030;
    --rule-2: #3D3D3D;
    --edge-control: #737373;

    /* Accent */
    --accent: #4C7DFF;
    --accent-text: #8AA9FF;
    --accent-fill: #3563E9;
    --accent-hover: #4170F0;
    --accent-ink: #FFFFFF;        /* white on --accent-fill 5.11:1; --accent itself is a mark (3.69:1 with white) */

    /* Status */
    --ok: #3FB27F;
    --warn: #E0A030;
    --err: #EF6B5B;
    --ok-tint: rgba(63, 178, 127, .12);
    --warn-tint: rgba(224, 160, 48, .12);
    --err-tint: rgba(239, 107, 91, .12);

    /* Fills */
    --sel: #22314F;
    --hover: #2E2E2E;
    --tl-bg: #121212;
    --tl-fg: #9A9A9A;
    --wave: #7A7A7A;
    --tl-shot: #D9A441;
    --stage: #0B0B0B;
    --code-bg: #121212;

    /* panel frame (§0.2): the shell below the panels, a lit 1 px panel edge */
    --frame: #151515;
    --panel-edge: #2D2D2D;

    /* Focus, scrim, elevation — no shadows in dark, ever */
    --focus: #4C7DFF;
    --focus-halo: rgba(76, 125, 255, .40);
    --scrim: rgba(0, 0, 0, .60);
    --shadow-pop: none;

    /* Speakers (same hues as the stage set) */
    --spk-1: #4FB3A9;
    --spk-2: #A08DDB;
    --spk-3: #D0839A;
    --spk-4: #A3B05A;
    --spk-5: #C8A27A;
    --spk-6: #8EA2B8;

    /* Caption overlay (identical to light) */
    --caption-ink: #FFFFFF;
    --caption-band: rgba(0, 0, 0, .60);

    /* Counter dark-theme thinning below 13px */
    --track-small: 0.005em;

    /* Select chevron (stroke = --ink-2) */
    --icon-chevron: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23BDBDBD' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><path d='m3.5 6 4.5 4.5L12.5 6'/></svg>");
}

/* ── Non-colour tokens (theme-independent, §2.4) ─────────────────── */
:root {
    /* ── Type faces (§3.1) ─────────────────────────────────────── */
    --font-ui: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, Helvetica, Arial, sans-serif;
    --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

    /* ── Radii ────────────────────────────────────────────────── */
    --r-0: 0;          /* panes, cells, stage, tabs, ruler, header, nav */
    --r-1: 2px;        /* inputs, chips, tags, segment blocks, code chips, scrubber knob */
    --r-2: 4px;        /* buttons, popovers, dialogs, login frame — maximum for any container */
    --r-3: 6px;        /* floating menus and toasts only — reserved */
    --r-pill: 9999px;  /* switch track and status dots only */
    --r-panel: 6px;    /* the review workspace's panels (§0.2) — the one container above --r-2 */

    /* ── Spacing (4px grid) ───────────────────────────────────── */
    --s1: 4px;
    --s2: 8px;
    --s3: 12px;
    --s4: 16px;
    --s6: 24px;
    --s8: 32px;
    --s12: 48px;

    /* ── Sizes ────────────────────────────────────────────────── */
    --ctl-h: 32px;
    --ctl-h-sm: 28px;
    --ctl-h-lg: 40px;
    --row-h: 28px;
    --header-h: 44px;
    --transport-h: 36px;
    --nav-w: 200px;
    --nav-rail-w: 48px;
    --dock-w: clamp(360px, 30vw, 560px);   /* 30vw: the picture is width-bound on laptops, so the dock yields first */
    --ledger-w: 200px;
    --tl-ruler: 24px;
    --tl-audio: 56px;
    --tl-sub: 40px;
    --tl-scenes: 32px;
    --tl-dub: 0px;          /* the Dub row: 32px while a dub plays (.timeline-col.has-dub) */
    --tl-sounds: 28px;      /* the Sounds row */
    --tl-text: 0px;           /* the Text row: 26px while the project has on-screen text (.timeline-col.has-screen-text) */
    --tl-narr: 0px;           /* the Description row: 28px while the project has audio description (.timeline-col.has-narration) */
    --tl-gutter: 120px;
    --gutter: 4px;          /* the frame between the review workspace's panels (§0.2) */
    /* --tl-h, the rows' sum, is declared on .timeline-col (workspace.css): the rows
       a project has and the rows folded away (.hide-*, the Rows menu) set their
       --tl-* there, and a custom property resolves where it is declared */

    /* ── Motion ───────────────────────────────────────────────── */
    --dur: 120ms;
    --ease: cubic-bezier(.2, .7, .2, 1);

    /* ── Z-index ladder ───────────────────────────────────────── */
    --z-splitter: 5;
    --z-scene-marker: 6;
    --z-playhead: 10;
    --z-overlay: 20;
    --z-sticky: 30;
    --z-popover: 100;
    --z-dialog: 200;
}
