/* ══════════════════════════════════════════════════════
   MLB STANDINGS · STYLESHEET
   Aesthetic: Editorial sports scorecard, light mode
   Fonts: Barlow Condensed (display) · JetBrains Mono (data)
   ══════════════════════════════════════════════════════ */

:root {
  --bg:           #EEE9DF;
  --card:         #FFFFFF;
  --navy:         #002554;
  --navy-mid:     #0A3A7C;
  --red:          #BA0C2F;
  --text:         #111827;
  --text-mid:     #374151;
  --text-muted:   #6B7280;
  --border:       #D8D1C5;
  --border-light: #EAE4D9;
  --stripe:       #F7F4EF;
  --al-accent:    #002554;
  --nl-accent:    #BA0C2F;
  --win-green:    #15803D;
  --loss-red:     #B91C1C;
  --gold:         #B45309;
  --shadow-xs:    0 1px 2px rgba(0,0,0,0.06);
  --shadow-sm:    0 1px 4px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md:    0 4px 16px rgba(0,0,0,0.09), 0 2px 6px rgba(0,0,0,0.06);
  --radius:       8px;
  --transition:   0.15s ease;
}

/* ── RESET ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  font-family: 'Barlow', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden; /* prevent horizontal scroll during swipe animations */
}

/* ── HEADER ─────────────────────────────────────────── */
.site-header {
  background: var(--navy);
  color: #fff;
  position: relative;
  overflow: hidden;
}

/* diagonal pinstripe texture */
.site-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    -55deg,
    transparent,
    transparent 18px,
    rgba(255,255,255,0.025) 18px,
    rgba(255,255,255,0.025) 19px
  );
  pointer-events: none;
}

/* red bottom accent line */
.site-header::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: var(--red);
}

.header-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 20px 24px 18px;
  position: relative;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-ball {
  font-size: 2.2rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.brand-year {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 0.65rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--red);
  background: rgba(186,12,47,0.18);
  padding: 2px 7px 1px;
  border-radius: 2px;
  display: inline-block;
  width: fit-content;
}

h1 {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 900;
  font-size: 2.1rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1;
  color: #fff;
}

.header-subtitle {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.45);
  margin-top: 6px;
}

/* ── DATE NAVIGATION ────────────────────────────────── */
.date-nav-wrapper {
  background: #fff;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 200;
}

.date-nav {
  max-width: 1240px;
  margin: 0 auto;
  padding: 10px 20px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 58px;
}

.date-nav .nav-arrow:first-of-type {
  position: absolute;
  left: 20px;
}

.date-nav .nav-arrow:last-of-type {
  position: absolute;
  right: 20px;
}

.nav-arrow {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-mid);
  transition: all var(--transition);
  flex-shrink: 0;
}
.nav-arrow:hover:not(:disabled) {
  border-color: var(--navy);
  background: var(--navy);
  color: #fff;
  transform: scale(1.05);
}
.nav-arrow:active:not(:disabled) { transform: scale(0.95); }
.nav-arrow:disabled { opacity: 0.28; cursor: not-allowed; pointer-events: none; }
.nav-arrow svg { width: 15px; height: 15px; }

.date-display { position: relative; }

.date-label {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 7px 14px;
  border-radius: 6px;
  transition: background var(--transition);
}
.date-label:hover { background: var(--stripe); }

.date-badge {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  background: var(--red);
  color: #fff;
  padding: 2px 7px 1px;
  border-radius: 3px;
}

#date-text {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.03em;
  color: var(--text);
}

.calendar-icon {
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.hidden-datepicker {
  /* Overlaid on top of the date-label button so iOS Safari receives a
     real tap on the native <input type="date"> element — no JS .click()
     or .showPicker() needed, which are unreliable on iOS. */
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 10;
  /* Keep the browser's native date-picker styling from leaking through */
  -webkit-appearance: none;
  appearance: none;
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
}

.swipe-hint {
  text-align: center;
  font-size: 0.65rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0 0 7px;
  display: none;
}

/* ── MAIN ───────────────────────────────────────────── */
.standings-main {
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 20px 20px;
  flex: 1;
}

/* ── STATES ─────────────────────────────────────────── */
.loading-state,
.error-state,
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  gap: 12px;
  text-align: center;
}

.loading-spinner {
  width: 34px;
  height: 34px;
  border: 2.5px solid var(--border);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-state p { color: var(--text-muted); font-size: 0.9rem; letter-spacing: 0.05em; }

.error-icon, .empty-icon { font-size: 2.5rem; }
.error-title, .empty-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: 0.05em;
  color: var(--text);
}
.error-sub, .empty-sub { color: var(--text-muted); font-size: 0.88rem; }

