/* =========================================================
   Hypnix — styles.css
   Themes: purple (default) · blue · bw (hypnotic black & white)
   Colour tokens live in the three theme blocks right below.
   ========================================================= */

@font-face {
  font-family: "Press Start 2P";
  src: url("assets/fonts/PressStart2P.woff2") format("woff2");
  font-display: swap;
}

:root {
  --font-pixel: "Press Start 2P", ui-monospace, "Courier New", monospace;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --maxw: 1120px;
  --radius: 14px;
  --header-h: 64px;
}

/* ---------- Theme 1: dark + purple (default) ---------- */
:root,
:root[data-theme="purple"] {
  color-scheme: dark;
  --bg: #0a0615;
  --bg-alt: #0f0920;
  --surface: #150d2b;
  --surface-2: #1d1238;
  --header-bg: rgba(10, 6, 21, .88);
  --text: #ece7ff;
  --muted: #b8acdd;
  --accent: #c4b5fd;
  --accent-strong: #a78bfa;
  --btn-bg: #7c3aed;
  --btn-bg-hover: #6d28d9;
  --btn-text: #ffffff;
  --border: #3b2a6b;
  --glow: 0 0 28px rgba(167, 139, 250, .28);
  --glow-strong: 0 0 18px rgba(167, 139, 250, .55);
  --focus: #f0abfc;
  --danger: #ff9eb5;
  --ok: #86efac;
  --glyph: 167, 139, 250;
  --scene-filter: none;
  --sprite-filter: none;
  --swatch: linear-gradient(135deg, #7c3aed 0 50%, #0a0615 50%);
}

/* ---------- Theme 2: white + blue ---------- */
:root[data-theme="blue"] {
  color-scheme: light;
  --bg: #f5f8ff;
  --bg-alt: #e9f0ff;
  --surface: #ffffff;
  --surface-2: #eef3ff;
  --header-bg: rgba(245, 248, 255, .92);
  --text: #0c1a3a;
  --muted: #42507a;
  --accent: #1d4ed8;
  --accent-strong: #1d4ed8;
  --btn-bg: #1d4ed8;
  --btn-bg-hover: #1e40af;
  --btn-text: #ffffff;
  --border: #bccdf3;
  --glow: 0 10px 28px rgba(29, 78, 216, .14);
  --glow-strong: 0 6px 18px rgba(29, 78, 216, .3);
  --focus: #0b3bb8;
  --danger: #b4162f;
  --ok: #0f7a3a;
  --glyph: 29, 78, 216;
  --scene-filter: hue-rotate(-55deg) saturate(1.1);
  --sprite-filter: none;
  --swatch: linear-gradient(135deg, #1d4ed8 0 50%, #ffffff 50%);
}

/* ---------- Theme 3: hypnotic black & white ---------- */
:root[data-theme="bw"] {
  color-scheme: light;
  --bg: #ffffff;
  --bg-alt: #ffffff;
  --surface: #ffffff;
  --surface-2: #efefef;
  --header-bg: rgba(255, 255, 255, .96);
  --text: #000000;
  --muted: #222222;
  --accent: #000000;
  --accent-strong: #000000;
  --btn-bg: #000000;
  --btn-bg-hover: #333333;
  --btn-text: #ffffff;
  --border: #000000;
  --glow: 6px 6px 0 #000;
  --glow-strong: 4px 4px 0 #000;
  --focus: #000000;
  --danger: #9b0000;
  --ok: #005a1f;
  --glyph: 0, 0, 0;
  --scene-filter: grayscale(1) contrast(1.25);
  --sprite-filter: grayscale(1) contrast(1.15);
  --swatch: repeating-conic-gradient(#000 0 25%, #fff 0 50%) 0 0 / 8px 8px;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 12px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.65;
  overflow-x: hidden;
}
img { max-width: 100%; height: auto; }
h1, h2, h3 { line-height: 1.3; margin: 0; }
p { margin: 0 0 1rem; }
a { color: var(--accent); }
ul { padding: 0; margin: 0; list-style: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 4px; }
[hidden] { display: none !important; }

.container { width: min(100% - 2rem, var(--maxw)); margin-inline: auto; }
.container--narrow { width: min(100% - 2rem, 760px); }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: .75rem; top: -4rem; z-index: 100; padding: .6rem 1rem;
  background: var(--btn-bg); color: var(--btn-text); border-radius: 8px; text-decoration: none; font-weight: 700;
}
.skip-link:focus { top: .75rem; }

/* ---------- Type helpers ---------- */
.eyebrow {
  font-family: var(--font-pixel); font-size: .62rem; letter-spacing: .04em; line-height: 1.8;
  color: var(--accent); text-transform: uppercase; margin-bottom: .9rem;
}
.section-title {
  font-family: var(--font-pixel); font-weight: 400;
  font-size: clamp(1rem, 2.6vw + .45rem, 1.65rem); line-height: 1.55; overflow-wrap: anywhere;
}
.section-title::after {
  content: ""; display: block; width: 64px; height: 4px; margin: 1rem 0 1.5rem;
  background: var(--accent-strong); box-shadow: var(--glow-strong);
}
.lead { font-size: 1.15rem; color: var(--muted); max-width: 62ch; }
.fine, .source { font-size: .85rem; color: var(--muted); }
.req { color: var(--accent); font-weight: 700; }
.optional { color: var(--muted); font-weight: 400; font-size: .9em; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .6rem;
  min-height: 48px; padding: .75rem 1.4rem;
  font-family: var(--font-pixel); font-size: .68rem; line-height: 1.4; text-decoration: none; text-align: center;
  color: var(--btn-text); background: var(--btn-bg);
  border: 2px solid var(--btn-bg); border-radius: 10px; cursor: pointer;
  box-shadow: var(--glow-strong);
  transition: transform .15s ease, background-color .15s ease;
}
.btn:hover { background: var(--btn-bg-hover); border-color: var(--btn-bg-hover); transform: translateY(-2px); }
.btn:active { transform: translateY(0); }
.btn--small { min-height: 40px; padding: .5rem .9rem; font-size: .6rem; }
.btn--block { width: 100%; }
.btn--ghost { background: transparent; color: var(--accent); border-color: var(--accent-strong); box-shadow: none; }
.btn--ghost:hover { background: var(--surface-2); border-color: var(--accent-strong); }
.btn[disabled] { cursor: progress; opacity: .85; transform: none; }
.btn[aria-busy="true"]::after {
  content: ""; width: 1em; height: 1em; border: 3px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .8s linear infinite;
}

/* ---------- Header / nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50; background: var(--header-bg);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 2px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: .75rem; min-height: var(--header-h); position: relative; }
.logo { display: inline-flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--text); margin-right: auto; }
.logo__text { font-family: var(--font-pixel); font-size: .95rem; text-shadow: var(--glow-strong); }
.logo img { image-rendering: pixelated; }

.site-nav ul { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; }
.site-nav a:not(.btn) { color: var(--text); text-decoration: none; font-weight: 600; font-size: .95rem; padding: .4rem .2rem; }
.site-nav a:not(.btn):hover { color: var(--accent); text-decoration: underline; text-underline-offset: 6px; }
.site-nav { order: 2; }

.theme-toggle {
  order: 3; display: inline-flex; align-items: center; gap: .55rem; min-height: 40px; padding: .35rem .75rem;
  background: var(--surface); color: var(--text); border: 2px solid var(--border); border-radius: 999px;
  font: 600 .85rem var(--font-body); cursor: pointer;
}
.theme-toggle:hover { border-color: var(--accent-strong); }
.theme-toggle__swatch { width: 18px; height: 18px; border-radius: 50%; background: var(--swatch); border: 2px solid var(--text); flex: none; }

.menu-btn { display: none; order: 4; width: 44px; height: 44px; background: var(--surface); border: 2px solid var(--border); border-radius: 10px; cursor: pointer; padding: 0; }
.menu-btn__bars, .menu-btn__bars::before, .menu-btn__bars::after {
  display: block; width: 20px; height: 2px; background: var(--text); margin: auto; position: relative; content: "";
}
.menu-btn__bars::before { position: absolute; top: -6px; left: 0; }
.menu-btn__bars::after { position: absolute; top: 6px; left: 0; }

@media (max-width: 899px) {
  .menu-btn { display: block; }
  .theme-toggle__label { display: none; }
  .theme-toggle { padding: .35rem; min-width: 44px; min-height: 44px; justify-content: center; }
  .js .site-nav {
    display: none; position: absolute; top: 100%; left: -1rem; right: -1rem; padding: 1rem;
    background: var(--surface); border-bottom: 2px solid var(--border); box-shadow: 0 18px 30px rgba(0,0,0,.25);
  }
  .js .site-nav.is-open { display: block; }
  .site-nav ul { flex-direction: column; align-items: stretch; gap: .2rem; }
  .site-nav a:not(.btn) { display: block; padding: .8rem .5rem; }
  .site-nav .btn { width: 100%; margin-top: .5rem; }
  .no-js .site-nav, html:not(.js) .site-nav { order: 5; width: 100%; }
}

/* ---------- Hero ---------- */
.hero { position: relative; isolation: isolate; overflow: hidden; padding-block: clamp(2.5rem, 7vw, 5rem) clamp(3rem, 8vw, 6rem); background: radial-gradient(900px 420px at 80% 10%, rgba(124, 58, 237, .18), transparent 70%), var(--bg); }
:root[data-theme="blue"] .hero { background: radial-gradient(900px 420px at 80% 10%, rgba(29, 78, 216, .12), transparent 70%), var(--bg); }
:root[data-theme="bw"] .hero { background: var(--bg); }
.glyphs {
  position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; opacity: .3; pointer-events: none;
  -webkit-mask-image: linear-gradient(#000 55%, transparent); mask-image: linear-gradient(#000 55%, transparent);
}
.hero__grid { display: grid; gap: 2.5rem; align-items: center; }
.hero__title {
  font-family: var(--font-pixel); font-weight: 400; font-size: clamp(1.25rem, 4.6vw + .5rem, 2.6rem); line-height: 1.5;
  text-shadow: var(--glow-strong); margin-bottom: 1.5rem;
}
.hero__title span { display: block; }
:root[data-theme="bw"] .hero__title { text-shadow: none; }
.hero__pitch { font-size: clamp(1.1rem, 1.2vw + .9rem, 1.4rem); color: var(--muted); max-width: 34ch; margin-bottom: 1.75rem; }
.hero__cta { display: flex; flex-wrap: wrap; gap: .9rem; }
.hero__visual { position: relative; width: 100%; max-width: 420px; margin-inline: auto; }
@media (min-width: 900px) { .hero__visual { margin-right: 0; } }

@media (min-width: 900px) {
  .hero__grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 3rem; }
}

/* pixel scenes */
.scene {
  position: relative; aspect-ratio: var(--ar, 64 / 40); background: #150c2b; overflow: hidden;
  border: 3px solid var(--border); border-radius: 12px; box-shadow: var(--glow);
}
.scene--hero { --ar: 128 / 80; }
.scene--town { --ar: 120 / 72; }
.scene img { position: absolute; image-rendering: pixelated; max-width: none; }
.scene__bg { inset: 0; width: 100%; height: 100%; filter: var(--scene-filter); }
.scene__ghost { left: 18.75%; top: 37.5%; width: 37.5%; height: auto; filter: var(--sprite-filter); }

/* bw hypnotic spiral (only visible in the bw theme) */
.spiral-wrap { display: none; position: absolute; inset: 0; z-index: -1; place-items: center; }
:root[data-theme="bw"] .spiral-wrap { display: grid; }
.spiral {
  position: relative; width: 125%; aspect-ratio: 1; border-radius: 50%; flex: none;
  background: repeating-conic-gradient(#000 0 7.5deg, #fff 7.5deg 15deg);
  animation: spin 50s linear infinite;
}
.spiral::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: repeating-radial-gradient(circle, transparent 0 13px, #000 13px 17px);
  mix-blend-mode: difference; opacity: .85;
}

/* ---------- Sections ---------- */
.section { padding-block: clamp(3.5rem, 8vw, 6rem); }
.section--alt { background: var(--bg-alt); border-block: 2px solid var(--border); }
:root[data-theme="bw"] .section--alt { background: repeating-linear-gradient(45deg, #fff 0 14px, #f1f1f1 14px 28px); }
:root[data-theme="bw"] .section-title::after {
  width: 100%; max-width: 360px; height: 12px; box-shadow: none; border: 2px solid #000;
  background: repeating-linear-gradient(90deg, #000 0 6px, #fff 6px 12px);
}

.card {
  background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius);
  padding: 1.5rem; box-shadow: var(--glow);
}
.card h3 { font-size: 1.15rem; margin-bottom: .6rem; }
.card p:last-child { margin-bottom: 0; }

.grid { display: grid; gap: 1.25rem; margin-top: 1rem; }
@media (min-width: 640px) { .grid--4 { grid-template-columns: repeat(2, 1fr); } .grid--2 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .grid--3 { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1060px) { .grid--4 { grid-template-columns: repeat(4, 1fr); } }

/* problem */
.stats { display: grid; gap: 1.25rem; margin-top: 1rem; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { margin: 0; }
.stat__num { font-family: var(--font-pixel); font-size: clamp(1.5rem, 3vw + .6rem, 2.4rem); line-height: 1.3; color: var(--accent); margin-bottom: .75rem; }
.stat__num span { font-size: .45em; color: var(--text); }
.stat figcaption { color: var(--muted); }
.source { margin: 1rem 0 1.5rem; }

/* features */
.feature .pix-icon { image-rendering: pixelated; margin-bottom: 1rem; width: 36px; height: auto; }
.feature p { color: var(--muted); }

/* ---------- Hypnix Town ---------- */
.town { display: grid; gap: 1.5rem; margin-top: 2rem; align-items: start; }
@media (min-width: 960px) { .town { grid-template-columns: minmax(0, 1.75fr) minmax(290px, 1fr); } }

.npc {
  position: absolute; left: calc((var(--x) + 5) * 100% / 120); top: calc(var(--y) * 100% / 72);
  width: calc(10 * 100% / 120); min-width: 44px; transform: translateX(-50%);
  padding: 0; margin: 0; background: transparent; border: 0; cursor: pointer; border-radius: 8px;
}
.npc__sprite { position: static !important; display: block; width: 100%; height: auto; filter: var(--sprite-filter); transition: transform .15s ease; }
.npc:hover .npc__sprite { transform: translateY(-3px); }
.npc__status {
  position: absolute !important; top: -10%; right: -38%; width: 52% !important; height: auto;
  background: #1a1030; border: 2px solid #c4b5fd; border-radius: 50%; padding: 12%;
}
.npc__name {
  position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: 2px;
  padding: 1px 7px; background: #1a1030; color: #fff; border: 1px solid #a78bfa; border-radius: 6px;
  font-size: .72rem; font-weight: 700; line-height: 1.5; white-space: nowrap;
}
.npc[aria-pressed="true"] { outline: 3px solid #f0abfc; outline-offset: 4px; background: rgba(240, 171, 252, .18); }
.npc[aria-pressed="true"] .npc__name { background: #7c3aed; border-color: #fff; }
.npc:focus-visible { outline: 3px solid #fff; outline-offset: 4px; box-shadow: 0 0 0 6px #7c3aed; }

.legend { display: flex; flex-wrap: wrap; gap: .5rem 1.4rem; margin-top: 1rem; color: var(--muted); font-size: .92rem; }
.legend li { display: inline-flex; align-items: center; gap: .5rem; }
.legend img { image-rendering: pixelated; background: #1a1030; border-radius: 50%; padding: 3px; width: 24px; height: 24px; }

.town__card-title { font-family: var(--font-pixel); font-weight: 400; font-size: .85rem !important; line-height: 1.6; margin-bottom: 1rem !important; }
.town__card-hint { color: var(--muted); }
.town__who { display: flex; align-items: center; gap: .9rem; margin-bottom: 1rem; }
.town__who img { image-rendering: pixelated; width: 50px; height: auto; background: #150c2b; border: 2px solid var(--border); border-radius: 10px; padding: 4px; filter: var(--sprite-filter); }
.town__who strong { display: block; font-size: 1.15rem; line-height: 1.3; }
.town__who span { color: var(--muted); font-size: .92rem; }
.town__status { display: flex; align-items: center; gap: .5rem; font-weight: 600; margin-bottom: 1rem; }
.town__status img { image-rendering: pixelated; width: 22px; height: 22px; background: #1a1030; border-radius: 50%; padding: 3px; }
.town__actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; margin-bottom: 1rem; }
.chip {
  min-height: 44px; padding: .5rem .6rem; font: 600 .88rem/1.25 var(--font-body); color: var(--text);
  background: var(--surface-2); border: 2px solid var(--border); border-radius: 10px; cursor: pointer; text-align: center;
}
.chip:hover { border-color: var(--accent-strong); background: var(--surface); }
.chip--wide { grid-column: 1 / -1; }
.town__preview {
  padding: .8rem 1rem; border: 2px dashed var(--accent-strong); border-radius: 10px; background: var(--surface-2);
  font-size: .95rem; margin: 0 0 1rem;
}
.town__card .fine { margin-top: 1rem; }

/* ---------- Science ---------- */
.study__cite { font-family: var(--font-pixel); font-size: .6rem; line-height: 1.8; color: var(--accent); margin-bottom: .9rem; }
.why { margin-top: 1rem; padding-top: 1rem; border-top: 2px dashed var(--border); color: var(--muted); font-size: .98rem; }
.why strong { color: var(--text); }

/* ---------- Insights ---------- */
.panel h3 { font-family: var(--font-pixel); font-weight: 400; font-size: .8rem; line-height: 1.7; margin-bottom: 1.1rem; }
.checklist li { display: flex; gap: .75rem; align-items: baseline; padding: .55rem 0; border-bottom: 1px dashed var(--border); font-weight: 600; }
.checklist li:last-child { border-bottom: 0; }
.checklist span { font-weight: 900; width: 1.2em; flex: none; }
.checklist--yes span { color: var(--ok); }
.checklist--no span { color: var(--danger); }

/* ---------- Form ---------- */
.form { margin-top: 1.5rem; display: grid; gap: 1.25rem; }
.form__grid { display: grid; gap: 1.25rem; }
@media (min-width: 640px) { .form__grid { grid-template-columns: repeat(2, 1fr); } }
.field { display: grid; gap: .4rem; align-content: start; min-width: 0; }
.field label, .fieldset legend { font-weight: 700; font-size: .98rem; }
input[type="text"], input[type="email"], select, textarea {
  width: 100%; min-height: 48px; padding: .7rem .85rem; font: inherit; color: var(--text);
  background: var(--bg); border: 2px solid var(--border); border-radius: 10px;
}
:root[data-theme="purple"] input, :root[data-theme="purple"] select, :root[data-theme="purple"] textarea { background: #0d0820; }
textarea { resize: vertical; min-height: 110px; }
input:hover, select:hover, textarea:hover { border-color: var(--accent-strong); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-color: var(--focus); }
[aria-invalid="true"] { border-color: var(--danger) !important; }
.field__error { margin: 0; min-height: 0; color: var(--danger); font-size: .9rem; font-weight: 600; }
.field__error:not(:empty)::before { content: "⚠ "; }
.fieldset { border: 0; padding: 0; margin: 0; }
.fieldset legend { padding: 0; margin-bottom: .6rem; }
.checks { display: grid; gap: .5rem; }
@media (min-width: 640px) { .checks { grid-template-columns: repeat(2, 1fr); } }
.check { display: flex; align-items: center; gap: .7rem; min-height: 46px; padding: .4rem .8rem; background: var(--bg); border: 2px solid var(--border); border-radius: 10px; cursor: pointer; font-weight: 500; }
.check:hover { border-color: var(--accent-strong); }
.check input { width: 22px; height: 22px; accent-color: var(--btn-bg); flex: none; margin: 0; }
.hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }
.banner { padding: .9rem 1.1rem; border-radius: 10px; font-weight: 600; border: 2px solid; }
.banner--error { color: var(--danger); border-color: var(--danger); background: var(--surface-2); }

.success { margin-top: 1.5rem; display: flex; gap: 1.25rem; align-items: center; flex-wrap: wrap; }
.success:focus { outline: 3px solid var(--focus); outline-offset: 4px; }
.success__ghost { width: 112px; height: auto; image-rendering: pixelated; background: #150c2b; border: 2px solid var(--border); border-radius: 12px; padding: 6px; filter: var(--sprite-filter); }
.success > div { flex: 1 1 260px; }
.success__title { font-family: var(--font-pixel); font-size: .65rem; line-height: 1.8; color: var(--accent); margin-bottom: .5rem; }
.success__text { font-size: 1.25rem; font-weight: 700; line-height: 1.45; }

/* ---------- FAQ ---------- */
.faq { display: grid; gap: .75rem; margin-top: 1rem; }
.faq details { background: var(--surface); border: 2px solid var(--border); border-radius: 12px; }
.faq summary {
  list-style: none; cursor: pointer; padding: 1rem 3rem 1rem 1.2rem; font-weight: 700; position: relative; min-height: 52px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; position: absolute; right: 1.2rem; top: 50%; transform: translateY(-50%); font: 700 1.4rem var(--font-pixel); color: var(--accent); }
.faq details[open] summary::after { content: "−"; }
.faq details p { padding: 0 1.2rem 1.1rem; margin: 0; color: var(--muted); }

/* ---------- Footer ---------- */
.site-footer { border-top: 2px solid var(--border); padding-block: 2.5rem; background: var(--bg-alt); }
.footer__inner { display: grid; gap: .75rem; }
.footer__brand { font-family: var(--font-pixel); font-size: 1rem; margin: 0; }
.footer__privacy, .footer__year { margin: 0; color: var(--muted); font-size: .95rem; max-width: 70ch; }

/* ---------- Motion ---------- */
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .glyphs { display: none; }
  .btn[aria-busy="true"]::after { display: none; }
}
