/* ════════════════════════════════════════════════════════════════════
   THE VAULT — /brain-teaser
   Paper, ink and the sketched vault door. One riddle, one answer.
   Riddles: js/brain-teaser-case.js · behaviour: js/brain-teaser.js
   ════════════════════════════════════════════════════════════════════ */
body[data-page="vault"] {
  --paper: #f8f7f3; --paper-off: #f1efe8; --paper-3: #e7e4da;
  --ink: #0f172a; --ink-2: #334155; --muted: #5b6678;
  --hair: rgba(15, 23, 42, 0.14); --hair-2: rgba(15, 23, 42, 0.07);
  --stamp: #8f2d2d; --ok: #2f6b4f; --brass: #a8843a;
  --sans: 'Poppins', system-ui, -apple-system, sans-serif;
  --serif: 'Source Serif Pro', Georgia, 'Times New Roman', serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  background: var(--paper); color: var(--ink); font-family: var(--sans);
}
html:has(body[data-page="vault"]) { background: var(--paper); }
body[data-page="vault"] main *, body[data-page="vault"] main *::before, body[data-page="vault"] main *::after { box-sizing: border-box; }
body[data-page="vault"] [hidden] { display: none !important; }
body[data-page="vault"] #site-footer .footer { margin-top: 0; }
body[data-page="vault"].is-through { overflow: hidden; }

.vt { width: min(1240px, 100% - 32px); margin: 0 auto; padding: clamp(92px, 11vh, 116px) 0 clamp(48px, 8vh, 88px); }
/* vault on the left, the riddle beside it: everything above the fold */
.vt-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr); gap: clamp(20px, 3.4vw, 52px); align-items: center; min-height: min(760px, calc(100dvh - 150px)); }
.vt-side { min-width: 0; }

/* ── head ─────────────────────────────────────────────────────────── */
.vt-head { margin: 0 0 clamp(14px, 2.4vh, 22px); }
.vt-kicker { display: inline-flex; align-items: center; gap: 8px; margin: 0; font: 600 10.5px/1 var(--sans); letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); }
.vt-dot { width: 4px; height: 4px; border-radius: 50%; background: currentColor; }
.vt-title { margin: 10px 0 6px; font: 600 clamp(1.6rem, 2.5vw, 2.2rem)/1.1 var(--serif); letter-spacing: -0.015em; color: var(--ink); }
.vt-sub { margin: 0; font-size: 0.86rem; line-height: 1.5; color: var(--muted); }
.vt-sub b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── the drawing ──────────────────────────────────────────────────── */
.vt-stage { position: relative; margin: 0; width: 100%; aspect-ratio: 1 / 1; max-height: calc(100dvh - 140px); overflow: hidden; }
.vt-still, .vt-idle { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.vt-idle { opacity: 0; transition: opacity 1.4s ease; }
.vt-idle.is-playing { opacity: 1; }
/* blend the picture's edges into the page so it reads as drawn on it */
.vt-stage::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, var(--paper) 0%, transparent 9%, transparent 91%, var(--paper) 100%),
              linear-gradient(180deg, var(--paper) 0%, transparent 7%, transparent 90%, var(--paper) 100%); }
.vt-stage.rattle { animation: vt-rattle 0.55s cubic-bezier(0.36, 0.07, 0.19, 0.97); }
@keyframes vt-rattle { 10%, 90% { transform: translateX(-1px); } 20%, 80% { transform: translateX(3px); } 30%, 50%, 70% { transform: translateX(-5px); } 40%, 60% { transform: translateX(5px); } }

/* rubber stamps */
.vt-stamp { position: absolute; z-index: 3; padding: 8px 18px; border: 3px solid currentColor; border-radius: 6px; font: 700 clamp(18px, 2.4vw, 28px)/1 var(--mono);
  letter-spacing: 0.22em; text-transform: uppercase; opacity: 0; pointer-events: none; mix-blend-mode: multiply; transform: rotate(-9deg) scale(1.8); }
.vt-stamp.in { animation: vt-stamp 0.42s cubic-bezier(0.3, 1.5, 0.5, 1) forwards; }
@keyframes vt-stamp { to { opacity: 0.88; transform: rotate(-9deg) scale(1); } }
.vt-stamp-ok { color: var(--ok); left: 50%; top: 50%; margin: -24px 0 0 -80px; }
.vt-stamp-no { color: var(--stamp); right: 22px; top: 18px; }

