/*
 * GTG Forum styling — matches the gtg.supply site exactly (same palette, fonts, buttons, panels).
 * Self-hosted fonts only (CSP: default-src 'self'; no inline styles anywhere).
 * tests/unit/ui.test.ts parses the token blocks below and asserts WCAG AA (>= 4.5:1).
 * Schemes: [data-scheme="dark"|"light"|"system"]; dark is the GTG look and the default.
 */
@font-face { font-family: "Bebas Neue"; font-weight: 400; font-style: normal; font-display: swap; src: url("/assets/bebas-neue-latin-400.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 600; font-style: normal; font-display: swap; src: url("/assets/barlow-condensed-latin-600.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 800; font-style: normal; font-display: swap; src: url("/assets/barlow-condensed-latin-800.woff2") format("woff2"); }

/* ---------- tokens: dark (default) ---------- */
:root {
  --bg: #0b0612;
  --surface: #1b0f29;
  --surface-2: #2b1a3d;
  --border: #000000;
  --line: #2b1a3d;
  --text: #ffffff;
  --muted: #c4bdd0;
  --link: #27e0d0;
  --pink: #ff3d9a;
  --teal: #27e0d0;
  --accent: #ff3d9a;
  --accent-ink: #000000;
  --danger: #ff7a7a;
  --ok: #4ade80;
  --warn: #fbbf24;
  --focus: #ff3d9a;
  --radius: 0;
  --gap: 1rem;
  --maxw: 72rem;
  --font: "Barlow Condensed", Arial, sans-serif;
  --display: "Bebas Neue", Impact, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}

/* ---------- tokens: light ---------- */
[data-scheme="light"] {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #eeeeea;
  --border: #d0d3d8;
  --text: #15181d;
  --muted: #4a5563;
  --link: #0a58a8;
  --accent: #ff3d9a;
  --accent-ink: #15181d;
  --danger: #b42318;
  --ok: #067647;
  --warn: #8a5a00;
  --focus: #0a58a8;
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  [data-scheme="system"] {
    --bg: #f6f6f3;
    --surface: #ffffff;
    --surface-2: #eeeeea;
    --border: #d0d3d8;
    --text: #15181d;
    --muted: #4a5563;
    --link: #0a58a8;
    --accent: #ff3d9a;
    --accent-ink: #15181d;
    --danger: #b42318;
    --ok: #067647;
    --warn: #8a5a00;
    --focus: #0a58a8;
    color-scheme: light;
  }
}

/* ---------- skins share the GTG palette ---------- */
[data-skin="plain"] { --accent: #ff3d9a; --focus: #ff3d9a; }
[data-skin="plain"][data-scheme="light"] { --accent: #ff3d9a; --focus: #0a58a8; }

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  background-image: radial-gradient(ellipse at 50% 50%, #2a1340 0%, var(--bg) 70%);
  background-attachment: fixed;
  color: var(--text);
  font: 600 18px/1.4 var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--link); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
img { max-width: 100%; height: auto; }
h1, h2, h3 { font-family: var(--display); font-weight: 400; letter-spacing: 1.5px; line-height: 1.1; margin: 0 0 .6rem; }
h1 { font-size: 2.4rem; }
h2 { font-size: 1.7rem; }
h3 { font-size: 1.3rem; }
p { margin: 0 0 .8rem; }
code, pre { font-family: var(--mono); font-size: .92em; }
pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: 0; padding: .8rem; overflow-x: auto; }
:not(pre) > code { background: var(--surface-2); padding: .1em .35em; border-radius: 4px; }
blockquote { margin: 0 0 .8rem; padding-left: .9rem; border-left: 3px solid var(--border); color: var(--muted); }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.2rem 0; }


.eyebrow { font-family: var(--display); font-size: 1rem; letter-spacing: 1.5px; color: var(--pink); font-weight: 400; margin-bottom: .25rem; text-transform: uppercase; }

/* ---------- accessibility ---------- */
.skip-link {
  position: absolute; left: -9999px; top: .5rem; z-index: 10;
  background: var(--accent); color: var(--accent-ink); padding: .5rem .8rem; border-radius: 0; font-weight: 800;
}
.skip-link:focus { left: .5rem; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
@media (prefers-reduced-motion: no-preference) {
  a, .card { transition: background-color .15s ease, border-color .15s ease, color .15s ease; }
  .btn { transition: transform .12s ease, box-shadow .12s ease; }
}

/* ---------- layout ---------- */
.site-header { border-bottom: 3px solid #000; background: var(--surface); box-shadow: 0 0 0 2px var(--line) inset; }
.site-header .inner, main, .site-footer .inner { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 1rem; }
.site-header .inner { display: flex; align-items: center; gap: 1rem; min-height: 3.5rem; flex-wrap: wrap; }
.brand { font-family: var(--display); font-weight: 400; font-size: 1.6rem; letter-spacing: 2px; color: var(--text); text-decoration: none; display: flex; align-items: center; gap: .6rem; text-transform: uppercase; }
.brand-mark { display: inline-grid; place-items: center; width: 2.6rem; height: 2.6rem; background: radial-gradient(circle at 50% 45%, #ff3d9a33 0%, #12081d 70%); box-shadow: 0 0 0 2px #ff3d9a55 inset; border: 2px solid #000; }
.brand-mark img { width: 2.1rem; height: 2.1rem; object-fit: contain; display: block; }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; margin: 0; padding: 0; list-style: none; }
.nav a { display: block; padding: .45rem .7rem; color: var(--text); text-decoration: none; font-family: var(--display); font-weight: 400; letter-spacing: 1.5px; font-size: 1.15rem; text-transform: uppercase; }
.nav a:hover, .nav a[aria-current="page"] { background: #000; box-shadow: 3px 3px 0 var(--pink); }
.nav-end { margin-left: auto; display: flex; gap: .5rem; align-items: center; }
.count { display: inline-block; min-width: 1.4rem; padding: 0 .35rem; background: var(--accent); color: var(--accent-ink); font-size: .75rem; font-weight: 800; text-align: center; margin-left: .25rem; }
main { flex: 1; padding-top: 1.5rem; padding-bottom: 3rem; }
.site-footer { border-top: 3px solid #000; letter-spacing: 1px; color: var(--muted); font-size: .85rem; padding: 1rem 0; }
.grid { display: grid; gap: var(--gap); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); }
.with-aside { display: grid; gap: 1.5rem; grid-template-columns: minmax(0, 1fr) 18rem; }
@media (max-width: 860px) { .with-aside { grid-template-columns: 1fr; } }
.stack > * + * { margin-top: .75rem; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.narrow { max-width: 28rem; margin: 0 auto; }

/* ---------- components ---------- */
.card { background: var(--surface); border: 3px solid #000; box-shadow: 0 0 0 2px var(--line) inset; border-radius: 0; padding: 1rem 1.1rem; }
.card h2, .card h3 { margin-top: 0; }
.card-link { display: block; color: inherit; text-decoration: none; }
.card-link:hover { border-color: var(--pink); }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-bottom: 2px solid var(--line); padding: .75rem 0; }
.list > li:last-child { border-bottom: 0; }
.meta { color: var(--muted); font-size: .875rem; }
.muted { color: var(--muted); }
.badge { display: inline-block; padding: .05rem .5rem; border: 2px solid #fff; font-family: var(--display); letter-spacing: 1.5px; font-size: .9rem; font-weight: 400; color: var(--text); background: var(--surface-2); vertical-align: middle; }
.badge-accent { background: var(--accent); color: var(--accent-ink); border-color: #000; }
.badge-ai { border-color: var(--link); color: var(--link); background: transparent; }
.badge-warn { border-color: var(--warn); color: var(--warn); background: transparent; }
.badge-danger { border-color: var(--danger); color: var(--danger); background: transparent; }
.badge-ok { border-color: var(--ok); color: var(--ok); background: transparent; }
.avatar { display: inline-grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: 50%; background: var(--surface-2); border: 2px solid #fff; font-family: var(--display); font-weight: 400; font-size: .85rem; flex: none; }
.rank { display: inline-flex; gap: .4rem; align-items: center; }
progress, meter { width: 100%; height: .6rem; accent-color: var(--accent); }

/* buttons + forms */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: 6px 14px 4px; min-height: 2.5rem; border: 2px solid #fff; border-radius: 0;
  background: #000; color: #fff; font-family: var(--display); font-weight: 400; font-size: 1.2rem; letter-spacing: 1.5px;
  text-transform: uppercase; cursor: pointer; text-decoration: none; box-shadow: 4px 4px 0 var(--pink);
}
.btn:hover, .btn:focus-visible { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--pink); }
.btn-primary { box-shadow: 4px 4px 0 var(--pink); background: #000; }
.btn-primary:hover, .btn-primary:focus-visible { box-shadow: 6px 6px 0 var(--pink); }
.btn-alt, .btn-small:not(.btn-primary) { box-shadow: 3px 3px 0 var(--teal); }
.btn-small:not(.btn-primary):hover, .btn-small:not(.btn-primary):focus-visible { box-shadow: 5px 5px 0 var(--teal); }
.btn-danger { border-color: var(--danger); color: var(--danger); box-shadow: 4px 4px 0 var(--danger); }
.btn-small { min-height: 2rem; padding: 4px 10px 2px; font-size: 1rem; }
.btn-link { background: none; border: 0; box-shadow: none; color: var(--link); padding: 0; min-height: 0; font-family: var(--font); font-size: inherit; text-transform: none; font-weight: 600; text-decoration: underline; cursor: pointer; letter-spacing: 0; }
.btn-link:hover { transform: none; box-shadow: none; }
.inline-form { display: inline; margin: 0; }
label { display: block; font-family: var(--display); font-weight: 400; letter-spacing: 1.5px; font-size: 1.1rem; text-transform: uppercase; margin-bottom: .3rem; }
.field { margin-bottom: 1rem; }
.hint { color: var(--muted); font-size: .85rem; margin-top: .25rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="number"], select, textarea {
  width: 100%; padding: 6px 8px 4px; border-radius: 0; border: 2px solid #fff;
  background: #000; color: #fff; font: 600 1.1rem var(--font); letter-spacing: 1px;
}
textarea { min-height: 9rem; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--pink); box-shadow: 0 0 0 2px #ff3d9a55; outline: none; }
fieldset { border: 2px solid var(--line); border-radius: 0; padding: .8rem 1rem; margin: 0 0 1rem; }
legend { font-weight: 700; padding: 0 .3rem; }
.check { display: flex; gap: .5rem; align-items: center; font-weight: 500; }

/* alerts */
.alert { border: 3px solid #000; box-shadow: 0 0 0 2px var(--line) inset; border-left-width: 6px; border-radius: 0; padding: .7rem .9rem; margin-bottom: 1rem; background: var(--surface); }
.alert-ok { border-left-color: var(--ok); }
.alert-err { border-left-color: var(--danger); }
.alert-warn { border-left-color: var(--warn); }
.banner-incident { background: var(--surface-2); border-bottom: 2px solid var(--warn); padding: .5rem 1rem; text-align: center; font-weight: 600; }

/* threads + posts */
.thread-row { display: flex; gap: .8rem; align-items: flex-start; }
.thread-row .title { font-weight: 700; color: var(--text); text-decoration: none; }
.thread-row .title:hover { text-decoration: underline; }
.post { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .8rem; padding: 1rem 0; border-bottom: 2px solid var(--line); }
.post:last-child { border-bottom: 0; }
.post.reply { margin-left: 2.5rem; }
@media (max-width: 600px) { .post.reply { margin-left: 1rem; } }
.post-body { overflow-wrap: anywhere; }
.post-body img { border-radius: 0; }
.post-ai { border-left: 3px solid var(--link); padding-left: .8rem; }
.post-accepted { border-left: 3px solid var(--ok); padding-left: .8rem; }
.reactions { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .5rem; }
.summary { border: 1px dashed var(--link); }
.tags { display: flex; gap: .35rem; flex-wrap: wrap; }

/* missions */
.missions { counter-reset: m; }
.mission { display: grid; grid-template-columns: 2rem minmax(0, 1fr) auto; gap: .7rem; align-items: center; }
.mission::before { counter-increment: m; content: counter(m); display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%; border: 2px solid var(--border); font-weight: 800; }
.mission.done::before { content: "✓"; background: var(--ok); color: var(--bg); border-color: transparent; }

/* tables (admin) */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-family: var(--display); font-weight: 400; font-size: 1rem; text-transform: uppercase; letter-spacing: 1.5px; }
.kpi { font-family: var(--display); font-size: 2.2rem; font-weight: 400; letter-spacing: 1.5px; }
.sev-critical { color: var(--danger); font-weight: 800; }
.sev-high { color: var(--danger); }
.sev-medium { color: var(--warn); }
.sev-low { color: var(--muted); }
.admin-shell .site-header { border-bottom: 2px solid var(--warn); }

/* mobile: header nav scrolls instead of wrapping into a tall stack */
@media (max-width: 700px) {
  .site-header nav { order: 3; width: 100%; overflow-x: auto; }
  .nav { flex-wrap: nowrap; }
  h1 { font-size: 2rem; }
}

/* TOTP enrolment QR: always dark-on-white so phones can scan it */
.qr { width: 14rem; max-width: 100%; margin-top: .75rem; border: 3px solid #000; background: #fff; line-height: 0; }
.qr svg { display: block; width: 100%; height: auto; }