.retry-btn {
  margin-top: 8px;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 9px 22px;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background var(--transition);
}
.retry-btn:hover { background: var(--navy-mid); }

/* ── STANDINGS GRID ─────────────────────────────────── */
.standings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  align-items: start;
}

/* ── LEAGUE SECTION ─────────────────────────────────── */
.league-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.league-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 2px;
}

.league-stripe {
  display: block;
  width: 4px;
  height: 22px;
  border-radius: 2px;
  flex-shrink: 0;
}
.al-stripe { background: var(--al-accent); }
.nl-stripe { background: var(--nl-accent); }

.league-name {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 800;
  font-size: 0.8rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ── DIVISION CARD ──────────────────────────────────── */
.division-card {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  animation: slideUp 0.28s ease both;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.division-title {
  background: var(--navy);
  color: #fff;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 9px 14px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.division-title-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255,255,255,0.35);
  flex-shrink: 0;
}

/* ── STANDINGS TABLE ────────────────────────────────── */
.standings-table {
  width: 100%;
  border-collapse: collapse;
}

.standings-table thead tr {
  background: var(--stripe);
  border-bottom: 1px solid var(--border);
}

.standings-table thead th {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 0.67rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 7px 9px 6px;
  text-align: right;
  white-space: nowrap;
}
.standings-table thead th.col-team { text-align: left; padding-left: 14px; }

.standings-table tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
}
.standings-table tbody tr:last-child { border-bottom: none; }
.standings-table tbody tr:hover { background: var(--stripe); }

/* Leader row – subtle left accent */
.standings-table tbody tr.row-leader td.col-team {
  font-weight: 600;
  border-left: 3px solid var(--gold);
  padding-left: 11px;
}

.standings-table td {
  padding: 9px 9px 8px;
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.77rem;
  color: var(--text-mid);
  white-space: nowrap;
}

.standings-table td.col-team {
  text-align: left;
  padding-left: 14px;
  font-family: 'Barlow', sans-serif;
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--text);
}

.team-rank {
  display: inline-block;
  min-width: 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-right: 6px;
}

.clinch-badge {
  display: inline-block;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 0.6rem;
  letter-spacing: 0.05em;
  background: var(--gold);
  color: #fff;
  padding: 1px 5px;
  border-radius: 2px;
  margin-left: 5px;
  vertical-align: middle;
  position: relative;
  top: -1px;
}

.streak-w { color: var(--win-green);  font-weight: 600; }
.streak-l { color: var(--loss-red);   font-weight: 600; }
.streak-dash { color: var(--text-muted); }

/* W column bold, L column slightly muted */
.standings-table td.col-w { font-weight: 600; color: var(--text); }
.standings-table td.col-l { color: var(--text-mid); }

/* ── TRANSITION FADE ────────────────────────────────── */
.standings-grid.is-loading {
  opacity: 0.45;
  pointer-events: none;
  transition: opacity 0.15s;
}

/* ── FOOTER ─────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 20px 24px;
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  border-top: 1px solid var(--border);
  margin-top: auto;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.footer-dot { color: var(--border); }

/* ══════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════ */

/* Tablet */
@media (max-width: 960px) {
  .standings-grid { grid-template-columns: 1fr; gap: 20px; }
  h1 { font-size: 1.7rem; }
  .header-subtitle { display: none; }
}

/* Mobile */
@media (max-width: 600px) {
  .swipe-hint { display: block; }

  .standings-main { padding: 16px 10px 16px; }

  h1 { font-size: 1.4rem; }
  .brand-ball { font-size: 1.6rem; }

  .date-nav { gap: 8px; padding: 8px 12px; }
  #date-text { font-size: 1rem; }

  /* Hide L10 + Home + Away on small screens */
  .col-home,
  .col-away,
  .col-l10 { display: none; }

  .standings-table td,
  .standings-table thead th { padding: 8px 6px 7px; }

  .standings-table td.col-team,
  .standings-table thead th.col-team { padding-left: 10px; }

  .standings-table tbody tr.row-leader td.col-team { padding-left: 7px; }

  .division-card { border-radius: 6px; }
}

/* Very small mobile */
@media (max-width: 380px) {
  .col-strk { display: none; }
  .standings-table td.col-team { font-size: 0.8rem; }
  .team-rank { display: none; }
}
