/* ============================================================
   KAYEM Naughty List Smart Coal — styles.
   --bg / --accent are set per level by coal.js from coal-content.js
   STAGES; [data-level] adds the escalating extras (hazard tape,
   steam, shake). All motion is optional: prefers-reduced-motion
   removes it without hiding anything.
   ============================================================ */
:root {
  --bg: #173c32;
  --accent: #e7c281;
  --cream: #f6ecd5;
  --ink: #332c23;
  --ink-soft: #6f5b49;
  --stamp: #a3433b;
  --button: #bd3b32;
  --button-edge: #7a2624;
  --skin: #f3c9a8;
  --text: #f7f0e3;
  --text-soft: #e2d8c8;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background-color: var(--bg);
  background-image: radial-gradient(ellipse 120% 70% at 50% -10%, rgba(255, 255, 255, 0.14), transparent 70%);
  transition: background-color 0.45s ease;
  text-align: center;
}
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
[hidden] { display: none !important; }

.snow {
  position: fixed; inset: 0; pointer-events: none; opacity: 0.35;
  background-image:
    radial-gradient(2px 2px at 12% 18%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 72% 8%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 40% 62%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 88% 44%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 22% 86%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 60% 92%, #fff 50%, transparent 51%);
}

.shell {
  position: relative;
  max-width: 460px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

.brandbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 11px; letter-spacing: 0.12em; }
.brand { color: var(--text); font-weight: 800; text-decoration: none; letter-spacing: 0.08em; }
.brand-dot { color: var(--accent); }
.brand-caption { color: var(--text-soft); opacity: 0.85; text-align: right; }

.masthead { margin: 18px 0 14px; }
.eyebrow { margin: 0; font-size: 11px; font-weight: 800; letter-spacing: 0.18em; color: var(--accent); }
.title {
  margin: 6px 0 4px;
  font: 700 clamp(34px, 10vw, 46px)/1.02 Georgia, "Times New Roman", serif;
  color: #fff3d9; text-transform: uppercase; letter-spacing: 0.01em;
}
.subtitle { margin: 0; font-size: 13px; color: var(--text-soft); font-style: italic; }

/* ---------- Santa ---------- */
.santa-head { display: flex; justify-content: center; margin: 8px 0 2px; }
.santa-face {
  width: 132px; height: 132px; overflow: visible;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid var(--accent);
  transition: transform 0.3s ease;
}
.santa-face .hat { transform-origin: 60px 44px; transition: transform 0.35s ease; }
.hat-red { fill: #c8312b; }
.hat-pom, .hat-trim, .beard, .moustache { fill: #fbf7f0; }
.beard, .moustache { stroke: #e3dccf; stroke-width: 1; }
.skin { fill: var(--skin); transition: fill 0.4s ease; }
.cheek { fill: #e8746a; opacity: 0.35; transition: opacity 0.4s ease; }
.nose { fill: #e48a7c; }
.eye { fill: #2b2420; transition: all 0.25s ease; }
.eyes-x { display: none; stroke: #2b2420; stroke-width: 2.6; stroke-linecap: round; }
.brow { stroke: #fbf7f0; stroke-width: 4.5; stroke-linecap: round; fill: none; transition: transform 0.3s ease; }
.mouth { fill: none; stroke: #6b2a26; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.mouth.open { fill: #5a1f1c; stroke-width: 2.4; }
.steam, .vein, .grawlix { display: none; }
.steam path { fill: none; stroke: rgba(255, 255, 255, 0.75); stroke-width: 3; stroke-linecap: round; }
.vein { stroke: #ff4d4d; stroke-width: 2.6; fill: none; stroke-linecap: round; }
.grawlix rect { fill: #fff; stroke: #2b2420; stroke-width: 1.5; }
.grawlix text { font: 800 11px system-ui, sans-serif; fill: #b3261e; }

body[data-level="6"] .steam, body[data-level="7"] .steam, body[data-level="8"] .steam,
body[data-level="9"] .steam, body[data-level="10"] .steam { display: inline; }
body[data-level="8"] .vein, body[data-level="9"] .vein, body[data-level="10"] .vein { display: inline; }
body[data-level="7"] .grawlix, body[data-level="9"] .grawlix, body[data-level="10"] .grawlix { display: inline; }
body[data-level="10"] .eyes-x { display: inline; }
body[data-level="10"] .eye { display: none; }

.mood { margin: 8px 0 2px; font-size: 18px; font-weight: 800; color: var(--accent); letter-spacing: 0.02em; }
.warning {
  display: inline-block; margin: 4px 0 14px; padding: 6px 12px; border-radius: 6px;
  font-size: 12.5px; color: var(--text-soft); background: rgba(0, 0, 0, 0.18);
}
body[data-level="6"] .warning, body[data-level="7"] .warning, body[data-level="8"] .warning,
body[data-level="9"] .warning, body[data-level="10"] .warning {
  color: #1b1b1b; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em;
  background: repeating-linear-gradient(-45deg, #ffd23f 0 12px, #ffe48a 12px 24px);
  box-shadow: 0 0 0 2px #1b1b1b inset;
}

/* ---------- cream notices ---------- */
.letter {
  position: relative;
  background: var(--cream);
  color: var(--ink);
  border-radius: 6px;
  padding: 22px 20px 18px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(0, 0, 0, 0.08) inset;
  background-image: repeating-linear-gradient(0deg, transparent 0 27px, rgba(111, 91, 73, 0.07) 27px 28px);
}
.letter::before {
  content: ""; position: absolute; inset: 6px; border: 1px dashed rgba(111, 91, 73, 0.35); border-radius: 4px; pointer-events: none;
}
.stamp {
  display: inline-block; margin: 0 0 12px; padding: 5px 9px;
  border: 2px solid var(--stamp); border-radius: 3px; color: var(--stamp);
  font-size: 10.5px; font-weight: 900; letter-spacing: 0.08em; transform: rotate(-2deg);
}
.verdict {
  margin: 4px 0 12px; min-height: 4.2em;
  font: 700 clamp(19px, 5.4vw, 23px)/1.38 Georgia, "Times New Roman", serif;
  overflow-wrap: anywhere;
  display: flex; align-items: center; justify-content: center;
}
.signature { margin: 0; font-size: 12px; color: var(--ink-soft); font-style: italic; }
.letter-verdict.fresh { animation: slam 0.32s ease-out; }
@keyframes slam { 0% { transform: scale(0.96) rotate(-0.6deg); } 60% { transform: scale(1.015); } 100% { transform: none; } }
body[data-level="8"] .letter-verdict.fresh, body[data-level="9"] .letter-verdict.fresh, body[data-level="10"] .letter-verdict.fresh { animation: shake 0.42s ease-out; }
@keyframes shake {
  0%, 100% { transform: none; } 20% { transform: translateX(-6px) rotate(-1deg); }
  40% { transform: translateX(5px) rotate(0.8deg); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); }
}
.santa-face.fresh { animation: bob 0.35s ease-out; }
@keyframes bob { 50% { transform: translateY(-4px) scale(1.04); } }

/* ---------- personalized message ---------- */
.personal { margin-bottom: 22px; }
.letter-personal { text-align: center; }
.stamp-gift { border-color: #1f6b4f; color: #1f6b4f; }
.personal-state p { margin: 0 0 10px; }
.pm-recipient { font-size: 13px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
.pm-title { font: 700 22px/1.25 Georgia, "Times New Roman", serif; }
.pm-subtitle { font-size: 14px; color: var(--ink-soft); font-style: italic; }
.pm-text { font: 400 18px/1.55 Georgia, "Times New Roman", serif; white-space: pre-line; overflow-wrap: anywhere; text-align: left; }
.pm-signature { font-size: 14px; font-style: italic; color: var(--ink-soft); }
.personal-note { font-size: 14px; color: var(--ink-soft); }
.unlock-link {
  display: inline-block; margin-top: 4px; padding: 12px 18px; border-radius: 8px;
  background: #1f6b4f; color: #fff; font-weight: 800; text-decoration: none;
}
.secondary {
  margin-top: 16px; width: 100%; min-height: 52px; padding: 14px 12px; cursor: pointer;
  border: 2px solid var(--accent); border-radius: 10px; background: rgba(0, 0, 0, 0.18);
  color: var(--text); font: 800 15px system-ui, sans-serif; letter-spacing: 0.04em;
}
body[data-mode="personal"] .santa { margin-top: 6px; }

/* ---------- welcome back ---------- */
.welcome {
  margin: 0 0 16px; padding: 18px 16px 14px; border-radius: 12px;
  background: var(--cream); color: var(--ink);
  box-shadow: 0 0 0 3px var(--accent), 0 10px 24px rgba(0, 0, 0, 0.35);
  animation: drop 0.35s ease-out;
}
@keyframes drop { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.welcome-title { margin: 0 0 6px; font-size: 12px; font-weight: 900; letter-spacing: 0.16em; color: #994537; }
.welcome-text { margin: 0 0 8px; font: 700 20px/1.38 Georgia, "Times New Roman", serif; overflow-wrap: anywhere; }
.welcome-recovery { margin: 0 0 10px; font-size: 12.5px; color: var(--ink-soft); }
.welcome-dismiss {
  min-height: 46px; padding: 10px 18px; border: 0; border-radius: 8px; cursor: pointer;
  background: #ad382d; color: #fff; font: 800 14px system-ui, sans-serif;
}

/* ---------- gauge + button ---------- */
.gauge { margin: 18px 0 4px; }
.gauge-row { display: flex; justify-content: space-between; gap: 8px; font-size: 11.5px; font-weight: 700; color: #ecd5ad; letter-spacing: 0.04em; }
.meter { display: flex; gap: 3px; margin-top: 7px; }
.meter span { flex: 1; height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.18); transition: background-color 0.3s ease; }
.meter span.on { background: var(--accent); }
.chaos-badge {
  margin: 12px 0 0; padding: 7px 10px; border-radius: 999px;
  background: #140b18; color: #ffb4f1; border: 1px solid #ffb4f1;
  font-size: 11px; font-weight: 900; letter-spacing: 0.08em;
}
.primary {
  margin-top: 18px; width: 100%; min-height: 60px; padding: 16px 12px; cursor: pointer;
  border: 0; border-radius: 12px; background: var(--button); color: #fff;
  font: 900 17px/1.2 system-ui, sans-serif; letter-spacing: 0.06em;
  box-shadow: 0 5px 0 var(--button-edge), 0 10px 22px rgba(0, 0, 0, 0.3);
  transition: transform 0.08s ease, box-shadow 0.08s ease, background-color 0.3s ease;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.primary:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--button-edge), 0 4px 10px rgba(0, 0, 0, 0.3); }
body[data-level="9"] .primary, body[data-level="10"] .primary { background: #8e1630; --button-edge: #4c0b1a; }
body.chaos .primary { background-image: linear-gradient(90deg, rgba(255, 180, 241, 0.18), transparent 60%); }
button:focus-visible, a:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.info { margin: 14px 0 0; font-size: 12.5px; color: var(--text-soft); }

.footer { display: flex; flex-direction: column; gap: 4px; margin-top: 26px; font-size: 11px; letter-spacing: 0.06em; color: rgba(255, 255, 255, 0.62); }

/* ---------- milestone 50 ---------- */
.milestone {
  width: min(92vw, 400px); padding: 26px 20px 20px; border: 0; border-radius: 16px; overflow: hidden;
  background: radial-gradient(circle at 50% 0%, #5b1e41, #1a0d1f 75%); color: #fff3d9; text-align: center;
  box-shadow: 0 0 0 3px #ffb4f1, 0 20px 60px rgba(0, 0, 0, 0.6);
}
.milestone::backdrop { background: rgba(10, 4, 12, 0.82); }
.milestone[open] { animation: boom 0.5s cubic-bezier(0.2, 1.4, 0.4, 1); }
@keyframes boom { from { transform: scale(0.6) rotate(-4deg); opacity: 0; } to { transform: none; opacity: 1; } }
.milestone-kicker { margin: 0; font-size: 12px; font-weight: 900; letter-spacing: 0.22em; color: #ffb4f1; }
.milestone-title { margin: 6px 0 12px; font: 800 24px/1.15 Georgia, serif; }
.milestone-text { margin: 0 0 14px; font: 800 20px/1.4 Georgia, serif; color: #fff; }
.milestone-unlock { margin: 0; font-size: 13px; font-weight: 800; color: #ffd23f; }
.milestone .primary { margin-top: 18px; }
.milestone-burst { position: absolute; inset: 0; pointer-events: none; }
.milestone-burst span {
  position: absolute; left: 50%; top: 38%; font-size: 18px;
  animation: fly 1.4s ease-out forwards;
}
@keyframes fly {
  from { transform: translate(-50%, -50%) scale(0.4); opacity: 1; }
  to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(var(--rot)) scale(1); opacity: 0; }
}

/* ---------- Santa's Secret Patience Trick ---------- */
/* Santa's face is a plain button: no visible button chrome (it must not compete with
   the big verdict button), but a full keyboard focus ring and a 44px+ touch target. */
.santa-poke {
  display: inline-flex; padding: 0; margin: 0; border: 0; border-radius: 50%; background: none; color: inherit;
  cursor: pointer; font: inherit;
  touch-action: manipulation; /* iPhone: no double-tap zoom, no 300ms delay between quick taps */
  -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
}
.santa-poke:focus-visible { outline: 3px solid #fff; outline-offset: 4px; }
.santa-poke .santa-face { pointer-events: none; } /* the button, not the SVG parts, receives the tap */
.santa-poke.poked .santa-face { animation: poke 0.16s ease-out; box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.45); }
@keyframes poke { 50% { transform: scale(0.94) rotate(-2deg); } }

body.soothed { background-color: #2f5f6b; }
body.soothed::before {
  content: ""; position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(circle at 50% 28%, rgba(190, 236, 255, 0.35), transparent 62%);
  animation: calm-glow 4.5s ease-out forwards;
}
@keyframes calm-glow { 0% { opacity: 0; } 15% { opacity: 1; } 100% { opacity: 0.6; } }
body.soothed .santa-face { border-color: #bfe9ff; box-shadow: 0 0 22px rgba(191, 233, 255, 0.7); }
body.soothed .steam, body.soothed .vein, body.soothed .grawlix, body.soothed .eyes-x { display: none !important; }
body.soothed .eye { display: inline !important; }

.trick {
  margin: 10px 0 12px; padding: 16px 16px 12px; border-radius: 12px;
  background: #eaf6fb; color: #17323b;
  box-shadow: 0 0 0 3px #bfe9ff, 0 10px 24px rgba(0, 0, 0, 0.3);
  animation: drop 0.35s ease-out;
}
.trick[data-kind="cooldown"], .trick[data-kind="calm"] { background: var(--cream); color: var(--ink); box-shadow: 0 0 0 3px var(--accent), 0 10px 24px rgba(0, 0, 0, 0.3); }
.trick-title { margin: 0 0 6px; font-size: 12px; font-weight: 900; letter-spacing: 0.16em; color: #2a6f8a; }
.trick[data-kind="cooldown"] .trick-title, .trick[data-kind="calm"] .trick-title { color: #994537; }
.trick-text { margin: 0 0 8px; font: 700 19px/1.38 Georgia, "Times New Roman", serif; overflow-wrap: anywhere; }
.trick-effect { margin: 0 0 10px; font-size: 12.5px; font-weight: 700; opacity: 0.8; }
.trick-dismiss {
  min-height: 44px; padding: 9px 16px; border: 2px solid currentColor; border-radius: 8px; cursor: pointer;
  background: transparent; color: inherit; font: 800 13px system-ui, sans-serif;
}

.surprise {
  margin: 0 0 12px; padding: 12px; border-radius: 6px;
  background: repeating-linear-gradient(-45deg, #ffd23f 0 12px, #ffe48a 12px 24px); color: #1b1b1b;
  box-shadow: 0 0 0 2px #1b1b1b inset;
}
.surprise:not([hidden]) { animation: shake 0.42s ease-out; }
.surprise-text { margin: 0 0 6px; font: 900 16px/1.35 system-ui, sans-serif; overflow-wrap: anywhere; }
.surprise-effect { margin: 0; font-size: 12px; font-weight: 800; }
.ps { margin: 0 0 10px; font: italic 600 14.5px/1.45 Georgia, "Times New Roman", serif; color: var(--ink-soft); overflow-wrap: anywhere; }
.ps-label { font-style: normal; font-weight: 900; color: var(--stamp); }

/* ---------- language (EN / ES) ---------- */
.brand-left { display: flex; align-items: center; gap: 10px; }
.lang-switch { display: inline-flex; border: 1px solid rgba(255, 255, 255, 0.45); border-radius: 999px; overflow: hidden; }
.lang-switch button {
  min-width: 40px; min-height: 32px; padding: 4px 10px; border: 0; cursor: pointer;
  background: transparent; color: var(--text-soft); font: 800 11px system-ui, sans-serif; letter-spacing: 0.1em;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.lang-switch button[aria-pressed="true"] { background: var(--accent); color: #1b1b1b; }
.lang-switch button:focus-visible { outline: 3px solid #fff; outline-offset: -3px; }

.lang-gate {
  width: min(92vw, 380px); padding: 26px 20px 22px; border: 0; border-radius: 16px; text-align: center;
  background: var(--cream); color: var(--ink);
  box-shadow: 0 0 0 3px var(--accent), 0 20px 60px rgba(0, 0, 0, 0.6);
}
.lang-gate::backdrop { background: rgba(10, 20, 16, 0.86); }
.lang-gate-kicker { margin: 0 0 6px; font-size: 28px; }
.lang-gate-title { margin: 0 0 6px; font: 800 20px/1.3 Georgia, "Times New Roman", serif; }
.lang-gate-buttons { display: grid; gap: 12px; margin-top: 14px; }
.lang-gate .primary { margin-top: 0; }
.lang-gate .primary:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }

.noscript { position: fixed; inset: auto 12px 12px; padding: 14px; border-radius: 10px; background: var(--cream); color: var(--ink); font: 700 15px/1.4 Georgia, serif; }

@media (min-width: 520px) {
  .shell { padding-top: 32px; }
  .santa-face { width: 148px; height: 148px; }
}

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