/* public/styles.css */
:root, :host {
  /* Brand axis — standplass's own identity. A [data-club="..."] override
     (themes.css) replaces this whole group; it never changes with mode. */
  --brand-primary:       #1b1d22;
  --brand-primary-light: #2a2d33;
  --brand-accent:        #c1272d;
  --brand-accent-dark:   #9c1f24;
  --brand-accent-hover:         rgba(193,39,45,0.07);
  --brand-accent-tint:          rgba(193,39,45,0.10);
  --brand-accent-bg-subtle:     rgba(193,39,45,0.15);
  --brand-accent-badge:         rgba(193,39,45,0.25);
  --brand-accent-border:        rgba(193,39,45,0.23);
  --brand-accent-border-accent: rgba(193,39,45,0.29);
  --brand-accent-glow:          rgba(193,39,45,0.38);
  --brand-accent-border-active: rgba(193,39,45,0.45);
  --brand-accent-border-cta:    rgba(193,39,45,0.50);

  /* Mode axis — light values (default). A [data-mode="dark"] override
     (themes.css) replaces this whole group; brand variables above are
     untouched by it. */
  --radius-card: 14px;
  --radius:       8px;
  --radius-sm:    6px;

  --green: #2d6a4f;
  --white: #ffffff;
  --text:        #1c1f26;
  --text-muted:  #6b6558;

  --surface-page:  #f6f3ea;
  --surface-card:  #fffdf9;
  --surface-dark:  #1b1d22;
  --surface-base:  rgba(27,29,34,0.03);
  --border-faint:  rgba(27,29,34,0.06);
  --border:        rgba(27,29,34,0.10);
  --border-strong: rgba(27,29,34,0.15);
  --surface-hover: rgba(27,29,34,0.05);

  --font-family: 'Inter', system-ui, sans-serif;
  --font-display: 'Space Grotesk', var(--font-family);
  --font-mono: 'JetBrains Mono', 'IBM Plex Mono', monospace;
}

body {
  background: var(--surface-page);
  color: var(--text);
  font-family: var(--font-family);
}

/* WCAG 2.4.1 Bypass Blocks — skip-link visible on focus only */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  background: var(--brand-primary);
  color: var(--white);
  padding: 0.75rem 1.25rem;
  text-decoration: none;
  z-index: 1000;
  border-radius: 0 0 var(--radius-sm) 0;
  font-weight: 600;
}
.skip-link:focus {
  top: 0;
}
/* Programmatic focus (tabindex="-1") on <main> via skip-link or drilldown
   load — must not show a focus outline around the whole page. */
main[tabindex="-1"]:focus {
  outline: none;
}

/* A shadow root has no <body>, so the rule above never reaches an embed —
   the host element carries the same page-level surface/text/font. Matches
   nothing outside a shadow tree, so felt.html/bane.html are unaffected. */
:host {
  display: block;
  background: var(--surface-page);
  color: var(--text);
  font-family: var(--font-family);
}

h1, h2, h3 {
  font-family: var(--font-display);
}

/* ── Shared site header: logo, Resultater dropdown nav, mode toggle ── */
.site-header {
  background: var(--brand-primary);
  padding: 0.75rem 1.5rem;
}
.site-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.site-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  color: var(--white);
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-decoration: none;
}
.site-logo svg { flex-shrink: 0; }
.site-logo:focus-visible,
.nav-dropdown-btn:focus-visible,
.nav-link:focus-visible,
#site-mode-toggle:focus-visible {
  outline: 2px solid var(--brand-accent);
  outline-offset: 2px;
  border-radius: 2px;
}
/* Header nav now holds multiple items (two dropdowns + a plain link) --
   previously just one .nav-dropdown, which relied on the header's own
   flex layout and never needed this itself. */
.site-header-inner nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
/* Below ~720px the header's min-content width exceeds the viewport; let
   the ribbon stack instead of overflowing the page (nowrap above keeps
   each label on one line). */
@media (max-width: 720px) {
  /* Wrapped ribbon: top-align lines so the mode toggle is not centered
     against nav's wrapped height, and let the toggle share the logo's row
     (DOM order stays logo, nav, toggle — `order` affects visual placement
     only). */
  .site-header-inner { flex-wrap: wrap; align-items: flex-start; row-gap: 0.25rem; }
  .site-header-inner nav { flex-wrap: wrap; row-gap: 0.25rem; order: 3; }
  #site-mode-toggle { order: 2; }
}
.nav-dropdown { position: relative; }
.nav-dropdown-btn {
  background: none;
  border: none;
  color: var(--white);
  font: inherit;
  font-size: 0.9375rem;
  cursor: pointer;
  padding: 0.4rem 0.6rem;
  white-space: nowrap;
}
.nav-dropdown-btn:hover { color: var(--brand-accent); }
/* Plain nav item (Terminliste) alongside the dropdowns -- one page, no
   submenu needed. Same look as .nav-dropdown-btn, just an <a>. */
.nav-link {
  color: var(--white);
  font-size: 0.9375rem;
  text-decoration: none;
  padding: 0.4rem 0.6rem;
}
.nav-link:hover { color: var(--brand-accent); }
.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 180px;
  background: var(--surface-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 200;
  padding: 0.25rem 0;
}
.nav-dropdown-menu a {
  display: block;
  padding: 0.5rem 0.875rem;
  color: var(--text);
  text-decoration: none;
  font-size: 0.875rem;
}
.nav-dropdown-menu a:hover { background: var(--surface-hover); color: var(--brand-accent); }
#site-mode-toggle {
  margin-left: auto;
  background: none;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 50%;
  width: 2rem;
  height: 2rem;
  color: var(--white);
  cursor: pointer;
  font-size: 1rem;
}
#site-mode-toggle:hover { border-color: var(--brand-accent); color: var(--brand-accent); }