/* ── the riddle card ──────────────────────────────────────────────── */
.vt-card { position: relative; margin: 0; z-index: 2; padding: clamp(22px, 2.6vw, 34px);
  background: #fdfcf9; border: 1px solid var(--hair); border-radius: 6px; overflow: clip;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 22px 50px -28px rgba(15, 23, 42, 0.35); }
.vt-card::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; border-radius: 6px 6px 0 0;
  background: repeating-linear-gradient(90deg, var(--ink) 0 14px, transparent 14px 22px); opacity: 0.85; }
.vt-card-kicker { display: flex; justify-content: space-between; margin: 0 0 18px; font: 600 11px/1 var(--mono); letter-spacing: 0.24em; text-transform: uppercase; color: var(--stamp); }
.vt-card-kicker span + span { color: var(--muted); transition: opacity 0.2s; }
.vt-card.stamped .vt-card-kicker span + span { opacity: 0; }
.vt-riddle { margin: 0; font: 400 clamp(1.08rem, 1.45vw, 1.3rem)/1.58 var(--serif); color: var(--ink); text-wrap: pretty; }
/* ink redaction bars lift word by word when the card comes into view */
.vt-riddle .rd { position: relative; }
.vt-riddle .rd::after { content: ""; position: absolute; left: -2px; right: -2px; top: 0.2em; bottom: 0.08em; background: var(--ink); border-radius: 2px;
  transform-origin: right center; transition: transform 0.6s var(--ease) var(--d, 0s); }
.vt-card.open .vt-riddle .rd::after { transform: scaleX(0); }

.vt-answer { display: flex; align-items: flex-end; gap: 12px; margin-top: clamp(18px, 2.6vh, 26px); }
.vt-field { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.vt-field-label { font: 600 11px/1 var(--sans); letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.vt-field input { width: 100%; min-height: 52px; padding: 0 2px; border: 0; border-bottom: 1.5px solid var(--ink); background: transparent; border-radius: 0;
  font: 600 1.3rem/1 var(--serif); color: var(--ink); letter-spacing: 0.01em; }
.vt-field input::placeholder { color: rgba(15, 23, 42, 0.32); font-weight: 400; font-style: italic; }
.vt-field input:focus { outline: 0; border-bottom-width: 2.5px; }
.vt-field input:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }
.vt-field input:disabled { opacity: 0.6; }
.vt-unlock { position: relative; overflow: hidden; flex: none; min-height: 52px; padding: 0 22px; border: 1.5px solid var(--ink); border-radius: 999px; background: var(--ink); color: var(--paper);
  font: 600 14px/1 var(--sans); letter-spacing: 0.02em; cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none; transition: opacity 0.2s, background 0.2s, color 0.2s; }
.vt-unlock:disabled { background: transparent; color: var(--muted); border-color: var(--hair); cursor: not-allowed; --hold: 0 !important; }
.vt-unlock:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.vt-unlock-fill { position: absolute; inset: 0; transform-origin: left center; transform: scaleX(var(--hold, 0)); background: var(--brass); }
.vt-unlock-label { position: relative; }
.vt-note { margin: 14px 0 0; font-size: 0.9rem; line-height: 1.55; color: var(--muted); }

.vt-result { margin-top: 22px; padding: 18px 20px; border-left: 3px solid var(--ink); background: var(--paper-off); border-radius: 0 4px 4px 0; line-height: 1.6; color: var(--ink-2); animation: vt-in 0.4s var(--ease) both; }
.vt-result.ok { border-color: var(--ok); }
.vt-result.no { border-color: var(--stamp); }
.vt-result .h { display: block; margin-bottom: 4px; font: 600 11px/1 var(--mono); letter-spacing: 0.2em; text-transform: uppercase; }
.vt-result.ok .h { color: var(--ok); } .vt-result.no .h { color: var(--stamp); }
.vt-result strong { color: var(--ink); }
.vt-result a { color: var(--ink); font-weight: 600; }
@keyframes vt-in { from { opacity: 0; transform: translateY(6px); } }
.vt-card.shake { animation: vt-rattle 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97); }

