:root {
  --paper: #fbf6ea;
  --ink: #2a2633;
  --muted: #6f6a76;
  --accent: #c8572f;
  --bar-bg: rgba(20, 18, 34, 0.55);
  --bar-ink: #f4efe6;
  --page: #16152a;
  --page-ink: #efe9df;
}
body[data-mode="day"] {
  --bar-bg: rgba(255, 250, 240, 0.7);
  --bar-ink: #2a2633;
  --page: #f3ead9;
  --page-ink: #2a2633;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--page-ink);
  font: 16px/1.55 Inter, system-ui, sans-serif;
}
a { color: inherit; }

/* ---------- top bar ---------- */
.bar {
  position: fixed; inset: 0 0 auto 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px;
  background: var(--bar-bg); color: var(--bar-ink);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.brand { font: 700 26px/1 Caveat, cursive; text-decoration: none; white-space: nowrap; }
.brand span { opacity: 0.75; }
.langs { display: flex; gap: 4px; margin: 0 auto; }
.langs a {
  text-decoration: none; font-weight: 700; font-size: 13px; letter-spacing: 0.04em;
  padding: 6px 10px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap;
}
.langs a:hover { border-color: currentColor; }
.tools { display: flex; gap: 6px; }
.chip {
  font: 500 13px Inter, sans-serif; color: inherit; text-decoration: none; cursor: pointer;
  background: transparent; border: 1px solid currentColor; border-radius: 999px; padding: 5px 11px; opacity: 0.85; white-space: nowrap;
}
/* touch screens keep :hover on the last thing tapped, which left the Back chip showing over the desk */
@media (hover: hover) { .chip:hover { opacity: 1; } }
@media (hover: none) { .back .kbd { display: none; } }
body[data-mode="night"] .day-only, body[data-mode="day"] .night-only { display: none; }

/* ---------- stage ---------- */
.stage-wrap { position: relative; height: 100vh; height: 100svh; overflow: hidden; }
#stage { display: block; width: 100%; height: 100%; touch-action: manipulation; }
/* instant poster: a still of the home view (tools/make_posters.mjs); the 3D fades in over it when ready */
#poster {
  position: absolute; inset: 0; background: var(--page) no-repeat center;
}
#poster.fit-w { background-size: 100% auto; }
#poster.fit-h { background-size: auto 100%; }
body.ready #poster { visibility: hidden; transition: visibility 0s 1s; }
#stage { position: relative; opacity: 0; transition: opacity 0.6s; }
body.ready #stage { opacity: 1; }
#poster-hints { position: absolute; inset: 0; pointer-events: none; transition: opacity 0.4s; }
body.ready #poster-hints { display: none; }
body.focused #poster-hints { opacity: 0; }
body.focused #poster-hints .hint { pointer-events: none; }
/* ?poster=1 screenshots: the bare 3D view only */
body.poster-shot .bar, body.poster-shot #hints, body.poster-shot .hello, body.poster-shot #tip,
body.poster-shot .back, body.poster-shot #poster, body.poster-shot #poster-hints { display: none !important; }
body.poster-shot #stage { transition: none; }
.hello {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); margin: 0;
  font: 700 24px Caveat, cursive; color: #fff; text-shadow: 0 1px 8px rgba(0,0,0,0.5);
  transition: opacity 0.4s; pointer-events: none; white-space: nowrap;
}
body.focused .hello { opacity: 0; }
#tip {
  position: fixed; left: 0; top: 0; z-index: 15; pointer-events: none;
  background: var(--paper); color: var(--ink); padding: 3px 10px; border-radius: 6px;
  font: 700 20px Caveat, cursive; box-shadow: 0 4px 14px rgba(0,0,0,0.25);
}
#hints { position: absolute; inset: 0; pointer-events: none; transition: opacity 0.4s; }
body.focused #hints { opacity: 0; }
body.focused #hints .hint { pointer-events: none; }
.hint {
  position: absolute; left: 0; top: 0; pointer-events: auto; cursor: pointer;
  display: flex; align-items: center; gap: 6px; margin: -9px 0 0 -9px;
  background: none; border: 0; padding: 0; color: #fff;
}
.hint .dot {
  width: 18px; height: 18px; border-radius: 50%; background: rgba(255, 214, 150, 0.95);
  box-shadow: 0 0 0 0 rgba(255, 214, 150, 0.7); animation: pulse 2.2s infinite;
}
.hint .lbl {
  font: 700 18px Caveat, cursive; text-shadow: 0 1px 6px rgba(0,0,0,0.6);
  opacity: 0; transform: translateX(-4px); transition: 0.25s;
}
.hint:hover .lbl, .hint:focus-visible .lbl { opacity: 1; transform: none; }
@media (hover: none) { .hint .lbl { opacity: 1; transform: none; } }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 214, 150, 0.7); }
  70% { box-shadow: 0 0 0 14px rgba(255, 214, 150, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 214, 150, 0); }
}
.back {
  position: absolute; left: 16px; bottom: 16px; z-index: 12;
  background: rgba(20, 18, 34, 0.6); color: #fff; border-color: rgba(255,255,255,0.6);
  opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
body.focused .back { opacity: 1; pointer-events: auto; }

/* ---------- note card ---------- */
#card {
  position: absolute; z-index: 14; right: 5vw; top: 50%;
  width: min(380px, calc(100vw - 32px));
  max-height: 72vh; overflow: auto;
  background: var(--paper); color: var(--ink);
  padding: 30px 26px 22px; border-radius: 4px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  transform: translateY(-46%) rotate(1.2deg) scale(0.96); opacity: 0;
  transition: opacity 0.35s 0.35s, transform 0.45s 0.35s cubic-bezier(.2,.8,.2,1);
}
#card.show { opacity: 1; transform: translateY(-50%) rotate(-0.8deg); }
#card::before {
  content: ""; position: absolute; top: -12px; left: 50%; width: 110px; height: 26px; margin-left: -55px;
  background: rgba(240, 214, 140, 0.75); transform: rotate(-3deg);
}
#card-close {
  position: absolute; right: 8px; top: 6px; border: 0; background: none; cursor: pointer;
  font-size: 26px; line-height: 1; color: var(--muted);
}
@media (max-aspect-ratio: 1/1) {
  #card {
    left: 16px; right: 16px; width: auto; top: auto; bottom: 60px; max-height: 56svh;
    padding: 22px 20px 0; font-size: 15px; line-height: 1.45;
    transform: translateY(20px) rotate(0.6deg);
  }
  #card.show { transform: rotate(-0.4deg); }
  /* fades the last visible line while there is more to scroll; plain bottom padding otherwise */
  #card::after {
    content: ""; display: block; position: sticky; bottom: 0; height: 26px; pointer-events: none;
    background: linear-gradient(rgba(251, 246, 234, 0), var(--paper) 80%);
  }
  #card h2 { font-size: 32px; margin-bottom: 8px; }
  #card p { margin-bottom: 8px; }
  .langs a { padding: 6px 7px; }
}

