/* ============================================================
   CSS Custom Properties (defaults; overridden per-league via base.html <style>)
   ============================================================ */
:root {
  --upl-dark:       #14213d;
  --upl-teal:       #0d7377;
  --upl-accent:     #fca311;
  --upl-transition: 0.18s ease;
}

/* ============================================================
   Typography — Oswald (headings) + Inter (body)
   ============================================================ */
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

main { flex: 1; }

h1, h2, h3,
.display-1, .display-2, .display-3, .display-4, .display-5, .display-6 {
  font-family: 'Oswald', sans-serif;
  letter-spacing: 0.01em;
}

/* ============================================================
   Brand utilities
   ============================================================ */
.bg-upl   { background-color: var(--upl-dark) !important; }
.text-upl { color: var(--upl-teal) !important; }

.btn-upl {
  background-color: var(--upl-teal);
  color: #fff;
  border-color: var(--upl-teal);
  transition: background-color var(--upl-transition), box-shadow var(--upl-transition);
}
.btn-upl:hover, .btn-upl:focus-visible {
  background-color: #0a5c5f;
  border-color: #0a5c5f;
  color: #fff;
  box-shadow: 0 4px 12px rgba(13, 115, 119, 0.35);
}

.btn-outline-upl {
  color: var(--upl-teal);
  border-color: var(--upl-teal);
  transition: all var(--upl-transition);
}
.btn-outline-upl:hover, .btn-outline-upl:focus-visible {
  background-color: var(--upl-teal);
  color: #fff;
}

/* ============================================================
   Navbar
   ============================================================ */
.navbar-brand { letter-spacing: 0.02em; }

/* Active nav link — accent underline */
.navbar-nav .nav-link.active {
  color: #fff !important;
  font-weight: 600;
  position: relative;
}
.navbar-nav .nav-link.active::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 0.5rem;
  right: 0.5rem;
  height: 2px;
  background: var(--upl-accent);
  border-radius: 1px;
}

/* ============================================================
   Focus accessibility
   ============================================================ */
:focus-visible {
  outline: 3px solid var(--upl-accent);
  outline-offset: 2px;
  border-radius: 3px;
}
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(252, 163, 17, 0.45);
}

/* ============================================================
   Cards — hover lift
   ============================================================ */
.card {
  transition: transform var(--upl-transition), box-shadow var(--upl-transition);
}
.card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.09) !important;
}
.card-hover:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.13) !important;
}

/* ============================================================
   Hero section (full-width, outside .container)
   ============================================================ */
.hero-section {
  position: relative;
  overflow: hidden;
}

/* Text colours on a dark hero background */
.hero-dark-bg,
.hero-dark-bg h1,
.hero-dark-bg h2,
.hero-dark-bg h3,
.hero-dark-bg .lead { color: #fff !important; }
.hero-dark-bg .text-muted { color: rgba(255, 255, 255, 0.72) !important; }

/* Frosted-glass logo container */
.hero-logo-box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 220px;
  height: 220px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 1.25rem;
  padding: 2rem;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  margin: 0 auto;
  overflow: hidden;
}
.hero-logo-img {
  display: block;
  width: 160px;
  height: 160px;
  object-fit: contain;
  filter: drop-shadow(0 4px 18px rgba(0, 0, 0, 0.35));
}

/* ============================================================
   Event date tiles
   ============================================================ */
.event-date-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  width: 52px;
  height: 60px;
  background: var(--upl-teal);
  color: #fff;
  border-radius: 0.5rem;
  text-align: center;
  flex-shrink: 0;
}
.event-date-month {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  line-height: 1;
  padding-top: 6px;
}
.event-date-day {
  font-family: 'Oswald', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
  padding-bottom: 4px;
}

/* ============================================================
   HTMX top-of-page progress bar
   ============================================================ */
#htmx-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0;
  height: 3px;
  background: var(--upl-accent);
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  border-radius: 0 2px 2px 0;
  transition: opacity 0.15s ease, width 0.35s ease;
}
#htmx-progress.htmx-active {
  opacity: 1;
  width: 75%;
}
#htmx-progress.htmx-done {
  width: 100%;
  opacity: 0;
  transition: width 0.15s ease, opacity 0.3s ease 0.1s;
}

