/* Base: tokens, reset, typography, buttons, header, mobile menu, footer, shared widgets. Mobile first. */

:root {
  --bg: #121214;
  --bg-deep: #0c0c0d;
  --card: #1e2120;
  --card-2: #181a19;
  --card-hover: #252827;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.18);
  --red: #cc0000;
  --red-bright: #e60000;
  --red-soft: rgba(230, 0, 0, 0.14);
  --red-glow: rgba(230, 0, 0, 0.45);
  --text: #f3f3f1;
  --muted: #a3a6a4;
  --faint: #6f7371;
  --gold: #f2c14e;
  --radius: 4px;
  --header-h: 64px;
  --gutter: 16px;
  --max: 1344px;
  --font-body: 'Barlow', system-ui, sans-serif;
  --font-cond: 'Barlow Condensed', 'Barlow', system-ui, sans-serif;
  --font-title: 'Russo One', 'Barlow Condensed', system-ui, sans-serif;
  color-scheme: dark;
}

@media (min-width: 700px) {
  :root { --gutter: 32px; }
}
@media (min-width: 1100px) {
  :root { --gutter: 48px; --header-h: 84px; }
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

img, svg, video, iframe { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--red-bright); outline-offset: 3px; }

.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;
}

.skip {
  position: fixed; left: 12px; top: -60px; z-index: 100; padding: 12px 16px;
  background: var(--red-bright); color: #fff; font-weight: 700; text-decoration: none;
}
.skip:focus { top: 12px; }

.icon { width: 1em; height: 1em; flex: none; }

/* Titles: Russo One with a red underline accent, like the reference section headings */
.section-title {
  font-family: var(--font-title);
  font-weight: 400;
  font-size: clamp(1.6rem, 5vw, 2.1rem);
  line-height: 1.05;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}
.section-title::after {
  content: '';
  display: block;
  width: 44px;
  height: 3px;
  margin-top: 12px;
  background: var(--red-bright);
}

.muted { color: var(--muted); }
.red { color: var(--red-bright); }

/* Buttons: 44px minimum touch target everywhere */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1.1;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.button:hover { background: rgba(255, 255, 255, 0.09); border-color: rgba(255, 255, 255, 0.3); }
.button:active { transform: translateY(1px); }
.button[disabled], .button[aria-disabled='true'] { opacity: 0.5; cursor: not-allowed; }
.button .icon { width: 14px; height: 14px; }

