/* =====================================================================
   Inkwell — design tokens & dark-mode cascade.
   Version: 6.0.0 — "Open Canvas"
   Palette: restrained indigo (#5661B3) over warm paper surfaces;
   persistent navigation, local chronology, and an open writing canvas.
   Spec: docs/superpowers/specs/2026-11-10-open-canvas-design.md

   This file contains ONLY:
     • :root custom-property declarations
     • Pattern B dark-mode cascade (auto via prefers-color-scheme,
       manual override via [data-theme="dark"|"light"] on <html>)
     • The dark-mode .select chevron override

   The app shell uses opaque flat surfaces and 1px column dividers.
   Legacy depth/glass tokens remain available for existing dialogs and
   static content pages. Colors resolve through tokens in both themes;
   nothing loads off-origin.

   Component CSS lives in inkwell-components.css; app layout in app.css.
   ===================================================================== */

:root {
  /* ---------- Wash (page background) ---------- */
  --wash-base: #f8f7f4;
  --wash-app: var(--wash-base);
  --wash-hero:
    radial-gradient(1100px 600px at 20% -10%, rgba(96, 112, 226, 0.2), transparent 60%),
    radial-gradient(900px 560px at 105% 40%, rgba(236, 166, 140, 0.18), transparent 55%), var(--wash-base);

  /* ---------- Surfaces ---------- */
  --ivory: var(--wash-base); /* page base (legacy alias) */
  --paper: #fffefc; /* opaque card surface: active row, document */
  --slate: #211e1a; /* primary text / ink (legacy alias) */
  --oat: #e7e1d3; /* tertiary surface */
  --surface-canvas: var(--ivory);
  --surface-rail: color-mix(in srgb, var(--paper) 40%, var(--ivory));
  --surface-list: color-mix(in srgb, var(--paper) 75%, var(--ivory));
  --surface-document: var(--paper);
  --surface-document-stage: var(--paper);

  /* ---------- Glass ---------- */
  --glass-bg: rgba(255, 255, 255, 0.92);
  --glass-bg-strong: rgba(255, 255, 255, 0.96); /* empty-state card */
  --glass-bg-pill: rgba(255, 255, 255, 0.94); /* floating pills / nav */
  --glass-blur: 26px;
  --glass-blur-strong: 28px;
  --glass-blur-pill: 22px;
  --glass-border: 1px solid #d8d1c1;
  --glass-border-strong: 1px solid #c9c1b0;
  --glass-shadow: 0 24px 56px rgba(40, 33, 22, 0.09), 0 4px 12px rgba(40, 33, 22, 0.05);
  --glass-fallback: rgba(255, 255, 255, 0.98); /* opaque, no-blur fallback */

  /* ---------- Text ---------- */
  --ink: #211e1a;
  --text-secondary: #55504a;
  --text-muted: #797368; /* timestamps, placeholders, meta — decorative secondary */
  --text-body: #423d36;
  --text-quote: #514a3e;

  /* ---------- Lines & fills ---------- */
  --hairline-color: #e3ddd0;
  --hairline-color-2: #d8d1c1;
  --control-fill: rgba(33, 30, 26, 0.05);
  --control-fill-hover: rgba(33, 30, 26, 0.09);
  --row-hover: rgba(33, 30, 26, 0.04);
  --code-fill: rgba(33, 30, 26, 0.05);
  --field-bg: rgba(255, 255, 255, 0.92);
  --field-bg-textarea: rgba(255, 255, 255, 0.84);
  --field-inset-shadow: inset 0 1px 2px rgba(33, 30, 26, 0.03);
  --textarea-inset-shadow: inset 0 1px 3px rgba(33, 30, 26, 0.04);
  --idle-border: #c9c1b0; /* checkbox idle, dashed add-tag */
  --meta-dot: #c9c1b0;

  /* ---------- Accent (Porcelain Indigo) ---------- */
  --accent: #5661b3;
  --accent-d: #414b91; /* hover/pressed */
  --on-accent: #ffffff; /* text/icon on accent fill */
  --accent-text: var(--accent); /* accent text/glyph ON an accent tint */
  /* Secondary text ON an accent tint. Derived, so it follows the theme. */
  --accent-text-secondary: color-mix(in srgb, var(--accent-text) 45%, var(--ink));
  --accent-soft: #e8e9f4; /* chip / soft tint bg */
  --accent-soft-2: #dbddf1; /* stronger current-state tint */
  --accent-grad: var(--accent);
  --accent-2: #727cc5; /* lighter indigo — About display-text gradient */
  --glyph-ink: #ffffff; /* brand-glyph strokes: white in both themes */
  --accent-tint: var(--accent-soft); /* legacy alias (badge-accent bg) */
  --accent-focus-ring: rgba(86, 97, 179, 0.25); /* focus halo */
  --accent-strong-border: rgba(86, 97, 179, 0.35); /* active-card border */

  /* ---------- Semantic ---------- */
  --success: #57b26a;
  --success-text: #3b7a4b; /* success text on tint */
  --success-tint: rgba(87, 178, 106, 0.12);
  --olive: var(--success); /* legacy alias */
  --olive-tint: var(--success-tint); /* legacy alias */
  --olive-strong-border: rgba(87, 178, 106, 0.45);

  --warning: #e8a23d;
  --warning-dark: #a2701f; /* warning text (contrast) */
  --warning-tint: rgba(232, 162, 61, 0.14);
  --warning-strong-border: rgba(232, 162, 61, 0.45);

  --rust: #b04a3f; /* danger, deletions */
  --rust-d: #9a3f3f;
  --rust-tint: rgba(176, 74, 63, 0.1);
  --rust-tint-border: rgba(176, 74, 63, 0.45);
  --rust-focus-ring: rgba(176, 74, 63, 0.2);

  --info: #5c7ca3;
  --sky: #6a8caf;

  /* ---------- Neutral scale (remapped to Soft Glass) ---------- */
  --gray-100: rgba(33, 30, 26, 0.05); /* control fill / row hover (semi over glass) */
  --gray-200: rgba(33, 30, 26, 0.09); /* stronger hover (circle icon buttons) */
  --gray-300: #c9c1b0; /* visible element border, idle states, meta dots */
  --gray-500: #797368; /* muted text */
  --gray-700: #55504a; /* secondary text */

  /* ---------- Typography ---------- */
  /* Ink-and-Chrome split: --serif carries the document (note title, rendered
     h2/h3, page titles, wordmark); --sans carries the chrome (buttons, rows,
     chips, labels, dialogs); --mono is metadata only (timestamps, counts,
     tags, shortcuts, code) and never prose. See DESIGN.md § Typography. */
  --serif: "Iowan Old Style", "Palatino", "Palatino Linotype", "Source Serif Pro", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Monaco, Consolas, monospace;

  /* Type scale */
  --t-display: 62px;
  --t-h1: 32px;
  --t-h2: 24px;
  --t-h3: 20px;
  --measure-doc: 680px; /* shared reading/writing measure */
  --t-lede: 17px;
  --t-body: 16px;
  --t-small: 14px;
  --t-caption: 12px;
  --t-eyebrow: 11px;

  /* ---------- Spacing (8px base, 4px micro) ---------- */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --sp-8: 64px;

  /* ---------- Radius ---------- */
  --r-xs: 4px;
  --r-code: 7px; /* inline code */
  --r-sm: 8px; /* segments, hints */
  --r-glyph: 9px; /* brand glyph squircle */
  --r-seg-track: 11px; /* segmented / chip-group track */
  --r-md: 12px; /* inputs, New note */
  --r-lg: 14px; /* cards, code blocks, quotes, note rows */
  --r-textarea: 16px;
  --r-xl: 20px; /* icon squircle */
  --r-panel: 22px; /* floating panels */
  --r-empty: 26px; /* empty-state card */
  --r-pill: 999px;

  /* ---------- Borders (1px hairlines) ---------- */
  --border: 1px solid var(--gray-300);
  --border-strong: 1px solid var(--accent-strong-border);
  --border-hair: 1px solid var(--hairline-color);
  --border-rule: 1px solid var(--hairline-color-2);

  /* ---------- Shadows ---------- */
  --shadow-sm: 0 1px 2px rgba(33, 30, 26, 0.05);
  --shadow-md: 0 8px 20px rgba(40, 33, 22, 0.1);
  --shadow-lg: 0 20px 50px rgba(40, 33, 22, 0.12);
  --shadow-card-hover: 0 8px 20px rgba(40, 33, 22, 0.12);
  --shadow-card: 0 8px 20px rgba(40, 33, 22, 0.12); /* active note card */
  --shadow-row-active: 0 2px 8px rgba(40, 33, 22, 0.07); /* selected note row */
  --shadow-empty: 0 30px 70px rgba(40, 33, 22, 0.16); /* empty-state card */
  --shadow-primary: 0 8px 18px rgba(78, 95, 216, 0.35);
  --shadow-primary-sm: 0 6px 14px rgba(78, 95, 216, 0.3);
  --shadow-primary-lg: 0 10px 24px rgba(78, 95, 216, 0.4);
  --shadow-seg: 0 2px 6px rgba(33, 30, 26, 0.1); /* active segment */
  --shadow-chip: 0 1px 4px rgba(33, 30, 26, 0.12); /* active format chip */
  --shadow-glyph: 0 4px 10px rgba(78, 95, 216, 0.35); /* brand glyph */
  --shadow-glyph-inset: inset 0 1px 2px #ffffff; /* empty icon squircle */
  --shadow-pill-float: 0 14px 34px rgba(40, 33, 22, 0.12); /* about nav pill */

  /* ---------- Backdrop (dialog scrim) ---------- */
  --backdrop: rgba(28, 23, 14, 0.35);
  --backdrop-blur: 8px;

  /* ---------- Motion ---------- */
  --t-fast: 120ms;
  --t-base: 150ms;
  --t-slow: 300ms;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);
  --press: cubic-bezier(0.2, 0.8, 0.2, 1);

  /* ---------- Layout ---------- */
  --content-narrow: 820px;
  --content-default: 920px;
  --content-wide: 1120px;
  --page-pad-x: 24px;

  /* ---------- Z-index scale ---------- */
  --z-base: 1;
  --z-raised: 10;
  --z-sticky: 20;
  --z-overlay: 30;
  --z-modal: 50;

  color-scheme: light dark;
}