/* ============================================================
   Empty states
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: #6c757d;
}
.empty-state .empty-state-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  opacity: 0.45;
}
.empty-state h5 {
  font-family: 'Oswald', sans-serif;
  color: #495057;
  margin-bottom: 0.5rem;
}

/* Tournament bracket tree view */
.bracket-tree-scroll {
  overflow-x: auto;
}
.bracket-tree {
  display: grid;
  grid-auto-flow: column;
  gap: 0.5rem 2rem;
  align-items: start;
  position: relative;
}
.bracket-tree-lines {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  overflow: visible;
}
.bracket-tree-line {
  fill: none;
  stroke: var(--upl-teal, #0d7377);
  stroke-width: 2px;
}
.bracket-tree-col {
  display: grid;
  grid-template-rows: subgrid;
  grid-row: 1 / -1;
}
.bracket-tree-match {
  border: 1px solid var(--upl-teal, #0d7377);
  border-radius: 0.25rem;
  background: #fff;
  min-width: 180px;
  align-self: center;
}
.bracket-tree-entry {
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
}
.bracket-tree-entry:last-child {
  border-bottom: none;
}

/* Always present, so every box carries its match number; the table
   number joins it on the right once one is assigned. */
.bracket-tree-header {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  background: var(--upl-dark, #14213d);
  color: #fff;
}
/* "Winner of Match 12" is a pending slot, not a competitor — keep it
   visually subordinate to a real entrant's name. */
.bracket-tree-placeholder {
  font-style: italic;
  color: #6c757d;
}

/* ============================================================
   Table Assignments — matchup rows & venue grouping
   ============================================================ */
.ta-matchup-table {
  table-layout: fixed;
}
.ta-matchup-col {
  width: 360px;
}
.ta-matchup-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ta-game-slot {
  flex: 0 0 230px;
  min-width: 0;
}
.ta-game-info {
  min-width: 0;
}
.ta-scorekeeper {
  font-size: 0.72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 767.98px) {
  /* Below md: the fixed-width column layout that keeps table
     assignments aligned across desktop venue cards just forces
     horizontal scrolling — collapse each row into a stacked block
     instead, letting matchup names and scorekeepers wrap normally. */
  .ta-matchup-table,
  .ta-matchup-table tbody,
  .ta-matchup-table tr,
  .ta-matchup-table td {
    display: block;
    width: auto !important;
  }
  .ta-matchup-table thead {
    display: none;
  }
  .ta-matchup-table tbody tr {
    padding: 0.75rem 0.9rem;
    border-bottom: 1px solid #eee;
  }
  .ta-matchup-table tbody tr:last-child {
    border-bottom: none;
  }
  .ta-matchup-table td {
    padding: 0.15rem 0;
    border: none;
  }
  .ta-matchup-name {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    margin-bottom: 0.4rem;
  }
  .ta-game-slot {
    flex: 1 1 140px;
  }
  .ta-scorekeeper {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }
}

/* ============================================================
   Operator dashboard primitives
   ============================================================ */
.upl-zone-label {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #4d5769;
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .5rem;
}
.upl-zone-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #d7dce5;
}

.upl-num {
  font-family: 'Oswald', sans-serif;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.upl-lbl { font-size: .72rem; color: #8c95a6; line-height: 1.3; }
.upl-tnum { font-variant-numeric: tabular-nums; }

.upl-meter {
  height: 6px;
  border-radius: 999px;
  background: #d7dce5;
  overflow: hidden;
  display: flex;
  width: 100%;
}
.upl-meter-thin { height: 5px; }
.upl-meter i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--upl-teal);
}
.upl-meter i.warn { background: #a8600a; }
.upl-meter i.crit { background: #b42318; }

.upl-chip {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  font-size: .7rem;
  font-weight: 600;
  border-radius: 999px;
  padding: .125rem .5rem .125rem .375rem;
  white-space: nowrap;
}
.upl-chip-ok      { background: #e3f4ea; color: #1a7f4b; }
.upl-chip-warn    { background: #fdf0dc; color: #a8600a; }
.upl-chip-crit    { background: #fdeceb; color: #b42318; }
.upl-chip-neutral { background: #f4f6f9; color: #5a6478; border: 1px solid #e4e7ec; }
.upl-chip-teal    { background: #e2f0f0; color: var(--upl-teal); }

/* Attention cards carry a severity stripe on their leading edge. */
.upl-attention-card { border-left: 3px solid #e4e7ec; }
.upl-attention-card.crit { border-left-color: #b42318; }
.upl-attention-card.warn { border-left-color: #a8600a; }
.upl-attention-card.info { border-left-color: var(--upl-teal); }

.upl-attention-icon {
  width: 2rem;
  height: 2rem;
  border-radius: .5rem;
  display: grid;
  place-items: center;
  flex: none;
}
.upl-attention-icon.crit { background: #fdeceb; color: #b42318; }
.upl-attention-icon.warn { background: #fdf0dc; color: #a8600a; }
.upl-attention-icon.info { background: #e2f0f0; color: var(--upl-teal); }

/* ============================================================
   Operator dashboard — surface & emphasis
   Scoped to .upl-operator-surface so public pages are untouched.
   ============================================================ */

/* A sunken ground so the white cards read as raised objects. Bleeds past
   the content column's padding so the tint reaches the viewport edges. */
body.upl-operator-page { background: #f1f3f7; }

/* .upl-operator-surface is now purely a scoping hook for the rules below --
   the ground itself is painted on the body so the gutters either side of
   the content column match rather than staying white. */
.upl-operator-surface { padding-bottom: 1.5rem; }

/* Cards sit on the tint, so they need a hairline as well as a shadow —
   shadow alone disappears against a mid-tone ground. */
.upl-operator-surface .card {
  border: 1px solid #e6e9ef;
}

/* Severity stripe. Bootstrap's .border-0 is `border: 0 !important`, which
   beats any plain border-left declaration — so these cards must NOT carry
   .border-0, and the stripe is set here with the base border zeroed. */
.upl-attention-card {
  border: 0;
  border-left: 3px solid #e4e7ec;
}
.upl-operator-surface .upl-attention-card {
  border: 1px solid #e6e9ef;
  border-left-width: 3px;
}
.upl-attention-card.crit { border-left-color: #b42318; }
.upl-attention-card.warn { border-left-color: #a8600a; }
.upl-attention-card.info { border-left-color: var(--upl-teal); }

/* A critical division reads as critical at row level, not just in its chip. */
.upl-row-crit { background: #fdf4f3; }
.upl-row-crit td { background: transparent; }
.upl-row-crit td:first-child { box-shadow: inset 3px 0 0 #b42318; }
/* The rail needs more contrast against the tinted row than against white. */
.upl-row-crit .upl-meter { background: #e8d6d4; }

/* Tonight's match column, tinted with the league's own accent. */
/* Fallback first: a browser without color-mix() gets the fixed teal wash,
   not `var(--upl-teal)` at full strength, which would paint a solid block. */
.upl-today { background: rgba(13, 115, 119, .07); }
@supports (background: color-mix(in srgb, red 50%, white)) {
  .upl-today { background: color-mix(in srgb, var(--upl-teal) 8%, #fff); }
}
.upl-today .upl-lbl { color: var(--upl-teal); font-weight: 600; }

/* Table chrome: quieter header, roomier rows than Bootstrap's default. */
.upl-operator-surface .table > thead th {
  border-bottom: 1px solid #e4e7ec;
  font-weight: 600;
  padding-top: .6rem;
  padding-bottom: .6rem;
}
.upl-operator-surface .table > tbody td { padding-top: .7rem; padding-bottom: .7rem; }
.upl-operator-surface .table > :not(:first-child) { border-top: 0; }

/* Card headers: quieter and tighter than Bootstrap's default, so the band
   labels stay the loudest text on the page. */
.upl-operator-surface .card-header {
  padding: .6rem .9rem;
  font-size: .82rem;
  border-bottom-color: #eef1f5;
}
.upl-operator-surface .card-body { padding: .9rem; }
.upl-operator-surface .upl-zone-label { margin-top: .25rem; }