/* ── Ranking table ────────────────────────────────────────────────── */
.ranking-table {
    width: 100%;
    border-collapse: collapse;
}

.ranking-table th {
    text-align: left;
    padding: 0.5rem 0.875rem;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    background: var(--surface-base);
    border-bottom: 1px solid var(--border-faint);
}
.ranking-table th.ranking-score { text-align: right; }
.ranking-table th.ranking-rank { text-align: center; }

.ranking-table td {
    padding: 0.4375rem 0.875rem;
    border-bottom: 1px solid var(--border-faint);
    color: var(--text-muted);
    font-size: 0.875rem;
}

.ranking-table tbody tr:last-child td { border-bottom: none; }

.ranking-rank {
    font-weight: 700;
    color: var(--brand-primary);
    width: 2rem;
    min-width: 2rem;
    font-size: 0.8125rem;
}

.ranking-score {
    font-weight: 600;
    color: var(--brand-primary);
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.ranking-toggle {
    display: block;
    width: 100%;
    padding: 0.625rem;
    background: none;
    border: none;
    border-top: 1px solid var(--border-faint);
    color: var(--brand-accent-dark);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    font-family: inherit;
    transition: background 0.15s;
}

.ranking-toggle:hover { background: var(--brand-accent-hover); }

.ranking-loading,
.ranking-error,
.ranking-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.ranking-error { color: #c0392b; }

.ranking-full-table {
    margin-top: 1.5rem;
    background: var(--surface-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    overflow-x: auto;
}

.ranking-full-table .ranking-table {
    min-width: 400px;
}

/* ── Links in ranking tables ──────────────────────────── */
.ranking-full-table a,
.ranking-table td a {
    color: var(--brand-primary);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.ranking-full-table a:hover,
.ranking-table td a:hover { color: var(--brand-accent-dark); }

/* Standard screen-reader-only utility: used by terminliste's detail-column
   header, which needs a labeled header cell without visible text. */
.visually-hidden {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ── Terminliste ──────────────────────────────────────── */
.terminliste-row--clickable { cursor: pointer; }
.terminliste-row--clickable:hover td, .terminliste-row--clickable:active td { background: var(--surface-hover); }
.terminliste-detail-col { width: 2.5rem; text-align: center; }
.comp-detail-btn {
    background: none;
    border: 1px solid var(--border-strong);
    border-radius: 50%;
    width: 1.75rem;
    height: 1.75rem;
    color: var(--text-muted);
    cursor: pointer;
}
.comp-detail-btn:hover, .comp-detail-btn:focus-visible { border-color: var(--brand-accent); color: var(--brand-accent); }
.terminliste-sub { display: block; font-size: 0.75rem; color: var(--text-muted); }
.terminliste-date { white-space: nowrap; }
.terminliste-result-cell { text-align: center; }

/* Status row-tinting -- 1 (Godkjent) is the default, no tint. Written with
   [data-mode="dark"] overrides from the start (not a later fix round) --
   see this plan's Global Constraints and STATUS.md's klubb-view gotcha #2
   about --brand-primary-as-text; this uses fixed amber/red instead, same
   choice the source itself made, just re-keyed to this project's own
   [data-mode="dark"] convention instead of [data-theme="dark"]. */
tr[data-status="0"] td { background: rgba(160, 110, 0, 0.07); }
tr[data-status="2"] td, tr[data-status="3"] td { background: rgba(180, 30, 30, 0.07); }
tr[data-status="0"] .comp-detail-btn { border-color: #b45309; color: #b45309; }
tr[data-status="2"] .comp-detail-btn, tr[data-status="3"] .comp-detail-btn { border-color: #b41e1e; color: #b41e1e; }
[data-mode="dark"] tr[data-status="0"] td { background: rgba(250, 200, 80, 0.09); }
[data-mode="dark"] tr[data-status="2"] td, [data-mode="dark"] tr[data-status="3"] td { background: rgba(248, 113, 113, 0.09); }
[data-mode="dark"] tr[data-status="0"] .comp-detail-btn { border-color: #fbbf24; color: #fbbf24; }
[data-mode="dark"] tr[data-status="2"] .comp-detail-btn, [data-mode="dark"] tr[data-status="3"] .comp-detail-btn { border-color: #f87171; color: #f87171; }

/* Column hiding: terminliste uses its OWN semantic classes
   (.terminliste-mobile-hide/.terminliste-tablet-hide), never nth-child --
   deliberately avoiding this session's own .ranking-card[data-comp-id]
   nth-child collision class of bug (a positional rule that accidentally
   also matched a differently-shaped table reusing the same base class). */
@media (max-width: 700px) {
    .terminliste-mobile-hide { display: none; }
}
@media (max-width: 900px) {
    .terminliste-tablet-hide { display: none; }
}

/* Norgesfelt uses its own semantic hide classes for the same documented
   reason terminliste does (see above) -- never nth-child on a shared
   .ranking-card/.ranking-table class. */
@media (max-width: 700px) {
    .norgesfelt-mobile-hide { display: none; }
}
@media (max-width: 900px) {
    .norgesfelt-tablet-hide { display: none; }
}

/* Compact club widget (the embeddable stevner-widget.js replacement) --
   the year-nav button styling mirrors .filter-period-toggle's
   [aria-pressed="true"] pattern: the active state uses var(--text), which
   is already redefined per [data-mode="dark"] in themes.css, so (like
   .filter-period-toggle) it needs no separate dark-mode override rule. */
.terminliste-widget { margin: 0.5rem 0; }
.terminliste-widget-years {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-bottom: 0.75rem;
}
.terminliste-widget-year-btn {
    background: none;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 0.125rem 0.625rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    cursor: pointer;
}
.terminliste-widget-year-btn[aria-current="true"] { color: var(--text); border-color: var(--text); font-weight: 600; }
.terminliste-widget-link { margin-top: 0.75rem; font-size: 0.8125rem; }
.terminliste-widget-link a { color: var(--brand-primary); text-decoration: underline; text-underline-offset: 2px; }
.terminliste-widget-link a:hover { color: var(--brand-accent-dark); }

/* ── Ranking card ─────────────────────────────────────── */
.ranking-grid {
    display: grid;
    /* minmax(0, 1fr), not bare 1fr -- a bare 1fr track's minimum size is
       "auto" (content-based), so a wide card (e.g. a table with a Klubb
       column showing) refuses to shrink below its own min-content width
       and blows the grid out past its container instead. minmax(0, 1fr)
       lets tracks shrink to fit, so the table wraps/compresses within its
       column instead of pushing the next one off-screen. */
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1.5rem;
}

/* Norgesfelt's own cards are far denser (up to 6 columns, needing a
   horizontal scroll) than klubb/nasjonalt's simple 3-column ones, which
   share the base .ranking-grid gap above -- the same 1.5rem costs more
   here than there, so this narrows it specifically rather than shrinking
   the shared rule for pages that don't need it. */
#norgesfelt-cards-wrap { gap: 0.75rem; }

.ranking-card {
    background: var(--surface-card);
    border: 1px solid var(--brand-accent-border-accent);
    border-radius: var(--radius-card);
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    overflow: hidden;
}

.ranking-card-header {
    padding: 0.875rem 1.125rem 0.75rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

/* Same pattern as .ranking-full-table (overflow-x:auto + a floor on the
   table's own width) -- a 2-column card grid gives each card roughly half
   the viewport, which can be narrower than a 6-column table needs even on
   a normal desktop width where .norgesfelt-tablet-hide/-mobile-hide's own
   viewport-width breakpoints don't fire (they react to the *viewport*,
   not the card, so they can't tell a 2-up desktop card apart from a
   comfortably wide one). Scrolling avoids both silent clipping
   (.ranking-card's own overflow:hidden) and forced column/header
   wrapping when the card itself is the constraint, not the viewport. */
.ranking-card-table-wrap { overflow-x: auto; }
.ranking-card-table-wrap .ranking-table { min-width: 400px; }
.ranking-card--collapsed .ranking-card-header {
    border-bottom: none;
}
.ranking-card-title {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--brand-primary);
}
/* ponytail: klubb-page.js only toggles #klubb-grid-wrap's hidden attribute
   (never a wrapper around it), so #klubb-results mirrors that state via
   :has() instead of getting its own hidden flag the JS would need to know
   about. */
#klubb-results:has(#klubb-grid-wrap[hidden]) {
    display: none;
}
/* #klubb-grid-wrap carries .ranking-grid (display: grid), an author rule
   that beats the UA stylesheet's [hidden] { display: none } regardless of
   specificity -- same gotcha already documented for #felt/#bane-person-modal
   above. Needs the same explicit override. */
#klubb-grid-wrap[hidden] {
    display: none;
}
.stevner-card-info {
    flex: 1;
    min-width: 0;
}
.stevner-comp-title-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.stevner-comp-btn {
    display: block;
    background: none;
    border: none;
    padding: 0;
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--brand-primary);
    cursor: pointer;
    text-align: left;
}
.stevner-comp-btn:hover { color: var(--brand-accent); }
.stevner-comp-btn:focus-visible {
    outline: 2px solid var(--brand-accent);
    outline-offset: 2px;
    border-radius: 2px;
}
.stevner-comp-links a {
    display: inline-block;
    margin-left: 0.25rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--brand-primary);
    text-decoration: none;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 0.15rem 0.4rem;
}
.stevner-comp-links a:hover { background: var(--border-faint); }
.stevner-comp-meta {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
}
.stevner-comp-stats {
    display: block;
    margin-top: 0.2rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    opacity: 0.8;
}
.stevner-collapse-btn {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    margin-top: -0.125rem;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.15s, background 0.15s;
}
.stevner-collapse-btn:hover {
    color: var(--brand-accent);
    background: var(--brand-accent-hover);
}
.stevner-collapse-btn:focus-visible {
    outline: 2px solid var(--brand-accent);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}
.stevner-collapse-icon {
    display: block;
    font-size: 1.25rem;
    line-height: 1;
    transition: transform 0.2s ease;
}
.ranking-card--collapsed .stevner-collapse-icon {
    transform: rotate(-90deg);
}
.stevner-overall-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}
.stevner-collapse-all-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.25rem 0.75rem;
    cursor: pointer;
    color: var(--text-muted);
}
.stevner-hide-club-col td:nth-child(3), .stevner-hide-club-col th:nth-child(3) {
    display: none;
}
.stevner-disc-group th {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0.5rem 0.5rem 0.2rem;
    background: var(--surface-base);
    text-align: left;
}

/* ── Ranking filters ──────────────────────────────────── */
.ranking-filters {
    background: var(--surface-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    flex: 1;
    min-width: 150px;
}

.filter-group--narrow { flex: 0 0 110px; min-width: 0; }

.ranking-filters .filter-group { min-width: 135px; }
.ranking-filters .filter-group--narrow { min-width: 0; }

.filter-group--period { flex: 0 0 280px; min-width: 0; }

.filter-period-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.filter-period-toggle {
    background: none;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 0.125rem 0.5rem;
    font-size: 0.6875rem;
    color: var(--text-muted);
    cursor: pointer;
}
.filter-period-toggle[aria-pressed="true"] { color: var(--text); border-color: var(--text); }
.filter-period-input[data-period-mode="periode"] { display: flex; gap: 0.5rem; }
.filter-period-input[hidden] { display: none; }
#nasjonalt-mode-error { color: #c0392b; font-size: 0.8125rem; margin: 0.25rem 0 0; }

@media (max-width: 640px) {
    .filter-group--period { flex: 1 1 100%; }
    .filter-period-input[data-period-mode="periode"] { flex-direction: column; }
}

.filter-group label,
.filter-group > span,
.filter-group .filter-group-label {
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.filter-group select,
.filter-group input[type="text"],
.filter-group input[type="date"],
.filter-group input[type="search"] {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    font-size: 0.875rem;
    color: var(--text);
    background: var(--surface-card);
    font-family: inherit;
    width: 100%;
    /* Without this, width:100% + padding + border (content-box default)
       overflows the flex item by the padding+border amount. Every prior
       text input in this pattern sat inside .autocomplete-wrap (flex:1;
       min-width:0), which never hit this -- norgesfelt's plain Søk field
       is the first bare input[type="text"] in a .filter-group, and it
       overflowed into the next filter field. */
    box-sizing: border-box;
}

.filter-group select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7' viewBox='0 0 12 7'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236c757d' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
    cursor: pointer;
}

.filter-group select:focus,
.filter-group input[type="text"]:focus,
.filter-group input[type="date"]:focus,
.filter-group input[type="search"]:focus {
    outline: 2px solid var(--brand-accent);
    outline-offset: 1px;
    border-color: transparent;
}

.filter-group select:disabled,
.filter-group input[type="text"]:disabled,
.filter-group input[type="date"]:disabled,
.filter-group input[type="search"]:disabled { opacity: 0.5; cursor: default; }

.clear-all-filters-btn {
    align-self: flex-end;
    background: none;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    padding: 0.5rem 0.875rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
    cursor: pointer;
}
.clear-all-filters-btn:hover { border-color: var(--brand-accent); color: var(--text); }

@media (max-width: 700px) {
    .ranking-grid { grid-template-columns: minmax(0, 1fr); }
    .filter-group--narrow { flex: 1; }
}

@media (max-width: 600px) {
    .filter-group:not(.filter-group--narrow) { flex: 1 1 100%; }
    .filter-group { min-width: auto; }
    .autocomplete-list { max-height: 40vh; }

}

/* ── Checkbox dropdown ─────────────────────────────────── */
.checkbox-dropdown { position: relative; }

.checkbox-dropdown-btn {
    width: 100%;
    text-align: left;
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    font-size: 0.875rem;
    color: var(--text);
    background: var(--surface-card)
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7' viewBox='0 0 12 7'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236c757d' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
        no-repeat right 0.75rem center;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.checkbox-dropdown-btn:focus-visible {
    outline: 2px solid var(--brand-accent);
    outline-offset: 1px;
    border-color: transparent;
}
.checkbox-dropdown-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.checkbox-dropdown-panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    min-width: 180px;
    background: var(--surface-card);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 200;
    padding: 0.25rem 0;
}

.checkbox-dropdown-clear-all {
    display: block;
    width: 100%;
    padding: 0.3rem 0.75rem;
    text-align: left;
    font-family: inherit;
    font-size: 0.75rem;
    color: var(--text-muted);
    background: none;
    border: none;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    margin-bottom: 0.125rem;
}
.checkbox-dropdown-clear-all:hover { color: var(--brand-primary); }
.checkbox-dropdown-clear-all:focus-visible { outline: 2px solid var(--brand-accent); outline-offset: -2px; }

.checkbox-dropdown-list {
    list-style: none;
    margin: 0;
    padding: 0.125rem 0;
    max-height: 220px;
    overflow-y: auto;
    /* Without this, an overflow-y other than visible makes the browser
       compute overflow-x as auto too (not visible) per spec -- so any
       overflow on this axis silently became a horizontal scrollbar instead
       of the long option text just wrapping, which the rules below ensure
       it can. */
    overflow-x: hidden;
}
.checkbox-dropdown-list li { padding: 0; }
.checkbox-dropdown-list label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
}
.checkbox-dropdown-list label:hover { background: var(--surface-hover); }
.checkbox-dropdown-list label span {
    min-width: 0;
    overflow-wrap: anywhere;
}
.checkbox-dropdown-list input[type="checkbox"] {
    flex-shrink: 0;
    accent-color: var(--brand-primary);
    width: 1rem;
    height: 1rem;
    cursor: pointer;
}

/* ── Checkbox dropdown - searchable variant ───────────── */
.checkbox-dropdown-search {
    display: block;
    width: 100%;
    padding: 0.4rem 0.75rem;
    border: none;
    border-bottom: 1px solid var(--border);
    font: inherit;
    font-size: 0.875rem;
    color: var(--text);
    background: transparent;
    box-sizing: border-box;
    outline: none;
}
.checkbox-dropdown-search::placeholder { color: var(--text-muted); }
.checkbox-dropdown-search:focus { background: var(--surface-base); }
.checkbox-dropdown-no-results {
    padding: 0.4rem 0.75rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* ── Autocomplete combo ───────────────────────────────── */
.autocomplete-group {
    padding: 0.3rem 0.875rem 0.2rem;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    cursor: default;
    border-bottom: 1px solid var(--border);
    pointer-events: none;
}
.autocomplete-group:hover { background: none; color: var(--text-muted); }

.autocomplete-wrap { position: relative; display: flex; align-items: center; }
.autocomplete-wrap input { flex: 1; min-width: 0; }

.combo-clear {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1;
    padding: 0.2rem 0.35rem;
    border-radius: 4px;
    visibility: hidden;
    pointer-events: none;
}
.combo-clear:hover { color: var(--text); background: var(--surface-hover); }
.autocomplete-wrap--has-value .combo-clear { visibility: visible; pointer-events: auto; }
.autocomplete-wrap--has-value input { text-overflow: ellipsis; }

.autocomplete-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--surface-card);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,0.10);
    list-style: none;
    /* UA default <ul> padding-left (~40px) isn't removed by list-style:none
       alone -- unlike .checkbox-dropdown-list, this was never reset here,
       so every option rendered shifted ~40px right of its own item padding. */
    margin: 0;
    padding: 0;
    max-height: 240px;
    overflow-y: auto;
    z-index: 200;
}

.autocomplete-list li {
    padding: 0.5rem 0.875rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text);
    border-bottom: 1px solid var(--border-faint);
}

