/* Layout, the innocent quiz-site look, and how it degrades stage by stage. */
:root {
  --bg: #fff7fb; --bg2: #ffeccc; --card: #ffffff; --ink: #1f1a2e; --muted: #6b6680;
  --accent: #ff3d7f; --accent-ink: #ffffff; --line: #efe6f2; --tile: #ffffff;
  --page: #1f1a2e; --page-muted: #6b6680;
  --tile-0: #ffe3ec; --tile-1: #dff1ff; --tile-2: #fff1c4; --tile-3: #e2f8e4; --tile-4: #eee3ff; --tile-5: #ffe7d1;
  --font-display: 'Nunito', system-ui, sans-serif;
  --font-body: 'Nunito', system-ui, sans-serif;
  --title-scale: 1; --title-style: normal;
  --fx-o: 0; --front-o: 0; --grain-o: 0; --vig-o: 0;
  --radius: 20px;
  --slow: 1.6s;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; overflow-x: hidden;
  background: var(--bg); color: var(--page);
  font-family: var(--font-body); font-size: 16px; line-height: 1.5;
  transition: background-color var(--slow), color var(--slow);
}
button { font: inherit; }

/* ---------- background, effects and overlays ---------- */
#bg { position: fixed; inset: 0; z-index: -3; background-color: var(--bg); transition: background-color var(--slow); }
#bg::before {
  content: ''; position: absolute; inset: -15% -10% 35%;
  background-color: var(--bg2); transition: background-color var(--slow);
  -webkit-mask-image: radial-gradient(closest-side, #000, transparent); mask-image: radial-gradient(closest-side, #000, transparent);
}
#fx, #fx-front { position: fixed; inset: 0; pointer-events: none; overflow: hidden; transition: opacity 2s; }
#fx { z-index: -1; opacity: var(--fx-o); }
#fx-front { z-index: 30; opacity: var(--front-o); }
.fx-layer { position: absolute; inset: 0; transition: opacity 1.2s; }
.fx-layer.out { opacity: 0; }
#grain {
  position: fixed; inset: -50%; z-index: 40; pointer-events: none;
  background-image: var(--noise); background-size: 220px; mix-blend-mode: overlay;
  opacity: var(--grain-o); transition: opacity 2s; animation: grain 1s steps(6) infinite;
}
#vignette {
  position: fixed; inset: 0; z-index: 41; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(0, 0, 0, .9) 100%);
  opacity: var(--vig-o); transition: opacity 2s;
}
@keyframes grain {
  0% { transform: translate(0, 0); } 20% { transform: translate(-3%, 2%); } 40% { transform: translate(2%, -3%); }
  60% { transform: translate(-2%, -1%); } 80% { transform: translate(3%, 3%); } 100% { transform: translate(0, 0); }
}

#scare { position: fixed; inset: 0; z-index: 1000; display: none; place-items: center; overflow: hidden; background: #000; color: #f4f4f4; pointer-events: none; }
#scare.on { display: grid; animation: scare var(--dur, .8s) linear forwards; }
#scare.slow { animation-name: scare-slow; animation-timing-function: ease; }
#scare.themed { background: var(--bg); color: var(--accent); }
.scare-eye { position: absolute; width: min(92vw, 900px); opacity: .28; }
.scare-text {
  position: relative; padding: 0 16px; text-align: center; line-height: 1.05;
  font-family: 'Nosifer', cursive; font-size: clamp(40px, 10vw, 140px);
  text-shadow: 0 0 30px rgba(255, 0, 0, .55);
}
#scare.themed .scare-text { font-family: var(--font-display); font-size: calc(clamp(40px, 10vw, 140px) * var(--title-scale)); text-shadow: 0 0 30px var(--accent); }
#scare.slow .scare-text { font-size: clamp(32px, 7vw, 90px); }
@keyframes scare { 0%, 88% { opacity: 1; } 100% { opacity: 0; } }
@keyframes scare-slow { 0% { opacity: 0; } 25% { opacity: 1; } 75% { opacity: 1; } 100% { opacity: 0; } }

