/* Poetic Prompts — game page
   VOICE: a poet's page held between Adam and God
   PICTURE: real fresco hands, torn crumpled parchment, a dark old-master oil panel behind
   TYPE: Pinyon Script + Cinzel (the title), Cormorant Garamond (nav, prompt), Cormorant SC (labels),
         IM Fell English (the poem itself)
   COLOUR: parchment + iron-gall ink, rubric red accents, umber chiaroscuro with a warm glow */

:root {
  --ink: #2a2119;
  --ink-soft: #6b5440;
  --rubric: #a6321f;
  --rule: rgba(42, 33, 25, 0.075);
  --sky-tint: transparent;
  --paper-dim: none;
  --credit: rgba(240, 222, 190, 0.6);
  --backdrop: url("assets/chiaro-wide.webp");
  --backdrop-tall: url("assets/chiaro-tall.webp");
  --backdrop-base: #2a1a10;

  --paper-w: min(720px, 56vw);
  --gap: calc((100vw - var(--paper-w)) / 2);
  --overlap: 64px;                       /* how far each hand reaches onto the page */
  --adam-w: max(calc(var(--gap) + var(--overlap) + 90px), min(70vw, 1000px));
  --god-w: max(calc(var(--gap) + var(--overlap) + 90px), min(64vw, 920px));
  --hand-y: 42%;                         /* where the hands meet the page, top→bottom */

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --sky-tint: rgba(8, 5, 3, 0.32);
    --paper-dim: brightness(0.96) sepia(0.06);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --sky-tint: rgba(8, 5, 3, 0.32);
  --paper-dim: brightness(0.96) sepia(0.06);
  color-scheme: dark;
}
/* alternative backdrop for comparison: ?bg=sky */
:root[data-bg="sky"] {
  --backdrop: url("assets/backdrop-wide.webp");
  --backdrop-tall: url("assets/backdrop-tall.webp");
  --backdrop-base: #2c4a7a;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; }
html { overflow-x: clip; }   /* the arms bleed off both edges */
body {
  min-height: 100svh;
  background: var(--backdrop-base) var(--backdrop) center / cover fixed;
  color: var(--ink);
  font: 18px/1.5 "IM Fell English", Georgia, serif;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
}
body::before {                           /* dusk tint in dark mode */
  content: "";
  position: fixed;
  inset: 0;
  background: var(--sky-tint);
  pointer-events: none;
  z-index: 0;
}

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

a { color: inherit; }
:focus-visible { outline: 2px solid var(--rubric); outline-offset: 4px; border-radius: 2px; }

/* ---------- torn paper masthead ---------- */
.masthead {
  position: fixed;
  z-index: 20;
  top: -26px; left: -28px; right: -28px;
  height: 104px;
  padding: 34px 56px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: url("assets/paper-strip.webp") center / 100% 100% no-repeat;
  filter: var(--paper-dim) drop-shadow(0 6px 10px rgba(40, 30, 30, 0.22));
}
.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 0.42em;
  color: var(--ink);
  text-decoration: none;
  line-height: 1;
}
.brand-script { font: 400 36px/1 "Pinyon Script", "Cormorant Garamond", cursive; }
.brand-caps { font: 600 21px/1 "Cinzel", "Cormorant SC", serif; letter-spacing: 0.16em; }
.topnav { display: flex; align-items: center; gap: clamp(18px, 3vw, 40px); }
.topnav a {
  font: italic 500 25px/1 "Cormorant Garamond", Georgia, serif;
  text-decoration: none;
  padding: 8px 2px;
  background: linear-gradient(var(--rubric), var(--rubric)) 0 92% / 0 1.5px no-repeat;
  transition: background-size 0.35s ease;
}
.topnav a:hover { background-size: 100% 1.5px; }
.burger {
  width: 52px; height: 44px;
  padding: 4px;
  border: 0;
  background: none;
  color: var(--ink);
  cursor: pointer;
}
.burger svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 3.4; stroke-linecap: round; }