/* ---------- card content (shared with lite page) ---------- */
[data-card] h2 { font: 700 38px/1.05 Caveat, cursive; margin: 0 0 10px; }
[data-card] h2.tag::after {
  content: ""; display: block; width: 46px; height: 5px; margin-top: 6px; border-radius: 3px; background: var(--c);
}
[data-card] p { margin: 0 0 10px; }
[data-card] .soon { font: 700 22px Caveat, cursive; color: var(--accent); }
[data-card] .links a { font-weight: 600; }
[data-card] .go {
  display: inline-block; text-decoration: none; background: var(--ink); color: var(--paper);
  padding: 8px 14px; border-radius: 999px;
}
.eps { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.eps a { display: flex; gap: 10px; align-items: center; text-decoration: none; }
.eps img { width: 84px; aspect-ratio: 16/9; object-fit: cover; border-radius: 4px; flex: none; }
.eps span { font-size: 14px; font-weight: 500; line-height: 1.3; }
.eps small { display: block; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; opacity: .6; margin-bottom: 2px; }

/* ---------- lite page ---------- */
#lite { max-width: 1080px; margin: 0 auto; padding: 72px 16px 40px; }
.lite-head h1 { font: 700 clamp(40px, 7vw, 64px)/1 Caveat, cursive; margin: 0 0 12px; }
.lite-head p { max-width: 620px; opacity: 0.85; margin: 0 0 28px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.cards article {
  background: var(--paper); color: var(--ink); padding: 22px 20px 16px; border-radius: 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
}
.cards article:nth-child(odd) { transform: rotate(-0.6deg); }
.cards article:nth-child(even) { transform: rotate(0.5deg); }
.cards article.quiet { display: none; }
.foot { margin-top: 36px; font-size: 13px; opacity: 0.7; }
.foot p { margin: 0 0 6px; }
.foot .credits { font-size: 12px; max-width: 720px; line-height: 1.5; }
.foot a { color: inherit; }

body.no3d .stage-wrap { display: none; }
body.no3d #lite { padding-top: 84px; }
@media (max-width: 520px) {
  .brand span { display: none; }
  .tools .chip:last-child { display: none; }
}
@media (max-width: 360px) {
  .bar { gap: 8px; padding: 10px; }
  .langs { gap: 1px; }
  .langs a { padding: 6px 5px; }
  #card { max-height: 68svh; padding: 16px 18px 0; font-size: 14px; line-height: 1.38; }
  #card::after { height: 16px; }
  #card h2 { font-size: 28px; margin-bottom: 6px; }
  #card p { margin-bottom: 7px; }
}
