/* ============================================================
   Portal Engine — stylesheet
   1. Tokens (defaults; overridden by config.php inline :root)
   2. Base & typography
   3. Portal animation
   4. Layout
   5. Components (sections, lists, seal, deck, buttons)
   6. Motion preferences
   Mobile-first throughout.
   ============================================================ */

/* ---------- 1. tokens ---------- */
:root {
  --bg: #0c141e;
  --panel: #131e2a;
  --text: #f3e9d7;
  --dim: #b7a88f;
  --copper: #d29a6b;
  --gold: #e6c887;
  --seal: #8c2f2a;
  --serif: Georgia, 'Iowan Old Style', 'Palatino Linotype', 'Book Antiqua', serif;
  --sans: -apple-system, 'Segoe UI', Roboto, sans-serif;
}

/* ---------- 2. base ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body {
  font-family: var(--serif);
  color: var(--text);
  line-height: 1.7;
  min-height: 100dvh;
  background:
    radial-gradient(120vmin 60vmin at 50% -10vmin, rgba(210, 154, 107, .14), transparent 70%),
    radial-gradient(2px 2px at 15% 25%, rgba(230, 200, 135, .55), transparent 60%),
    radial-gradient(1.6px 1.6px at 78% 14%, rgba(230, 200, 135, .45), transparent 60%),
    radial-gradient(1.5px 1.5px at 62% 46%, rgba(230, 200, 135, .3), transparent 60%),
    radial-gradient(1.8px 1.8px at 28% 66%, rgba(230, 200, 135, .35), transparent 60%),
    radial-gradient(1.5px 1.5px at 86% 82%, rgba(230, 200, 135, .35), transparent 60%),
    var(--bg);
}
img { max-width: 100%; }
a { color: var(--gold); }
a:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

.eyebrow {
  font-family: var(--sans); font-size: 11px; font-weight: 600;
  letter-spacing: .38em; text-indent: .38em; text-transform: uppercase;
  color: var(--copper); text-align: center;
}
h1 {
  font-weight: 500; font-style: italic; color: var(--gold); text-align: center;
  font-size: clamp(26px, 7vw, 36px); line-height: 1.2; margin: 10px 0 4px; text-wrap: balance;
}
.orn { color: var(--copper); text-align: center; letter-spacing: .5em; text-indent: .5em; font-size: 12px; margin: 14px 0; }

/* ink-bleed reveal */
.ink { opacity: 0; filter: blur(8px); transition: opacity .9s ease, filter 1.1s ease; }
.ink.rev { opacity: 1; filter: blur(0); }

/* ---------- 3. portal ---------- */
#portal {
  position: fixed; inset: 0; z-index: 50; display: none;
  align-items: center; justify-content: center; background: var(--bg);
}
#portal.on { display: flex; }
.pring {
  width: 38vmin; height: 38vmin; border-radius: 50%;
  border: 2px solid var(--gold);
  box-shadow: 0 0 26px rgba(230, 200, 135, .55), inset 0 0 22px rgba(210, 154, 107, .5);
  display: flex; align-items: center; justify-content: center;
}
.pring .pnum { font-size: 11vmin; color: var(--gold); letter-spacing: .1em; font-style: italic; }
#portal.anim .pring { animation: pring 1.15s cubic-bezier(.4, 0, .2, 1) .15s forwards; }
@keyframes pring {
  0% { transform: scale(1); opacity: 1; }
  55% { transform: scale(1.25); opacity: 1; }
  100% { transform: scale(6); opacity: 0; }
}
#portal.anim { animation: pfade .3s ease 1.15s forwards; }
@keyframes pfade { to { opacity: 0; visibility: hidden; } }
.dust { position: absolute; width: 5px; height: 5px; border-radius: 50% 40% 55% 45%; background: var(--gold); opacity: 0; }
#portal.anim .dust { animation: dust 1.5s ease-out .35s forwards; }
@keyframes dust {
  0% { transform: translate(0, 0) scale(1); opacity: .95; }
  100% { transform: translate(var(--dx), var(--dy)) scale(.2); opacity: 0; }
}