.autocomplete-list li:last-child { border-bottom: none; }
.autocomplete-list li:hover,
.autocomplete-list li[aria-selected="true"] { background: var(--brand-accent-tint); color: var(--brand-primary); }

/* ── Tag chips (multi-select combo) ───────────────────── */
.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    list-style: none;
    margin: 0;
    padding: 0;
}
.tag-list:not(:empty) { margin-bottom: 5px; }

.tag-item {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: var(--surface-dark);
    color: #fff;
    border-radius: 4px;
    padding: 2px 4px 2px 8px;
    font-size: 0.8rem;
    white-space: nowrap;
    max-width: 100%;
}
.tag-item > span { overflow: hidden; text-overflow: ellipsis; }

.tag-item-remove {
    flex-shrink: 0;
    background: none;
    border: none;
    color: rgba(255,255,255,0.65);
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
    font-size: 1.1rem;
}
.tag-item-remove:hover { color: #fff; }
.tag-item-remove:focus-visible { outline: 2px solid var(--brand-accent); border-radius: 2px; }

/* ── Program toggle ────────────────────────────────────── */
.program-toggle {
    display: flex;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface-card);
    width: 100%;
}

.program-btn {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: none;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: normal;
    cursor: pointer;
    transition: background 0.18s, color 0.18s;
}

