/* =====================================================================
   Czech Memories — core.css
   Shared grid, tokens, components. Themes override variables only.
   ===================================================================== */
:root {
  --bg: #F5F1E8;
  --bg-2: #ECE5D6;
  --ink: #111111;
  --ink-2: #4a4640;
  --paper: #ffffff;
  --line: rgba(17, 17, 17, .14);
  --accent: #D99A2B;
  --accent-2: #B8442E;
  --play: #6D4AFF;
  --on-accent: #111;
  --f-body: "Noto Sans TC", system-ui, sans-serif;
  --f-zh-display: "Noto Sans TC", system-ui, sans-serif;
  --f-serif: "Noto Serif TC", serif;
  --f-en: "Unbounded", "Noto Sans TC", sans-serif;
  --f-data: "Space Grotesk", "Noto Sans TC", sans-serif;
  --f-cs: "Instrument Serif", "Noto Serif TC", serif;
  --f-hand: "Noto Serif TC", serif;
  --f-type: "Space Grotesk", monospace;
  --gutter: 16px;
  --gap: 16px;
  --maxw: 1440px;
  --radius: 14px;
  --topbar-h: 56px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}
@media (min-width: 900px) {
  :root { --gutter: 48px; --gap: 24px; --topbar-h: 64px; }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 12px); }
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-stopped { overflow: hidden; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--f-body); font-size: 17px; line-height: 1.75;
  overflow-x: clip; min-height: 100svh;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
@supports not (overflow: clip) { body { overflow-x: hidden; } }
img, svg { display: block; max-width: 100%; }
img { height: auto; }
a { color: inherit; text-underline-offset: .2em; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.15; font-weight: 900; }
p { margin: 0 0 1em; }
:focus-visible { outline: 3px solid var(--play); outline-offset: 3px; border-radius: 4px; }
::selection { background: var(--play); color: #fff; }

.skip { position: absolute; left: -9999px; top: 8px; z-index: 200; background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 8px; }
.skip:focus { left: 8px; }
.hand { font-family: var(--f-hand); }
.eyebrow { font-family: var(--f-data); font-size: 12px; letter-spacing: .22em; text-transform: uppercase; margin: 0 0 .8em; color: var(--ink-2); font-weight: 700; }

/* ---------- section head ---------- */
.sec-head { padding: 0 var(--gutter); max-width: 960px; margin: 0 auto 28px; }
.sec-title { font-size: clamp(30px, 7vw, 64px); letter-spacing: -.01em; }
.sec-sub { margin-top: .8em; color: var(--ink-2); max-width: 40em; }
main > section, main > header, main > nav { position: relative; }
main > section { padding-block: clamp(64px, 12vw, 140px); }

/* ---------- topbar ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 90; height: var(--topbar-h);
  display: flex; align-items: center; gap: 10px; padding: 0 max(var(--gutter), env(safe-area-inset-left)) 0 max(var(--gutter), env(safe-area-inset-left));
  pointer-events: none; mix-blend-mode: normal;
}
.topbar > * { pointer-events: auto; }
.brand { font-family: var(--f-en); font-weight: 900; font-size: 14px; letter-spacing: .08em; text-decoration: none; padding: 8px 12px; border-radius: 999px; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.chip-stamp {
  margin-left: auto; display: inline-flex; align-items: baseline; gap: 2px;
  border: 2px solid var(--ink); background: var(--bg); color: var(--ink);
  border-radius: 999px; padding: 6px 12px; font-family: var(--f-data); font-weight: 700; font-size: 14px;
  transition: transform .3s var(--ease);
}
.chip-stamp small { font-size: 10px; opacity: .6; }
.chip-stamp:hover { transform: rotate(-4deg) scale(1.05); }
.tools { display: flex; gap: 6px; }
.tool {
  min-width: 40px; height: 40px; display: grid; place-items: center; padding: 0 10px;
  border-radius: 999px; border: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); font-size: 13px;
}
.tool svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.tool svg circle + path { fill: currentColor; stroke: none; }
.tool[aria-pressed="false"] .wave { opacity: .25; }
.tool-quiet[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
@media (max-width: 420px) { .tool-quiet span { font-size: 12px; } .brand { font-size: 12px; padding: 8px 10px; } .tool { min-width: 36px; height: 36px; padding: 0 8px; } }

/* ---------- toc drawer ---------- */
.toc { position: fixed; inset: 0; z-index: 120; background: color-mix(in srgb, var(--ink) 55%, transparent); display: grid; justify-items: end; }
.toc[hidden] { display: none; }
.toc-in { width: min(460px, 100%); height: 100%; overflow: auto; background: var(--bg); padding: 76px 24px 40px; position: relative; overscroll-behavior: contain; }
.toc-h { font-family: var(--f-data); letter-spacing: .2em; font-size: 12px; text-transform: uppercase; }
.toc-in ol { list-style: none; margin: 0; padding: 0; }
.toc-in li a { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: baseline; padding: 12px 0; border-bottom: 1px solid var(--line); text-decoration: none; }
.toc-in li b { font-family: var(--f-data); font-size: 20px; }
.toc-in li i { font-family: var(--f-cs); font-style: italic; opacity: .6; font-size: 15px; }
.toc-in li.cur a { color: var(--accent-2); }
.toc-in li.future span::after { content: " · 旅途中"; font-size: 12px; opacity: .55; }
.toc-links { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 24px; font-family: var(--f-data); }
.toc-close { position: absolute; top: 14px; right: 16px; width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--ink); background: none; font-size: 24px; line-height: 1; }