/* ---------- 4. layout ---------- */
#stage { max-width: 640px; margin: 0 auto; padding: 22px 20px 70px; }
figure.art { margin: 22px -6px; }
figure.art img {
  width: 100%; border-radius: 10px; display: block;
  box-shadow: 0 0 0 1px rgba(210, 154, 107, .4), 0 18px 45px rgba(0, 0, 0, .55);
}
footer { color: var(--dim); text-align: center; font-size: 12.5px; font-style: italic; margin-top: 34px; }

/* ---------- 5. components ---------- */
/* his voice on card pages: handwritten (Bad Script); practical lists
   (path, feast, challenges) stay serif for street-level scannability */
.greet {
  font-family: 'Bad Script', 'Segoe Script', cursive;
  font-size: clamp(19px, 5vw, 21px); line-height: 1.55;
  text-align: center; max-width: 30em; margin: 6px auto 0; color: #f6f1e6;
}

section {
  background: var(--panel);
  border: 1px solid rgba(210, 154, 107, .25);
  border-radius: 10px; padding: 20px 22px; margin: 16px 0;
}
section h2 {
  font-family: var(--sans); font-size: 11.5px; letter-spacing: .3em; text-indent: .3em;
  text-transform: uppercase; color: var(--copper); font-weight: 600; margin-bottom: 12px;
}
section h2 .g { margin-right: 8px; color: var(--gold); }
section h2 .hint { float: right; color: var(--dim); letter-spacing: 0; text-indent: 0; text-transform: none; }
.tale {
  font-family: 'Bad Script', 'Segoe Script', cursive;
  font-size: clamp(18px, 4.8vw, 20px); line-height: 1.62;
  color: #f3eee2; margin-bottom: 12px;
}
.tale:last-of-type { margin-bottom: 0; }
.sign { font-style: italic; color: var(--copper); text-align: right; margin-top: 14px; }

ul.plain { list-style: none; }
ul.plain li {
  padding: 8px 0 8px 24px; position: relative;
  border-bottom: 1px dashed rgba(243, 233, 215, .14); font-size: 14.5px;
}
ul.plain li:last-child { border-bottom: none; }
ul.plain li::before { content: "✦"; position: absolute; left: 2px; top: 11px; color: var(--copper); font-size: 11px; }

ul.chal li { cursor: pointer; user-select: none; }
ul.chal li::before { content: ""; width: 14px; height: 14px; border: 1.5px solid var(--copper); border-radius: 3px; top: 11px; }
ul.chal li.done { color: var(--dim); text-decoration: line-through; }
ul.chal li.done::before {
  content: "✦"; border-color: var(--gold); color: var(--gold);
  font-size: 11px; line-height: 14px; text-align: center; text-decoration: none;
}

.ritual {
  font-family: 'Bad Script', 'Segoe Script', cursive;
  font-size: clamp(18px, 4.8vw, 20px); line-height: 1.62; color: #f3eee2;
}
.ritual::before { content: "☾  "; color: var(--gold); }