.red-button { background: var(--red); border-color: var(--red); color: #fff; }
.red-button:hover { background: var(--red-bright); border-color: var(--red-bright); }
.ghost-red { background: var(--red-soft); border-color: rgba(230, 0, 0, 0.55); }
.ghost-red:hover { background: rgba(230, 0, 0, 0.26); border-color: var(--red-bright); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-family: var(--font-cond);
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge[data-status='running'] { background: var(--red); }
.badge[data-status='running']::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%; background: #fff; animation: pulse 1.6s infinite;
}
.badge[data-status='ended'] { background: #3a3d3c; color: var(--muted); }
.badge[data-status='offline'], .badge[data-status='connecting'] { background: transparent; border: 1px solid var(--line-strong); color: var(--muted); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

/* ---------- Site header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--header-h);
  padding: 0 var(--gutter);
  background: rgba(14, 14, 15, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  min-width: 44px;
  text-decoration: none;
  font-family: var(--font-title);
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.wordmark img { width: 36px; height: 36px; }
.wordmark-text { display: none; }
.wordmark .wm-event { color: var(--red-bright); }

.header-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 4px;
  font-variant-numeric: tabular-nums;
}
.header-timer {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.08em;
}
.header-pause { display: inline-flex; color: var(--text); }
.header-pause .icon { width: 14px; height: 14px; }
.header-subs { display: none; color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.header-subs strong { color: var(--text); }

.header-nav { display: none; }

.menu-toggle {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: transparent;
  font-weight: 700;
  cursor: pointer;
}
.menu-toggle .icon { width: 18px; height: 18px; }

.mobile-menu {
  position: fixed;
  inset: var(--header-h) 0 auto 0;
  z-index: 39;
  max-height: calc(100dvh - var(--header-h));
  overflow-y: auto;
  padding: 8px var(--gutter) 20px;
  background: #101011;
  border-bottom: 1px solid var(--line-strong);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.6);
}
.mobile-menu a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  padding: 0 4px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.05rem;
}
.mobile-menu a[aria-current='page'] { color: var(--red-bright); }
.mobile-menu a .icon { width: 16px; height: 16px; color: var(--muted); }
.mobile-menu .menu-group-label {
  padding: 16px 4px 4px;
  color: var(--faint);
  font-family: var(--font-cond);
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

@media (min-width: 560px) {
  .header-subs { display: inline; }
}

@media (min-width: 1000px) {
  .wordmark-text { display: inline; }
  .menu-toggle, .mobile-menu { display: none !important; }
  .header-status {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
    gap: 14px;
  }
  .header-timer { font-size: 1.45rem; }
  .header-nav {
    display: flex;
    align-items: center;
    gap: 28px;
    margin-left: auto;
  }
  .header-nav > a:not(.button), .nav-dropdown > button {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 0;
    border: 0;
    background: none;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.92rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
  }
  .header-nav > a[aria-current='page']::after {
    content: '';
    position: absolute;
    left: 0; right: 0; bottom: 6px;
    height: 2px;
    background: var(--red-bright);
  }
  .nav-dropdown { position: relative; }
  .nav-dropdown > button .icon { width: 12px; height: 12px; transition: transform 0.15s; }
  .nav-dropdown > button[aria-expanded='true'] .icon { transform: rotate(180deg); }
  .nav-dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: -16px;
    min-width: 210px;
    padding: 6px;
    background: #161718;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
  }
  .nav-dropdown-menu a {
    display: flex;
    align-items: center;
    min-height: 40px;
    padding: 0 12px;
    border-radius: 3px;
    text-decoration: none;
    font-weight: 600;
  }
  .nav-dropdown-menu a:hover { background: rgba(255, 255, 255, 0.07); }
}

.header-twitch {
  min-height: 40px;
  padding: 8px 14px;
  border-color: var(--red);
  background: var(--red-soft);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.header-twitch:hover { background: var(--red); }

/* On /subathon the header timer only appears once the dashboard has scrolled away (desktop) */
@media (min-width: 1000px) {
  .site-header[data-status-visible='false'] .header-status { opacity: 0; pointer-events: none; }
  .header-status { transition: opacity 0.2s; }
}

/* ---------- Footer ---------- */

.site-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 48px var(--gutter) 40px;
  color: var(--faint);
  font-size: 0.85rem;
}

.socials { display: flex; flex-wrap: wrap; gap: 8px; }
.socials a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.socials a:hover { background: var(--red); border-color: var(--red); }
.socials .social-icon { width: 22px; height: 22px; }
.site-footer .socials a { border-color: transparent; background: none; color: var(--muted); }
.site-footer .socials a:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }

/* ---------- Shared widgets ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

progress {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 6px;
  border: 0;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
progress::-webkit-progress-bar { background: rgba(255, 255, 255, 0.12); border-radius: 6px; }
progress::-webkit-progress-value { background: var(--red-bright); border-radius: 6px; transition: width 0.6s ease; }
progress::-moz-progress-bar { background: var(--red-bright); border-radius: 6px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 80;
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #1b1c1d;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  font-weight: 600;
  transform: translate(-50%, 150%);
  opacity: 0;
  transition: transform 0.25s, opacity 0.25s;
  pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast[data-tone='error'] { border-color: var(--red); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
}
.chip .icon { width: 11px; height: 11px; }
.chip[data-state='unlocked'] { background: var(--red-soft); color: #ff6b6b; }
.chip[data-state='in_progress'] { background: rgba(242, 193, 78, 0.14); color: var(--gold); }
.chip[data-state='completed'] { background: rgba(98, 196, 120, 0.14); color: #7bd88f; }

dialog {
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100dvh - 48px);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #171819;
  color: var(--text);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(3px); }
.dialog-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 14px 20px;
  background: #171819;
  border-bottom: 1px solid var(--line);
}
.dialog-head h2 { font-family: var(--font-title); font-weight: 400; font-size: 1.25rem; text-transform: uppercase; }
.dialog-body { padding: 20px; }
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex: none;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
}
.icon-button:hover { background: rgba(255, 255, 255, 0.07); }
.icon-button .icon { width: 18px; height: 18px; }

/* Form fields */
.field { display: grid; gap: 6px; font-weight: 600; font-size: 0.92rem; }
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 48px;
  padding: 11px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #0f1010;
  font-size: 1rem; /* 16px avoids iOS zoom on focus */
  font-weight: 500;
}
.field textarea { resize: vertical; min-height: 120px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--red-bright); box-shadow: 0 0 0 3px rgba(230, 0, 0, 0.2); }
