/* Time Machine Library */
@font-face { font-family: "Courgette"; src: url("fonts/Courgette.ttf") format("truetype"); font-display: swap; }

:root {
  --text-scale: 1;
  --accent: #1f3a7a;
  --gold: #b8862b;
  --bg: #f4ecd8;
  --bg-page: #fbf6ea;
  --ink: #2a2118;
  --muted: #6c5f4f;
  --line: #d9ccb0;
  --btn: #fffaf0;
  --shadow: 0 1px 2px rgb(60 40 10 / .12), 0 6px 18px rgb(60 40 10 / .10);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17140f; --bg-page: #201c16; --ink: #ece3d0; --muted: #b3a68f; --line: #3d3528; --btn: #2a251d;
    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 6px 18px rgb(0 0 0 / .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] figure.art img { mix-blend-mode: normal; }
:root[data-theme="dark"] {
  --bg: #17140f; --bg-page: #201c16; --ink: #ece3d0; --muted: #b3a68f; --line: #3d3528; --btn: #2a251d;
  --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 6px 18px rgb(0 0 0 / .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: calc(1.125rem * var(--text-scale))/1.6 var(--serif);
  min-height: 100vh; min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}
img { max-width: 100%; height: auto; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.skip { position: absolute; left: -999px; top: 0; }
.skip:focus { left: 8px; top: 8px; z-index: 50; background: var(--btn); padding: 8px 12px; }
main:focus { outline: none; }
.muted { color: var(--muted); font-size: .9em; }

/* top bar */
.bar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 4px;
  padding: calc(6px + env(safe-area-inset-top)) 8px 6px; background: #1b1a17; color: #f4ecd8;
}
.bar-title { flex: 1; font: 600 1rem/1.2 var(--sans); letter-spacing: .02em; text-align: center; }
.icon-btn {
  width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 10px;
  background: transparent; color: inherit; cursor: pointer;
}
.icon-btn svg { width: 24px; height: 24px; fill: currentColor; }
.icon-btn:hover { background: rgb(255 255 255 / .08); }
.icon-btn.hint { color: #f3c45a; animation: glow 2.4s ease-in-out infinite; }
@keyframes glow { 50% { filter: drop-shadow(0 0 6px #f3c45a); } }

/* page */
main { max-width: 42rem; margin: 0 auto; padding: 16px 16px 48px; }
main.enter { animation: enter .35s ease-out; }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } }
.page {
  background: var(--bg-page); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  padding: clamp(18px, 5vw, 40px);
}
.page p { margin: 0 0 1em; hyphens: none; }
.story > p:first-child::first-letter {
  float: left; font: 3.3em/.9 "Courgette", var(--serif); padding: .06em .16em 0 .02em; color: var(--accent);
}
h1, h2 { line-height: 1.2; margin: 0 0 .6em; }
.fancy, .title-page h1, .hero h1 { font-family: "Courgette", var(--serif); font-weight: 400; color: var(--accent); }
:root[data-theme="dark"] .fancy, :root[data-theme="dark"] .title-page h1, :root[data-theme="dark"] .hero h1 { color: #9db4ef; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) figure.art img { mix-blend-mode: normal; } }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) :is(.fancy, .title-page h1, .hero h1) { color: #9db4ef; } }
.fancy { font-size: 1.9em; }
figure.art { margin: 1.4em -8px; }
figure.art img { mix-blend-mode: multiply; display: block; margin: 0 auto; border-radius: 6px; max-height: 80vh; width: auto; }
ol.rules li, ol.facts li { margin-bottom: .7em; }
ol.facts li.fact-img { list-style: none; }

/* choices */
.choices { display: grid; gap: 10px; margin-top: 1.6em; }
.btn {
  display: block; width: 100%; text-align: left; text-decoration: none; cursor: pointer;
  font: 600 calc(1rem * var(--text-scale))/1.35 var(--sans); color: var(--ink);
  background: var(--btn); border: 1.5px solid var(--line); border-radius: 12px; padding: 14px 16px;
  transition: transform .08s, border-color .15s, background .15s;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: scale(.99); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.choice span { float: right; color: var(--gold); }
.mission-done { text-align: center; border-top: 2px solid var(--gold); margin-top: 2em; padding-top: 1.2em; }
.mission-done h2 { font: 400 2em/1.2 "Courgette", var(--serif); color: var(--gold); }

/* library */
.hero { text-align: center; padding: 12px 0 8px; }
.hero-mark { width: 72px; height: 72px; }
.hero h1 { font-size: clamp(2.2rem, 8vw, 3.2rem); margin: .1em 0 .1em; }
.lede { color: var(--muted); margin: 0 auto 1em; max-width: 30em; }
main:has(.library) { max-width: 72rem; }
.shelf {
  list-style: none; margin: 16px 0; padding: 0; display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.card {
  display: flex; flex-direction: column; height: 100%; text-decoration: none; color: var(--ink);
  background: var(--bg-page); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow);
  font-family: var(--sans); transition: transform .15s;
}
a.card:hover { transform: translateY(-3px); }
.card img { aspect-ratio: 2 / 3; object-fit: cover; width: 100%; background: var(--line); }
.card .num { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 10px 10px 0; }
.card .t { font-weight: 700; font-size: .95rem; line-height: 1.25; padding: 2px 10px 0; }
.card .by { font-size: .8rem; color: var(--muted); padding: 2px 10px 0; flex: 1; }
.card.off img { filter: grayscale(.65) brightness(.9); opacity: .8; }
.tag { margin: 10px; align-self: flex-start; font-size: .75rem; font-weight: 700; padding: 3px 9px; border-radius: 99px; }
.tag.go { background: var(--accent); color: #fff; }
.tag.done { background: var(--gold); color: #fff; }
.tag.soon { background: var(--line); color: var(--muted); }
.tag.buy { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent); }
.foot { text-align: center; color: var(--muted); font: .85rem/1.5 var(--sans); padding: 24px 0; }
.link { background: none; border: 0; color: var(--accent); font: inherit; text-decoration: underline; cursor: pointer; }

/* title page */
.title-page { display: grid; gap: 24px; align-items: center; }
.title-page .cover { width: min(280px, 70vw); margin: 0 auto; border-radius: 8px; box-shadow: var(--shadow); }
.title-page h1 { font-size: clamp(2rem, 7vw, 2.8rem); }
.eyebrow { font: 700 .8rem/1 var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--gold); margin: 0 0 .6em; }
.credits { font-style: italic; color: var(--muted); }
.actions { display: grid; gap: 10px; margin-top: 1.2em; }
@media (min-width: 720px) { .title-page { grid-template-columns: 300px 1fr; } main:has(.title-page) { max-width: 56rem; } }

/* sheet */
.sheet {
  border: 0; padding: 0; width: min(36rem, 100vw); max-height: 88vh; margin: auto auto 0; border-radius: 18px 18px 0 0;
  background: var(--bg-page); color: var(--ink); box-shadow: 0 -8px 40px rgb(0 0 0 / .3);
}
@media (min-width: 720px) { .sheet { margin: auto; border-radius: 18px; } }
.sheet::backdrop { background: rgb(10 8 5 / .55); }
.sheet[open] { animation: up .25s ease-out; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.sheet-head { position: sticky; top: 0; display: flex; align-items: center; padding: 8px 8px 8px 20px; background: var(--bg-page); border-bottom: 1px solid var(--line); }
.sheet-head h2 { flex: 1; margin: 0; font: 400 1.5rem/1.2 "Courgette", var(--serif); color: var(--accent); }
.sheet-body { padding: 16px 20px calc(24px + env(safe-area-inset-bottom)); overflow: auto; }
.menu-item {
  display: block; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line);
  padding: 14px 4px; font: 600 1rem/1.3 var(--sans); color: var(--ink); cursor: pointer;
}
.menu-item span { display: block; font-weight: 400; font-size: .85rem; color: var(--muted); }
.menu-row { display: flex; align-items: center; gap: 8px; padding: 12px 4px; border-bottom: 1px solid var(--line); font: 600 1rem var(--sans); }
.menu-row span { flex: 1; }
.chip { font: 600 .9rem var(--sans); padding: 8px 12px; border-radius: 99px; border: 1.5px solid var(--line); background: var(--btn); color: var(--ink); cursor: pointer; min-width: 44px; }
.chip.on { border-color: var(--accent); background: var(--accent); color: #fff; }
.hint { font-size: 1.2em; font-style: italic; }
.paths { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px; }
.paths li { aspect-ratio: 1; display: grid; place-items: center; border-radius: 8px; border: 1.5px dashed var(--line); font: 600 .8rem var(--sans); color: var(--muted); }
.paths li.found { border-style: solid; border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--ink); }
.paths li.end { background: var(--gold); border-color: var(--gold); color: #fff; }

/* time vortex */
.vortex { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: #05040a; color: #f4ecd8; overflow: hidden; }
[hidden] { display: none !important; }
.vortex .rings { position: relative; width: 10px; height: 10px; }
.vortex i {
  position: absolute; left: 50%; top: 50%; border-radius: 50%; border: 3px solid transparent;
  border-top-color: #f3c45a; border-left-color: #6d8ff0; translate: -50% -50%;
}
.vortex.on i { animation: spin 1.1s linear infinite, grow 1.9s ease-in forwards; }
.vortex i:nth-child(1) { width: 40px; height: 40px; }
.vortex i:nth-child(2) { width: 90px; height: 90px; animation-duration: .9s, 1.9s; animation-direction: reverse, normal; }
.vortex i:nth-child(3) { width: 150px; height: 150px; }
.vortex i:nth-child(4) { width: 220px; height: 220px; animation-duration: 1.4s, 1.9s; animation-direction: reverse, normal; }
.vortex i:nth-child(5) { width: 300px; height: 300px; }
.vortex i:nth-child(6) { width: 390px; height: 390px; animation-direction: reverse, normal; }
.vortex i:nth-child(7) { width: 490px; height: 490px; }
.vortex i:nth-child(8) { width: 600px; height: 600px; animation-direction: reverse, normal; }
@keyframes spin { to { rotate: 360deg; } }
@keyframes grow { 0% { scale: .2; opacity: 0; } 25% { opacity: 1; } 100% { scale: 2.2; opacity: .9; } }
.vortex p { position: absolute; bottom: 18%; left: 16px; right: 16px; text-align: center; font: 400 1.4rem/1.3 "Courgette", var(--serif); animation: enter .6s ease-out; }
@media (prefers-reduced-motion: reduce) {
  .vortex.on i, main.enter, .sheet[open], .icon-btn.hint { animation: none; }
}