/* wax seal */
.sealbox { text-align: center; padding: 26px 22px; }
.wax {
  width: 74px; height: 74px; border-radius: 50%; margin: 6px auto 10px; cursor: pointer;
  background: radial-gradient(circle at 35% 32%, #b6483d, var(--seal) 60%, #5f1d1a);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .5), inset 0 0 0 6px rgba(255, 255, 255, .06);
  display: flex; align-items: center; justify-content: center;
  color: #f2d8b8; font-size: 26px;
  transition: transform .5s ease, opacity .6s ease, filter .6s ease;
}
.wax:active { transform: scale(.94); }
.sealbox.open .wax { transform: scale(1.6); opacity: 0; filter: blur(6px); pointer-events: none; }
.sealhint {
  font-family: var(--sans); font-size: 11px; letter-spacing: .25em;
  text-transform: uppercase; color: var(--dim);
}
.note {
  display: none;
  font-family: 'Bad Script', 'Segoe Script', cursive;
  font-size: clamp(19px, 5vw, 21px);
  color: var(--gold); max-width: 26em; margin: 0 auto; line-height: 1.7;
}
.note .who { color: var(--copper); }
.sealbox.open .note { display: block; animation: inkin 1.2s ease; }
.sealbox.open .sealhint { display: none; }
@keyframes inkin { from { opacity: 0; filter: blur(8px); } to { opacity: 1; filter: blur(0); } }

/* buttons & nav */
.navrow { display: flex; justify-content: center; gap: 14px; margin: 26px 0 0; flex-wrap: wrap; }
.btn {
  font-family: var(--sans); font-size: 12px; letter-spacing: .22em; text-indent: .22em;
  text-transform: uppercase; color: var(--gold);
  border: 1px solid rgba(230, 200, 135, .5); border-radius: 999px;
  padding: 11px 22px; background: none; cursor: pointer; text-decoration: none;
}

/* handwritten love letter — self-hosted Dancing Script (true cursive on every
   device; the earlier system-cursive fallback rendered plain on Android).
   Weight 500 + line-height 1.55: bolder weights fill the loops, tighter
   leading tangles ascenders/descenders on phones. */
@font-face {
  font-family: 'Dancing Script';
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url('../fonts/dancing-script.woff2') format('woff2');
}
@font-face {
  font-family: 'Caveat';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../fonts/caveat.woff2') format('woff2');
}
@font-face {
  font-family: 'Bad Script';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/bad-script.woff2') format('woff2');
}
.handwritten {
  background:
    linear-gradient(rgba(230, 200, 135, .04), rgba(230, 200, 135, .04)),
    var(--panel);
  padding: 28px 26px;
}
.hand {
  /* Bad Script: the chosen hand — elegant connected handwriting, readable
     over paragraphs. Thin strokes, so brighter ink and roomy leading. */
  font-family: 'Bad Script', 'Segoe Script', 'Snell Roundhand', cursive;
  font-weight: 400;
  font-size: clamp(21px, 5.4vw, 23px);
  line-height: 1.62;
  color: #f6f1e6;
  margin-bottom: 18px;
  letter-spacing: .01em;
}
.hand:last-of-type { margin-bottom: 0; }
.hand-sign {
  font-family: 'Bad Script', 'Segoe Script', 'Snell Roundhand', cursive;
  font-weight: 400;
  font-size: clamp(24px, 6vw, 26px);
  color: var(--copper); text-align: right; margin-top: 16px;
}

/* sealed-deck gate: the whisper ritual */
.gate { padding-top: 2dvh; }         /* keep interactives in the upper half, clear of the keyboard */
.keyhole {
  width: 92px; height: 92px; border-radius: 50%;
  border: 1.5px solid var(--gold);
  display: flex; align-items: center; justify-content: center;
  margin: 4px auto 16px; color: var(--gold);
  animation: keypulse 3s ease-in-out infinite;
}
@keyframes keypulse {
  0%, 100% { box-shadow: 0 0 10px rgba(230, 200, 135, .25), inset 0 0 8px rgba(210, 154, 107, .2); transform: scale(1); }
  50% { box-shadow: 0 0 28px rgba(230, 200, 135, .55), inset 0 0 16px rgba(210, 154, 107, .4); transform: scale(1.04); }
}
.whisperform { text-align: center; margin: 26px 0 4px; }
.whisperwrap { position: relative; width: min(300px, 74vw); margin: 0 auto 18px; }
#whisper {
  width: 100%; background: transparent; border: none; outline: none;
  text-align: center; padding: 10px 0 12px;
  font-family: 'Bad Script', 'Segoe Script', cursive;
  font-weight: 400; font-size: 24px; letter-spacing: .08em;
  color: var(--gold);
  text-shadow: 0 0 10px rgba(230, 200, 135, .35);
  caret-color: var(--gold);
}
#whisper::placeholder { color: rgba(230, 200, 135, .4); font-size: 21px; letter-spacing: .04em; }
#whisper:focus { text-shadow: 0 0 16px rgba(230, 200, 135, .7); }
.whisperline {
  position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 62%; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  transition: width .6s cubic-bezier(.25, 1, .5, 1), box-shadow .4s;
}
#whisper:focus ~ .whisperline { width: 100%; box-shadow: 0 0 10px rgba(230, 200, 135, .6); }
.waswrong .whisperline { background: linear-gradient(90deg, transparent, #c96a52, transparent); }
.sealbtn {
  width: 62px; height: 62px; border-radius: 50%; border: 0; cursor: pointer;
  background: radial-gradient(circle at 35% 32%, #b6483d, var(--seal) 60%, #5f1d1a);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .5), inset 0 0 0 5px rgba(255, 255, 255, .06);
  color: #f2d8b8; font-size: 22px;
  transition: transform .2s ease, box-shadow .3s ease;
}
.sealbtn:hover { box-shadow: 0 6px 24px rgba(140, 47, 42, .7), inset 0 0 0 5px rgba(255, 255, 255, .1); }
.sealbtn:active { transform: scale(.92); }
.sealbtn:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.whisperform .sealhint { margin-top: 10px; }
.shake { animation: gentleshake .45s ease-in-out; }
@keyframes gentleshake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-7px); }
  40%, 80% { transform: translateX(7px); }
}
.gate.opening { animation: gateopen 1s cubic-bezier(.7, 0, .3, 1) forwards; }
@keyframes gateopen {
  0% { transform: scale(1); opacity: 1; filter: blur(0); }
  100% { transform: scale(1.6); opacity: 0; filter: blur(10px); }
}
.gatewrong { color: var(--copper); }
.gatehint { font-size: 15.5px; color: var(--dim); }
.cardhint { text-align: center; font-style: italic; color: var(--dim); font-size: 13.5px; margin-top: 14px; }
@media (prefers-reduced-motion: reduce) {
  .keyhole, .shake, .gate.opening { animation: none; }
}