/* ---------- drawer ---------- */
.drawer {
  position: fixed;
  z-index: 40;
  top: 0; right: -14px; bottom: 0;
  width: min(380px, 88vw);
  padding: 88px 46px 40px 52px;
  background: url("assets/paper-tall.webp") center / 100% 100% no-repeat;
  filter: var(--paper-dim) drop-shadow(-10px 0 20px rgba(40, 25, 25, 0.3));
  transform: translateX(110%);
  transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
  visibility: hidden;
}
.drawer.open { transform: none; visibility: visible; }
.drawer:not(.open) { display: none; }
.drawer.opening { display: block; }
.drawer-close {
  position: absolute; top: 34px; right: 46px;
  width: 44px; height: 44px;
  border: 0; background: none; cursor: pointer;
  font: 400 38px/1 "Cormorant Garamond", serif; color: var(--ink);
}
.drawer-list { list-style: none; margin: 0; padding: 0; }
.drawer-list a {
  display: flex; align-items: baseline; gap: 16px;
  padding: 12px 0;
  font: 600 27px/1.15 "Cormorant Garamond", Georgia, serif;
  text-decoration: none;
  border-bottom: 1px dotted rgba(42, 33, 25, 0.25);
}
.drawer-list i {
  font: normal 600 17px/1 "Cormorant SC", serif;
  color: var(--rubric);
  min-width: 26px;
}
.drawer-list small { font: italic 500 17px "Cormorant Garamond", serif; color: var(--ink-soft); }
.drawer-foot { margin-top: 28px; font-size: 16px; color: var(--ink-soft); }
.drawer-foot a { color: var(--rubric); }
.scrim { position: fixed; inset: 0; z-index: 30; background: rgba(20, 16, 24, 0.28); }

/* ---------- the stage: hands + page ---------- */
.stage {
  position: relative;
  z-index: 1;
  min-height: 100svh;
  display: grid;
  place-items: center;
  align-content: center;
  padding: 116px 0 56px;
}
.scene {
  position: relative;
  width: var(--paper-w);
}