/* ---------- progress ---------- */
.progress { position: fixed; left: 0; right: 0; bottom: 0; height: 4px; z-index: 95; background: transparent; }
.progress i { display: block; height: 100%; width: 100%; transform-origin: 0 50%; transform: scaleX(var(--p, 0)); background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--play)); }

/* ---------- pictures ---------- */
.pic { margin: 0; position: relative; overflow: hidden; background: var(--bg-2) center / cover no-repeat; border-radius: 4px; }
.pic img { width: 100%; height: 100%; object-fit: cover; object-position: var(--focus, 50% 50%); transition: opacity .6s; }
.pic.fill { position: absolute; inset: 0; border-radius: 0; }
.pic-tag { position: absolute; left: 8px; top: 8px; font: 700 10px/1 var(--f-data); letter-spacing: .12em; padding: 5px 7px; border-radius: 999px; background: rgba(17,17,17,.62); color: #fff; z-index: 2; pointer-events: none; }
.pic-credit { position: absolute; right: 6px; bottom: 5px; max-width: 80%; font: 10px/1.3 var(--f-data); color: rgba(255,255,255,.85); text-shadow: 0 1px 2px rgba(0,0,0,.7); z-index: 2; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; pointer-events: none; }
.pic-cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 26px 10px 18px; font-size: 13px; line-height: 1.4; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.65)); z-index: 1; text-align: left; }
.pic-empty { aspect-ratio: 4 / 3; display: grid; place-items: center; }
.pic-wait span { font-family: var(--f-data); letter-spacing: .2em; font-size: 12px; opacity: .6; }

/* ---------- status stamp ---------- */
.status-stamp { display: inline-block; font: 700 13px/1 var(--f-data); letter-spacing: .14em; padding: 10px 14px; border: 2px solid currentColor; border-radius: 6px; color: var(--accent-2); transform: rotate(-6deg); margin: 18px 0 0; }

/* ---------- chapter nav (page turn) ---------- */
.C-next { padding: 72px var(--gutter) 96px; display: grid; gap: 18px; justify-items: center; }
.next-link { position: relative; display: grid; gap: 6px; width: min(720px, 100%); padding: 34px 28px 30px; border-radius: 6px; background: var(--ink); color: var(--bg); text-decoration: none; overflow: hidden; isolation: isolate; }
.nl-k { font-family: var(--f-data); font-size: 12px; letter-spacing: .24em; text-transform: uppercase; opacity: .7; }
.nl-no { font-family: var(--f-data); font-size: 18px; }
.nl-big { font-family: var(--f-en); font-weight: 900; font-size: clamp(30px, calc((min(100vw, 720px) - 2 * var(--gutter) - 56px) / (var(--len, 6) * 1)), 96px); line-height: .95; letter-spacing: -.02em; overflow-wrap: anywhere; color: var(--accent); }
.nl-t { font-size: 18px; }
.curl { position: absolute; right: 0; bottom: 0; width: 64px; height: 64px; background: linear-gradient(135deg, transparent 50%, var(--bg-2) 50%); box-shadow: -4px -4px 10px rgba(0,0,0,.35); transition: width .45s var(--ease), height .45s var(--ease); z-index: -0; }
.next-link:hover .curl, .next-link:focus-visible .curl { width: 120px; height: 120px; }
.nav-row { display: flex; gap: 28px; font-family: var(--f-data); }

.site-foot { padding: 32px var(--gutter) 56px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-2); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.site-foot p { margin: 0; }