/* ask-fate page: a breathing deck that swirls and chooses one door */
.fatewords { text-align: center; max-width: 24em; margin: 10px auto 0; }
.fatedeck {
  position: relative; height: 250px; width: min(320px, 84vw);
  margin: 30px auto 8px; cursor: pointer; perspective: 900px; outline: none;
}
.fatedeck:focus-visible { outline: 2px solid var(--gold); outline-offset: 6px; border-radius: 14px; }
.fcard {
  position: absolute; left: 50%; top: 50%; width: 118px; height: 168px;
  margin: -84px 0 0 -59px; border-radius: 10px;
  background:
    radial-gradient(2px 2px at 24% 22%, rgba(230, 200, 135, .5), transparent 60%),
    radial-gradient(1.6px 1.6px at 74% 34%, rgba(230, 200, 135, .4), transparent 60%),
    radial-gradient(1.8px 1.8px at 38% 76%, rgba(230, 200, 135, .4), transparent 60%),
    linear-gradient(150deg, #182635, var(--panel) 60%, #0f1926);
  border: 1px solid rgba(230, 200, 135, .5);
  box-shadow: 0 8px 22px rgba(0, 0, 0, .5), inset 0 0 0 6px rgba(230, 200, 135, .07);
  display: flex; align-items: center; justify-content: center;
  color: var(--gold); font-size: 30px;
  transform: rotate(calc((var(--i) - 3) * 6deg)) translateY(calc((var(--i) - 3) * 2px));
  animation: fatebreathe 4.2s ease-in-out calc(var(--i) * .35s) infinite;
}
@keyframes fatebreathe {
  0%, 100% { box-shadow: 0 8px 22px rgba(0, 0, 0, .5), 0 0 10px rgba(230, 200, 135, .12); }
  50% { box-shadow: 0 10px 26px rgba(0, 0, 0, .55), 0 0 24px rgba(230, 200, 135, .3); }
}
.fatedeck.shuffling .fcard {
  animation: fateshuffle .5s ease-in-out calc(var(--i) * 55ms) infinite alternate;
}
@keyframes fateshuffle {
  from { transform: rotate(calc((var(--i) - 3) * 16deg)) translate(calc((var(--i) - 3) * 22px), -14px); }
  to   { transform: rotate(calc((3 - var(--i)) * 12deg)) translate(calc((3 - var(--i)) * 18px), 12px); }
}
.fatedeck .fcard.chosen {
  animation: fatechosen 1.15s cubic-bezier(.3, 1.2, .4, 1) forwards; z-index: 6;
}
@keyframes fatechosen {
  0%   { transform: rotate(0) scale(1) rotateY(0); }
  45%  { transform: translateY(-26px) scale(1.22) rotateY(90deg); }
  100% { transform: translateY(-22px) scale(1.28) rotateY(0);
         box-shadow: 0 0 55px rgba(230, 200, 135, .8), 0 14px 30px rgba(0, 0, 0, .55);
         border-color: var(--gold); }
}
.fcard.chosen span { font-family: 'Cormorant Garamond', Georgia, serif; font-style: italic; letter-spacing: .06em; }
.fatedeck.shuffling ~ #fatebtn, .fatedeck.done ~ #fatebtn { opacity: 0; pointer-events: none; }
#fatebtn { transition: opacity .5s ease; display: block; margin: 14px auto 0; }
.fdust {
  position: absolute; left: 50%; top: 50%; width: 5px; height: 5px;
  border-radius: 50% 40% 55% 45%; background: var(--gold); opacity: 0; pointer-events: none;
  animation: fdust 1.3s ease-out forwards;
}
@keyframes fdust {
  0% { transform: translate(0, 0) scale(1); opacity: .95; }
  100% { transform: translate(var(--dx), var(--dy)) scale(.15); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .fcard, .fatedeck.shuffling .fcard, .fcard.chosen, .fdust { animation: none; }
}

/* hello start page */
.hello { padding-top: 4dvh; }
.brand {
  display: block; width: min(240px, 60vw); margin: 0 auto 22px;
  border-radius: 50%; box-shadow: 0 0 40px rgba(230, 200, 135, .25), 0 0 0 1px rgba(210, 154, 107, .35);
}
.brandline { display: block; width: 120px; margin: 26px auto 0; border-radius: 50%; opacity: .9; }

/* deck grid (intro side) */
.landing p.big { font-style: italic; text-align: center; font-size: 18px; max-width: 30em; margin: 12px auto; }
.cover {
  width: 100%; border-radius: 12px; margin: 18px 0 6px;
  box-shadow: 0 0 0 1px rgba(210, 154, 107, .4), 0 20px 50px rgba(0, 0, 0, .55);
}
.deckhead {
  font-weight: 500; font-style: italic; color: var(--gold); text-align: center;
  font-size: clamp(20px, 5vw, 26px); margin: 34px 0 6px;
}
.deckgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-top: 16px; }
.mini {
  background: var(--panel); border: 1px solid rgba(210, 154, 107, .3); border-radius: 10px;
  overflow: hidden; text-align: center; padding-bottom: 12px; text-decoration: none;
  transition: transform .2s ease; display: block;
}
.mini:hover { transform: translateY(-3px); }
.mini img {
  width: 100%; aspect-ratio: 3 / 2; object-fit: cover; display: block; margin-bottom: 9px;
  filter: saturate(.35) brightness(.75); transition: filter .4s;
}
.mini.unlocked img { filter: none; }
.mini .mn { display: block; color: var(--copper); font-size: 12px; letter-spacing: .2em; }
.mini .mt { display: block; font-style: italic; color: var(--text); font-size: 13.5px; padding: 2px 10px 0; line-height: 1.35; }
.mini.unlocked .mt { color: var(--gold); }

/* ---------- 6. motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  #portal.anim .pring, #portal.anim .dust { animation: none; }
  #portal.anim { animation: pfade .5s ease .4s forwards; }
  .ink { transition: none; }
  .mini, .wax { transition: none; }
}
