/* What Happened Here?, digital (play/what_happened.templ).
   A detective's desk: the site's forest green as the desk blotter, a warm
   lamp pool over it, and one manila case folder at a time. Typewriter type
   for the case (Special Elite for titles and stamps, Courier Prime to read
   aloud from), handwriting (Caveat) for the hints on sticky notes. The one
   big moment is the CASE CLOSED stamp; everything else just slides.
   Nothing here is a card or a pile — that's Story Sparks' look, and this
   game must not be mistaken for it. */
.wh {
  --wh-desk: #1a3828;
  --wh-desk-deep: #11261b;
  --wh-lamp: rgba(255, 214, 150, 0.2);
  --wh-manila: #e6c98f;
  --wh-manila-edge: #c8a462;
  --wh-paper: #fbf7ec;
  --wh-ink: #2a241c;
  --wh-ink-soft: #5d5244;
  --wh-red: #b8322a;
  --wh-note: #ffe47e;
  --wh-brass: #e8a84a;
  --wh-cream: #f4ecd9;
  --wh-type: "Courier Prime", "Courier New", monospace;
  --wh-title: "Special Elite", "Courier Prime", monospace;
  --wh-hand: "Caveat", "Comic Sans MS", cursive;
}
.wh [x-cloak] { display: none !important; }

.wh-lede {
  margin: 0 0 1rem;
  max-width: 46ch;
  color: var(--slate);
  font-size: 0.95rem;
  line-height: 1.45;
}

/* ---- The desk ---------------------------------------------------------- */
.wh-desk {
  position: relative;
  isolation: isolate;
  display: grid;
  justify-items: center;
  padding: 1.75rem 1rem 0;
  border-radius: var(--radius-lg, 18px);
  overflow: hidden;
  background:
    radial-gradient(ellipse 70% 55% at 50% 0%, var(--wh-lamp), transparent 70%),
    radial-gradient(ellipse at 50% 120%, var(--wh-desk-deep), transparent 60%),
    var(--wh-desk);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05), 0 18px 40px rgba(17, 38, 27, 0.25);
}
/* The magnifying glass left lying on the desk. */
.wh-prop {
  position: absolute;
  right: -1.5rem;
  bottom: 4.5rem;
  z-index: -1;
  width: 8rem;
  color: rgba(244, 236, 217, 0.1);
  rotate: -18deg;
}

