/* ============================================================
   WPAL Support — design system
   Token-driven, hand-authored, no framework.
   Default palette: navy ink + gold accent (light).
   Dark palette via [data-theme="dark"].
   Components reference semantic tokens only.
   Aesthetic: sibling of Ars Galactica / Voicebox — warm,
   professional, mono-accented — but light by default.
   ============================================================ */

/* ---------- Design tokens ---------- */
:root {
  --font-body: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;

  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --content: 1080px;
  --gutter: clamp(16px, 4vw, 40px);

  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px; --space-7: 48px; --space-8: 64px;
}

/* Light (default) — white canvas, navy ink, gold accent */
:root, [data-theme="light"] {
  --bg:#ffffff; --surface:#ffffff; --surface-2:#f4f5f8;
  --border:#e4e7ee; --border-strong:#cbd2dd;
  --text:#15233b; --text-muted:#5b6678; --text-dim:#8d93a4;
  --accent:#b9791a; --accent-dim:#8a5d12; --accent-soft:rgba(185,121,26,.12);
  --interactive:#1f5a96; --success:#2a7d3b; --warning:#9a6a00;
  --danger:#c0322b; --info:#1f5a96;
  --shadow-color:rgba(21,35,59,.10);
  --shadow:0 1px 0 rgba(21,35,59,.04), 0 8px 30px var(--shadow-color);
  --glow:rgba(185,121,26,.20);
  --scanline:rgba(21,35,59,.022);
}

