/* Desktop composition: polder backdrop, the centre column, type, HUD. */
:root {
  --night: #090d22;
  --bar: #121731;
  --bar-ink: #f1e6c8;
  --bar-muted: #a9a3b8;
  --parchment: #e4d3ab;
  --parchment-deep: #d6c294;
  --ink: #2a2015;
  --gold: #e0b452;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --column: min(640px, 100vw);
  /* the notch and the home bar (tools/shoot.ts overrides these to emulate an installed app) */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: var(--night);
  color: var(--bar-ink);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

.backdrop {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block;
  .sails { animation: sails 60s linear infinite; }
  .mill:nth-child(2n) .sails { animation-duration: 44s; animation-direction: reverse; }
  .lattice { opacity: .55; }
  .lit { fill: #f0b860; }
  /* the water wolf: 1.6 units of water per point of land eaten, creeping up over the polder and the mills' feet */
  .flood { transform: translateY(calc(var(--wolf, 35) * -1.6px)); transition: transform 2.4s ease-in-out; }
}
@keyframes sails { to { rotate: 360deg; } }

/* ── HUD ─────────────────────────────────────────────── */
.hud {
  position: fixed;
  z-index: 1;
  color: var(--bar-ink);
  letter-spacing: .04em;
  text-shadow: 0 2px 10px rgb(0 0 0 / .5);
  font-size: 1.5rem;
  b { font-weight: 600; font-variant-numeric: lining-nums tabular-nums; }
}
.hud-years {
  top: 64px; left: max(24px, calc(25vw - 320px - 6vw));
  b { font-size: 5rem; line-height: 1; margin-right: .2em; vertical-align: -.12em; }
}
.hud-anno {
  top: 64px; right: max(24px, calc(25vw - 320px - 6vw));
  font-style: italic;
  b { font-style: normal; font-size: 5rem; line-height: 1; margin-left: .15em; vertical-align: -.12em; }
}
/* the reeve's name is the way to this term's goals */
.hud-reeve {
  bottom: 56px; left: max(24px, calc(25vw - 320px - 6vw));
  display: grid; gap: .25em; justify-items: start;
  font: inherit; font-size: 1.9rem; text-align: start;
  background: none; border: 0; padding: 6px 10px; margin: -6px -10px;
  border-radius: 8px; cursor: pointer;
  small { font-size: 1.05rem; font-style: italic; color: var(--bar-muted); letter-spacing: .06em; }
  #reeve-name::after {
    content: ""; display: inline-block; width: .5em; height: .5em; margin-left: .45em; vertical-align: .08em;
    border: 2px solid var(--gold); border-radius: 3px; rotate: 45deg; scale: .8;
  }
  &:hover #reeve-name { text-decoration: underline; text-decoration-color: var(--gold); text-underline-offset: .2em; }
  &:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
}

/* ── Column ──────────────────────────────────────────── */
.column {
  position: relative;
  z-index: 2;
  width: var(--column);
  height: 100dvh;
  margin-inline: auto;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background:
    radial-gradient(120% 60% at 50% 45%, transparent 55%, rgb(120 90 40 / .18)),
    var(--parchment);
  box-shadow: 0 0 0 1px rgb(0 0 0 / .4), 0 0 80px rgb(0 0 0 / .55);
}

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  gap: clamp(12px, 2.4vh, 28px);
  padding: clamp(12px, 2.5vh, 32px) 40px;
  min-height: 0;
}

/* the card takes whatever height is left between the question and the name */
.deck-slot {
  flex: 1 1 0; min-height: 0; width: 100%;
  container-type: size;
  display: grid; place-items: center;
}

.prompt {
  margin: 0;
  min-height: calc(3 * 1.35em);
  max-width: 32ch;
  display: grid; place-items: center;
  text-align: center;
  color: var(--ink);
  font-size: clamp(1.15rem, 2.5vh, 1.7rem);
  line-height: 1.35;
  text-wrap: balance;
  &.fresh { animation: fresh .35s ease-out; }
}
@keyframes fresh { from { opacity: 0; translate: 0 6px; } }

.who {
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.1rem, 2.4vh, 1.6rem);
  font-variant: small-caps;
  letter-spacing: .08em;
  text-align: center;
  text-wrap: balance;
}

.ledger {
  background: var(--bar);
  min-height: clamp(64px, 11vh, 120px);
  display: grid; place-items: center;
  padding: 12px 24px;
  border-top: 3px solid #0a0d1f;
  .keys { margin: 0; color: var(--bar-muted); font-size: 1rem; letter-spacing: .03em; }
}

@media (prefers-reduced-motion: reduce) {
  .backdrop .sails { animation: none; }
  .backdrop .flood { transition: none; }
  .prompt.fresh { animation: none; }
}