.program-btn:hover:not(.program-btn--active) {
    background: var(--border-faint);
}

.program-btn--active {
    background: var(--surface-dark);
    color: var(--white);
}

/* ── Ranking meta / section / status / blank state ────── */
.ranking-section { background: var(--surface-page); padding: 3rem 1.5rem 5rem; }

.container { max-width: 1100px; margin: 0 auto; }
.section-label { font-size: 0.8125rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--brand-accent); margin: 0 0 0.25rem; }
/* No max-width here (was 60ch) -- roughly half the .container's own
   960px, so a longer intro sentence (e.g. klubb/nasjonalt's attribution
   link) wrapped well before the actual page edge, reading as an awkward
   early cutoff rather than deliberate line-length control. */
.section-lead { color: var(--text-muted); margin: 0.5rem 0 1.5rem; }
/* Without this, the link falls back to the browser's UA default link color,
   including :visited (a dark purple once skyting.no has been visited) --
   unreadable on a dark surface and not something [data-mode="dark"] can
   override since it's not one of this project's own CSS variables. */
.section-lead a, .section-lead a:visited { color: var(--brand-accent); }
.section-lead a:hover { color: var(--brand-accent-dark); }

/* Reuses this repo's existing 700px breakpoint (already used elsewhere in
   this file, e.g. above) rather than porting the source's 900px -- this
   repo already treats 700px as its one tablet/mobile line. */
