/* ============================================================
   Papyrus — "Evidence Desk" Design Tokens
   A warm, tactile research-desk identity built around the app's
   real Evidence Board (claim-cards → threaded citation drawer).
   Deliberately divergent from the cloned generic-Apple-minimal look:
   parchment surface (not white), serif display (not sans), mono
   citation ornament, no radial glow.

   Theme model: light is the :root default. Dark applies when the OS
   prefers dark (unless the user forced light) OR when [data-theme="dark"]
   is set by the in-page toggle. Forced light via [data-theme="light"].
   ============================================================ */

/* ---------- Self-hosted fonts (latin subset, variable; OFL — see fonts/) ---------- */
@font-face { font-family: "Source Serif 4"; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url("fonts/source-serif-4-latin.woff2") format("woff2"); }
@font-face { font-family: "Source Serif 4"; font-style: italic; font-weight: 400 600; font-display: swap;
  src: url("fonts/source-serif-4-italic-latin.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url("fonts/inter-latin.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 400 500; font-display: swap;
  src: url("fonts/jetbrains-mono-latin.woff2") format("woff2"); }

:root {
  /* Native UI (scrollbars, canvas, controls) follows the theme. */
  color-scheme: light dark;
  /* ---------- Surface: "the desk" (light) ---------- */
  --pp-desk:         #EFEEE9;  /* page canvas — warm paper stock      */
  --pp-desk-sunk:    #E7E4DB;  /* recessed wells (citation drawer)    */
  --pp-card:         #FBF8F1;  /* claim-card / panel paper            */
  --pp-card-raised:  #FFFFFF;  /* hover / active rows                 */
  --pp-ink:          #1D1D1F;  /* primary text  (≈14:1 on card)       */
  --pp-ink-2:        #5E5E63;  /* secondary text                      */
  --pp-ink-3:        #646469;  /* captions / meta (≥4.5:1 on desk/card) */
  --pp-hairline:     #E3DCCB;  /* card rules, dividers                */
  --pp-hairline-2:   #D8CDB8;  /* stronger rule                       */

  /* ---------- Brand accents (UNCHANGED from the app) ---------- */
  --pp-gold:         #C8922A;  /* primary accent — claim / pins       */
  --pp-gold-hover:   #D4A23A;
  --pp-gold-deep:    #9A6F12;  /* gold text on cream (AA-safe)        */
  --pp-blue:         #0071E3;  /* citation chips + links ONLY         */
  --pp-blue-deep:    #005BBF;

  /* ---------- Seven-section spectrum == ProjectEvidenceSection ---------- */
  --pp-claim:        #C8922A;  /* Claim         */
  --pp-related:      #5E6470;  /* Related Work  */
  --pp-method:       #2DA44E;  /* Method        */
  --pp-result:       #0071E3;  /* Result        */
  --pp-limitation:   #B06A1F;  /* Limitation    */
  --pp-future:       #1D9E75;  /* Future Work   */
  --pp-rebuttal:     #D1453B;  /* Rebuttal      */

  /* ---------- Threads + semantic ---------- */
  --pp-thread:       rgba(200, 146, 42, 0.42);  /* connective leader lines */
  --pp-success:      #2DA44E;
  --pp-danger:       #D1453B;

  /* ---------- Ledger (the dark "board summary" strip) ---------- */
  --pp-ledger-bg:    #1B1A17;
  --pp-ledger-card:  #232220;
  --pp-ledger-ink:   #F2ECDD;
  --pp-ledger-ink-2: #B4AC97;
  --pp-ledger-hair:  #34322B;

  /* ---------- Typography (the three-way split) ---------- */
  --pp-serif: "Source Serif 4", "Iowan Old Style", "Source Serif Pro", Georgia, "Times New Roman", serif;
  --pp-sans:  "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Helvetica Neue", Arial, sans-serif;
  --pp-mono:  "JetBrains Mono", "IBM Plex Mono", "SF Mono", ui-monospace, Menlo, Monaco, monospace;

  /* serif = argument/voice · sans = interface · mono = evidence/data */

  --pp-fs-display:   clamp(2.6rem, 5.2vw, 4rem);   /* hero serif headline 42–64px */
  --pp-fs-h2:        clamp(1.9rem, 3.4vw, 2.6rem);  /* section serif title 30–42px */
  --pp-fs-h3:        1.3125rem;  /* 21px card / feature heading */
  --pp-fs-h4:        1.0625rem;  /* 17px */
  --pp-fs-lead:      1.1875rem;  /* 19px hero standfirst */
  --pp-fs-body:      1rem;       /* 16px */
  --pp-fs-sm:        0.9375rem;  /* 15px */
  --pp-fs-xs:        0.8125rem;  /* 13px */
  --pp-fs-xxs:       0.6875rem;  /* 11px — mono eyebrows / keys */

  --pp-lh-display:   1.1;
  --pp-lh-tight:     1.3;
  --pp-lh-body:      1.6;

  --pp-track-tight:  -0.01em;
  --pp-track-mono:   0.04em;   /* mono labels */
  --pp-track-eyebrow:0.14em;   /* small-caps-style eyebrows */

  --pp-w-regular:    400;
  --pp-w-medium:     500;
  --pp-w-semibold:   600;

  /* ---------- Spacing ---------- */
  --pp-s1: 4px;  --pp-s2: 8px;  --pp-s3: 12px; --pp-s4: 16px;
  --pp-s5: 20px; --pp-s6: 24px; --pp-s8: 32px; --pp-s10: 40px;
  --pp-s12: 48px; --pp-s14: 56px; --pp-s16: 64px; --pp-s20: 80px; --pp-s24: 96px;

  /* ---------- Layout ---------- */
  --pp-w-page:   1120px;
  --pp-w-narrow: 760px;
  --pp-w-text:   640px;   /* reading measure for serif body */
  --pp-gutter:   24px;

  /* ---------- Radii (cards are gently rounded, not pill-soft) ---------- */
  --pp-r-sm:  6px;
  --pp-r-md:  10px;
  --pp-r-lg:  14px;
  --pp-r-pill: 980px;

  /* ---------- Shadows (single-direction, warm, soft — never glow) ---------- */
  --pp-shadow-card:  0 6px 18px rgba(60, 46, 18, 0.09);
  --pp-shadow-card-hv: 0 12px 30px rgba(60, 46, 18, 0.14);
  --pp-shadow-plate: 0 18px 50px rgba(40, 30, 10, 0.16);
  --pp-shadow-pin:   0 1px 2px rgba(0, 0, 0, 0.28);

  /* ---------- Motion ---------- */
  --pp-ease:  cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --pp-dur:   0.3s;
  --pp-dur-fast: 0.15s;

  /* ---------- Translucent nav ---------- */
  --pp-nav-bg:   rgba(239, 238, 233, 0.78);
  --pp-nav-blur: saturate(160%) blur(18px);
}

/* ---------- Dark = "oxidized manuscript" ---------- */
:root[data-theme="dark"],
.pp-dark-vars {
  color-scheme: dark;
  --pp-desk:         #1C1C1E;  /* warm charcoal desk, never pure black */
  --pp-desk-sunk:    #161617;
  --pp-card:         #252528;  /* card paper stays WARM, never gray    */
  --pp-card-raised:  #2C2C2E;
  --pp-ink:          #F5EFE2;  /* warm paper-text                      */
  --pp-ink-2:        #C5C0B6;
  --pp-ink-3:        #97917F;
  --pp-hairline:     #38383B;
  --pp-hairline-2:   #44444A;

  --pp-gold:         #E8C987;  /* ember — gold survives on dark        */
  --pp-gold-hover:   #F0D69A;
  --pp-gold-deep:    #E8C987;
  --pp-blue:         #4C9AFF;
  --pp-blue-deep:    #6E9BC4;

  --pp-claim:        #E8C987;
  --pp-related:      #8A909C;
  --pp-method:       #4FBE6E;
  --pp-result:       #4C9AFF;
  --pp-limitation:   #D89A4F;
  --pp-future:       #4FBE9A;
  --pp-rebuttal:     #E8736B;

  --pp-thread:       rgba(232, 201, 135, 0.50);
  --pp-success:      #4FBE6E;
  --pp-danger:       #E8736B;

  /* ledger inverts only slightly — it is already dark in light mode */
  --pp-ledger-bg:    #131211;
  --pp-ledger-card:  #1E1D1B;
  --pp-ledger-ink:   #F2ECDD;
  --pp-ledger-ink-2: #ABA48F;
  --pp-ledger-hair:  #2C2A24;

  --pp-nav-bg:   rgba(28, 28, 30, 0.74);
  --pp-shadow-card:  0 8px 22px rgba(0, 0, 0, 0.45);
  --pp-shadow-card-hv: 0 14px 34px rgba(0, 0, 0, 0.55);
  --pp-shadow-plate: 0 20px 56px rgba(0, 0, 0, 0.6);
}

/* Follow the OS when the user has NOT forced a theme via the toggle. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --pp-desk:         #1C1C1E;
    --pp-desk-sunk:    #161617;
    --pp-card:         #252528;
    --pp-card-raised:  #2C2C2E;
    --pp-ink:          #F5EFE2;
    --pp-ink-2:        #C5C0B6;
    --pp-ink-3:        #97917F;
    --pp-hairline:     #38383B;
    --pp-hairline-2:   #44444A;
    --pp-gold:         #E8C987;
    --pp-gold-hover:   #F0D69A;
    --pp-gold-deep:    #E8C987;
    --pp-blue:         #4C9AFF;
    --pp-blue-deep:    #6E9BC4;
    --pp-claim:        #E8C987;
    --pp-related:      #8A909C;
    --pp-method:       #4FBE6E;
    --pp-result:       #4C9AFF;
    --pp-limitation:   #D89A4F;
    --pp-future:       #4FBE9A;
    --pp-rebuttal:     #E8736B;
    --pp-thread:       rgba(232, 201, 135, 0.50);
    --pp-success:      #4FBE6E;
    --pp-danger:       #E8736B;
    --pp-ledger-bg:    #131211;
    --pp-ledger-card:  #1E1D1B;
    --pp-ledger-ink:   #F2ECDD;
    --pp-ledger-ink-2: #ABA48F;
    --pp-ledger-hair:  #2C2A24;
    --pp-nav-bg:       rgba(28, 28, 30, 0.74);
    --pp-shadow-card:  0 8px 22px rgba(0, 0, 0, 0.45);
    --pp-shadow-card-hv: 0 14px 34px rgba(0, 0, 0, 0.55);
    --pp-shadow-plate: 0 20px 56px rgba(0, 0, 0, 0.6);
  }
}

@media (prefers-reduced-motion: reduce) {
  :root { --pp-dur: 0.001s; --pp-dur-fast: 0.001s; }
}

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