/* Dark — navy-black, amber accent */
[data-theme="dark"] {
  --bg:#0a0e14; --surface:#11161d; --surface-2:#161c25;
  --border:#232b36; --border-strong:#2f3947;
  --text:#d6dde6; --text-muted:#8a97a8; --text-dim:#5c6675;
  --accent:#f0a830; --accent-dim:#8a6420; --accent-soft:rgba(240,168,48,.12);
  --interactive:#4cc2e0; --success:#3fb950; --warning:#d29922;
  --danger:#f85149; --info:#4cc2e0;
  --shadow-color:rgba(0,0,0,.45);
  --shadow:0 1px 0 rgba(0,0,0,.20), 0 8px 30px var(--shadow-color);
  --glow:rgba(240,168,48,.25);
  --scanline:rgba(240,168,48,.03);
}

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
/* faint texture veil — barely visible, adds warmth */
body::before {
  content: "";
  position: fixed; inset: 0;
  background: repeating-linear-gradient(to bottom, transparent 0, transparent 2px, var(--scanline) 3px);
  pointer-events: none; z-index: 1;
  transform: translateZ(0);
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; }
::selection { background: var(--accent); color: #fff; }
:focus-visible { outline: 2px solid var(--interactive); outline-offset: 2px; border-radius: 4px; }

/* ---------- Layout helpers ---------- */
.wrap { width: 100%; max-width: var(--content); margin: 0 auto; padding-inline: var(--gutter); position: relative; z-index: 2; }
.section { padding-block: clamp(48px, 7vw, 88px); position: relative; z-index: 2; }
.divider { height: 1px; background: var(--border); border: 0; margin: 0; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: .78rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
  display: inline-flex; align-items: center; gap: .55em;
  margin: 0 0 var(--space-4);
}
.eyebrow::before { content: ">"; color: var(--text-dim); }

.section h2 {
  font-size: clamp(1.6rem, 3.6vw, 2.4rem);
  line-height: 1.12; letter-spacing: -.02em; font-weight: 700;
  margin: 0 0 18px; max-width: 20ch;
}
.section h2 em { color: var(--accent); font-style: normal; }
.lede { font-size: 1.08rem; color: var(--text-muted); max-width: 62ch; margin: 0; }
.section-head { margin-bottom: clamp(32px, 4vw, 48px); }
.section-head .lede { margin-top: 14px; }
.section-head h1 { font-size: clamp(1.6rem, 3.6vw, 2.4rem); line-height: 1.12; letter-spacing: -.02em; font-weight: 700; margin: 0; max-width: 22ch; }
.section-head--row { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.section-head--row .lede { margin-top: 12px; }

/* ---------- Nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.nav__inner { display: flex; align-items: center; gap: 18px; height: 62px; }
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-mono); font-weight: 700;
  letter-spacing: .04em; font-size: .95rem; color: var(--text);
}
.brand:hover { color: var(--accent); }
.brand__mark { width: 26px; height: 26px; color: var(--accent); filter: drop-shadow(0 0 8px var(--glow)); }
.nav__spacer { flex: 1; }
.nav__actions { display: flex; align-items: center; gap: var(--space-2); }
.nav__who {
  color: var(--text-muted); font-size: .88rem; max-width: 200px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nav__form { display: inline; margin: 0; }

.theme-toggle {
  width: 34px; height: 34px; display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-muted);
  transition: color .15s, border-color .15s;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--border-strong); }
[data-theme="dark"] .theme-toggle .ico-sun { display: block; }
[data-theme="dark"] .theme-toggle .ico-moon { display: none; }
[data-theme="light"] .theme-toggle .ico-sun,
:root:not([data-theme]) .theme-toggle .ico-sun { display: none; }
[data-theme="light"] .theme-toggle .ico-moon,
:root:not([data-theme]) .theme-toggle .ico-moon { display: block; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  font-size: .92rem; font-weight: 600;
  padding: 11px 18px; border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: transform .08s ease, background .15s, border-color .15s, box-shadow .15s, color .15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn--primary {
  background: var(--accent); color: #1a1206;
  box-shadow: 0 0 0 1px var(--accent-dim), 0 8px 24px -8px var(--glow);
}
.btn--primary:hover { background: color-mix(in srgb, var(--accent) 88%, #fff); }
.btn--ghost { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn--ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn--danger { background: var(--danger); color: #fff; box-shadow: 0 0 0 1px color-mix(in srgb, var(--danger) 65%, #000); }
.btn--danger:hover { background: color-mix(in srgb, var(--danger) 85%, #000); }
.btn--lg { padding: 14px 22px; font-size: 1rem; }
.btn--block { width: 100%; }

/* ---------- Pills / badges ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: .8rem; line-height: 1;
  padding: var(--space-1) var(--space-3); border-radius: 999px;
  border: 1px solid var(--border-strong); color: var(--text-muted);
  background: var(--surface-2); white-space: nowrap;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill--accent  { color: var(--accent);  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));  background: var(--accent-soft); }
.pill--solid   { background: var(--accent); color: #1a1206; border-color: var(--accent-dim); }
.pill--info    { color: var(--info);    border-color: color-mix(in srgb, var(--info) 40%, var(--border)); }
.pill--success { color: var(--success); border-color: color-mix(in srgb, var(--success) 45%, var(--border)); }
.pill--danger  { color: var(--danger);  border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.pill--muted   { color: var(--text-dim); border-color: var(--border); }

/* ---------- Hero ---------- */
.hero { padding-block: clamp(56px, 9vw, 110px); position: relative; z-index: 2; }
.hero h1 {
  font-size: clamp(2.2rem, 5.6vw, 3.6rem);
  line-height: 1.04; letter-spacing: -.03em; font-weight: 800;
  margin: 0 0 22px; max-width: 18ch;
}
.hero h1 em { color: var(--accent); font-style: normal; }
.hero__sub {
  font-size: clamp(1.05rem, 1.6vw, 1.2rem);
  color: var(--text-muted); max-width: 58ch; margin: 0 0 28px;
}
.hero__cta { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-bottom: 18px; }
.hero__badges {
  font-family: var(--font-mono); font-size: .8rem; color: var(--text-dim);
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}

/* ---------- Feature grid ---------- */
.grid { display: grid; gap: var(--space-4); grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid--2 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .grid--3 { grid-template-columns: repeat(3, 1fr); } }
.card {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); padding: 22px;
  transition: border-color .15s, transform .12s, box-shadow .15s;
}
.card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); transform: translateY(-2px); }
.card__ico {
  width: 38px; height: 38px; border-radius: var(--radius-sm);
  display: grid; place-items: center; margin-bottom: 14px;
  color: var(--accent); background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
}
.card h3 { margin: 0 0 var(--space-2); font-size: 1.08rem; letter-spacing: -.01em; }
.card p { margin: 0; color: var(--text-muted); font-size: .94rem; }