/* nth-child, not a class on the <th>s: renderRows() emits plain <td>s with no
   per-cell classes, so a class-based rule would hide the headers only and
   misalign every card table. Columns: # / Navn / Klubb / Øvelse / Klasse /
   Poeng / Ranking -- Klubb is 3, Ranking is 7. Coexists with
   .stevner-hide-club-col (JS-toggled, column 3 only); display:none is
   idempotent, so both may apply at once.
   Scoped to [data-comp-id] (stevner-page.js's per-competition cards only,
   the 7-column layout this rule was written for) -- klubb-page.js reuses
   the bare .ranking-card class for its own 3-column (#/Navn/Poeng)
   per-discipline cards, which have no data-comp-id, so an unscoped
   :nth-child(3) rule was hiding klubb's Poeng column on mobile instead. */
@media (max-width: 700px) {
    .ranking-card[data-comp-id] td:nth-child(3), .ranking-card[data-comp-id] th:nth-child(3),
    .ranking-card[data-comp-id] td:nth-child(7), .ranking-card[data-comp-id] th:nth-child(7) { display: none; }
}

.ranking-meta {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.ranking-status-msg {
    margin-top: 1rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    min-height: 1.25rem;
}
/* .ranking-error also sets padding/text-align for its usual card-level empty-state
   context — override those back to a plain inline line here. */
.ranking-status-msg.ranking-error {
    padding: 0;
    text-align: left;
    font-weight: 600;
}

.ranking-blank-state {
    margin-top: 2rem;
    text-align: center;
    padding: 4rem 1.5rem;
    color: var(--text-muted);
    font-size: 0.9375rem;
}

/* ── Filter/toggle spacing ─────────────────────────────── */
/* The source page did this with inline styles on the same elements
   (resultatliste-felt.html:120, 194, 201, 210). */
.ranking-filters { margin-top: 1rem; }
.program-toggle { margin-top: 0.5rem; }
#felt-root > .ranking-table,
#bane-root > .ranking-table { margin-top: 1.5rem; }

/* ── Person link in result tables (style.css:1357-1376) ── */
.stevner-person-btn.link-btn {
    background: none;
    border: none;
    padding: 0;
    color: var(--text);
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
    font: inherit;
    text-align: left;
}
.stevner-person-btn.link-btn:hover {
    color: var(--brand-accent);
    text-decoration-color: var(--brand-accent);
}
.stevner-person-btn.link-btn:focus-visible {
    outline: 2px solid var(--brand-accent);
    outline-offset: 2px;
    border-radius: 2px;
}

/* ── Person modal (style.css:2130-2204) ─────────────────── */
/* The source's modal is a native <dialog>; this repo's is a plain <div>
   toggled with [hidden] (stevner-page.js showModal/closePersonModal), so
   ::backdrop becomes the container's own background and [open] becomes the
   default state. */
.person-modal {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(2px);
}
.person-modal[hidden] { display: none; }

.person-modal-shell {
    display: flex;
    flex-direction: column;
    padding: 0;
    border: none;
    border-radius: var(--radius-card);
    box-shadow: 0 8px 40px rgba(0,0,0,0.25);
    max-width: min(860px, 92vw);
    width: 100%;
    min-height: min(520px, 60dvh);
    max-height: 88dvh;
    overflow: hidden;
    margin: auto;
    background: var(--surface-card);
    color: var(--text);
}

.person-modal-shell .program-toggle {
    flex-shrink: 0;
    width: auto;
}

.person-modal-shell .comp-modal-body {
    overflow-y: auto;
    /* Same overflow-x:auto-by-default gotcha as .checkbox-dropdown-list
       above -- without this, the chart tooltip (absolutely positioned,
       up to 240px wide) gets clipped by this ancestor whenever it
       overflows past the right edge, worst for the rightmost datapoints. */
    overflow-x: hidden;
    padding: 1rem 1.5rem 0;
    flex: 1 1 auto;
}
.person-modal-shell .comp-modal-body::after {
    content: '';
    display: block;
    height: 1.5rem;
}

.comp-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.5rem 0.75rem;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
}