/* ---- The folder -------------------------------------------------------- */
.wh-folder {
  position: relative;
  width: min(100%, 42rem);
  margin-top: 1.4rem;
  padding: 0.9rem 0.7rem 0.8rem;
  border-radius: 4px 10px 10px 10px;
  background:
    linear-gradient(170deg, rgba(255, 255, 255, 0.18), transparent 40%),
    var(--wh-manila);
  box-shadow:
    inset 0 -3px 0 var(--wh-manila-edge),
    0 22px 40px rgba(5, 15, 10, 0.45),
    0 4px 10px rgba(5, 15, 10, 0.3);
  rotate: -0.6deg;
}
.wh-tab {
  position: absolute;
  bottom: 100%;
  left: 0;
  padding: 0.45rem 1.1rem 0.35rem;
  border-radius: 9px 9px 0 0;
  background: var(--wh-manila);
  color: var(--wh-ink);
  font: 400 0.95rem/1 var(--wh-title);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.wh-tab b { font-weight: 400; color: var(--wh-red); }

/* Closed: the front of the folder is the button. */
.wh-cover {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 1rem;
  width: 100%;
  min-height: 19rem;
  padding: 2rem 1rem;
  border: 2px dashed rgba(42, 36, 28, 0.25);
  border-radius: 8px;
  background: none;
  color: var(--wh-ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.2s ease;
}
.wh-confidential {
  padding: 0.35rem 0.8rem;
  border: 3px double var(--wh-red);
  color: var(--wh-red);
  font: 400 clamp(1.25rem, 6vw, 1.6rem)/1 var(--wh-title);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  rotate: -7deg;
  opacity: 0.85;
}
.wh-cover-title {
  font: 400 clamp(2rem, 10vw, 2.8rem)/1 var(--wh-title);
  letter-spacing: 0.04em;
}
.wh-cover-title b { font-weight: 400; color: var(--wh-red); }
.wh-cover-cta {
  padding: 0.7rem 1.4rem;
  border-radius: 9px;
  background: var(--wh-desk);
  color: var(--wh-cream);
  font: 700 0.9rem/1 var(--wh-type);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  box-shadow: 0 6px 14px rgba(17, 38, 27, 0.3);
  transition: background 0.15s ease;
}
@media (hover: hover) {
  .wh-cover:hover { border-color: rgba(42, 36, 28, 0.45); }
  .wh-cover:hover .wh-cover-cta { background: #24503a; }
}
.wh-cover:focus-visible { outline: 3px solid var(--wh-brass); outline-offset: 4px; }

/* Open: the typed case sheet, clipped into the folder. */
.wh-sheet {
  position: relative;
  padding: 2rem 1.25rem 1.5rem;
  border-radius: 3px;
  background:
    repeating-linear-gradient(to bottom, transparent 0 1.9rem, rgba(70, 110, 150, 0.08) 1.9rem calc(1.9rem + 1px)),
    var(--wh-paper);
  color: var(--wh-ink);
  box-shadow: 0 2px 6px rgba(60, 40, 10, 0.18);
  rotate: 1deg;
}
.wh-clip {
  position: absolute;
  top: -1.6rem;
  left: 1.6rem;
  width: 1.1rem;
  color: #8d949c;
  filter: drop-shadow(0 2px 1px rgba(0, 0, 0, 0.25));
}
.wh-title {
  margin: 0 0 0.9rem;
  font: 400 clamp(1.55rem, 6.5vw, 2.1rem)/1.15 var(--wh-title);
  text-wrap: balance;
}
.wh-title:focus { outline: none; }
.wh-scene {
  margin: 0;
  max-width: 62ch;
  font: 400 clamp(1.08rem, 4.4vw, 1.25rem)/1.6 var(--wh-type);
  text-wrap: pretty;
}
.wh-ask {
  margin: 1.1rem 0 0;
  color: var(--wh-red);
  font: 700 clamp(1.05rem, 4.4vw, 1.2rem)/1.3 var(--wh-type);
}

/* Hints: sticky notes slapped on the sheet, each a little crooked. */
.wh-notes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin: 1.3rem 0 0;
  padding: 0;
  list-style: none;
}
.wh-note {
  flex: 0 1 17rem;
  display: grid;
  gap: 0.15rem;
  padding: 0.75rem 0.9rem 0.85rem;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.05), transparent 0.9rem), var(--wh-note);
  color: #3b2f12;
  font: 600 1.4rem/1.15 var(--wh-hand);
  box-shadow: 0 8px 14px rgba(60, 40, 10, 0.2);
  rotate: -1.5deg;
  animation: wh-note-in 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.wh-note:nth-child(2) { rotate: 1.8deg; }
.wh-note-label {
  font: 700 0.72rem/1 var(--wh-type);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.7;
}

/* Debrief, once the case is stamped. */
.wh-talk {
  margin-top: 1.4rem;
  padding-top: 1rem;
  border-top: 1.5px dashed rgba(42, 36, 28, 0.3);
  animation: wh-fade 0.4s 0.35s ease-out both;
}
.wh-talk-label {
  color: var(--wh-ink-soft);
  font: 700 0.75rem/1.3 var(--wh-type);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.wh-talk-q {
  margin: 0.35rem 0 0;
  font: 600 clamp(1.45rem, 6vw, 1.75rem)/1.15 var(--wh-hand);
  color: var(--wh-desk);
}

/* The stamp: inked, double-ruled, thumped down when the case closes. */
/* Struck across the sheet's top edge, half on the folder, so it never covers
   the title. */
.wh-stamp {
  position: absolute;
  top: -1.1rem;
  right: 0.4rem;
  z-index: 1;
  padding: 0.35rem 0.75rem;
  border: 4px double var(--wh-red);
  border-radius: 6px;
  color: var(--wh-red);
  background: rgba(251, 247, 236, 0.6);
  font: 400 clamp(1.25rem, 5.5vw, 1.7rem)/1 var(--wh-title);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  pointer-events: none;
  opacity: 0;
  rotate: -9deg;
  /* Uneven ink: the stamp never presses down perfectly. */
  -webkit-mask-image: radial-gradient(circle at 30% 40%, #000 55%, rgba(0, 0, 0, 0.55) 80%), linear-gradient(#000, #000);
  mask-image: radial-gradient(circle at 30% 40%, #000 55%, rgba(0, 0, 0, 0.55) 80%);
}
.is-solved .wh-stamp { animation: wh-stamp 0.42s cubic-bezier(0.3, 1.4, 0.5, 1) both; }
.is-solved .wh-sheet { animation: wh-thud 0.42s 0.12s ease-out; }

.is-leaving { animation: wh-leave 0.32s ease-in forwards; }
.is-arriving { animation: wh-arrive 0.32s cubic-bezier(0.2, 0.8, 0.2, 1); }

/* ---- Controls, along the desk's bottom edge ---------------------------- */
.wh-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  width: calc(100% + 2rem);
  margin-top: 1.5rem;
  padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, rgba(26, 56, 40, 0), var(--wh-desk) 30%);
  transition: opacity 0.25s ease, visibility 0.25s;
}
.wh-actions:not(.is-ready) { opacity: 0; visibility: hidden; }
.wh-btn {
  flex: 1 1 10rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  max-width: 20rem;
  min-height: 3.25rem;
  padding: 0 1.3rem;
  border-radius: 9px;
  font: 700 0.95rem/1 var(--wh-type);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.wh-btn:active:not(:disabled) { transform: translateY(1px); }
.wh-btn svg {
  width: 1.15rem;
  height: 1.15rem;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.wh-btn--brass {
  border: 0;
  background: var(--wh-brass);
  color: #24170a;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}
.wh-btn--ghost {
  border: 1.5px solid rgba(244, 236, 217, 0.55);
  background: transparent;
  color: var(--wh-cream);
}
@media (hover: hover) {
  .wh-btn--brass:hover { background: #f0b964; }
  .wh-btn--ghost:hover:not(:disabled) { border-color: var(--wh-cream); background: rgba(244, 236, 217, 0.08); }
}
.wh-btn:disabled { opacity: 0.45; cursor: default; }
.wh-btn:focus-visible { outline: 3px solid var(--wh-brass); outline-offset: 3px; }
.wh-btn--brass:focus-visible { outline-color: var(--wh-cream); }

/* ---- Motion ------------------------------------------------------------ */
@keyframes wh-stamp {
  0% { opacity: 0; scale: 1.9; filter: blur(3px); }
  60% { opacity: 0.95; scale: 0.94; filter: blur(0); }
  100% { opacity: 0.88; scale: 1; }
}
@keyframes wh-thud {
  0%, 100% { translate: 0 0; }
  30% { translate: 0 3px; }
}
@keyframes wh-note-in {
  from { opacity: 0; translate: 0 -0.6rem; scale: 1.06; }
}
@keyframes wh-fade {
  from { opacity: 0; translate: 0 0.4rem; }
}
@keyframes wh-leave {
  to { opacity: 0; translate: -40% 0; rotate: -6deg; }
}
@keyframes wh-arrive {
  from { opacity: 0; translate: 30% 0; rotate: 4deg; }
}

/* ---- Wide screens ------------------------------------------------------ */
@media (min-width: 760px) {
  .wh-lede { max-width: 52ch; font-size: 1.05rem; }
  .wh-desk { padding: 3rem 2.5rem 0; }
  .wh-folder { padding: 1.2rem 1rem 1rem; }
  .wh-sheet { padding: 2.6rem 2.6rem 2.2rem; }
  .wh-stamp { top: -1.3rem; right: 1.4rem; }
  .wh-cover { min-height: 24rem; }
  .wh-prop { width: 12rem; right: 2rem; bottom: 2rem; }
  .wh-actions {
    position: static;
    width: 100%;
    padding: 1.75rem 0 2rem;
    background: none;
  }
  .wh-btn { flex: 0 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  .wh-note,
  .wh-talk,
  .is-solved .wh-stamp,
  .is-solved .wh-sheet,
  .is-leaving,
  .is-arriving { animation: none; }
  .is-solved .wh-stamp { opacity: 0.88; }
  .wh-actions { transition: none; }
}