/* ---------- Forms ---------- */
.field { display: grid; gap: var(--space-1); margin-bottom: var(--space-4); }
.field > label { font-size: .84rem; font-weight: 600; color: var(--text); }
.field__help { font-size: .8rem; color: var(--text-muted); }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=search], input[type=url], select, textarea {
  width: 100%; padding: 11px 13px; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder { color: var(--text-dim); }

/* ---------- Auth ---------- */
.auth {
  min-height: calc(100vh - 62px); display: grid; place-items: center;
  padding: var(--space-5) var(--gutter);
  background-image: repeating-linear-gradient(0deg, var(--scanline) 0 1px, transparent 1px 3px);
}
.auth__shell {
  display: grid; grid-template-columns: 1fr;
  width: min(880px, 94vw);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
.auth__aside {
  display: none; background: var(--bg); border-right: 1px solid var(--border);
  padding: clamp(28px, 4vw, 40px);
}
.auth__aside .auth__brand { margin-bottom: var(--space-5); }
.auth__main { background: var(--surface); padding: clamp(28px, 4vw, 40px); }
.auth__brand { display: flex; align-items: center; gap: 10px; margin-bottom: var(--space-4); }
.auth__brand .name { font-family: var(--font-mono); font-weight: 700; letter-spacing: .04em; }
.auth__brand .name::before { content: ">_ "; color: var(--text-dim); }
.auth__brand .name span { color: var(--accent); }
.auth h1 { font-size: 1.4rem; margin: var(--space-2) 0 var(--space-1); letter-spacing: -.01em; }
.auth__sub { color: var(--text-muted); font-size: .9rem; margin: 0 0 22px; }
.auth__variant h2 { font-size: 1.18rem; line-height: 1.3; margin: 0 0 var(--space-3); letter-spacing: -.01em; }
.auth__variant p { color: var(--text-muted); font-size: .92rem; line-height: 1.6; margin: 0 0 var(--space-4); }
.auth__aside-list { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--space-3); }
.auth__aside-list li { display: grid; grid-template-columns: 22px 1fr; gap: 10px; font-size: .9rem; color: var(--text-muted); }
.auth__aside-list .tick { color: var(--success); font-family: var(--font-mono); }
.auth__btns { display: flex; gap: .5rem; margin-top: 4px; }
.auth__btns .btn { flex: 1; min-width: 0; white-space: normal; line-height: 1.25; padding-inline: 10px; }
.auth__btns.is-pwmode #loginSubmit {
  color: #1a1206; background: var(--accent); border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-dim), 0 8px 24px -8px var(--glow);
}
.auth__btns.is-pwmode #magicSubmit {
  background: var(--surface); color: var(--text); border-color: var(--border);
}
.auth__foot { margin-top: 18px; font-size: .82rem; color: var(--text-dim); text-align: center; }
.auth .btn--primary {
  font-size: 1rem; font-weight: 600; font-family: inherit;
  color: #1a1206; background: var(--accent); border: 0; border-radius: var(--radius-sm);
  cursor: pointer; box-shadow: 0 0 0 1px var(--accent-dim), 0 8px 24px -8px var(--glow);
  transition: background .15s; padding: 12px 16px;
}
.auth .btn--primary:hover { background: color-mix(in srgb, var(--accent) 88%, #fff); }
.auth .btn--ghost {
  font-size: 1rem; font-weight: 600; font-family: inherit;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; transition: background .15s; padding: 12px 16px;
  background: var(--surface); color: var(--text);
}
.auth .btn--ghost:hover { background: var(--surface-2); }
.field { display: grid; gap: var(--space-1); margin-bottom: var(--space-4); }
.field > label { font-size: 13px; font-weight: 600; color: var(--text); }
.field__input-wrap { position: relative; display: flex; align-items: center; }
.field__input-wrap input { width: 100%; padding-right: 56px; }
.field__toggle {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: 0; cursor: pointer; font-size: .8rem;
  color: var(--text-muted); padding: 4px 6px; font-family: inherit;
}
.field__toggle:hover { color: var(--text); }
.field__help { font-size: 12px; color: var(--text-muted); }
.form-msg { min-height: 18px; margin-top: 14px; font-size: .86rem; font-family: var(--font-mono); transition: opacity .3s ease; }
.form-msg:not(:empty) { margin-bottom: 14px; }
.form-msg.is-error { color: var(--danger); }
.form-msg.is-fading { opacity: 0; }
.auth__shell--narrow { max-width: 440px; }
@media (min-width: 880px) {
  .auth__shell:not(.auth__shell--narrow) { grid-template-columns: minmax(0, 0.85fr) minmax(0, 1fr); }
  .auth__aside { display: block; }
}

/* ---------- Flash / alerts ---------- */
.flash {
  padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); font-size: .9rem; margin: 0 0 1.25rem;
}
.flash.error {
  color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, var(--surface));
  border-color: color-mix(in srgb, var(--danger) 40%, var(--border));
}

