/* === Site header === */
.site-header {
  background: color-mix(in srgb, var(--color-surface) 90%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

@supports not (backdrop-filter: blur(12px)) {
  .site-header {
    background: var(--color-surface);
  }
}

.site-header__inner {
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: 0 20px;
  height: var(--nav-height);
  display: flex;
  align-items: center;
  gap: 20px;
}

/* The .wm utility supplies font, weight, sizing, letter-spacing, and the
   CSS-drawn dot. .site-header__brand only adds layout + min-touch height. */
.site-header__brand {
  display: inline-flex;
  align-items: baseline;
  min-height: var(--hit-touch);
  color: var(--color-text);
  white-space: nowrap;
}

.site-header__controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

/* === Per-theme team logos (WVIZ-202) ===
   Teams may ship optional logo_dark / logo_light overrides, rendered as
   two <img> tags by team_logo_tag. A single pair of rules toggles
   visibility for every site in the codebase. */
[data-theme="dark"]  .team-logo--light { display: none; }
[data-theme="light"] .team-logo--dark  { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .team-logo--light { display: none; }
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .team-logo--dark { display: none; }
}

/* === Per-theme competition logos (WVIZ-232) ===
   Same contract as team logos but for competition crests. Generator emits
   logo_url_dark / logo_url_light alongside the default logo_url; templates
   render the dual <img> pair when both variants are present. */
[data-theme="dark"]  .comp-logo--light { display: none; }
[data-theme="light"] .comp-logo--dark  { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .comp-logo--light { display: none; }
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .comp-logo--dark { display: none; }
}

/* === Theme toggle === */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface-raised);
  color: var(--color-text-muted);
  cursor: pointer;
}

.theme-toggle:hover {
  color: var(--color-text);
  border-color: var(--color-text-muted);
}

/* Icon visibility: dark=sun, light=moon, system=monitor */
.theme-toggle__icon--dark { display: none; }
.theme-toggle__icon--light { display: none; }
.theme-toggle__icon--system { display: block; }

[data-theme="dark"] .theme-toggle__icon--dark { display: block; }
[data-theme="dark"] .theme-toggle__icon--light { display: none; }
[data-theme="dark"] .theme-toggle__icon--system { display: none; }

[data-theme="light"] .theme-toggle__icon--dark { display: none; }
[data-theme="light"] .theme-toggle__icon--light { display: block; }
[data-theme="light"] .theme-toggle__icon--system { display: none; }

/* === Breadcrumbs === */
.index-breadcrumb {
  font-size: 12px;
  color: var(--color-text-faint);
  border-bottom: 1px solid var(--color-border);
  background: color-mix(in srgb, var(--color-surface) 50%, var(--color-bg));
}

.index-breadcrumb__inner {
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: 12px 20px;
}

.index-breadcrumb a {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  color: var(--color-text-muted);
  text-decoration: underline;
}

.index-breadcrumb__separator {
  color: var(--color-text-faint);
  margin: 0 6px;
}

.index-breadcrumb--alt {
  font-size: 11px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
}

.index-breadcrumb--alt .index-breadcrumb__inner {
  padding: 6px 20px;
}

/* Override inherited .index-breadcrumb a (underline + muted). Touch-target
   safety: WCAG 2.2 SC 2.5.8 minimum 24x24, even when the crumb label is a
   single short token (e.g. country name). */
.index-breadcrumb--alt a {
  color: var(--color-text-faint);
  text-decoration: none;
  border-bottom: 1px dotted var(--color-text-faint);
  min-width: 24px;
  padding: 0 4px;
  justify-content: center;
}

/* :hover rules grouped at the bottom so source order matches the specificity
   ladder (no-descending-specificity stylelint rule). */
.index-breadcrumb a:hover {
  color: var(--color-text);
}

.index-breadcrumb--alt a:hover {
  color: var(--color-text-muted);
  border-bottom-color: var(--color-text-muted);
}

.index-breadcrumb__alt-label {
  color: var(--color-text-faint);
  font-style: italic;
  margin-right: 8px;
}

/* === Viz controls bar === */
.page-context {
  max-width: var(--content-max-width);
  margin: 16px auto 0;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* === Team selector (details/summary dropdown) === */
.team-selector {
  position: relative;
}

.team-selector__current {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-raised);
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
  list-style: none;
}

.team-selector__current::-webkit-details-marker { display: none; }

