/* =====================================================================
 * WC 2026 Predictor — design system (EPIC-8)
 * Mobile-first, host-nation-inspired palette (USA / Canada / México):
 * deep navy brand, with red, green and gold accents. No official
 * tournament marks — flags + generic football iconography only.
 * ===================================================================== */

:root {
  /* Surfaces & ink */
  --bg: #eef1f7;
  --surface: #ffffff;
  --surface-2: #f4f6fb;
  --border: #dbe0ea;
  --text: #131722;
  --muted: #5a6473;

  /* Brand & accents */
  --brand: #14254c;          /* deep navy */
  --brand-2: #1d3a6e;        /* lighter navy for gradients */
  --brand-ink: #0c1830;
  --accent: #1f6feb;         /* action blue (links, primary buttons) */
  --accent-dark: #1657c2;
  --red: #d7263d;            /* USA / Canada / México red */
  --green: #128a4f;          /* México green */
  --gold: #e3a008;

  /* States */
  --ok: #1a7f37;
  --error: #c2371a;
  --locked: #8a9099;

  /* Podium medals */
  --medal-gold: #d4a017;
  --medal-silver: #9aa3ad;
  --medal-bronze: #b3793f;

  /* Geometry */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --maxw: 960px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 6px 16px rgba(16, 24, 40, 0.06);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  overflow-wrap: break-word;
}

a {
  color: var(--accent);
}

h1 {
  font-size: clamp(1.5rem, 4vw, 2rem);
  line-height: 1.2;
}

main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1rem;
}

/* Keyboard users can skip the header straight to content. */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 50;
  background: var(--brand);
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus {
  left: 0;
}

/* --- Header / brand / nav --------------------------------------------- */
.site-header {
  background: linear-gradient(120deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #fff;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 20;
}

.site-header__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0.6rem 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
}

.brand__mark {
  display: inline-flex;
  color: #fff;
}

.brand__text {
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}
.brand__text b {
  color: var(--gold);
}
.brand__sub {
  margin-left: 0.4rem;
  padding-left: 0.5rem;
  border-left: 1px solid rgba(255, 255, 255, 0.35);
  font-weight: 500;
  opacity: 0.92;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.4rem;
  margin-left: auto;
}

.site-nav a {
  color: rgba(255, 255, 255, 0.92);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-pill);
  line-height: 1;
}
.site-nav a:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.site-nav__cta {
  background: var(--gold);
  color: var(--brand-ink) !important;
}
.site-nav__cta:hover {
  background: #f0ac1a;
}

.site-nav__user {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: 0.3rem;
  padding-left: 0.6rem;
  border-left: 1px solid rgba(255, 255, 255, 0.25);
}
.site-nav__name {
  font-size: 0.86rem;
  font-weight: 600;
  opacity: 0.9;
}
.site-nav__user form {
  margin: 0;
}
.site-nav__logout {
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius-pill);
  padding: 0.35rem 0.75rem;
  cursor: pointer;
}
.site-nav__logout:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* --- Flash messages ---------------------------------------------------- */
ul.flash {
  max-width: var(--maxw);
  margin: 0.75rem auto 0;
  padding: 0 1rem;
  list-style: none;
}
ul.flash li {
  background: #e6f0ff;
  border: 1px solid #b9d2ff;
  color: var(--accent-dark);
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
}

.error {
  color: var(--error);
}

/* --- Buttons ----------------------------------------------------------- */
.btn {
  display: inline-block;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
}
.btn:hover {
  background: var(--accent-dark);
}
.btn:focus-visible {
  outline: 3px solid rgba(31, 111, 235, 0.4);
  outline-offset: 2px;
}

.btn--ghost {
  background: transparent;
  color: var(--accent);
}
.btn--ghost:hover {
  background: rgba(31, 111, 235, 0.08);
}

.btn--save {
  padding: 0.55rem 1.25rem;
}

/* --- Hero (homepage) --------------------------------------------------- */
.hero {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(120% 120% at 85% -20%, rgba(227, 160, 8, 0.22), transparent 55%),
    linear-gradient(125deg, var(--brand) 0%, var(--brand-2) 70%, #244a8c 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 1.75rem 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}
/* Subtle host-nation stripe accent along the top edge. */
.hero::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(90deg, var(--red) 0 33%, #fff 33% 66%, var(--green) 66%);
  opacity: 0.85;
}
.hero__eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
}
.hero__title {
  margin: 0 0 0.4rem;
  font-size: clamp(1.7rem, 5vw, 2.4rem);
}
.hero__intro {
  margin: 0;
  max-width: 52ch;
  color: rgba(255, 255, 255, 0.88);
}

/* --- Generic section heading ------------------------------------------ */
.section-head h1 {
  margin-bottom: 0.25rem;
}
.predictions__intro,
.admin__intro,
.leaderboard__intro,
.rules__intro {
  color: var(--muted);
  max-width: 62ch;
}

/* --- Stage navigation -------------------------------------------------- */
.stage-nav {
  position: sticky;
  top: 52px; /* sits below the sticky header */
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.6rem 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}
.stage-nav a {
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--brand);
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
}
.stage-nav a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.stage__title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1.75rem;
  padding-bottom: 0.3rem;
  border-bottom: 2px solid var(--brand);
  font-size: 1.2rem;
}

