/* THE SINNERS BALL — visual language lifted from the cards:
   near-black ground, engraved gold, thin rules, wide letterspacing. */

:root {
  --ink: #050505;
  --ink-2: #0b0a09;
  --gold: #d4af52;
  --gold-hi: #f4e0a3;
  --gold-lo: #8a6c2a;
  --gold-dim: rgba(212, 175, 82, 0.42);
  --rule: rgba(212, 175, 82, 0.22);
  /* Prose is read, not admired. Saturated gold is tiring at length, so body
     copy uses a warm parchment (15.5:1 on the ground) and gold is reserved
     for headings, rules and ornament. */
  --read: #ece0c4;
  --read-dim: #b8ad93;
  --ember: #ff9d3c;
  --display: "Cinzel", "Trajan Pro", Georgia, serif;
  --text: "EB Garamond", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--ink);
  color: var(--gold);
  font-family: var(--text);
  font-size: 19px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100dvh;
  background-image:
    radial-gradient(120% 80% at 50% -10%, rgba(212,175,82,0.09), transparent 60%),
    radial-gradient(90% 60% at 50% 110%, rgba(255,157,60,0.07), transparent 60%);
  background-attachment: fixed;
}

/* film grain over everything */
body::after {
  content: "";
  position: fixed; inset: 0; z-index: 9;
  pointer-events: none; opacity: 0.03;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/></filter><rect width='140' height='140' filter='url(%23n)'/></svg>");
}

.gilt {
  background: linear-gradient(180deg, var(--gold-hi) 0%, var(--gold) 46%, var(--gold-lo) 100%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}

h1, h2, h3, .display {
  font-family: var(--display);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin: 0;
}

.wrap { max-width: 720px; margin: 0 auto; padding: 0 24px; }

/* ── ornaments ─────────────────────────────────────────── */
.eye, .keyhole { display: block; margin: 0 auto; color: var(--gold); }
.rule {
  display: flex; align-items: center; gap: 14px;
  margin: 28px 0; color: var(--gold-dim);
}
.rule::before, .rule::after {
  content: ""; flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, var(--rule), transparent);
}
.rule span { font-family: var(--display); font-size: 11px; letter-spacing: 0.26em; color: var(--read-dim); }

/* ── the gate ──────────────────────────────────────────── */
#gate {
  min-height: 100dvh;
  display: grid; place-items: center;
  text-align: center; padding: 48px 24px;
}
#gate .inner { max-width: 520px; width: 100%; }

.brand {
  font-family: var(--display);
  font-size: clamp(26px, 7vw, 46px);
  letter-spacing: 0.2em;
  line-height: 1.15;
}
.brand .the {
  display: block; font-size: 0.42em; letter-spacing: 0.55em; margin-bottom: 10px;
  /* the gilt gradient clips to the h1, so this child needs its own fill */
  color: var(--gold-dim); -webkit-text-fill-color: var(--gold-dim);
}

.tagline {
  font-style: italic; font-size: 16px;
  color: var(--read-dim); letter-spacing: 0.05em;
  margin: 20px 0 40px;
}

.field { position: relative; margin: 0 auto; max-width: 340px; }
#code {
  width: 100%;
  background: transparent;
  border: none; border-bottom: 1px solid var(--rule);
  color: var(--gold-hi);
  font-family: var(--display);
  font-size: 26px; letter-spacing: 0.3em; text-align: center; text-transform: uppercase;
  padding: 14px 0 12px;
  outline: none;
  transition: border-color 0.4s;
}
#code::placeholder { color: rgba(212,175,82,0.2); letter-spacing: 0.3em; }
#code:focus { border-bottom-color: var(--gold); }

button.seal {
  margin-top: 30px;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--gold);
  font-family: var(--display);
  font-size: 12px; letter-spacing: 0.34em; text-transform: uppercase;
  padding: 14px 30px;
  cursor: pointer;
  transition: all 0.35s;
}
button.seal:hover { border-color: var(--gold); background: rgba(212,175,82,0.06); color: var(--gold-hi); }
button.seal:disabled { opacity: 0.35; cursor: wait; }

.deny {
  min-height: 26px; margin-top: 22px;
  font-style: italic; font-size: 15px;
  color: #a8452f; opacity: 0; transition: opacity 0.4s;
}
.deny.show { opacity: 1; }
.shake { animation: shake 0.45s cubic-bezier(.36,.07,.19,.97); }
@keyframes shake {
  10%,90% { transform: translateX(-2px); } 20%,80% { transform: translateX(4px); }
  30%,50%,70% { transform: translateX(-7px); } 40%,60% { transform: translateX(7px); }
}

/* ── the reveal ────────────────────────────────────────── */
#reveal { min-height: 100dvh; display: none; place-items: center; padding: 40px 24px; }
#reveal.on { display: grid; }