.team-selector__current::after {
  content: '';
  border: 4px solid transparent;
  border-top-color: var(--color-text-muted);
  margin-left: 4px;
  margin-top: 3px;
}

.team-selector[open] .team-selector__current::after {
  border-top-color: transparent;
  border-bottom-color: var(--color-text-muted);
  margin-top: -3px;
}

.team-selector__logo {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.team-selector__dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 4px;
  list-style: none;
  min-width: 260px;
  max-height: 70vh;
  overflow-y: auto;
  z-index: 200;
  box-shadow: 0 8px 24px rgb(0 0 0 / 40%);
}

.team-selector__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 14px;
  color: var(--color-text-muted);
  transition: background 0.1s, color 0.1s;
}

.team-selector__item:hover {
  background: var(--color-border);
  color: var(--color-text);
}

.team-selector__item--active {
  color: var(--color-text);
  font-weight: 600;
}

.team-selector__item--all {
  border-bottom: 1px solid var(--color-border);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
}

.team-selector__item-logo {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

/* === Competition selector (details/summary dropdown, mirrors team-selector) === */
.comp-selector {
  position: relative;
}

.comp-selector__current {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-raised);
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
  list-style: none;
}

.comp-selector__current::-webkit-details-marker { display: none; }

.comp-selector__current::after {
  content: '';
  border: 4px solid transparent;
  border-top-color: var(--color-text-muted);
  margin-left: 4px;
  margin-top: 3px;
}

.comp-selector[open] .comp-selector__current::after {
  border-top-color: transparent;
  border-bottom-color: var(--color-text-muted);
  margin-top: -3px;
}

.comp-selector__logo {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.comp-selector__dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 4px;
  list-style: none;
  min-width: 260px;
  max-height: 70vh;
  overflow-y: auto;
  z-index: 200;
  box-shadow: 0 8px 24px rgb(0 0 0 / 40%);
}

.comp-selector__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 14px;
  color: var(--color-text-muted);
  transition: background 0.1s, color 0.1s;
}

.comp-selector__item:hover {
  background: var(--color-border);
  color: var(--color-text);
}

.comp-selector__item--active {
  color: var(--color-text);
  font-weight: 600;
}

.comp-selector__item--all {
  border-bottom: 1px solid var(--color-border);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
}

.comp-selector__item-logo {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

/* === Timezone selector === */
.tz-selector {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 0.85rem;
  cursor: pointer;
}

.tz-selector:focus {
  outline: 2px solid var(--color-home);
  outline-offset: 1px;
}

/* === Viz type nav === */
.viz-nav {
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  border-bottom: 1px solid var(--color-border);
}

@media (width <= 480px) {
  .viz-nav__link {
    padding: 8px 10px;
    font-size: 12px;
  }
}

.viz-nav__link {
  display: block;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.viz-nav__link:hover {
  color: var(--color-text);
}

.viz-nav__link--active {
  color: var(--color-text);
  font-weight: 600;
  border-bottom-color: var(--color-home);
}

.viz-nav__link--disabled {
  color: var(--color-text-faint);
  cursor: not-allowed;
  opacity: 0.5;
}

/* === Viz page header (shared by every viz: timeline, match grid, day-of-
   week, monthly, standings, race-for-the-shield). One source of truth
   for the crest + title + subtitle treatment so they cannot drift. */
.viz-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-5);
  margin-bottom: var(--space-5);
}

.viz-header__crest {
  width: 80px;
  height: 80px;
  object-fit: contain;
  flex-shrink: 0;
}

.viz-header__text {
  display: flex;
  flex-direction: column;
}

.viz-header__title {
  font-family: var(--font-display);
  font-size: var(--fs-h1);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-display);
  color: var(--color-text);
  margin-bottom: var(--space-1);
}

.viz-header__subtitle {
  font-size: var(--fs-body);
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}

/* === Viz summary cards (shared) === */
.viz-summary {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-2);
}

.viz-summary__card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 10px var(--space-4);
  text-align: center;
  flex: 1;
  min-width: 120px;
}

.viz-summary__value {
  font-family: var(--font-display);
  font-size: var(--fs-h2);
  font-weight: var(--fw-bold);
  font-variant-numeric: tabular-nums;
  color: var(--color-text);
}

.viz-summary__value--home    { color: var(--color-home-on-surface); }
.viz-summary__value--away    { color: var(--color-away-on-surface); }
.viz-summary__value--neutral { color: var(--color-text); }

.viz-summary__label {
  font-size: var(--fs-caption);
  color: var(--color-text-muted);
}