.day-heading {
  margin: 1.25rem 0 0.5rem;
  font-size: 0.9rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* --- Fixture card ------------------------------------------------------ */
.fixture {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 0.75rem;
  scroll-margin-top: 6rem;
  box-shadow: var(--shadow-sm);
}
.fixture--locked {
  opacity: 0.8;
  background: var(--surface-2);
}

.fixture__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.7rem;
}
.fixture__meta time {
  font-weight: 700;
  color: var(--text);
}
.fixture__venue {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Badges ------------------------------------------------------------ */
.badge {
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 0.12rem 0.55rem;
  white-space: nowrap;
}

.badge--locked {
  background: #e9e9ec;
  color: var(--locked);
  border-color: var(--locked);
}
.badge--entered {
  background: #e3f3e8;
  border-color: var(--ok);
  color: var(--ok);
}
.badge--pending {
  background: #fdece7;
  border-color: var(--error);
  color: var(--error);
}

/* Stage badge: neutral base, with a left tick of stage colour. */
.badge--stage {
  background: var(--surface);
  color: var(--brand);
  border-color: var(--border);
  box-shadow: inset 3px 0 0 var(--brand);
  padding-left: 0.6rem;
}
.badge--stage-group { box-shadow: inset 3px 0 0 var(--muted); color: var(--muted); }
.badge--stage-r32   { box-shadow: inset 3px 0 0 var(--accent); color: var(--accent-dark); }
.badge--stage-r16   { box-shadow: inset 3px 0 0 var(--green); color: var(--green); }
.badge--stage-qf    { box-shadow: inset 3px 0 0 #c77d0a; color: #b56f08; }
.badge--stage-sf    { box-shadow: inset 3px 0 0 var(--red); color: var(--red); }
.badge--stage-third_place { box-shadow: inset 3px 0 0 var(--medal-bronze); color: var(--medal-bronze); }
.badge--stage-final { box-shadow: inset 3px 0 0 var(--gold); color: #a9760a; }

/* --- Flags ------------------------------------------------------------- */
.flag {
  font-size: 1.15rem;
  line-height: 1;
  flex: 0 0 auto;
}
/* Placeholder teams (e.g. "Winner Group A") get a neutral marker. */
.flag--tbc {
  display: inline-block;
  width: 1.15rem;
  height: 0.8rem;
  border-radius: 2px;
  border: 1px dashed var(--border);
  background: repeating-linear-gradient(
    45deg, var(--surface-2), var(--surface-2) 3px, #e7eaf1 3px, #e7eaf1 6px
  );
}

/* --- Score row --------------------------------------------------------- */
.fixture__score {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.4rem 0.6rem;
}
.team {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}
.team--home {
  justify-content: flex-end;
}
.team--away {
  justify-content: flex-start;
}
.team__name {
  font-weight: 600;
  min-width: 0;
  overflow-wrap: anywhere;
}

.score {
  width: 3rem;
  height: 2.75rem; /* >=44px touch target */
  text-align: center;
  font-size: 1.1rem; /* >=16px avoids iOS focus zoom */
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.score:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.2);
}
.score:disabled {
  background: #e9e9ec;
  color: var(--muted);
}
.score-sep {
  color: var(--muted);
  font-weight: 700;
}

.penalties {
  margin-top: 0.65rem;
  font-size: 0.9rem;
}
.penalties select {
  margin-left: 0.4rem;
  min-height: 2.6rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: inherit;
}

.is-hidden {
  display: none;
}

.fixture__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 0.75rem;
  margin-top: 0.7rem;
}
.outcome {
  font-weight: 700;
  color: var(--brand);
}
.status {
  font-size: 0.85rem;
}
.status--ok { color: var(--ok); }
.status--error { color: var(--error); }
.status--locked { color: var(--locked); }

.countdown {
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.no-prediction {
  font-size: 0.85rem;
  font-style: italic;
  color: var(--locked);
}

/* --- Admin results page ------------------------------------------------ */
.admin__summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.6rem 0;
}
.admin__filter {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: var(--muted);
}
/* Pending fixtures get a warm left edge so they're easy to spot. */
.fixture--pending {
  border-left: 4px solid var(--error);
}

/* --- Homepage leaderboard --------------------------------------------- */
.podium {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin: 0 0 1.75rem;
}
.podium__slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 5px solid var(--border);
  border-radius: var(--radius);
  padding: 0.95rem 1rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.podium__slot--1 { border-top-color: var(--medal-gold); background: #fffaf0; }
.podium__slot--2 { border-top-color: var(--medal-silver); background: #f8fafc; }
.podium__slot--3 { border-top-color: var(--medal-bronze); background: #fdf6f0; }

.podium__medal { font-size: 1.7rem; line-height: 1; }
.podium__rank {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
}
.podium__name { font-size: 1.15rem; font-weight: 700; }
.podium__points { font-weight: 700; color: var(--brand); }
.podium__meta { font-size: 0.8rem; color: var(--muted); }

.podium__empty {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  text-align: center;
  color: var(--muted);
  max-width: 52ch;
  margin: 0 auto;
}

/* On wider screens, arrange as a real podium: 2nd, 1st (tallest), 3rd. */
@media (min-width: 640px) {
  .podium {
    flex-direction: row;
    align-items: flex-end;
    justify-content: center;
    gap: 1rem;
  }
  .podium__slot {
    flex: 1 1 0;
    max-width: 13rem;
    justify-content: flex-end;
  }
  .podium__slot--1 { order: 2; padding-top: 1.85rem; }
  .podium__slot--2 { order: 1; padding-top: 1.15rem; }
  .podium__slot--3 { order: 3; }
}

/* --- Standings table --------------------------------------------------- */
.standings {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.standings th,
.standings td {
  padding: 0.65rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.standings thead th {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--surface-2);
}
.standings tbody tr:last-child td {
  border-bottom: none;
}
.standings__rank {
  width: 2.5rem;
  font-weight: 700;
  text-align: center;
}
.standings__num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.standings__name {
  font-weight: 600;
}
.standings__row--top {
  background: #fffdf6;
}

.leaderboard__note {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 0.75rem;
}

/* --- Auth pages (login / change password) ----------------------------- */
.auth-card {
  max-width: 26rem;
  margin: 1.5rem auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.auth-card h1 {
  margin-top: 0;
}
.auth-card label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.85rem;
}
.auth-card input[type="text"],
.auth-card input[type="password"] {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.6rem 0.7rem;
  font: inherit;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.auth-card input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.2);
}
.auth-card button[type="submit"] {
  width: 100%;
  margin-top: 0.25rem;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.auth-card button[type="submit"]:hover {
  background: var(--accent-dark);
}
.auth-card .error {
  background: #fdece7;
  border: 1px solid #f3c2b4;
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
}

/* --- Footer ------------------------------------------------------------ */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  max-width: var(--maxw);
  margin: 2.5rem auto 1.5rem;
  padding: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--muted);
}
.site-footer a {
  font-weight: 600;
  text-decoration: none;
}
.site-footer__note {
  flex: 1 1 16rem;
  min-width: 0;
}
.site-footer__brand {
  font-weight: 600;
}

/* --- Rules page -------------------------------------------------------- */
.rules h2 {
  margin-top: 1.75rem;
  border-bottom: 2px solid var(--brand);
  padding-bottom: 0.25rem;
}
.rules section p {
  max-width: 65ch;
}

.rules__awards {
  display: grid;
  gap: 0.6rem;
  margin: 1.25rem 0;
}
.award {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 5px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow-sm);
}
.award__points {
  flex: 0 0 auto;
  min-width: 3.4rem;
  text-align: center;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
}
.award--4 { border-left-color: var(--medal-gold); }
.award--3 { border-left-color: var(--ok); }
.award--2 { border-left-color: var(--accent); }
.award--0 { border-left-color: var(--locked); }

.badge--pts {
  font-weight: 700;
  color: #fff;
  border: none;
}
.award--4.badge--pts { background: var(--medal-gold); }
.award--3.badge--pts { background: var(--ok); }
.award--2.badge--pts { background: var(--accent); }
.award--0.badge--pts { background: var(--locked); }

.examples { display: block; }
.example {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 0.6rem;
  box-shadow: var(--shadow-sm);
}
.example__lines {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.example__line { font-size: 0.92rem; }
.example__verdict {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.example__why {
  font-size: 0.82rem;
  color: var(--muted);
  max-width: 32ch;
}

/* --- Small-screen tuning ---------------------------------------------- */
@media (max-width: 28rem) {
  main { padding: 0.85rem; }

  /* Leave room below the (possibly two-row) sticky header. */
  .stage-nav { top: 92px; }

  /* Tighten the score row; long team names wrap instead of scrolling. */
  .fixture__score { gap: 0.35rem 0.4rem; }
  .score { width: 2.85rem; }
  .team { gap: 0.35rem; }

  .site-nav a { font-size: 0.86rem; padding: 0.35rem 0.5rem; }
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