.card-stage { perspective: 1600px; }
.card-flip {
  width: min(300px, 74vw); aspect-ratio: 946 / 1662;
  position: relative; transform-style: preserve-3d;
  transform: rotateY(180deg) scale(0.92);
  transition: transform 1.5s cubic-bezier(.2,.8,.25,1);
  filter: drop-shadow(0 30px 60px rgba(0,0,0,0.85));
}
.card-flip.flipped { transform: rotateY(0deg) scale(1); }
.card-flip .face {
  position: absolute; inset: 0;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border-radius: 14px; overflow: hidden;
  border: 1px solid rgba(212,175,82,0.28);
}
.card-flip .front img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-flip .back {
  transform: rotateY(180deg);
  background:
    repeating-linear-gradient(45deg, rgba(212,175,82,0.05) 0 2px, transparent 2px 9px),
    linear-gradient(160deg, #0d0b08, #050505);
  display: grid; place-items: center;
}

/* ── the ledger ────────────────────────────────────────── */
#ledger { display: none; padding: 56px 0 120px; }
#ledger.on { display: block; }

.crest { text-align: center; margin-bottom: 10px; }
.house-name { font-size: clamp(22px, 5.4vw, 34px); }
.house-rank {
  font-family: var(--display); font-size: 12px;
  letter-spacing: 0.28em; color: var(--read-dim); margin-top: 12px;
}
.epithet { font-style: italic; color: var(--read-dim); text-align: center; margin-top: 8px; }
.fate { text-align: center; max-width: 60ch; margin: 22px auto 0; color: var(--read); }

.card-mini {
  display: block; width: 132px; margin: 0 auto 22px;
  border-radius: 8px; border: 1px solid rgba(212,175,82,0.25);
}

/* countdown */
.count { text-align: center; margin: 40px 0 10px; }
.count .label { font-family: var(--display); font-size: 11px; letter-spacing: 0.28em; color: var(--read-dim); }
.count .clock {
  font-family: var(--display); font-size: clamp(26px, 8vw, 44px);
  letter-spacing: 0.1em; margin-top: 12px;
}
.count .unit { font-size: 0.34em; letter-spacing: 0.24em; opacity: 0.55; margin: 0 12px 0 3px; }
.count .what { font-style: italic; color: var(--read-dim); font-size: 16px; margin-top: 10px; }

/* chapters */
.chapter {
  border-top: 1px solid var(--rule);
  padding: 30px 0;
}
.chapter:last-child { border-bottom: 1px solid var(--rule); }
.ch-head { display: flex; align-items: baseline; gap: 16px; }
.ch-n {
  font-family: var(--display); font-size: 13px; letter-spacing: 0.14em;
  color: var(--read-dim); min-width: 42px;
}
.ch-title { font-family: var(--display); font-size: 16px; letter-spacing: 0.16em; text-transform: uppercase; }
.ch-body p { margin: 16px 0 0 58px; color: var(--read); max-width: 62ch; }
.ch-body p:first-child { margin-top: 18px; }

.chapter.locked { opacity: 0.62; }
.chapter.locked .ch-title { color: var(--read-dim); }
.sealed {
  margin: 12px 0 0 58px; font-style: italic; font-size: 16px; color: var(--read-dim);
  display: flex; align-items: center; gap: 10px;
}

/* toll / passphrase / corruption blocks */
.inset {
  margin: 22px 0 0 58px; padding: 20px 22px;
  border: 1px solid var(--rule); background: rgba(212,175,82,0.03);
}
.inset .k { font-family: var(--display); font-size: 11px; letter-spacing: 0.26em; color: var(--read-dim); }
.inset .v { margin-top: 10px; color: var(--read); max-width: 62ch; }
.inset .v.mono {
  font-family: var(--display); font-size: 24px; letter-spacing: 0.28em;
}

/* confession */
.confess { margin: 22px 0 0 58px; }
.confess textarea {
  width: 100%; min-height: 84px; resize: vertical;
  background: rgba(212,175,82,0.03);
  border: 1px solid var(--rule); color: var(--read);
  font-family: var(--text); font-size: 18px; line-height: 1.6;
  padding: 14px 16px; outline: none;
}
.confess textarea:focus { border-color: var(--gold-dim); }
.confess .row { display: flex; align-items: center; gap: 16px; margin-top: 12px; }
.confess .count-left { font-size: 14px; color: var(--read-dim); letter-spacing: 0.08em; }
.confess .done { font-style: italic; color: var(--read-dim); }

/* the address, revealed */
.address {
  margin: 22px 0 0 58px; padding: 26px 24px;
  border: 1px solid var(--gold-dim);
  background: linear-gradient(180deg, rgba(212,175,82,0.07), transparent);
  text-align: center;
}
.address .street { font-family: var(--display); font-size: clamp(19px, 5vw, 27px); letter-spacing: 0.1em; }
.address .city { font-family: var(--display); font-size: 14px; letter-spacing: 0.22em; color: var(--read-dim); margin-top: 10px; }
.address .note { font-style: italic; margin-top: 18px; color: var(--read); }

/* the whisper */
.whisper { text-align: center; margin-top: 52px; }
.whisper .w-line { font-style: italic; color: var(--read-dim); margin: 0 0 14px; }
.whisper .w-row {
  display: flex; align-items: stretch; justify-content: center; gap: 14px;
  max-width: 400px; margin: 0 auto;
}
.whisper input {
  flex: 1; min-width: 0;
  background: transparent;
  border: none; border-bottom: 1px solid var(--rule);
  color: var(--gold-hi);
  font-family: var(--display);
  font-size: 16px; letter-spacing: 0.14em; text-align: center;
  padding: 10px 0 8px;
  outline: none;
  transition: border-color 0.4s;
}
.whisper input::placeholder { color: rgba(212,175,82,0.25); letter-spacing: 0.2em; }
.whisper input:focus { border-bottom-color: var(--gold); }
.whisper button.seal { margin-top: 0; padding: 10px 20px; font-size: 11px; letter-spacing: 0.26em; }
.whisper .w-note { font-size: 14px; font-style: italic; color: var(--read-dim); opacity: 0.8; margin-top: 14px; }
.whisper .w-note.bad { color: #a8452f; opacity: 1; }
.whisper .w-note a { color: inherit; }

.footer {
  text-align: center; margin-top: 60px;
  font-family: var(--display); font-size: 11px; letter-spacing: 0.26em; color: var(--read-dim); opacity: 0.6;
}
.footer a { color: inherit; }

@media (max-width: 560px) {
  body { font-size: 18px; }
  .ch-body p, .inset, .confess, .sealed, .address { margin-left: 0; }
  .ch-n { min-width: 34px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition-duration: 0.01ms !important; }
}