html.flicker .shell { animation: power .9s linear; }
@keyframes power { 0% { opacity: 1; } 10% { opacity: .05; } 22% { opacity: 1; } 40% { opacity: .2; } 55% { opacity: 1; } 70% { opacity: .1; } 100% { opacity: 1; } }
html.quake .shell { animation: quake .7s linear; }
@keyframes quake {
  0%, 100% { transform: translate(0, 0); } 10% { transform: translate(-7px, 3px); } 20% { transform: translate(6px, -4px); }
  30% { transform: translate(-5px, 5px); } 40% { transform: translate(5px, 2px); } 55% { transform: translate(-3px, -3px); }
  70% { transform: translate(3px, 2px); } 85% { transform: translate(-1px, 1px); }
}
html.inverted { filter: invert(1) hue-rotate(180deg); }

/* ---------- page chrome ---------- */
.wrap { width: min(1120px, 100% - 32px); margin-inline: auto; }
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: var(--card); color: var(--ink); border-bottom: 1px solid var(--line);
  transition: background-color var(--slow), border-color var(--slow), opacity 3s;
}
.header-inner { display: flex; align-items: center; gap: 24px; height: 60px; }
.logo { display: flex; align-items: center; gap: 8px; flex: none; color: var(--ink); font-weight: 900; font-size: 25px; letter-spacing: -.04em; }
.logo-sun {
  width: 24px; height: 24px; border-radius: 50%; background: #ffc83d;
  box-shadow: 0 0 0 4px #ffe9a8; transition: background-color var(--slow), box-shadow var(--slow);
}
.nav { display: flex; gap: 4px; min-width: 0; overflow: hidden; }
.nav-link {
  padding: 6px 12px; border: 0; border-radius: 999px; background: none; cursor: pointer;
  color: var(--ink); font-size: 14px; font-weight: 800; white-space: nowrap;
}
.nav-link:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.nav-link:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.nav-link:first-child { background: var(--accent); color: var(--accent-ink); }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 48px; padding: 28px 0 64px; }
.article { min-width: 0; max-width: 680px; }
.article-head { transition: opacity 3s; }
.tag {
  display: inline-block; margin: 0 0 10px; padding: 3px 10px; border-radius: 6px;
  background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 900; letter-spacing: .08em;
}
.article-title {
  margin: 0 0 10px; font-family: var(--font-display); font-weight: 900; line-height: 1.1;
  font-size: calc(clamp(30px, 5vw, 46px) * var(--title-scale)); letter-spacing: -.02em; text-wrap: balance;
}
.dek { margin: 0 0 16px; color: var(--page-muted); font-size: 18px; transition: color var(--slow); }
.byline { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; font-size: 14px; }
.avatar {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); font-size: 13px; font-weight: 900;
}
.byline-name { display: block; font-weight: 800; }
.byline-meta { display: block; color: var(--page-muted); font-size: 13px; }
.count { margin: 0; color: var(--page-muted); font-size: 13px; font-weight: 700; }

.hero {
  position: relative; height: 170px; margin: 20px 0 24px; overflow: hidden; border-radius: var(--radius);
  background: linear-gradient(135deg, #ffd6e5, #ffe8b3 50%, #d9f0ff);
  transition: height 1.2s var(--ease), margin 1.2s var(--ease), opacity 1s, filter var(--slow);
}
.hero span { position: absolute; font-size: 46px; line-height: 1; animation: bob 3s ease-in-out infinite; animation-delay: var(--d, 0s); }
.hero-badge {
  position: absolute; left: 16px; bottom: 14px; padding: 4px 12px; border-radius: 999px;
  background: #fff; color: #1f1a2e; font-size: 13px; font-weight: 900; box-shadow: 0 4px 12px rgba(0, 0, 0, .08);
}
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-8px) rotate(4deg); } }