/* ---------- Main / footer ---------- */
.site-main { display: block; }
.footer {
  border-top: 1px solid var(--border); padding-block: var(--space-6) 24px;
  position: relative; z-index: 2; margin-top: var(--space-7);
}
.footer__bottom {
  display: flex; flex-wrap: wrap; gap: var(--space-3); justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono); font-size: .78rem; color: var(--text-dim);
}

/* ---------- Utility ---------- */
.muted { color: var(--text-muted); }
.mono { font-family: var(--font-mono); }
.center { text-align: center; }

/* reveal-on-load */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.rise { animation: rise .5s ease both; }

/* ── Ticket list ─────────────────────────────────────────────── */
.ticket-list { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.ticket-item {
	display: flex; align-items: center; justify-content: space-between; gap: 16px;
	padding: 14px 16px; background: var(--surface); border: 1px solid var(--border);
	border-radius: var(--radius); transition: border-color .15s;
}
.ticket-item { box-shadow: var(--shadow); }
.ticket-item:hover { border-color: var(--accent); transform: translateY(-1px); }
.ticket-item__main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ticket-item__subject { font-weight: 600; color: var(--text); line-height: 1.3; }
a.ticket-item__subject { text-decoration: none; display: block; }
a.ticket-item__subject:hover { color: var(--accent); }
.ticket-item__meta { display: inline-flex; align-items: center; gap: 8px; font-size: .78rem; }
.ticket-item__meta .sep { opacity: .5; }

/* ── Form controls: select + textarea ────────────────────────── */
select, textarea {
	display: block; width: 100%; padding: 10px 12px; font-size: 1rem; font-family: inherit;
	color: var(--text); background: var(--surface); border: 1px solid var(--border);
	border-radius: var(--radius-sm); transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 120px; }
select:focus, textarea:focus {
	border-color: var(--accent); outline: none;
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

/* ── Pagination ──────────────────────────────────────────────── */
.pagination { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
.pagination .pill { text-decoration: none; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

@media (max-width: 560px) {
  .nav__who { display: none; }
  .hero h1 { font-size: 1.9rem; }
}

/* ── Account settings ─────────────────────────────────────────── */
.account-shell { padding-block: 32px 64px; }
.account-title { font-size: 1.6rem; margin: 0 0 24px; letter-spacing: -.01em; }
.account-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 32px;
  align-items: start;
}
@media (max-width: 640px) {
  .account-layout { grid-template-columns: 1fr; }
  .account-nav ul { flex-direction: row; flex-wrap: wrap; }
}
.account-nav ul {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 2px;
}
.account-nav a {
  display: block; padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: .92rem;
  transition: color .15s, background .15s;
}
.account-nav a:hover { color: var(--text); background: var(--surface-2); }
.account-nav a.is-active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.account-content { min-width: 0; }
.account-content .section-title { font-weight: 700; }

/* ── Flash success variant ────────────────────────────────────── */
.flash.success {
  color: var(--success);
  background: color-mix(in srgb, var(--success) 8%, var(--surface));
  border-color: color-mix(in srgb, var(--success) 40%, var(--border));
}

/* ── Form field errors ────────────────────────────────────────── */
.field--error input,
.field--error select,
.field--error textarea {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 12%, transparent);
}
.field__error {
  display: block; color: var(--danger); font-size: .82rem; margin-top: 2px;
}

/* ── Form stack ───────────────────────────────────────────────── */
.form-stack { display: flex; flex-direction: column; gap: 0; }
.form-stack .field { margin-bottom: var(--space-4); }
.form-stack .btn { align-self: flex-start; }
