/* ==========================================================================
   Cold Flame Codex — the Book's design layer (frozen contract:
   _website architecture\universe-lore-site-2026-07-23\design-tokens-frozen.md,
   visual reference prototypes\A-cold-flame-codex.html).
   The cold-flame gradient (violet→cyan→white) is the ONLY accent.
   ========================================================================== */

/* ---- fonts (self-hosted, estate discipline: no third-party requests) ---- */
@font-face {
  font-family: 'Fraunces'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('/assets/fonts/fraunces-latin-500-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Fraunces'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('/assets/fonts/fraunces-latin-600-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Fraunces'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('/assets/fonts/fraunces-latin-ext-500-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Fraunces'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('/assets/fonts/fraunces-latin-ext-600-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url('/assets/fonts/inter-var-latin.woff2') format('woff2');
  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: 'Inter'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url('/assets/fonts/inter-var-latin-ext.woff2') format('woff2');
  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;
}
@font-face {
  font-family: 'Noto Sans Thai'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url('/assets/fonts/noto-sans-thai-var-thai.woff2') format('woff2');
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}
@font-face {
  font-family: 'Noto Sans Thai'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url('/assets/fonts/noto-sans-thai-var-latin.woff2') format('woff2');
  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;
}

/* ---- tokens ---- */
:root {
  --uq-bg: #0b0b10;
  --uq-bg-2: #12121a;
  --uq-ink: #eceaf4;
  --uq-muted: #8f8aa8;
  --uq-line: #262336;
  --uq-flame-a: #b48cff;
  --uq-flame-b: #6ee7ff;
  --uq-flame-c: #f4f1ff;
  --uq-body: #c9c5da;          /* chapter body ink (contract) */
  --uq-lock-line: #3a3752;
  --uq-head-veil: rgba(11, 11, 16, .82);
  --uq-flame-wash-a: rgba(180, 140, 255, .08);
  --uq-flame-wash-b: rgba(110, 231, 255, .05);
  /* the ONE accent formula (frozen contract) — no second gradient variant exists */
  --uq-flame: linear-gradient(100deg, var(--uq-flame-a), var(--uq-flame-b) 55%, var(--uq-flame-c));
  --serif: 'Fraunces', 'Noto Sans Thai', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', 'Noto Sans Thai', system-ui, sans-serif;
  color-scheme: dark;
}
[data-theme='light'] {
  --uq-bg: #f6f4fb;
  --uq-bg-2: #ffffff;
  --uq-ink: #232030;
  --uq-muted: #6d6885;
  --uq-line: #dcd8ea;
  --uq-flame-a: #7c4fe0;       /* flame stops deepen for contrast (contract) */
  --uq-flame-b: #0a7691;       /* owner-amended 2026-07-24 (T10 gate): 4.8:1 on pale ash, was #0ea5c9 @ 2.66:1 */
  --uq-flame-c: #232030;       /* white stop must not vanish on pale ash */
  --uq-body: #3c3850;
  --uq-lock-line: #c4bede;
  --uq-head-veil: rgba(246, 244, 251, .85);
  --uq-flame-wash-a: rgba(124, 79, 224, .07);
  --uq-flame-wash-b: rgba(10, 118, 145, .05);
  color-scheme: light;
}

/* ---- base ---- */
* { margin: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  background: var(--uq-bg); color: var(--uq-ink);
  font: 16px/1.7 var(--sans);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
.serif { font-family: var(--serif); }
img { max-width: 100%; }
a { color: inherit; }

/* language toggle — exactly one language renders (T05: one URL, live toggle) */
[data-lang='en'] .l-th { display: none !important; }
[data-lang='th'] .l-en { display: none !important; }

.kicker {
  letter-spacing: .34em; text-transform: uppercase;
  font-size: .7rem; color: var(--uq-muted); font-family: var(--sans);
}
[data-lang='th'] .kicker { letter-spacing: .18em; } /* Thai has no uppercase; wide tracking breaks sara placement */
.flame-text {
  background: var(--uq-flame);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

.skip {
  position: absolute; left: -999px; top: 0; z-index: 50;
  background: var(--uq-bg-2); color: var(--uq-ink); padding: .6rem 1rem;
  border: 1px solid var(--uq-flame-a); border-radius: 0 0 8px 0; text-decoration: none;
}
.skip:focus { left: 0; }

:focus-visible { outline: 2px solid var(--uq-flame-b); outline-offset: 2px; border-radius: 2px; }

/* ---- header ---- */
.site-head {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: 1.1rem 2rem; border-bottom: 1px solid var(--uq-line);
  position: sticky; top: 0; z-index: 5;
  background: var(--uq-head-veil); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.brand { font-weight: 650; letter-spacing: .02em; text-decoration: none; font-size: 1.05rem; display: inline-flex; align-items: center; gap: .45rem; }
.brand em { font-style: normal; color: var(--uq-flame-b); }
/* inline SVG (fill: currentColor) so the mark follows the ink in both themes — an <img>-loaded SVG would render black */
.brand-logo { height: 28px; width: 28px; vertical-align: middle; display: block; }
.pills { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.pill-group { display: flex; gap: 0; border: 1px solid var(--uq-line); border-radius: 999px; overflow: hidden; }
.pill-group .pill { border: 0; border-radius: 0; }
.pill {
  border: 1px solid var(--uq-line); border-radius: 999px; padding: .35rem .95rem;
  font-size: .8rem; color: var(--uq-ink); background: none; cursor: pointer;
  font-family: var(--sans); text-decoration: none; display: inline-block; line-height: 1.5;
}
.pill[aria-pressed='true'] { color: var(--uq-flame-a); box-shadow: inset 0 0 0 1px var(--uq-flame-a); }
.pill:hover { border-color: var(--uq-flame-a); }
.pill-group .pill:hover { box-shadow: inset 0 0 0 1px var(--uq-flame-a); }

/* www-style dual-swatch theme switch (replaces the single theme pill) */
.theme-switch { display: inline-flex; align-items: center; gap: .28rem; flex: none; padding: .26rem; border: 1px solid var(--uq-line); border-radius: 999px; }
.theme-opt {
  appearance: none; border: 0; margin: 0; padding: 2px; background: transparent;
  border-radius: 999px; line-height: 0; cursor: pointer; opacity: .45;
  transition: opacity .2s ease, box-shadow .2s ease, transform .2s ease;
}
.theme-opt:hover { opacity: .8; transform: translateY(-1px); }
.theme-opt[aria-pressed='true'] { opacity: 1; box-shadow: 0 0 0 2px var(--uq-flame-a); }
.theme-chip {
  position: relative; display: block; width: 26px; height: 26px;
  border-radius: 50%; overflow: hidden; border: 1px solid rgba(120, 120, 150, .35);
}
.theme-opt-light .theme-chip { background: #f7f7fb; }
.theme-opt-dark .theme-chip { background: #0b0d18; border-color: rgba(255, 255, 255, .16); }
.tc-bar, .tc-dot { position: absolute; }
.tc-bar { height: 2px; border-radius: 2px; }
.tc-bar-1 { top: 7px; right: 9px; width: 10px; }
.tc-bar-2 { top: 12px; right: 12px; width: 7px; }
.tc-dot { bottom: 5px; left: 5px; width: 6px; height: 6px; border-radius: 50%; }
.theme-opt-light .tc-bar { background: rgba(20, 22, 45, .3); }
.theme-opt-light .tc-dot { background: var(--uq-flame-b); }
.theme-opt-dark .tc-bar { background: rgba(255, 255, 255, .45); }
.theme-opt-dark .tc-dot { background: var(--uq-flame-a); }

/* profile chip (populated by site.js from /api/me) */
.nav-account-link { display: inline-flex; align-items: center; gap: .45rem; text-decoration: none; color: var(--uq-ink); }
.nav-avatar {
  width: 26px; height: 26px; border-radius: 50%; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--uq-line); font-size: .75rem;
}
.nav-avatar-img { width: 100%; height: 100%; object-fit: cover; }
/* initial ink follows the accent-filled convention: dark ink on the bright dark-theme cyan, white on the deep light-theme teal */
.nav-avatar--initial { background: var(--uq-flame-b); color: #0b0b10; }
[data-theme='light'] .nav-avatar--initial { color: #fff; }
.nav-account-name { font-size: .8rem; max-width: 10ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* accent-filled auth pill — mirrors .cta's ink (dark ink on light-violet dark theme, white on deep-violet light theme) */
.pill-auth { background: var(--uq-flame-a); color: #0b0b10; border-color: transparent; }
.pill-auth:hover { filter: brightness(1.08); border-color: transparent; }
[data-theme='light'] .pill-auth { color: #fff; }
/* narrow header: avatar only, drop the name so the pills don't wrap */
@media (max-width: 40rem) { .nav-account-name { display: none; } }

/* ---- book-cover hero ---- */
.hero { max-width: 68rem; margin: 0 auto; padding: 6rem 2rem 4rem; text-align: center; position: relative; }
.hero::before { /* cold-flame aurora — static blur, no loop (GPU discipline) */
  content: ''; position: absolute; inset: 10% 15% 30% 15%; z-index: -1;
  filter: blur(70px); opacity: .3;
  background: radial-gradient(ellipse at 30% 60%, var(--uq-flame-a), transparent 60%),
              radial-gradient(ellipse at 70% 40%, var(--uq-flame-b), transparent 60%);
}
[data-theme='light'] .hero::before { opacity: .18; }
.hero h1 {
  font-size: clamp(2.6rem, 7vw, 4.6rem); line-height: 1.12;
  font-weight: 600; margin: 1.2rem 0;
}
.hero h1.l-th, .hero h1 .l-th { line-height: 1.3; } /* Thai vowels above/below need air */
.hero p.tag { color: var(--uq-muted); max-width: 34rem; margin: 0 auto 2.2rem; }
.cta {
  display: inline-block; padding: .8rem 1.8rem; border-radius: 999px; text-decoration: none;
  color: #0b0b10; font-weight: 600; font-size: .95rem;
  background: var(--uq-flame);
}
.cta:hover { filter: brightness(1.08); }
[data-theme='light'] .cta { color: #fff; }

/* ---- chapter shelf ---- */
.toc { max-width: 76rem; margin: 0 auto; padding: 2rem; }
.toc h2 { font-size: .7rem; font-weight: 500; margin-bottom: 1.2rem; }
.shelf { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1.1rem; }
.cover {
  aspect-ratio: 2 / 3; border-radius: 10px; border: 1px solid var(--uq-line);
  position: relative; overflow: hidden;
  background: linear-gradient(160deg, var(--uq-bg-2), #191926);
  display: flex; flex-direction: column; justify-content: flex-end; padding: 1rem;
  text-decoration: none; color: var(--uq-ink);
  transition: border-color .2s, transform .2s;
}
[data-theme='light'] .cover { background: linear-gradient(160deg, var(--uq-bg-2), #eeeaf8); }
.cover:hover { border-color: var(--uq-flame-a); transform: translateY(-4px); }
.cover .num {
  position: absolute; top: .4rem; right: .8rem; z-index: 2;
  font-size: 3.2rem; font-weight: 700; opacity: .14; pointer-events: none;
}
.cover .art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover .art-pending { background: radial-gradient(ellipse at 50% 30%, var(--uq-flame-wash-a), transparent 65%); }
.cover-veil { /* keeps title/desc legible over the art */
  position: absolute; inset: 40% 0 0 0; pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(11, 11, 16, .88) 78%);
}
[data-theme='light'] .cover-veil { background: linear-gradient(180deg, transparent, rgba(11, 11, 16, .82) 78%); }
/* literals, not tokens, on purpose: this text sits on the fixed-DARK cover
   veil in BOTH themes, so it must not repaint with the light palette */
.cover b { font-weight: 600; font-size: 1.02rem; line-height: 1.25; position: relative; z-index: 1; color: #eceaf4; }
.cover-desc { font-size: .74rem; color: #b0abc6; position: relative; z-index: 1; }

/* ---- /game teaser cast (T11) ---- */
.cast-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1.1rem; max-width: 56rem; margin: 0 auto; }
.cast-card {
  aspect-ratio: 1 / 1; border-radius: 12px; border: 1px solid var(--uq-line); overflow: hidden;
  transition: border-color .2s, transform .2s;
}
.cast-card:hover { border-color: var(--uq-flame-a); transform: translateY(-4px); }
.cast-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cast-note { text-align: center; color: var(--uq-muted); font-size: .85rem; margin-top: 1.2rem; }
@media (prefers-reduced-motion: reduce) { .cast-card { transition: none; } .cast-card:hover { transform: none; } }

/* ---- game teaser strip (ooc promo-strip grammar) ---- */
.strip {
  max-width: 76rem; margin: 2.5rem auto; padding: 1.1rem 2rem;
  border: 1px solid var(--uq-line); border-radius: 12px;
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
  background: linear-gradient(90deg, var(--uq-flame-wash-a), var(--uq-flame-wash-b));
}
.strip a:not(.cta) { color: var(--uq-flame-b); text-decoration: none; font-size: .9rem; white-space: nowrap; }
/* light links use flame-VIOLET (a token — no second accent): the light cyan
   token measures ~2.7:1 on pale ash, below AA for small text */
[data-theme='light'] .strip a:not(.cta) { color: var(--uq-flame-a); }
.strip a:not(.cta):hover { text-decoration: underline; }
.strip-kicker { display: block; margin-bottom: .3rem; }
@media (max-width: 76rem) { .strip { margin-left: 2rem; margin-right: 2rem; } }
@media (max-width: 40rem) { .strip { margin-left: 1rem; margin-right: 1rem; } }

/* ---- chapter reading page ---- */
.progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 10; pointer-events: none; }
.progress-bar { height: 100%; width: 100%; background: var(--uq-flame); transform-origin: 0 50%; transform: scaleX(0); }

.chapter { max-width: 44rem; margin: 5rem auto; padding: 0 2rem; }
.ch-kicker {
  margin-bottom: .8rem;
  background: var(--uq-flame);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.ch-title { font-size: clamp(2rem, 5vw, 3rem); font-weight: 600; line-height: 1.15; margin-bottom: .6rem; }
.ch-title .l-th { line-height: 1.35; }
.ch-desc { color: var(--uq-muted); margin-bottom: 2.6rem; }
.chapter p.body { color: var(--uq-body); margin-bottom: 1.4rem; font-size: 1.06rem; }
.chapter .l-en p.drop::first-letter { /* EN only — Thai has no capitals; a giant first glyph misreads */
  font-family: var(--serif); float: left;
  font-size: 3.3em; line-height: .85; padding: .04em .12em 0 0;
  color: var(--uq-flame-a);
}
.ch-sub {
  font-size: 1.55rem; font-weight: 600; line-height: 1.25;
  margin: 2.8rem 0 1.1rem;
  background-image: var(--uq-flame);
  background-repeat: no-repeat; background-size: 0% 100%;
  -webkit-background-clip: text; background-clip: text;
}
.ch-sub.swept, html.no-motion .ch-sub, html.no-gsap .ch-sub { background-size: 100% 100%; color: transparent; }
html.no-motion .ch-sub, html.no-gsap .ch-sub { transition: none; }
.ch-sub3 { font-size: 1.2rem; font-weight: 600; margin: 2.2rem 0 .9rem; color: var(--uq-ink); }
.ch-list { color: var(--uq-body); margin: 0 0 1.4rem; padding-left: 1.2rem; }
.ch-list li { margin-bottom: .7rem; font-size: 1.02rem; }
.ch-list strong { color: var(--uq-ink); font-weight: 600; }

/* ---- locked deep-lore panel ---- */
.locked {
  border: 1px dashed var(--uq-lock-line); border-radius: 12px;
  padding: 1.4rem 1.6rem; margin: 2.4rem 0;
  background: var(--uq-flame-wash-a);
}
.lk-head { display: flex; align-items: center; gap: .6rem; font-weight: 600; flex-wrap: wrap; font-size: 1.05rem; }
.badge {
  font-family: var(--sans); font-weight: 500; font-size: .68rem;
  letter-spacing: .12em; text-transform: uppercase;
  border: 1px solid var(--uq-flame-a); color: var(--uq-flame-a);
  border-radius: 999px; padding: .15rem .6rem; white-space: nowrap;
}
.lk-teaser p { color: var(--uq-muted); font-size: .9rem; margin-top: .5rem; }
.lk-teaser a { color: var(--uq-flame-b); text-decoration: underline; }
[data-theme='light'] .lk-teaser a { color: var(--uq-flame-a); }
.locked.unlocked { border-style: solid; border-color: var(--uq-flame-a); }
.lk-body p { color: var(--uq-body); font-size: 1rem; margin-top: .9rem; }

/* ---- pager ---- */
.pager {
  max-width: 44rem; margin: 0 auto 5rem; padding: 0 2rem;
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem;
}
.pg {
  border: 1px solid var(--uq-line); border-radius: 12px; padding: 1rem 1.2rem;
  text-decoration: none; display: flex; flex-direction: column; gap: .35rem;
  transition: border-color .2s, transform .2s;
}
.pg:hover { border-color: var(--uq-flame-a); transform: translateY(-2px); }
.pg-next { text-align: right; align-items: flex-end; }
.pg .serif { font-weight: 600; line-height: 1.3; }
@media (max-width: 40rem) { .pager { grid-template-columns: 1fr; } .pg-next { text-align: left; align-items: flex-start; } }

/* ---- footer ---- */
.site-foot {
  text-align: center; color: var(--uq-muted); font-size: .78rem;
  padding: 3rem 1rem 2.5rem; border-top: 1px solid var(--uq-line);
}
.site-foot a { color: var(--uq-muted); }
.site-foot a:hover { color: var(--uq-flame-b); }

/* ---- motion discipline ---- */
.reveal { opacity: 1; } /* GSAP sets the from-state; content is visible without JS */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .cover, .pg, .cta { transition: none; }
  .cover:hover, .pg:hover { transform: none; }
}