.sidebar { min-width: 0; transition: opacity 3s; }
.trend-head { margin: 0 0 14px; font-family: var(--font-display); font-size: calc(19px * var(--title-scale)); font-weight: 900; }
.trending { display: grid; gap: 14px; margin: 0; padding: 0; list-style: none; }
.trend {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 0; border: 0;
  background: none; color: inherit; text-align: left; cursor: pointer;
}
.trend:hover .trend-title { text-decoration: underline; text-underline-offset: 3px; }
.trend:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; border-radius: 12px; }
.trend-thumb {
  display: grid; place-items: center; flex: none; width: 64px; height: 64px; border-radius: 12px;
  background: var(--tile-1); font-size: 30px; transition: background-color var(--slow), filter var(--slow);
}
.trending li:nth-child(2n) .trend-thumb { background: var(--tile-2); }
.trending li:nth-child(3n) .trend-thumb { background: var(--tile-4); }
.trend-title { font-weight: 800; font-size: 15px; line-height: 1.3; }

.site-footer { padding: 24px 0 40px; border-top: 1px solid var(--line); color: var(--page-muted); font-size: 13px; transition: border-color var(--slow); }

/* ---------- quiz card ---------- */
.card {
  position: relative; overflow: hidden; padding: 24px; scroll-margin-top: 80px;
  background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(31, 26, 46, .08);
  transition: background-color var(--slow), color var(--slow), border-color var(--slow), border-radius var(--slow), box-shadow var(--slow), transform 1s;
}
.card-body { transition: opacity .25s, transform .25s; }
.card-body.leaving { opacity: 0; transform: translateY(-8px); }
.card-body.entering { opacity: 0; transform: translateY(8px); }