.comp-modal-title {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--brand-primary);
}

.comp-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    padding: 0.125rem 0.375rem;
    cursor: pointer;
    color: var(--text-muted);
    flex-shrink: 0;
    border-radius: 4px;
}
.comp-modal-close:hover { color: var(--brand-primary); }
.comp-modal-close:focus-visible {
    color: var(--brand-primary);
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
}

/* ── Competition-detail modal (native <dialog>) ─ */
/* A native <dialog>'s UA default is background:white/color:black -- unlike
   every other surface in this project, it doesn't inherit the page's mode
   variables from anywhere, so it has to be set explicitly here. */
.comp-modal-dialog {
    max-width: 640px;
    width: 90vw;
    max-height: 85vh;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: 0;
    background: var(--surface-card);
    color: var(--text);
}
.comp-modal-dialog::backdrop { background: rgba(0,0,0,0.4); }
.comp-modal-dialog .program-toggle { margin: 0.75rem 1.5rem 0; width: auto; }
.comp-modal-dialog .comp-modal-body { padding: 0 1.5rem 1.5rem; }
.comp-modal-meta {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--text-muted);
    padding: 0.375rem 1.5rem 0;
    flex-shrink: 0;
}
.comp-modal-infocard {
    background: var(--surface-base);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin: 1rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.9rem;
}
.comp-modal-infocard a { color: var(--brand-primary); }
.comp-modal-infocard-row {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    color: var(--text);
}
.comp-modal-infocard-label {
    font-size: 0.775rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    flex-shrink: 0;
    min-width: 4.5rem;
}
.comp-modal-infocard-row-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.comp-modal-infocard-skyting {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
    font-size: 0.875rem;
}
.comp-modal-badge { display: inline-block; font-size: 0.725rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; padding: 0.15rem 0.5rem; border-radius: 4px; }
.comp-modal-badge--yes { background: rgba(45,106,79,0.12); color: var(--green); border: 1px solid rgba(45,106,79,0.25); }
.comp-modal-badge--no { background: var(--border-faint); color: var(--text-muted); border: 1px solid var(--border-strong); }
.comp-modal-badge--warn { background: rgba(180,30,30,0.08); color: #b41e1e; border: 1px solid rgba(180,30,30,0.2); }
.comp-modal-comp-number { font-size: 0.9rem; font-weight: 600; color: var(--text); }
.comp-modal-description { font-size: 0.9375rem; line-height: 1.6; margin: 0 0 1rem; }
.comp-modal-description p { margin: 0 0 0.75rem; }
.comp-modal-description p:last-child { margin-bottom: 0; }
.comp-modal-section-title { font-size: 0.8125rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin: 1.25rem 0 0.5rem; }
.comp-modal-events-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 1.5rem; }
.comp-modal-events-scroll { padding: 0.5rem 0.875rem 0.625rem; display: flex; flex-direction: column; gap: 0.6rem; }
.comp-modal-disc-name { font-size: 0.875rem; font-weight: 600; color: var(--brand-primary); margin-bottom: 0.2rem; }
.comp-modal-disc-fee { font-size: 0.775rem; font-weight: 400; color: var(--text-muted); margin-left: 0.35rem; }
.comp-modal-class-tags { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.comp-modal-class-tag { display: inline-block; background: var(--surface-card); border: 1px solid var(--border-strong); border-radius: 4px; padding: 0.1rem 0.45rem; font-size: 0.775rem; color: var(--text); }

/* ── Person modal filters (Year/Stevnetype/Øvelse/Klasse) ─ */
.person-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.person-filters .filter-group { flex: 1 1 150px; min-width: 130px; }

/* ── Person chart (style.css:1378-1484) ─────────────────── */
/* Tooltip/legend are wired now (hover/focus/click on .person-chart-dot).
   Positioned absolute within .person-chart-wrap, not fixed against the
   viewport as the source used — this modal is a plain <div>, not a native
   <dialog>, so viewport-relative positioning is unnecessary here. The
   measure-then-clamp step itself is still needed though (see
   wireChartTooltip's `show()` in person-modal.js) -- a wrap-relative
   position still overflows the wrap's own right edge for dots near it.
   The .chart-expand-btn / chart-expand-dialog rules are left out — that
   control isn't rendered here at all. */
.person-chart-wrap { position: relative; }
.person-chart-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.person-chart-dot { cursor: pointer; }
.person-chart-dot:focus-visible {
    outline: 2px solid var(--brand-accent);
    outline-offset: 3px;
}
.chart-tooltip {
    position: absolute;
    background: var(--surface-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.375rem 0.625rem;
    font-size: 0.75rem;
    line-height: 1.45;
    pointer-events: none;
    z-index: 5;
    box-shadow: 0 2px 10px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    max-width: 240px;
}
/* An unconditional `display` on the class has equal specificity to the
   UA's own `[hidden] { display: none }` rule -- author styles win ties over
   UA styles, so without this the tooltip's `hidden` attribute was silently
   ignored and it never actually disappeared once first shown. */
.chart-tooltip[hidden] { display: none; }
.chart-tip-val {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
}
.chart-tip-metric {
    font-size: 0.6875rem;
    font-weight: 400;
    opacity: 0.75;
}
.chart-tip-date { font-weight: 600; color: var(--text); }
.chart-tip-comp { color: var(--text); }
.chart-tip-meta { color: var(--text-muted); font-size: 0.6875rem; }
.chart-tip-row { color: var(--text); font-size: 0.6875rem; }
.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.75rem;
    margin-top: 0.375rem;
    font-size: 0.6875rem;
    color: var(--text-muted);
}
.chart-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}
.chart-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

