/* Formula Matchup Theme (dark default)
   Keep these classes small + semantic; let Tailwind handle layout when needed.
*/

:root {
  /* Brand-ish foundation: deep navy w/ subtle lift */
  --fm-bg0: #040913; /* deep navy */
  --fm-bg1: #071427; /* navy-blue */
  --fm-surface: rgba(17, 24, 39, 0.66);       /* slate-900-ish */
  --fm-surface2: rgba(17, 24, 39, 0.82);
  --fm-border: rgba(148, 163, 184, 0.16);     /* slate-400 @ low alpha */
  --fm-text: rgba(255, 255, 255, 0.92);
  --fm-muted: rgba(226, 232, 240, 0.70);
  --fm-muted2: rgba(226, 232, 240, 0.55);
  --fm-accent: #f97316;  /* orange */
  --fm-accent-dark: #c2410c; /* dark orange accent */
  --fm-accent2: #38bdf8; /* light blue accent */
  --fm-accent2-dark: #1d4ed8; /* deep blue accent */
  --fm-green: #22c55e;
  --fm-red: #ef4444;
  --fm-link: #2563EB;  /* default blue for text links (Tailwind blue-600) */

  --fm-radius: 16px;
  --fm-radius-sm: 12px;
  --fm-shadow: 0 20px 60px rgba(0,0,0,0.45);
}

/* Small inline edit affordance for Wagtail-managed content (admins only) */
.fm-cms-edit-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 9999px;
  border: 1px solid rgba(34, 197, 94, 0.45);
  background: rgba(34, 197, 94, 0.12);
  color: rgba(34, 197, 94, 1);
  opacity: 0.9;
  transition: opacity 120ms ease, background-color 120ms ease, border-color 120ms ease;
  flex: 0 0 auto;
}
.fm-cms-edit-icon:hover {
  opacity: 1;
  background: rgba(34, 197, 94, 0.18);
  border-color: rgba(34, 197, 94, 0.7);
}
.fm-cms-edit-icon svg {
  display: block;
}

/* FM Plus inline badge */
.fm-plus-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  position: relative;
  top: 2px; /* slightly below baseline */
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.45));
}
.fm-plus-badge img {
  display: block;
}