.progress { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.progress-track { flex: 1; height: 8px; overflow: hidden; border-radius: 999px; background: var(--line); transition: background-color var(--slow); }
.progress-fill { width: 0; height: 100%; border-radius: inherit; background: var(--accent); transition: width .6s var(--ease), background-color var(--slow); }
.progress-label { color: var(--muted); font-size: 13px; font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }

.q-title {
  margin: 0 0 20px; font-family: var(--font-display); font-weight: 900; font-style: var(--title-style);
  font-size: calc(clamp(22px, 3.4vw, 30px) * var(--title-scale)); line-height: 1.2; text-wrap: balance;
}
.msg-from { display: block; margin: 0 0 6px; color: var(--muted); font-size: 13px; font-weight: 800; }
.q-title.msg { font-family: 'Special Elite', monospace; font-weight: 400; font-style: normal; font-size: clamp(20px, 3vw, 26px); min-height: 1.3em; }
.caret { display: inline-block; width: .55em; height: 1em; margin-left: 2px; vertical-align: -.12em; background: currentColor; animation: caret 1s steps(1) infinite; }
@keyframes caret { 50% { opacity: 0; } }

.opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.opts.list { grid-template-columns: minmax(0, 1fr); }
.opts.waiting .opt { opacity: 0; pointer-events: none; transform: translateY(6px); }
.opt {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 120px; padding: 16px 12px; border: 3px solid transparent; border-radius: 16px;
  background: var(--t, var(--tile-0)); color: var(--ink); cursor: pointer;
  font-family: var(--font-body); font-weight: 800; font-size: 16px; line-height: 1.25; text-align: center;
  transition: transform .15s var(--ease), border-color .2s, box-shadow .2s, opacity .4s, background-color var(--slow), color var(--slow), filter .8s;
}
.opt:hover { transform: translateY(-2px); border-color: var(--accent); }
.opt:active { transform: scale(.98); }
.opt:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.opt.no-emoji { min-height: 84px; }
.opt.emoji-only .opt-emoji { font-size: 58px; }
.opts.list .opt { min-height: 60px; padding: 14px 18px; align-items: flex-start; text-align: left; }
.opt-emoji { font-size: 44px; line-height: 1; transition: filter var(--slow), opacity var(--slow); }
.opt-label { overflow-wrap: anywhere; }
.opt-label.wd { font-family: 'Segoe UI Symbol', 'Segoe UI Emoji', 'Noto Sans Symbols 2', sans-serif; letter-spacing: .06em; }
.opt-label.whisper { font-style: italic; color: var(--accent); }
.opt.picked { border-color: var(--accent); }
.opt.picked::after {
  content: '✓'; position: absolute; top: 8px; right: 8px; display: grid; place-items: center;
  width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 15px; font-weight: 900;
}
.opts.locked { pointer-events: none; }
.opts.locked .opt:not(.picked) { opacity: .4; }
.ch { transition: opacity .9s; }
.ch.gone { opacity: 0; }

/* loading + result */
.loading { display: grid; place-items: center; gap: 18px; min-height: 260px; text-align: center; }
.spinner { width: 46px; height: 46px; border: 4px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin-once 1s linear infinite; }
@keyframes spin-once { to { transform: rotate(360deg); } }
.loading-text { font-family: var(--font-display); font-size: calc(24px * var(--title-scale)); }
.res { text-align: center; padding: 8px 0; }
.res-label { display: block; color: var(--muted); font-size: 15px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.res-name {
  margin: 6px 0 4px; font-family: var(--font-display); font-weight: 400; font-style: var(--title-style);
  font-size: calc(clamp(40px, 9vw, 84px) * var(--title-scale)); line-height: 1; overflow-wrap: anywhere;
  color: var(--accent); text-shadow: 0 0 40px color-mix(in srgb, var(--accent) 45%, transparent);
}
.res-epithet { display: block; margin-bottom: 20px; color: var(--muted); font-style: italic; font-size: 18px; }
.res-verdict { max-width: 54ch; margin: 0 auto 26px; font-size: 19px; line-height: 1.6; text-wrap: pretty; }
.res-also { max-width: 380px; margin: 0 auto 24px; text-align: left; }
.res-also-head { display: block; margin-bottom: 8px; color: var(--muted); font-size: 14px; }
.res-row { display: grid; grid-template-columns: 96px 1fr 40px; align-items: center; gap: 10px; margin-bottom: 6px; font-size: 14px; }
.res-bar { height: 8px; overflow: hidden; border-radius: 999px; background: var(--line); }
.res-bar span { display: block; height: 100%; background: var(--accent); }
.res-pct { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.res-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.btn {
  min-height: 44px; padding: 10px 18px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
  background: var(--tile-0); color: var(--ink); font-weight: 700;
}
.btn-primary { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.btn:disabled { cursor: default; opacity: .8; font-style: italic; }

/* "one quiz at a time" pop-up */
.modal {
  position: fixed; inset: 0; z-index: 500; display: grid; place-items: center; padding: 16px;
  background: rgba(20, 16, 30, .45); opacity: 0; transition: opacity .2s;
}
.modal[hidden] { display: none; }
.modal.on { opacity: 1; }
.modal-box {
  width: min(360px, 100%); padding: 28px 24px 22px; text-align: center;
  background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: calc(var(--radius) + 4px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .3);
}
.modal.on .modal-box { animation: pop .25s var(--ease); }
@keyframes pop { from { transform: scale(.92); } to { transform: scale(1); } }
.modal-emoji { margin: 0 0 6px; font-size: 48px; line-height: 1; }
.modal-text { margin: 0 0 20px; font-family: var(--font-display); font-weight: 900; font-size: calc(22px * var(--title-scale)); line-height: 1.25; text-wrap: balance; }
.modal-btn { min-width: 120px; }
.creep .modal { background: rgba(0, 0, 0, .7); }
.creep .modal-box { border-color: var(--accent); box-shadow: 0 0 60px color-mix(in srgb, var(--accent) 30%, transparent); }
.creep .modal-text { font-weight: 400; font-synthesis: none; }
.full .modal.on .modal-box { animation: quake .5s linear; }

.glitch { animation: glitch .6s steps(2) 1; }
@keyframes glitch {
  0% { transform: translate(0); text-shadow: 2px 0 #f0f, -2px 0 #0ff; }
  25% { transform: translate(-3px, 1px) skewX(-8deg); }
  50% { transform: translate(3px, -1px); text-shadow: -2px 0 #f0f, 2px 0 #0ff; opacity: .6; }
  75% { transform: translate(-1px, 0) skewX(6deg); }
  100% { transform: translate(0); text-shadow: none; }
}

/* ---------- stage 1: something's off ---------- */
.stage-1 .opt-emoji, .stage-1 .trend-thumb, .stage-1 .hero { filter: saturate(.45); }
.stage-1 .card { transform: rotate(-.3deg); }
.stage-1 .logo-text { animation: flick 7s infinite; }
.stage-1 .logo-sun { background: #b9a56a; box-shadow: 0 0 0 4px #d8cba3; }
@keyframes flick { 0%, 96%, 100% { opacity: 1; } 97% { opacity: .2; } 98% { opacity: 1; } 99% { opacity: .4; } }

/* ---------- stage 2+: creepy ---------- */
.creep { --radius: 6px; }
.creep .hero { height: 0; margin: 0; opacity: 0; }
.creep .logo-sun { background: transparent; box-shadow: inset -7px -3px 0 0 var(--accent); }
.creep .article-title, .creep .q-title, .creep .trend-head { font-weight: 400; font-synthesis: none; letter-spacing: 0; }
.creep .tag, .creep .nav-link:first-child { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.creep .card { box-shadow: 0 0 0 1px var(--line), 0 20px 60px rgba(0, 0, 0, .5); }
.creep .opt { border-width: 1px; border-color: var(--line); border-radius: 6px; font-weight: 600; }
.creep .opt:hover { transform: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 24px color-mix(in srgb, var(--accent) 35%, transparent); }
.creep .opt-emoji { filter: grayscale(1) contrast(1.2); opacity: .55; font-size: 34px; }
.creep .trend-thumb { filter: grayscale(1) contrast(1.3) brightness(.8); }
.creep .progress-fill { box-shadow: 0 0 10px var(--accent); }
.full .opt:not(.emoji-only) .opt-emoji { display: none; }
.full .opt { min-height: 76px; font-size: 17px; }
.full .opts.list .opt { min-height: 60px; }
.is-invite .q-title { text-align: center; font-size: calc(clamp(26px, 4.2vw, 38px) * var(--title-scale)); }
.is-invite .opts.list .opt { align-items: center; text-align: center; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 36px; }
  .article { max-width: none; }
}
@media (max-width: 640px) {
  .nav-link:nth-child(n+3) { display: none; }
  .header-inner { gap: 14px; }
  .card { padding: 18px; }
  .hero { height: 130px; }
  .hero span { font-size: 36px; }
}
@media (max-width: 420px) {
  .opts { gap: 10px; }
  .opt { min-height: 100px; padding: 12px 8px; font-size: 15px; }
  .opt-emoji { font-size: 36px; }
  .res-row { grid-template-columns: 80px 1fr 36px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
  #scare.on { animation: scare-slow var(--dur) ease forwards !important; animation-duration: var(--dur) !important; }
}

/* ---------- debug panel ---------- */
#debug {
  position: fixed; left: 12px; bottom: 12px; z-index: 2000; width: 280px; padding: 10px;
  border: 1px solid #333; border-radius: 10px; background: rgba(14, 14, 18, .94); color: #e8e8e8;
  font: 12px/1.45 ui-monospace, Consolas, monospace; filter: none;
}
#debug.min .dbg-body { display: none; }
.dbg-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.dbg-state { margin-bottom: 8px; word-break: break-word; }
.dbg-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
#debug button, #debug select { padding: 4px 8px; border: 1px solid #444; border-radius: 6px; background: #22222a; color: #eee; font: inherit; cursor: pointer; }