/* ---------- loader ---------- */
.loader { display: none; }
.js .loader { display: grid; position: fixed; inset: 0; z-index: 300; place-items: center; background: var(--bg); transition: opacity .6s var(--ease), visibility .6s; }
.js .loader.done, .js:not(.motion-pending) .loader:not(.run) { opacity: 0; visibility: hidden; pointer-events: none; }
.ld-in { display: grid; justify-items: center; gap: 10px; width: min(320px, 70vw); }
.ld-map { width: 100%; overflow: visible; }
.ld-map path { fill: none; stroke: var(--ink); stroke-width: 3; stroke-dasharray: 4000; stroke-dashoffset: 4000; animation: ld-draw 1.6s var(--ease) forwards; }
@keyframes ld-draw { to { stroke-dashoffset: 0; } }
.ld-pct { font: 700 14px/1 var(--f-data); letter-spacing: .1em; margin: 0; }
.ld-t { font-family: var(--f-en); font-weight: 900; letter-spacing: .1em; margin: 0; }
.ld-blocks { position: relative; width: 64px; height: 64px; }
.ld-blocks i { position: absolute; width: 32px; height: 32px; animation: ld-block 1.2s var(--ease) both; }
.ld-blocks i:nth-child(1) { left: 0; top: 0; background: #D99A2B; clip-path: polygon(0 0, 100% 0, 0 100%); }
.ld-blocks i:nth-child(2) { right: 0; top: 0; background: #B8442E; animation-delay: .1s; }
.ld-blocks i:nth-child(3) { left: 0; bottom: 0; background: #1F5A7A; clip-path: polygon(0 0, 100% 100%, 0 100%); animation-delay: .2s; }
.ld-blocks i:nth-child(4) { right: 0; bottom: 0; background: #6D4AFF; clip-path: polygon(100% 0, 100% 100%, 0 100%); animation-delay: .3s; }
@keyframes ld-block { from { transform: translate(var(--lx, -30px), var(--ly, -30px)) rotate(-90deg); opacity: 0; } }
.ld-blocks i:nth-child(2) { --lx: 30px; } .ld-blocks i:nth-child(3) { --ly: 30px; } .ld-blocks i:nth-child(4) { --lx: 30px; --ly: 30px; }

/* ---------- motion-pending: hide animated bits until JS has set initial states ---------- */
.motion-pending main [data-split], .motion-pending main [data-reveal] { opacity: 0; }

/* ---------- custom cursor ---------- */
.cursor { position: fixed; left: 0; top: 0; z-index: 400; pointer-events: none; mix-blend-mode: difference; display: none; opacity: 0; transition: opacity .3s; }
.cursor.on { opacity: 1; }
.cursor i { position: absolute; width: 8px; height: 8px; margin: -4px; border-radius: 50%; background: #fff; }
.cursor b { position: absolute; width: 38px; height: 38px; margin: -19px; border-radius: 50%; border: 1.5px solid #fff; transition: width .25s, height .25s, margin .25s; display: grid; place-items: center; font: 700 9px/1 var(--f-data); color: #fff; letter-spacing: .1em; }
.cursor.big b { width: 74px; height: 74px; margin: -37px; }
@media (hover: hover) and (pointer: fine) { .has-cursor .cursor { display: block; } }

/* ---------- particles canvas ---------- */
.fx-canvas { position: fixed; inset: 0; z-index: 60; pointer-events: none; opacity: .9; }

/* ---------- view transitions (cross-document) ---------- */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: vt-out .55s var(--ease) both; }
::view-transition-new(root) { animation: vt-in .7s var(--ease) both; }
@keyframes vt-out { to { opacity: .2; transform: scale(.96); } }
@keyframes vt-in { from { clip-path: polygon(100% 0, 100% 0, 100% 100%, 100% 100%); } to { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%); } }

/* ---------- quiet / reduced ---------- */
html.quiet *, html.reduced * { scroll-behavior: auto !important; }
html.quiet .fx-canvas, html.reduced .fx-canvas, html.quiet .cursor, html.reduced .cursor { display: none !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
}
html.quiet *, html.quiet *::before, html.quiet *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
html.quiet::view-transition-old(root), html.quiet::view-transition-new(root) { animation: none; }
@keyframes blink { 50% { opacity: 0; } }
@media (max-width: 520px) {
  .topbar { gap: 6px; }
  .brand { font-size: 11px; letter-spacing: .02em; padding: 7px 9px; }
  .chip-stamp { padding: 5px 9px; font-size: 13px; }
  .tools { gap: 4px; }
  .tool { min-width: 34px; height: 34px; padding: 0 6px; }
  .tool-quiet span { font-size: 0; }
  .tool-quiet span::after { content: "靜"; font-size: 14px; font-weight: 700; }
}