.arm {
  position: absolute;
  z-index: 3;                 /* fingertips rest on top of the page */
  height: auto;
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(0 10px 12px rgba(50, 30, 30, 0.28));
}
.arm-adam {
  width: var(--adam-w);
  right: calc(100% - var(--overlap));
  top: calc(var(--hand-y) - var(--adam-w) * 0.329 * 0.5);
  animation: reach-left 1.6s cubic-bezier(0.16, 0.84, 0.24, 1) both, drift 7s 1.6s ease-in-out infinite;
}
.arm-god {
  width: var(--god-w);
  left: calc(100% - var(--overlap));
  top: calc(var(--hand-y) - var(--god-w) * 0.418 * 0.585);
  animation: reach-right 1.6s 0.12s cubic-bezier(0.16, 0.84, 0.24, 1) both, drift 8s 1.8s ease-in-out infinite reverse;
}
@keyframes reach-left  { from { transform: translateX(-38%); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes reach-right { from { transform: translateX(38%);  opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes drift { 50% { transform: translateY(-4px); } }

/* ---------- the page ---------- */
.sheet {
  position: relative;
  z-index: 2;
  margin: 0;
  padding: 62px 96px 44px;
  background: url("assets/paper-wide.webp") center / 100% 100% no-repeat;
  filter: var(--paper-dim) drop-shadow(0 22px 26px rgba(60, 35, 40, 0.3));
  animation: settle 1.1s 0.25s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes settle { from { transform: translateY(18px) rotate(-1.2deg); opacity: 0; } to { transform: none; opacity: 1; } }

.kicker {
  margin: 0 0 6px;
  font: 600 15px/1.2 "Cormorant SC", Georgia, serif;
  letter-spacing: 0.12em;
  color: var(--rubric);
}
.prompt {
  margin: 0;
  font: 600 clamp(28px, 3.2vw, 40px)/1.08 "Cormorant Garamond", Georgia, serif;
  text-wrap: balance;
}
.prompt .device { display: block; font-size: 0.62em; letter-spacing: 0.02em; color: var(--ink-soft); font-weight: 600; }
.prompt em { font-style: italic; font-weight: 600; }
.hint {
  margin: 10px 0 18px;
  font-style: italic;
  font-size: 17px;
  color: var(--ink-soft);
  max-width: 46ch;
}

textarea {
  display: block;
  width: 100%;
  min-height: calc(1.75em * 5 + 8px);
  max-height: calc(1.75em * 15 + 8px);
  padding: 4px 2px;
  border: 0;
  resize: none;
  overflow-y: auto;
  color: var(--ink);
  font: 21px/1.75 "IM Fell English", Georgia, serif;
  background: repeating-linear-gradient(transparent 0 calc(1.75em - 1px), var(--rule) calc(1.75em - 1px) 1.75em) 0 4px / 100% 1.75em local;
  caret-color: var(--rubric);
}
textarea::placeholder { color: rgba(107, 84, 64, 0.55); font-style: italic; }
textarea:focus { outline: none; }
textarea:focus-visible { outline: none; }
.sheet:focus-within .hint { color: var(--ink); }

/* the signature under the poem: "Signed, ____" in a hand-written script */
.signed { display: flex; align-items: baseline; justify-content: flex-end; gap: 10px; margin: 10px 0 0; }
.signed label { font: italic 500 20px "Cormorant Garamond", serif; color: var(--ink-soft); }
.signed input {
  width: min(15em, 60%); padding: 2px 4px 0; border: 0; border-bottom: 1.5px solid rgba(42, 33, 25, 0.35);
  background: transparent; color: var(--ink); font: 32px/1.1 "Pinyon Script", cursive; caret-color: var(--rubric);
}
.signed input::placeholder { font: italic 500 20px "Cormorant Garamond", serif; color: rgba(107, 84, 64, 0.55); }
.signed input:focus { outline: none; border-bottom-color: var(--rubric); }
.signed input:read-only { border-bottom-color: transparent; }

/* a button that reads as a link (sign in / sign out) */
.linklike {
  padding: 0; border: 0; background: none; cursor: pointer;
  font: inherit; color: var(--rubric); text-decoration: underline; text-underline-offset: 3px;
}
.linklike:hover { color: #7d2416; }
.linklike:focus-visible { outline: 2px solid var(--rubric); outline-offset: 2px; }
.topnav a[aria-current="page"] { background-size: 100% 1.5px; }
.drawer-list a[aria-current="page"] { text-decoration: underline; text-underline-offset: 5px; }

.sheet-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 18px;
}
.count { margin: 0; font: 600 15px "Cormorant SC", serif; letter-spacing: 0.08em; color: var(--ink-soft); }
.count.ok { color: var(--ink); }
.count.over { color: var(--rubric); }

.seal {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 48px;
  padding: 0 4px;
  border: 0; background: none; cursor: pointer;
  color: var(--rubric);
}
.seal .wax { width: 62px; height: 62px; filter: drop-shadow(0 3px 3px rgba(60, 10, 5, 0.35)); transition: transform 0.3s ease; }
.seal-label { font: italic 600 22px/1 "Cormorant Garamond", serif; }
.seal:not(:disabled):hover .wax { transform: rotate(-8deg) scale(1.05); }
.seal:disabled { cursor: not-allowed; opacity: 0.5; }
.seal:disabled .wax { filter: grayscale(0.7); }

.sheet.sealed textarea { cursor: default; }
.sheet.sealed .seal { pointer-events: none; opacity: 1; }
.sheet.sealed .seal .wax { animation: stamp 0.55s cubic-bezier(0.3, 1.6, 0.5, 1) both; }
@keyframes stamp { 0% { transform: scale(1.9) rotate(-18deg); opacity: 0.2; } 100% { transform: rotate(-6deg); opacity: 1; } }
.sealed-note { margin: 12px 0 0; font-style: italic; font-size: 15px; color: var(--ink-soft); }

.credit {
  position: relative;
  z-index: 1;
  margin: 26px 16px 0;
  text-align: center;
  font: italic 500 14px "Cormorant Garamond", serif;
  color: var(--credit);
}

/* ---------- phone: page fills the width, hands pinch its top corners ---------- */
@media (max-width: 720px) {
  :root {
    --paper-w: calc(100vw - 24px);
    --adam-w: 80vw;
    --god-w: 88vw;
  }
  body { background-image: var(--backdrop-tall); background-attachment: scroll; }
  .masthead { height: 88px; padding: 30px 40px 0; }
  .brand-script { font-size: 29px; }
  .brand-caps { font-size: 17px; }
  .topnav { gap: 10px; }
  .topnav a { display: none; }
  .stage { padding-top: 168px; align-content: start; }
  .arm-adam { right: calc(100% - 30vw); top: calc(30px - var(--adam-w) * 0.329 * 0.66); }
  /* God comes in from the bottom right, flipped, still reaching up for Adam */
  .arm-god {
    /* pivot on the fingertip: the forearm swings down to the bottom-right corner */
    left: calc(100% - 35vw);
    top: calc(80% - var(--god-w) * 0.418 * 0.415);
    transform-origin: 1% 41.5%;
    scale: 1 -1;
    rotate: 34deg;
  }
  .stage { padding-bottom: 96px; }
  .sheet {
    padding: 64px 28px 110px;
    background-image: url("assets/paper-tall.webp");
  }
  .prompt { font-size: 30px; }
  .hint { font-size: 16px; }
  textarea { font-size: 17.5px; min-height: calc(1.75em * 7 + 8px); }
  .seal .wax { width: 54px; height: 54px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* second click seals: the wax pulses while waiting for it */
.seal.confirming .wax { animation: wax-ready 0.7s ease-in-out infinite alternate; }
.seal.confirming .seal-label { text-decoration: underline; text-underline-offset: 4px; }
@keyframes wax-ready { to { transform: scale(1.1) rotate(-6deg); } }

/* ---------- streak candles (lit · wax save · snuffed · today, not yet) ---------- */
.candles { display: inline-flex; align-items: flex-end; gap: 4px; vertical-align: -3px; }
.candles { gap: 5px; padding-top: 6px; }
.candle { position: relative; display: inline-block; width: 9px; height: 19px; border-radius: 2px 2px 1px 1px;
  border: 1px solid rgba(70, 45, 25, 0.55);
  background: linear-gradient(90deg, #e3cfa4, #fbf0d6 45%, #cdb382); box-shadow: inset 0 -3px 0 rgba(60, 40, 20, 0.2); }
.candle::before { content: ""; position: absolute; left: 50%; bottom: 100%; width: 1px; height: 3px; background: #3a2a1c; translate: -50% 0; }
.candle.lit::after { content: ""; position: absolute; left: 50%; bottom: calc(100% + 1px); width: 7px; height: 10px; translate: -50% 0;
  border-radius: 50% 50% 45% 45% / 65% 65% 35% 35%; background: radial-gradient(circle at 50% 70%, #fff3b0, #f2a93b 55%, #c4561f);
  box-shadow: 0 0 6px 2px rgba(242, 169, 59, 0.45); }
.candle.wax::after { content: ""; position: absolute; left: 50%; top: 3px; width: 9px; height: 9px; translate: -50% 0; border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #d65a45, #9c2c1a 65%); box-shadow: 0 1px 1px rgba(40, 10, 5, 0.4); }
.candle.out { opacity: 0.5; height: 13px; }
.candle.today { opacity: 0.8; }
.candle.today::before { background: #8a7660; }
.device-link { color: inherit; text-decoration: underline dotted rgba(166, 50, 31, 0.45); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
.device-link:hover { text-decoration-color: currentColor; }

/* ---------- sound toggle (sound.js adds it to every masthead): a pixel speaker, crossed when muted ---------- */
.sound-toggle { display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; background: transparent; cursor: pointer; border-radius: 6px; }
.sound-toggle .ico { display: block; width: 36px; height: 36px; image-rendering: pixelated;
  background: url("assets/icons.png") -288px 0 / 360px 36px no-repeat; }
.sound-toggle.off .ico { background-position-x: -324px; opacity: 0.75; }
.sound-toggle:hover .ico { transform: scale(1.08); }
.sound-toggle:focus-visible { outline: 3px solid #26437e; outline-offset: 2px; }