/* A forced light theme must also pin native UI (scrollbars, form controls,
   system colors) to light, or a dark system keeps drawing them dark. */
:root[data-theme="light"] {
  color-scheme: light;
}

/* =====================================================================
   Dark mode — Pattern B  (proposal per handoff; AA-validated)
   • prefers-color-scheme: dark applies UNLESS data-theme="light"
   • data-theme="dark"  → forces dark
   • data-theme="light" → forces light
   The two dark blocks below are kept byte-parallel.
   ===================================================================== */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --wash-base: #191816;
    --wash-app:
      radial-gradient(900px 500px at 8% -5%, rgba(122, 138, 209, 0.14), transparent 60%),
      radial-gradient(800px 480px at 100% 108%, rgba(217, 165, 95, 0.1), transparent 55%), var(--wash-base);
    --wash-hero:
      radial-gradient(1100px 600px at 20% -10%, rgba(122, 138, 209, 0.18), transparent 60%),
      radial-gradient(900px 560px at 105% 40%, rgba(217, 165, 95, 0.12), transparent 55%), var(--wash-base);

    --ivory: var(--wash-base);
    --paper: #232220;
    --slate: #f1ece2;
    --oat: #2c2822;

    --glass-bg: rgba(26, 23, 17, 0.62);
    --glass-bg-strong: rgba(26, 23, 17, 0.72);
    --glass-bg-pill: rgba(26, 23, 17, 0.7);
    --glass-border: 1px solid rgba(255, 255, 255, 0.08);
    --glass-border-strong: 1px solid rgba(255, 255, 255, 0.12);
    --glass-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    --glass-fallback: rgba(26, 23, 17, 0.94);

    --ink: #f1ece2;
    --text-secondary: #b3aca0;
    --text-muted: #948a79;
    --text-body: #cfc9bd;
    --text-quote: #cbc2b0;

    --hairline-color: rgba(255, 255, 255, 0.08);
    --hairline-color-2: rgba(255, 255, 255, 0.1);
    --control-fill: rgba(255, 255, 255, 0.06);
    --control-fill-hover: rgba(255, 255, 255, 0.12);
    --row-hover: rgba(255, 255, 255, 0.05);
    --code-fill: rgba(255, 255, 255, 0.06);
    --field-bg: rgba(255, 255, 255, 0.06);
    --field-bg-textarea: rgba(255, 255, 255, 0.05);
    --field-inset-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25);
    --textarea-inset-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
    --idle-border: #4a4438;
    --meta-dot: #4a4438;

    --accent: #8593d6; /* lifted to clear AA (4.5+) on accent-soft chips */
    --accent-d: #6273c0;
    --on-accent: #0e1016;
    --accent-text: #8f9ee1; /* lifted for 4.5+ on accent-soft over --paper */
    --accent-soft: rgba(122, 138, 209, 0.16);
    --accent-soft-2: rgba(122, 138, 209, 0.22);
    --accent-grad: var(--accent);
    --accent-tint: var(--accent-soft);
    --accent-focus-ring: rgba(122, 138, 209, 0.35);
    --accent-strong-border: rgba(122, 138, 209, 0.5);

    --success: #6fbf83;
    --success-text: #9ad3a8;
    --success-tint: rgba(87, 178, 106, 0.18);
    --olive: var(--success);
    --olive-tint: var(--success-tint);
    --olive-strong-border: rgba(111, 191, 131, 0.55);

    --warning: #e8a23d;
    --warning-dark: #e8b45f;
    --warning-tint: rgba(232, 162, 61, 0.18);
    --warning-strong-border: rgba(232, 162, 61, 0.55);

    --rust: #d27468;
    --rust-d: #c96b5f;
    --rust-tint: rgba(210, 116, 104, 0.18);
    --rust-tint-border: rgba(210, 116, 104, 0.55);
    --rust-focus-ring: rgba(210, 116, 104, 0.3);

    --info: #7c9fd2;
    --sky: #85a6cb;

    --gray-100: rgba(255, 255, 255, 0.06);
    --gray-200: rgba(255, 255, 255, 0.12);
    --gray-300: #3b362c;
    --gray-500: #948a79;
    --gray-700: #b3aca0;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45);
    --shadow-md: 0 8px 20px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.55);
    --shadow-card-hover: 0 8px 20px rgba(0, 0, 0, 0.5);
    --shadow-card: 0 8px 20px rgba(0, 0, 0, 0.5);
    --shadow-row-active: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-empty: 0 30px 70px rgba(0, 0, 0, 0.6);
    --shadow-primary: 0 8px 18px rgba(0, 0, 0, 0.45);
    --shadow-primary-sm: 0 6px 14px rgba(0, 0, 0, 0.4);
    --shadow-primary-lg: 0 10px 24px rgba(0, 0, 0, 0.5);
    --shadow-seg: 0 2px 6px rgba(0, 0, 0, 0.45);
    --shadow-chip: 0 1px 4px rgba(0, 0, 0, 0.45);
    --shadow-glyph: 0 4px 10px rgba(0, 0, 0, 0.45);
    --shadow-glyph-inset: inset 0 1px 2px rgba(255, 255, 255, 0.1);
    --shadow-pill-float: 0 14px 34px rgba(0, 0, 0, 0.5);

    --backdrop: rgba(0, 0, 0, 0.55);
  }
  /* Select chevron in dark mode — data URIs can't read CSS vars, so the
     whole background-image is overridden with the lifted muted color.
     Higher specificity than the base .select rule in inkwell-components.css. */
  :root:not([data-theme="light"]) .select {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'><path d='M1 1.5L6 6.5L11 1.5' stroke='%23948A79' stroke-width='1.5' stroke-linecap='round'/></svg>");
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --wash-base: #191816;
  --wash-app:
    radial-gradient(900px 500px at 8% -5%, rgba(122, 138, 209, 0.14), transparent 60%),
    radial-gradient(800px 480px at 100% 108%, rgba(217, 165, 95, 0.1), transparent 55%), var(--wash-base);
  --wash-hero:
    radial-gradient(1100px 600px at 20% -10%, rgba(122, 138, 209, 0.18), transparent 60%),
    radial-gradient(900px 560px at 105% 40%, rgba(217, 165, 95, 0.12), transparent 55%), var(--wash-base);

  --ivory: var(--wash-base);
  --paper: #232220;
  --slate: #f1ece2;
  --oat: #2c2822;

  --glass-bg: rgba(26, 23, 17, 0.62);
  --glass-bg-strong: rgba(26, 23, 17, 0.72);
  --glass-bg-pill: rgba(26, 23, 17, 0.7);
  --glass-border: 1px solid rgba(255, 255, 255, 0.08);
  --glass-border-strong: 1px solid rgba(255, 255, 255, 0.12);
  --glass-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  --glass-fallback: rgba(26, 23, 17, 0.94);

  --ink: #f1ece2;
  --text-secondary: #b3aca0;
  --text-muted: #948a79;
  --text-body: #cfc9bd;
  --text-quote: #cbc2b0;

  --hairline-color: rgba(255, 255, 255, 0.08);
  --hairline-color-2: rgba(255, 255, 255, 0.1);
  --control-fill: rgba(255, 255, 255, 0.06);
  --control-fill-hover: rgba(255, 255, 255, 0.12);
  --row-hover: rgba(255, 255, 255, 0.05);
  --code-fill: rgba(255, 255, 255, 0.06);
  --field-bg: rgba(255, 255, 255, 0.06);
  --field-bg-textarea: rgba(255, 255, 255, 0.05);
  --field-inset-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25);
  --textarea-inset-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
  --idle-border: #4a4438;
  --meta-dot: #4a4438;

  --accent: #8593d6; /* lifted to clear AA (4.5+) on accent-soft chips */
  --accent-d: #6273c0;
  --on-accent: #0e1016;
  --accent-text: #8f9ee1; /* lifted for 4.5+ on accent-soft over --paper */
  --accent-soft: rgba(122, 138, 209, 0.16);
  --accent-soft-2: rgba(122, 138, 209, 0.22);
  --accent-grad: var(--accent);
  --accent-tint: var(--accent-soft);
  --accent-focus-ring: rgba(122, 138, 209, 0.35);
  --accent-strong-border: rgba(122, 138, 209, 0.5);

  --success: #6fbf83;
  --success-text: #9ad3a8;
  --success-tint: rgba(87, 178, 106, 0.18);
  --olive: var(--success);
  --olive-tint: var(--success-tint);
  --olive-strong-border: rgba(111, 191, 131, 0.55);

  --warning: #e8a23d;
  --warning-dark: #e8b45f;
  --warning-tint: rgba(232, 162, 61, 0.18);
  --warning-strong-border: rgba(232, 162, 61, 0.55);

  --rust: #d27468;
  --rust-d: #c96b5f;
  --rust-tint: rgba(210, 116, 104, 0.18);
  --rust-tint-border: rgba(210, 116, 104, 0.55);
  --rust-focus-ring: rgba(210, 116, 104, 0.3);

  --info: #7c9fd2;
  --sky: #85a6cb;

  --gray-100: rgba(255, 255, 255, 0.06);
  --gray-200: rgba(255, 255, 255, 0.12);
  --gray-300: #3b362c;
  --gray-500: #948a79;
  --gray-700: #b3aca0;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 8px 20px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.55);
  --shadow-card-hover: 0 8px 20px rgba(0, 0, 0, 0.5);
  --shadow-card: 0 8px 20px rgba(0, 0, 0, 0.5);
  --shadow-row-active: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-empty: 0 30px 70px rgba(0, 0, 0, 0.6);
  --shadow-primary: 0 8px 18px rgba(0, 0, 0, 0.45);
  --shadow-primary-sm: 0 6px 14px rgba(0, 0, 0, 0.4);
  --shadow-primary-lg: 0 10px 24px rgba(0, 0, 0, 0.5);
  --shadow-seg: 0 2px 6px rgba(0, 0, 0, 0.45);
  --shadow-chip: 0 1px 4px rgba(0, 0, 0, 0.45);
  --shadow-glyph: 0 4px 10px rgba(0, 0, 0, 0.45);
  --shadow-glyph-inset: inset 0 1px 2px rgba(255, 255, 255, 0.1);
  --shadow-pill-float: 0 14px 34px rgba(0, 0, 0, 0.5);

  --backdrop: rgba(0, 0, 0, 0.55);
}
/* Select chevron in dark mode — see comment in the @media block above. */
:root[data-theme="dark"] .select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'><path d='M1 1.5L6 6.5L11 1.5' stroke='%23948A79' stroke-width='1.5' stroke-linecap='round'/></svg>");
}
