/* Talefork Bookshelf tokens.
   Light = paper browse (default).
   Dark = lamp-lit #17120E family — same names, same as the reader retint.
   Resolved theme is data-theme="light"|"dark". Preference is data-theme-pref="system"|"light"|"dark". */

:root {
  --tf-paper: #F4EFE6;
  --tf-paper-2: #EBE4D8;
  --tf-card: #EBE4D8;
  --tf-chip: #E3D9C8;
  --tf-ink: #2C2620;
  --tf-ink-2: #5E564C;
  --tf-line: #D6CDBE;
  --tf-border: #D6CDBE;
  --tf-shelf: #CDBFA8;
  --tf-shelf-edge: #B9A98E;
  --tf-shelf-deep: #B6A585;
  --tf-gold: #FFCF5C;
  --tf-gold-ink: #2C2620;
  --tf-brass: #8B5A14;
  --tf-focus: #2C2620;
  --tf-shadow: 0 6px 16px rgba(44, 38, 32, 0.14);
  --tf-shadow-pressed: 0 2px 8px rgba(44, 38, 32, 0.12);
  --tf-grain: url("textures/paper-grain.png");
  --tf-grain-opacity: 0.11;
  --tf-grain-blend: multiply;

  --tf-romance: #9C335C;
  --tf-mystery: #2F5F96;
  --tf-fantasy: #6840A0;
  --tf-scifi: #0A6558;
  --tf-survival: #32661C;
  --tf-heist: #9A5420;
  --tf-comedy: #9A4630;
  --tf-historical: #8B3A3A;
  --tf-espionage: #3A4A7C;
  --tf-cozy-mystery: #3F6A38;
  --tf-superhero: #8B2E4A;

  --tf-font-display: Fraunces, "Source Serif Pro", Georgia, serif;
  --tf-font-ui: "Source Sans 3", "Source Sans Pro", system-ui, sans-serif;
  --tf-wordmark: 600 italic 22px/28px var(--tf-font-display);
  --tf-title: 600 26px/32px var(--tf-font-display);
  --tf-card-title: 600 17px/22px var(--tf-font-display);
  --tf-body: 400 16px/23px var(--tf-font-ui);
  --tf-hook: 400 14px/19px var(--tf-font-ui);
  --tf-sub: 400 14px/20px var(--tf-font-ui);
  --tf-meta: 400 13px/18px var(--tf-font-ui);
  --tf-caption: 600 12px/15px var(--tf-font-ui);
  --tf-kicker: 700 11px/16px var(--tf-font-ui);
  --tf-screen-pad: 20px;
  --tf-section-gap: 12px;
  --tf-row-gap: 12px;
  --tf-shelf-gap: 8px;
  --tf-radius-row: 16px;
  --tf-radius-cover: 6px;
  --tf-radius-pill: 28px;
  --tf-tap: 44px;
}

/* 1:1 dark counterparts — same names. Also used by the reader. */
[data-theme="dark"],
.theme-reader {
  --tf-paper: #17120E;
  --tf-paper-2: #241C16;
  --tf-card: #241C16;
  --tf-chip: #2C231C;
  --tf-ink: #F4E8D6;
  --tf-ink-2: #C9B8A2;
  --tf-line: #3E332A;
  --tf-border: #3E332A;
  --tf-shelf: #3D3126;
  --tf-shelf-edge: #5C4A38;
  --tf-shelf-deep: #2A2118;
  --tf-gold: #FFCF5C;
  --tf-gold-ink: #17120E;
  --tf-brass: #FFCF5C;
  --tf-focus: #FFCF5C;
  --tf-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
  --tf-shadow-pressed: 0 4px 10px rgba(0, 0, 0, 0.4);
  --tf-grain-opacity: 0.07;
  --tf-grain-blend: overlay;

  --tf-romance: #FF7AA8;
  --tf-mystery: #7DB2FF;
  --tf-fantasy: #B99AFF;
  --tf-scifi: #4FE3C9;
  --tf-survival: #A3E36B;
  --tf-heist: #FFB060;
  --tf-comedy: #FF9B7A;
  --tf-historical: #E08A8A;
  --tf-espionage: #8AA0FF;
  --tf-cozy-mystery: #A8D48A;
  --tf-superhero: #FF8A9A;
}

/* System default: apply dark when no explicit light is set. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --tf-paper: #17120E;
    --tf-paper-2: #241C16;
    --tf-card: #241C16;
    --tf-chip: #2C231C;
    --tf-ink: #F4E8D6;
    --tf-ink-2: #C9B8A2;
    --tf-line: #3E332A;
    --tf-border: #3E332A;
    --tf-shelf: #3D3126;
    --tf-shelf-edge: #5C4A38;
    --tf-shelf-deep: #2A2118;
    --tf-gold: #FFCF5C;
    --tf-gold-ink: #17120E;
    --tf-brass: #FFCF5C;
    --tf-focus: #FFCF5C;
    --tf-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
    --tf-shadow-pressed: 0 4px 10px rgba(0, 0, 0, 0.4);
    --tf-grain-opacity: 0.07;
    --tf-grain-blend: overlay;
    --tf-romance: #FF7AA8;
    --tf-mystery: #7DB2FF;
    --tf-fantasy: #B99AFF;
    --tf-scifi: #4FE3C9;
    --tf-survival: #A3E36B;
    --tf-heist: #FFB060;
    --tf-comedy: #FF9B7A;
    --tf-historical: #E08A8A;
    --tf-espionage: #8AA0FF;
    --tf-cozy-mystery: #A8D48A;
    --tf-superhero: #FF8A9A;
  }
}

/* Dark text: set -webkit-font-smoothing: auto (not antialiased) on the root so cream
   Fraunces titles stay AA. Keep .tf-grain behind content (z-index: 0), not over type. */
[data-theme="dark"] { -webkit-font-smoothing: auto; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { -webkit-font-smoothing: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
@media (prefers-reduced-transparency: reduce) {
  .tf-grain { display: none; }
}