/* ── Dark-mode text fixes ─────────────────────────────────────────── */
/* --brand-primary is club brand (navy for the kss preset) and by design
   never changes with mode, so every rule that paints text with it needs a
   dark override. Selector is [data-mode="dark"] here, not [data-theme="dark"];
   site-chrome.js always resolves and sets data-mode on every page (including
   when it falls through to the OS preference), so no prefers-color-scheme
   duplicate is needed. */
[data-mode="dark"] .stevner-person-btn.link-btn,
[data-mode="dark"] .stevner-comp-btn,
[data-mode="dark"] .stevner-comp-links a,
[data-mode="dark"] .comp-modal-infocard a,
[data-mode="dark"] .comp-modal-disc-name,
[data-mode="dark"] .comp-modal-title,
[data-mode="dark"] .ranking-card-title,
[data-mode="dark"] .ranking-full-table a,
[data-mode="dark"] .ranking-table td a,
[data-mode="dark"] .terminliste-widget-link a { color: var(--text); }
/* :not(.btn-primary) — .btn-primary paints itself with --brand-accent, which
   is readable in both modes and must not be overridden here. */
[data-mode="dark"] .btn:not(.btn-primary) {
    border-color: var(--text);
    color: var(--text);
}
[data-mode="dark"] .comp-modal-close:hover,
[data-mode="dark"] .comp-modal-close:focus-visible { color: var(--text); }
/* Badge greens/reds are tuned for light backgrounds; dark mode needs the
   brighter tones below to stay readable against a dark card. */
[data-mode="dark"] .comp-modal-badge--yes {
    color: #4ade80;
    background: rgba(74,222,128,0.10);
    border-color: rgba(74,222,128,0.25);
}
[data-mode="dark"] .comp-modal-badge--warn {
    color: #f87171;
    background: rgba(248,113,113,0.10);
    border-color: rgba(248,113,113,0.25);
}
/* The source leaves the focus ring navy in dark mode (an invisible focus
   indicator); recolor it with the text color instead. */
[data-mode="dark"] .comp-modal-close:focus-visible { outline-color: var(--text); }
/* Checkbox tint and autocomplete hover/selected are tuned for light
   backgrounds (near-black accent, near-black text on a red tint) --
   unreadable in dark mode. */
[data-mode="dark"] .checkbox-dropdown-list input[type="checkbox"] { accent-color: var(--brand-accent); }
[data-mode="dark"] .autocomplete-list li:hover,
[data-mode="dark"] .autocomplete-list li[aria-selected="true"] {
    background: var(--brand-accent-bg-subtle);
    color: var(--text);
}
[data-mode="dark"] .ranking-more-btn { border-color: var(--text); color: var(--text); }
[data-mode="dark"] .checkbox-dropdown-clear-all:hover { color: var(--text); }