/* Scoring points display (league tables + help scoring grid) */
.points-positive { color: #000000; background-color: rgb(255, 255, 255); }
.points-negative { color: #ffffff; background-color: rgba(0, 0, 0); }

/* Full-page background – solid dark on root so scroll/repaint never shows white */
html {
  background-color: var(--fm-bg0);
}
html, body {
  min-height: 100%;
}
body {
  background-color: var(--fm-bg0);
}

.fm-page {
  min-height: calc(100vh - 56px);
  background:
    radial-gradient(900px 400px at 30% 10%, rgba(249,115,23,0.12), transparent 55%),
    radial-gradient(1100px 500px at 70% 30%, rgba(0,162,255,0.10), transparent 60%),
    linear-gradient(180deg, var(--fm-bg0), var(--fm-bg1));
}

.fm-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem;
}

.fm-section {
  padding: 2.25rem 0;
}

/* Mobile: remove side margins, greatly reduce top gap */
@media (max-width: 500px) {
  .fm-page main {
    padding-left: 0 !important;
    padding-right: 0 !important;
    padding-top: 0.25rem !important;
  }
  .fm-container {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
  .fm-section {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
  }
  /* Minimal container padding on mobile for max content width */
  main.container,
  .fm-page .container {
    padding-left: 0.25rem !important;
    padding-right: 0.25rem !important;
  }
  /* Reduce footer padding on mobile */
  footer .container {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
    padding-top: 1.5rem !important;
    padding-bottom: 1.5rem !important;
  }
}
@media (min-width: 501px) and (max-width: 640px) {
  .fm-page main {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
  .fm-container {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
  }
}

.fm-section-title {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--fm-text);
  margin: 0 0 1.1rem;
}

.fm-card {
  background: var(--fm-surface);
  border: 1px solid var(--fm-border);
  border-radius: var(--fm-radius);
  box-shadow: var(--fm-shadow);
  backdrop-filter: blur(10px);
}

.fm-card-pad { padding: 1.25rem; }

.fm-card-title {
  font-weight: 650;
  color: var(--fm-text);
  font-size: 1.05rem;
  margin-bottom: 0.35rem;
}

.fm-card-body {
  color: var(--fm-muted);
  line-height: 1.55;
}

.fm-muted { color: var(--fm-muted2); }

.fm-link {
  color: var(--fm-accent);
  text-decoration: none;
}
.fm-link:hover { text-decoration: underline; }

/* Buttons */
.fm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.05rem;
  border-radius: 999px;
  border: 1px solid var(--fm-border);
  color: var(--fm-text);
  background: rgba(2,6,23,0.25);
  text-decoration: none;
  font-weight: 650;
}

.fm-btn-primary {
  background: linear-gradient(180deg, rgba(249,115,23,1), rgba(234,88,12,1));
  border-color: rgba(249,115,23,0.55);
  color: #0b1020;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.fm-btn-primary:hover {
  filter: brightness(1.12);
  box-shadow: 0 4px 20px rgba(249, 115, 22, 0.45), 0 0 0 1px rgba(249, 115, 22, 0.3);
  transform: translateY(-1px);
}

.fm-btn-primary:active {
  transform: translateY(0);
  filter: brightness(0.98);
}

.fm-btn-secondary {
  background: rgba(15, 23, 42, 0.2);
  border-color: rgba(100, 116, 139, 0.5);
  color: var(--fm-text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.fm-btn-secondary:hover {
  border-color: rgba(249, 115, 22, 0.6);
  background: rgba(249, 115, 22, 0.12);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.2), 0 4px 14px rgba(0, 0, 0, 0.2);
  transform: translateY(-1px);
}

.fm-btn-secondary:active {
  transform: translateY(0);
}

.fm-btn-ghost:hover {
  border-color: rgba(249,115,23,0.35);
}

/* Button sizes */
.fm-btn-sm {
  padding: 0.45rem 0.85rem;
  font-size: 0.875rem;
}

.fm-btn-lg {
  padding: 0.9rem 1.4rem;
  font-size: 1.05rem;
}

/* Button color variants */
.fm-btn-outline {
  background: transparent;
  border-color: var(--fm-border);
  color: var(--fm-text);
}

.fm-btn-outline:hover {
  border-color: rgba(249, 115, 23, 0.35);
  background: rgba(249, 115, 23, 0.08);
}

/* Simple responsive grid helper */
.fm-grid {
  display: grid;
  gap: 1rem;
}
.fm-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
@media (max-width: 980px) {
  .fm-grid-3 { grid-template-columns: 1fr; }
}

/* Hero */
.fm-hero { padding-top: 10px; }
.fm-hero-inner { padding: 1.6rem; }
.fm-hero-title {
  font-size: clamp(2rem, 4vw, 3.1rem);
  line-height: 1.05;
  margin: 0 0 0.75rem;
  color: var(--fm-text);
}
.fm-hero-subtitle {
  margin: auto;
  font-size: 1.05rem;
  color: var(--fm-muted);
  max-width: 65ch;
}
.fm-hero-actions { display:flex; flex-wrap:wrap; gap: 0.75rem; }

/* Steps */
.fm-step-kicker {
  font-size: 0.85rem;
  color: var(--fm-muted2);
  margin-bottom: 0.35rem;
}

/* Wagtail richtext */
.fm-prose {
  color: var(--fm-muted);
}
.fm-prose a { color: var(--fm-accent); }

/* Restore list styling inside Wagtail richtext blocks (Tailwind reset strips it) */
.fm-prose ul,
.fm-prose ol {
  margin-top: 0.25rem;
  margin-bottom: 0.75rem;
  padding-left: 1.25rem;
}

.fm-prose ul {
  list-style-type: disc;
}

.fm-prose ol {
  list-style-type: decimal;
}

.fm-prose li + li {
  margin-top: 0.15rem;
}

/* Accordion */
.fm-accordion-btn {
  width: 100%;
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 1rem;
  color: var(--fm-text);
  font-weight: 650;
  padding: 0.25rem 0;
}
.fm-accordion-icon { color: var(--fm-muted2); }

.fm-helptext { color: var(--fm-muted2); font-size: 0.9rem; }

/* Scoring grid block: 3-column table, mobile-friendly */
.fm-scoring-grid-table {
  border-collapse: collapse;
}
.fm-scoring-grid-table .fm-scoring-grid-point-col {
  width: 5rem;
}
.fm-scoring-grid-table th,
.fm-scoring-grid-table td {
  white-space: nowrap;
}
.fm-scoring-grid-table td:first-child {
  white-space: normal;
  min-width: 0;
}
@media (max-width: 640px) {
  .fm-scoring-grid-table th,
  .fm-scoring-grid-table td {
    padding: 0.5rem 0.4rem;
    font-size: 0.8125rem;
  }
  .fm-scoring-grid-table .fm-scoring-grid-point-col {
    width: 3.5rem;
  }
}

/* =====================
   Shared UI primitives (site-wide)
   ===================== */

/* Help pages: "inversion" layer so we can darken older light-themed templates
   without rewriting every Tailwind utility in-place.
   Scoped via .fm-help wrapper.
*/
.fm-help .bg-white { background: var(--fm-surface2) !important; }
.fm-help .bg-gray-50 { background: rgba(2, 6, 23, 0.22) !important; }
.fm-help .border-gray-200 { border-color: rgba(148, 163, 184, 0.18) !important; }
.fm-help .shadow-md,
.fm-help .shadow-sm { box-shadow: var(--fm-shadow) !important; }

/* Help/search inputs: ensure readable text even if an input keeps its default white background
   (common when older templates render inside the .fm-help dark theme overrides).
*/
.fm-help input[type="text"],
.fm-help input[type="search"],
.fm-help textarea,
.fm-help select {
  background: rgba(2, 6, 23, 0.35) !important;
  color: rgba(255,255,255,0.92) !important;
  border-color: rgba(148, 163, 184, 0.25) !important;
  caret-color: rgba(249,115,22,0.95);
}

.fm-help input[type="text"]::placeholder,
.fm-help input[type="search"]::placeholder,
.fm-help textarea::placeholder {
  color: rgba(226,232,240,0.65) !important;
}

.fm-help .text-gray-900,
.fm-help .text-gray-800 { color: rgba(255,255,255,0.92) !important; }
.fm-help .text-gray-700,
.fm-help .text-gray-600 { color: rgba(226,232,240,0.76) !important; }
.fm-help .text-gray-500 { color: rgba(226,232,240,0.62) !important; }
.fm-help .text-gray-400 { color: rgba(226,232,240,0.52) !important; }

/* Help page chips / quick-nav buttons */
.fm-help a.bg-orange-100,
.fm-help a.bg-orange-50 {
  background: rgba(2,6,23,0.28) !important;
  border: 1px solid rgba(249,115,22,0.28) !important;
  color: rgba(255,255,255,0.9) !important;
}
.fm-help a.bg-orange-100:hover,
.fm-help a.bg-orange-50:hover {
  border-color: rgba(249,115,22,0.5) !important;
  box-shadow: 0 0 0 4px rgba(249,115,22,0.14);
}

/* Orange utility overrides inside help pages */
.fm-help .bg-orange-100 { background: rgba(249,115,22,0.14) !important; }
.fm-help .bg-orange-50 { background: rgba(249,115,22,0.10) !important; }
.fm-help .border-orange-200 { border-color: rgba(249,115,22,0.22) !important; }
.fm-help .border-orange-300 { border-color: rgba(249,115,22,0.28) !important; }
.fm-help .text-orange-700,
.fm-help .text-orange-600 { color: rgba(253,186,116,0.95) !important; }

/* Blue / indigo callouts */
.fm-help .bg-blue-50,
.fm-help .bg-indigo-50 {
  background: rgba(56,189,248,0.10) !important;
  border-color: rgba(56,189,248,0.22) !important;
}
.fm-help .border-blue-200 { border-color: rgba(56,189,248,0.22) !important; }

/* Make list bullets & hr a bit softer on dark */
.fm-help hr { border-color: rgba(148,163,184,0.16) !important; }
.fm-help .divide-gray-200 > :not([hidden]) ~ :not([hidden]) { border-color: rgba(148,163,184,0.14) !important; }

/* League pages: same inversion trick as help pages, but scoped to .fm-league */
.fm-league .bg-white { background: var(--fm-surface2) !important; }

/* =====================
   FM-0059: Darken legacy light templates site-wide
   =====================
   Many older templates still use Tailwind light utilities like bg-white/text-gray-900.
   Apply a global "darkify" layer inside .fm-page so we stop seeing big white slabs.
   (Admin is separate and won’t inherit .fm-page.)
*/
.fm-page .bg-white { background: var(--fm-surface2) !important; }
.fm-page .bg-gray-50 { background: rgba(2, 6, 23, 0.22) !important; }
.fm-page .bg-gray-100 { background: rgba(2, 6, 23, 0.30) !important; }
.fm-page .border-gray-200 { border-color: rgba(148, 163, 184, 0.18) !important; }
.fm-page .border-gray-300 { border-color: rgba(148, 163, 184, 0.22) !important; }
.fm-page .divide-gray-200 > :not([hidden]) ~ :not([hidden]) { border-color: rgba(148,163,184,0.14) !important; }

/* Text utilities that are too dark on our dark gradient */
.fm-page .text-gray-900,
.fm-page .text-gray-800 { color: rgba(255,255,255,0.92) !important; }
.fm-page .text-gray-700,
.fm-page .text-gray-600 { color: rgba(226,232,240,0.76) !important; }
.fm-page .text-gray-500 { color: rgba(226,232,240,0.62) !important; }
.fm-page .text-gray-400 { color: rgba(226,232,240,0.52) !important; }

/* Legacy buttons */
.fm-page .bg-orange-50 { background: rgba(249,115,22,0.10) !important; }
.fm-page .bg-orange-100 { background: rgba(249,115,22,0.14) !important; }
.fm-page .text-orange-600,
.fm-page .text-orange-700 { color: rgba(253,186,116,0.95) !important; }

/* Inputs that were designed for white backgrounds */
.fm-page input[type="text"],
.fm-page input[type="email"],
.fm-page input[type="password"],
.fm-page input[type="number"],
.fm-page input[type="search"],
.fm-page textarea,
.fm-page select {
  background: rgba(2, 6, 23, 0.35) !important;
  color: rgba(255,255,255,0.92) !important;
  border-color: rgba(148, 163, 184, 0.25) !important;
}
.fm-page input::placeholder,
.fm-page textarea::placeholder {
  color: rgba(226,232,240,0.65) !important;
}
.fm-league .bg-gray-50 { background: rgba(2, 6, 23, 0.22) !important; }
.fm-league .bg-gray-100 { background: rgba(2, 6, 23, 0.30) !important; }

/* Playoffs bracket stylesheet uses its own wrappers; force dark surfaces there too */
.fm-league .bracket-wrapper { background: rgba(17,24,39,0.66) !important; }
.fm-league .bracket-matchup { background: rgba(2,6,23,0.22) !important; border-color: rgba(148,163,184,0.18) !important; }
.fm-league .bracket-matchup.upcoming { background: rgba(2,6,23,0.16) !important; }

/* Reduce winner/loser harsh contrast */
.fm-league .bracket-team { background: rgba(255,255,255,0.03) !important; }
.fm-league .bracket-team.winner { background: rgba(34, 197, 94, 0.16) !important; }
.fm-league .bracket-team.eliminated { opacity: 0.78 !important; }

/* Bracket text colors: page isn't using Tailwind `dark` class, so force readable text */
.fm-league .bracket-team-name { color: rgba(255,255,255,0.92) !important; }
.fm-league .bracket-manager-name { color: rgba(226,232,240,0.75) !important; }
.fm-league .bracket-team .tabular-nums { color: rgba(226,232,240,0.92) !important; }

/* Matchups page (league_matchups.css has hardcoded light backgrounds) */
.fm-league .matchup-block {
  background: rgba(17,24,39,0.55) !important;
  border-color: rgba(148,163,184,0.18) !important;
  box-shadow: var(--fm-shadow) !important;
  color: rgba(226,232,240,0.88) !important;
}

/* Text within matchups page uses Tailwind gray utilities (too dark on our league gradient) */
#matchups-root .team-name { color: rgba(255,255,255,0.92) !important; }
#matchups-root a { color: inherit; }
#matchups-root .text-gray-600 { color: rgba(226,232,240,0.72) !important; }
#matchups-root .text-gray-500 { color: rgba(226,232,240,0.62) !important; }
#matchups-root .text-gray-400 { color: rgba(226,232,240,0.55) !important; }

/* Individual player score numbers inside lineup rows are hardcoded `text-black` */
#matchups-root .driver-row .text-black,
#matchups-root .constructor-row .text-black,
#matchups-root .final-fix-row .text-black {
  color: rgba(226,232,240,0.92) !important;
}

.fm-league .driver-row,
.fm-league .constructor-row {
  background: rgba(2,6,23,0.18) !important;
}

.fm-league .team-column.winner-side { background: rgba(56, 189, 248, 0.10) !important; }
.fm-league .team-column.loser-side { background: rgba(148, 163, 184, 0.08) !important; }

.fm-league .highlighted-common { background: none !important; }
.fm-league .border-gray-200 { border-color: rgba(148, 163, 184, 0.18) !important; }
.fm-league .divide-gray-200 > :not([hidden]) ~ :not([hidden]) { border-color: rgba(148,163,184,0.14) !important; }
.fm-league .shadow-md,
.fm-league .shadow-sm { box-shadow: var(--fm-shadow) !important; }

/* Standings header row / table headings */
.fm-league thead.bg-gray-100 th,
.fm-league .text-gray-900 { color: rgba(255,255,255,0.92) !important; }

/* Current-user highlight row */
.fm-league .bg-blue-50 { background: rgba(56, 189, 248, 0.08) !important; }

.fm-league .text-gray-900,
.fm-league .text-gray-800 { color: rgba(255,255,255,0.92) !important; }
.fm-league .text-gray-700,
.fm-league .text-gray-600 { color: rgba(226,232,240,0.76) !important; }
.fm-league .text-gray-500 { color: rgba(226,232,240,0.62) !important; }
.fm-league .text-gray-400 { color: rgba(226,232,240,0.52) !important; }

/* League tab bar: keep orange header, darken the tab strip */
.fm-league .border-b.border-gray-200.bg-white {
  background: rgba(2,6,23,0.22) !important;
  border-color: rgba(148,163,184,0.16) !important;
}
.fm-league nav[aria-label="Tabs"] a {
  border-color: transparent;
}
.fm-league nav[aria-label="Tabs"] a.bg-orange-50 {
  background: rgba(249,115,22,0.12) !important;
}

/* Orange badges in league header (keep readable on orange gradient) */
.fm-league .bg-white.text-orange-600 {
  background: rgba(255,255,255,0.92) !important;
  color: #c2410c !important;
}

.fm-surface {
  background: var(--fm-surface);
  border: 1px solid var(--fm-border);
  border-radius: var(--fm-radius);
  box-shadow: var(--fm-shadow);
  backdrop-filter: blur(10px);
}

.fm-surface-strong {
  background: var(--fm-surface2);
  border: 1px solid var(--fm-border);
  border-radius: var(--fm-radius);
  box-shadow: var(--fm-shadow);
  backdrop-filter: blur(12px);
}

.fm-surface-header {
  background: rgba(2, 6, 23, 0.35);
  border-bottom: 1px solid var(--fm-border);
}

.fm-divider { border-color: var(--fm-border); }

/* Form controls */
.fm-input,
.fm-select {
  width: 100%;
  color: var(--fm-text);
  background: rgba(2, 6, 23, 0.35);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 14px;
  padding: 0.75rem 1rem;
  outline: none;
}
.fm-input::placeholder { color: rgba(226, 232, 240, 0.45); }
.fm-input:focus,
.fm-select:focus {
  border-color: rgba(249, 115, 23, 0.55);
  box-shadow: 0 0 0 4px rgba(249, 115, 23, 0.18);
}

/* Apply a sane dark style to unclassed controls inside our dark surfaces */
.fm-surface input[type="text"],
.fm-surface input[type="email"],
.fm-surface input[type="password"],
.fm-surface input[type="number"],
.fm-surface input[type="url"],
.fm-surface input[type="search"],
.fm-surface textarea,
.fm-surface select {
  width: 100%;
  color: var(--fm-text);
  background: rgba(2, 6, 23, 0.35);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 14px;
  padding: 0.7rem 0.9rem;
  outline: none;
}
.fm-surface select { appearance: none; }
.fm-surface input:focus,
.fm-surface textarea:focus,
.fm-surface select:focus {
  border-color: rgba(249, 115, 23, 0.55);
  box-shadow: 0 0 0 4px rgba(249, 115, 23, 0.18);
}

/* Make native select arrows visible on dark backgrounds */
.fm-surface select {
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(226,232,240,0.65) 50%),
    linear-gradient(135deg, rgba(226,232,240,0.65) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 12px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 2.25rem;
}

/* Tables (dark) */
.fm-table {
  width: 100%;
  border-collapse: collapse;
}
.fm-table th {
  color: rgba(226, 232, 240, 0.7);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: left;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}
.fm-table td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  color: rgba(255,255,255,0.86);
}
.fm-table tr:hover td {
  background: rgba(2, 6, 23, 0.18);
}

leagueDropdown {
  width: 320px;
}

/* Edit Profile / Signup: dark selects for favorites so they match the page background */
#id_favorite_current_driver,
#id_favorite_driver_all_time,
#id_favorite_current_team {
  background-color: #051321; /* match dark panel */
  color: #e5e7eb;
  border-color: #475569;
}

.discord-bar {
  background: linear-gradient(0deg, rgba(82, 95, 230, 1) 0%, rgba(27, 26, 97, 1) 100%);
  height: 116px;
  width: 390px;
  display: flex;
  padding-top: 13px;
  margin-bottom: auto;
}