/* Haad Breach — shared design system (tokens measured from haad.ai) */

/* ---------- fonts (self-hosted, no CDN at class time) ---------- */
@font-face { font-family: "Sora"; font-weight: 600; font-display: swap; src: url(/fonts/sora/sora-latin-600-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Sora"; font-weight: 600; font-display: swap; src: url(/fonts/sora/sora-latin-ext-600-normal.woff2) format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+20A0-20AB, U+20AD-20C0, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Sora"; font-weight: 700; font-display: swap; src: url(/fonts/sora/sora-latin-700-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Sora"; font-weight: 700; font-display: swap; src: url(/fonts/sora/sora-latin-ext-700-normal.woff2) format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+20A0-20AB, U+20AD-20C0, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Inter"; font-weight: 400; font-display: swap; src: url(/fonts/inter/inter-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Inter"; font-weight: 400; font-display: swap; src: url(/fonts/inter/inter-latin-ext-400-normal.woff2) format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+20A0-20AB, U+20AD-20C0, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Inter"; font-weight: 500; font-display: swap; src: url(/fonts/inter/inter-latin-500-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Inter"; font-weight: 600; font-display: swap; src: url(/fonts/inter/inter-latin-600-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "JetBrains Mono"; font-weight: 400; font-display: swap; src: url(/fonts/mono/jetbrains-mono-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "JetBrains Mono"; font-weight: 400; font-display: swap; src: url(/fonts/mono/jetbrains-mono-latin-ext-400-normal.woff2) format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+20A0-20AB, U+20AD-20C0, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "JetBrains Mono"; font-weight: 700; font-display: swap; src: url(/fonts/mono/jetbrains-mono-latin-700-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* ---------- tokens ---------- */
:root {
  color-scheme: dark;
  --bg: #000;
  --surface: #0a0d0b;
  --surface-2: #111612;
  --surface-3: #18201a;
  --line: rgba(255, 255, 255, 0.10);
  --line-2: rgba(255, 255, 255, 0.18);
  --text: #fff;
  --text-2: #d6ddd8;
  --muted: #a9b3ad;
  --muted-2: #8a958f;

  --green: #4abc5d;
  --green-hi: #8fe39d;
  --green-ink: #03150a;
  --green-glow: rgba(74, 188, 93, 0.32);
  --green-tint: rgba(74, 188, 93, 0.12);
  --danger: #ff5d6c;
  --danger-tint: rgba(255, 93, 108, 0.13);
  --amber: #f5b941;

  /* answer channels — always paired with a shape + letter, never colour alone */
  --a0: #ff5d73;
  --a1: #47c2f0;
  --a2: #f5b941;
  --a3: #4abc5d;

  --r-sm: 10px;
  --r: 14px;
  --r-lg: 24px;
  --shadow-glow: 0 14px 40px var(--green-glow);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --t-fast: 160ms;
  --t: 240ms;

  --font-head: "Sora", "Inter", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;

  --z-hud: 20;
  --z-overlay: 40;
  --z-toast: 100;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100dvh;
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
a { color: var(--green-hi); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, h4 { font-family: var(--font-head); font-weight: 600; letter-spacing: -0.035em; line-height: 1.08; margin: 0; }
p { margin: 0; }
code, kbd, .mono { font-family: var(--font-mono); }
code.ic {
  font-size: 0.92em;
  padding: 0.08em 0.38em;
  border-radius: 6px;
  background: rgba(74, 188, 93, 0.12);
  border: 1px solid rgba(74, 188, 93, 0.25);
  color: var(--green-hi);
  white-space: pre-wrap;
  word-break: break-word;
}
::selection { background: var(--green); color: var(--green-ink); }
:focus-visible { outline: 2px solid var(--green-hi); outline-offset: 3px; border-radius: 6px; }
.sr-only { 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; }

/* ---------- atmosphere: green glow + grid + scanlines ---------- */
.atmo { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.atmo::before {
  content: "";
  position: absolute; inset: -20% -10% auto -10%; height: 80vh;
  background: radial-gradient(60% 60% at 70% 20%, rgba(74, 188, 93, 0.20), transparent 70%);
}
.atmo::after {
  content: "";
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(74, 188, 93, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(74, 188, 93, 0.05) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 30%, transparent 75%);
}
.scan { position: fixed; inset: 0; pointer-events: none; z-index: 1; background: repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 3px); }
.page { position: relative; z-index: 2; }

/* ---------- brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-family: var(--font-body); font-weight: 500; font-size: 17px; letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.brand svg { width: 46px; height: auto; color: var(--text); }
.brand b { font-weight: 600; }
.brand .slash { color: var(--green); font-family: var(--font-mono); font-weight: 700; }

/* ---------- type helpers ---------- */
.eyebrow { font-family: var(--font-mono); font-size: 12.5px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--green); }
.muted { color: var(--muted); }
.accent { color: var(--green); }
.num { font-variant-numeric: tabular-nums; font-family: var(--font-mono); }

/* ---------- buttons ---------- */
.btn {
  --h: 52px;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: var(--h); padding: 0 22px;
  border-radius: var(--r); border: 1px solid transparent;
  font-family: var(--font-body); font-weight: 600; font-size: 16px; letter-spacing: -0.005em;
  transition: transform var(--t-fast) var(--ease-out), background-color var(--t-fast), box-shadow var(--t), border-color var(--t-fast), opacity var(--t-fast);
  user-select: none; white-space: nowrap; text-decoration: none !important;
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--green); color: var(--green-ink); box-shadow: var(--shadow-glow); }
.btn-primary:hover { background: #5ccd6e; }
.btn-ghost { background: rgba(255, 255, 255, 0.05); border-color: var(--line-2); color: var(--text); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.09); border-color: rgba(255, 255, 255, 0.28); }
.btn-danger { background: var(--danger-tint); border-color: rgba(255, 93, 108, 0.45); color: #ffb3bb; }
.btn-danger:hover { background: rgba(255, 93, 108, 0.22); }
.btn-sm { --h: 40px; padding: 0 14px; font-size: 14px; border-radius: 11px; }
.btn-lg { --h: 60px; padding: 0 30px; font-size: 18px; }
.btn-block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; box-shadow: none; transform: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); color: var(--text-2);
  transition: background-color var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.09); color: var(--text); border-color: var(--line-2); }
.icon-btn svg { width: 20px; height: 20px; }

/* ---------- forms ---------- */
.field { display: grid; gap: 8px; }
.label { font-size: 14px; font-weight: 500; color: var(--text-2); }
.hint { font-size: 13px; color: var(--muted-2); }
.input, .select, .textarea {
  width: 100%; min-height: 50px; padding: 12px 16px;
  background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 12px;
  color: var(--text); font-size: 16px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background-color var(--t-fast);
}
.textarea { resize: vertical; min-height: 84px; line-height: 1.45; }
.input::placeholder, .textarea::placeholder { color: #6f7a73; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(74, 188, 93, 0.22); background: #0d130f; }
.input[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(255, 93, 108, 0.18); }
.form-error { color: #ffb3bb; font-size: 14px; display: flex; gap: 8px; align-items: flex-start; }
.form-error:empty { display: none; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%23a9b3ad' stroke-width='1.8'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px; }
.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 15px; color: var(--text-2); min-height: 44px; }
.check input { width: 20px; height: 20px; accent-color: var(--green); }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.panel { background: linear-gradient(180deg, rgba(17, 22, 18, 0.92), rgba(10, 13, 11, 0.92)); border: 1px solid var(--line); border-radius: var(--r-lg); backdrop-filter: blur(6px); }
.pill {
  display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px;
  border-radius: 999px; border: 1px solid rgba(74, 188, 93, 0.45); background: rgba(74, 188, 93, 0.10);
  color: var(--green-hi); font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; white-space: nowrap;
}
.pill.warn { border-color: rgba(245, 185, 65, 0.5); background: rgba(245, 185, 65, 0.1); color: #ffd98a; }
.pill.off { border-color: var(--line-2); background: rgba(255, 255, 255, 0.04); color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); flex: none; }
.dot.off { background: #59625c; box-shadow: none; }
.blink { animation: blink 1.1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }

/* terminal panel */
.term { font-family: var(--font-mono); font-size: 13.5px; line-height: 1.6; color: var(--text-2); }
.term .p { color: var(--green); }
.term .ok { color: var(--green-hi); }
.term .err { color: #ff9aa5; }
.term .warn { color: #ffd98a; }
.term .dim { color: var(--muted-2); }

/* ---------- answer shapes (letter + shape + colour) ---------- */
.ans-key {
  display: inline-grid; place-items: center; flex: none;
  width: 44px; height: 44px; border-radius: 12px;
  background: color-mix(in srgb, var(--c) 20%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 60%, transparent);
  color: var(--c); font-family: var(--font-mono); font-weight: 700; font-size: 15px; position: relative;
}
.ans-key svg { width: 20px; height: 20px; }
.c0 { --c: var(--a0); } .c1 { --c: var(--a1); } .c2 { --c: var(--a2); } .c3 { --c: var(--a3); }

/* ---------- avatar (identicon) ---------- */
.avatar { width: 40px; height: 40px; border-radius: 11px; flex: none; overflow: hidden; background: #0f1511; border: 1px solid var(--line); }
.avatar svg { width: 100%; height: 100%; }

/* ---------- toasts ---------- */
.toasts { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: var(--z-toast); display: grid; gap: 10px; width: min(92vw, 440px); pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; border-radius: 14px; background: #0f1611; border: 1px solid var(--line-2);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6); font-size: 15px;
  animation: toast-in var(--t) var(--ease-out);
}
.toast.err { border-color: rgba(255, 93, 108, 0.5); }
.toast.ok { border-color: rgba(74, 188, 93, 0.5); }
.toast svg { width: 18px; height: 18px; flex: none; }
.toast.leaving { animation: toast-out 160ms ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

/* connection banner */
.netbar { position: fixed; top: 0; left: 0; right: 0; z-index: var(--z-toast); display: flex; justify-content: center; gap: 10px; align-items: center; padding: 8px 12px; background: rgba(245, 185, 65, 0.14); border-bottom: 1px solid rgba(245, 185, 65, 0.4); color: #ffd98a; font-family: var(--font-mono); font-size: 13px; }

/* ---------- motion ---------- */
.fade-in { animation: fade-in var(--t) var(--ease-out) both; }
@keyframes fade-in { from { opacity: 0; transform: translateY(8px); } }
.glitch { position: relative; }
.glitch.go { animation: glitch 420ms steps(2) 1; }
@keyframes glitch {
  0% { transform: translate(0); text-shadow: none; }
  20% { transform: translate(-2px, 1px); text-shadow: 2px 0 var(--a0), -2px 0 var(--a1); }
  40% { transform: translate(2px, -1px); text-shadow: -2px 0 var(--a0), 2px 0 var(--a1); }
  60% { transform: translate(-1px, 0); text-shadow: 1px 0 var(--green); }
  100% { transform: translate(0); text-shadow: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
  .blink { animation: none; }
}