/* ── Terminliste – Vis flere-knapp ─────────────────────── */
.ranking-more-btn {
    display: block;
    margin: 1.5rem auto 0;
    padding: 0.625rem 1.75rem;
    background: none;
    border: 2px solid var(--brand-primary);
    border-radius: var(--radius);
    color: var(--brand-primary);
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.ranking-more-btn:hover { background: var(--surface-dark); color: var(--white); }
.ranking-more-btn:disabled {
    cursor: default;
    animation: ranking-more-pulse 1.1s ease-in-out infinite;
}
@keyframes ranking-more-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}
@media (prefers-reduced-motion: reduce) {
    .ranking-more-btn:disabled { animation: none; opacity: 0.6; }
}

/* ── Landing page hero ─────────────────────────────────── */
.hero { padding: 4rem 1.5rem; }
.hero-inner { max-width: 1100px; margin: 0 auto; }
.hero-copy h1 {
  font-size: 2.5rem;
  line-height: 1.15;
  margin: 0 0 1rem;
  color: var(--text);
}
.hero-copy p {
  font-size: 1.0625rem;
  color: var(--text-muted);
  max-width: 40ch;
  margin: 0 0 1.5rem;
}
.hero-cta { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.hero-copy .hero-note { font-size: 0.8125rem; color: var(--text-muted); margin: 1.5rem 0 0; max-width: 40ch; }
.btn {
  display: inline-block;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius);
  font-weight: 600;
  text-decoration: none;
  border: 2px solid var(--brand-primary);
  color: var(--brand-primary);
  cursor: pointer;
  /* This class was only ever applied to <a> tags before (no native
     chrome), so no background was needed. A real <button> falls back to
     its UA stylesheet's own background (often white/light regardless of
     page theme) unless one is set explicitly -- invisible in light mode,
     but a white box behind near-unreadable dark-mode text otherwise. */
  background: none;
}
.btn:hover { background: var(--surface-hover); }
.btn-primary {
  background: var(--brand-accent);
  border-color: var(--brand-accent);
  color: var(--white);
}
.btn-primary:hover { background: var(--brand-accent-dark); border-color: var(--brand-accent-dark); }

.embed-snippet {
    margin-top: 0.75rem;
    padding: 0.875rem 1rem;
    background: var(--surface-base);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-all;
}
.embed-snippet:empty { display: none; }

/* ── Club statistics ─────────────────────────────────────────────────── */

.club-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-top: 1rem;
}
@media (max-width: 700px) {
  .club-stats-grid { grid-template-columns: 1fr; }
}

.club-stats-toplist .ranking-table { margin: 0; }
.club-stats-toplist .ranking-toggle { margin: 0.5rem 0 0; }

.club-stats-note {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 0.75rem 0 0;
  line-height: 1.5;
}

.club-stats-note summary { cursor: pointer; }

.apen-disc-tags { display: flex; flex-wrap: wrap; gap: 0.25rem; margin: 0.35rem 0; }
.apen-disc-tag {
  display: inline-block; background: var(--surface-card); border: 1px solid var(--border-strong);
  border-radius: 4px; padding: 0.1rem 0.45rem; font-size: 0.775rem; color: var(--text);
}

.club-stats-back {
  display: inline-block;
  font-size: 0.875rem;
  color: var(--brand-accent);
  text-decoration: none;
  margin-bottom: 0.5rem;
}
.club-stats-back:hover { text-decoration: underline; }

.club-stats-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin: 1rem 0;
}
@media (max-width: 700px) {
  .club-stats-summary { grid-template-columns: repeat(2, 1fr); }
}

.club-stats-summary-card {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.club-stats-summary-value {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}
.club-stats-summary-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.club-stats-section { margin-top: 1rem; }
.club-stats-section .ranking-table { margin: 0; }
.club-stats-section > .ranking-card-header ~ * {
  padding-left: 1.125rem;
  padding-right: 1.125rem;
}

/* Top-3 card placement-mode / øvelser-visibility toggle group */
.top3-mode { display: flex; flex-wrap: wrap; gap: 0.25rem; margin: 0.5rem 0 0; }
.top3-mode-btn {
  background: none; border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text-muted); font: inherit; font-size: 0.8125rem;
  cursor: pointer; padding: 0.2rem 0.6rem;
}
.top3-mode-btn[aria-pressed="true"] {
  background: var(--brand-accent); border-color: var(--brand-accent); color: var(--white);
}

/* Top-3 card: alternate-column shading for the ovelse columns, matching the
   row-header treatment (.ranking-table th / var(--surface-base)). Class-based,
   never nth-child — see the nth-child collision notes above in this file. */
[data-card="top3"] .top3-col-alt { background: var(--surface-base); }

.club-chart-wrap {
  padding: 0.5rem 0;
}
.club-stats-chart-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0.75rem 0 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.club-chart-dot:focus-visible {
  outline: 2px solid var(--brand-accent);
  outline-offset: 2px;
}

/* <details> data-table alternative under the chart — reset browser defaults */
.club-stats-section details {
  border: none;
  padding: 0;
  margin-top: 0.5rem;
}
.club-stats-section details > summary {
  cursor: pointer;
  font-size: 0.8125rem;
  color: var(--text-muted);
  list-style: none;
}
.club-stats-section details > summary::-webkit-details-marker { display: none; }
.club-stats-section details > summary::before { content: '▸ '; }
.club-stats-section details[open] > summary::before { content: '▾ '; }

/* Dark mode fixes — --brand-primary is mode-invariant, needs explicit override */
:root[data-mode="dark"] .club-stats-back,
:host([data-mode="dark"]) .club-stats-back {
  color: var(--brand-accent);
}
:root[data-mode="dark"] .club-stats-summary-value,
:host([data-mode="dark"]) .club-stats-summary-value {
  color: var(--text);
}