/* ── past cases ───────────────────────────────────────────────────── */
.vt-past { max-width: 760px; margin: clamp(32px, 6vh, 56px) auto 0; border-top: 1px solid var(--hair); }
.vt-past summary { display: flex; align-items: center; justify-content: space-between; min-height: 56px; cursor: pointer; list-style: none; font: 600 15px/1 var(--sans); color: var(--ink); }
.vt-past summary::-webkit-details-marker { display: none; }
.vt-past summary::after { content: "+"; font: 400 22px/1 var(--sans); color: var(--muted); transition: transform 0.25s var(--ease); }
.vt-past[open] summary::after { transform: rotate(45deg); }
.vt-past summary:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }
.vt-past-count { margin-left: 10px; margin-right: auto; font-weight: 500; color: var(--muted); }
.vt-past-list { list-style: none; margin: 0; padding: 0 0 8px; }
.vt-past-list li { padding: 18px 0; border-top: 1px solid var(--hair-2); }
.vt-past-list .no { font: 600 11px/1 var(--mono); letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.vt-past-list h3 { margin: 6px 0 6px; font: 600 1.1rem/1.3 var(--serif); }
.vt-past-list p { margin: 0; font-size: 0.95rem; line-height: 1.6; color: var(--ink-2); }
.vt-past-list button { margin-top: 10px; min-height: 40px; padding: 0 14px; border: 1px solid var(--hair); border-radius: 999px; background: transparent; color: var(--ink); font: 500 13px/1 var(--sans); cursor: pointer; }
.vt-past-list button:hover { border-color: var(--ink); }
.vt-past-list .ans { margin-top: 10px; font-size: 0.95rem; line-height: 1.55; }
.vt-past-list .ans b { font-family: var(--serif); font-size: 1.05rem; }

/* ── through the door ─────────────────────────────────────────────── */
.vt-through { position: fixed; z-index: 2000; left: 0; top: 0; width: 100vw; height: 100vh; height: 100dvh; overflow: hidden; background: var(--paper); opacity: 0; visibility: hidden; }
.vt-through.on { opacity: 1; visibility: visible; }
.vt-through video, .vt-through img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 50%; background: var(--paper); }
.vt-through-end { opacity: 0; }
.vt-through.ended .vt-through-end { opacity: 1; }
/* walking through: push into the lit doorway */
.vt-through video, .vt-through img { transform-origin: var(--ox, 52%) var(--oy, 48%); }
.vt-through.go video, .vt-through.go img { transition: transform 1.05s cubic-bezier(0.65, 0, 0.35, 1), filter 1.05s ease; transform: scale(4.6); filter: brightness(1.15); }
.vt-through-glow { position: absolute; inset: 0; background: radial-gradient(circle at var(--ox, 52%) var(--oy, 48%), #fff6dc 0%, #f8ebc6 40%, var(--paper) 75%); opacity: 0; transition: opacity 0.7s ease 0.4s; }
.vt-through.go .vt-through-glow { opacity: 1; }

/* ── reveal ───────────────────────────────────────────────────────── */
.vt-rv { opacity: 0; transform: translateY(14px); transition: opacity 0.8s var(--ease), transform 0.8s var(--ease); transition-delay: var(--rd, 0s); }
.vt-rv.in { opacity: 1; transform: none; }

@media (max-width: 980px) {
  .vt-grid { grid-template-columns: 1fr; gap: 0; min-height: 0; }
  .vt-side { display: contents; }
  .vt-head { order: 1; text-align: center; }
  .vt-stage { order: 2; aspect-ratio: 16 / 10; max-height: 46vh; }
  .vt-card { order: 3; margin-top: -10px; }
}
@media (max-width: 720px) {
  .vt { width: calc(100% - 32px); padding-top: 88px; }
  .vt-head { margin-bottom: 4px; }
  .vt-title { font-size: 1.55rem; }
  .vt-stage { aspect-ratio: 16 / 11; max-height: 34vh; width: calc(100% + 32px); margin-left: -16px; margin-right: -16px; }
  .vt-still, .vt-idle { object-position: 50% 50%; transform: scale(1.45); }
  .vt-card { margin-top: -6px; }
  .vt-answer { flex-direction: column; align-items: stretch; }
  .vt-unlock { min-height: 54px; }
  .vt-stamp-no { right: 12px; top: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .vt-riddle .rd::after { transition: none; transform: scaleX(0); }
  .vt-rv { opacity: 1; transform: none; transition: none; }
  .vt-stage.rattle, .vt-card.shake { animation: none; }
  .vt-stamp.in { animation: none; opacity: 0.88; transform: rotate(-9deg); }
}
