/* World Athletics 2027: styles. Theme: light by default; dark (navy) or grey via [data-theme] or the system setting. */
:root {
  --bg: #fafaf8; --fg: #1c1f22; --muted: #5d656d; --line: #dcdfe2; --head: #eef0f2;
  --warn: #8a5a00; --warn-bg: #fff4d6; --ok: #1d7a3a; --focus: #0b6fb8; --flagedge: rgba(0,0,0,.22);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0e1a2b; --fg: #e8eef7; --muted: #a3b3c9; --line: #26395a; --head: #15263d;
  --warn: #f0c56a; --warn-bg: #332d19; --ok: #4cc26f; --focus: #7ab8ff; --flagedge: rgba(255,255,255,.5);
  color-scheme: dark;
}
/* Grey: a neutral mid-grey theme, chosen explicitly via the toggle -- never picked automatically by the
   system setting (there is no OS "prefers grey"), so it is excluded from the prefers-color-scheme block below. */
:root[data-theme="grey"] {
  --bg: #3a3a3c; --fg: #f2f2f2; --muted: #c7c7ca; --line: #5a5a5e; --head: #47474a;
  --warn: #ffd166; --warn-bg: #4a3c1f; --ok: #8fe3a8; --focus: #9fd0ff; --flagedge: rgba(255,255,255,.4);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="grey"]) {
    --bg: #0e1a2b; --fg: #e8eef7; --muted: #a3b3c9; --line: #26395a; --head: #15263d;
    --warn: #f0c56a; --warn-bg: #332d19; --ok: #4cc26f; --focus: #7ab8ff; --flagedge: rgba(255,255,255,.5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body { margin: 0; padding-bottom: 64px; background: var(--bg); color: var(--fg);
       font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: inherit; }
small { color: var(--muted); }
ul { padding-left: 20px; } li { margin: 3px 0; }
h1 { font-size: 26px; margin: 0; line-height: 1.2; }
h2 { font-size: 18px; margin: 32px 0 8px; }
.page { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

/* Accessibility helpers */
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 8px; top: -60px; z-index: 30; background: var(--fg); color: var(--bg); padding: 8px 12px; border-radius: 4px; }
.skip:focus { top: 8px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Flag strip (waving, drawn by app.js). The title sits below it, on the page background. */
.flagbar { height: 96px; overflow: hidden; }
.titlerow { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 10px 16px; padding: 16px 0 8px; }
#sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; }

/* Buttons and chips */
.btn, .chip, select.chip { font: inherit; font-size: 13px; cursor: pointer; background: var(--head); color: var(--fg);
  border: 1px solid var(--line); border-radius: 18px; padding: 6px 14px; min-height: 32px; }
.btn:hover, .chip:hover { border-color: var(--muted); }
.chip { background: var(--bg); }
.chip[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.chip svg { vertical-align: -2px; margin-right: 6px; }
.chip[aria-pressed="true"] svg { filter: drop-shadow(0 0 0.6px #fff); }

/* Clock */
#clock { display: flex; flex-wrap: wrap; gap: 6px 8px; margin: 2px 0 10px; }
#clock div:last-child { margin-left: auto; }   /* first box on the left edge, last box on the right edge */
#clock div { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 10px; border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; background: var(--head); }
#clock b { font-size: 13px; color: var(--muted); font-weight: 600; }
#clock span { font-size: 15px; font-variant-numeric: tabular-nums; }
.note { background: var(--warn-bg); color: var(--warn); padding: 8px 12px; border-radius: 6px; margin: 0 0 8px; font-size: 14px; }

/* Filters */
details.filters { margin: 0 0 8px; }
details.filters > summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.fgroup { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 8px; }
.fgroup > .lbl { font-size: 13px; font-weight: 600; color: var(--muted); min-width: 72px; }
#count { color: var(--muted); font-size: 13px; margin: 4px 0 10px; }
#count button { font: inherit; color: var(--fg); background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; }

/* Map */
#map { height: 440px; border: 1px solid var(--line); border-radius: 6px; margin: 0 0 8px; background: var(--head); }
.mapmsg { padding: 16px; color: var(--muted); }
.pin { background: none; border: 0; }
.pin svg { display: block; filter: drop-shadow(0 0 1px rgba(0,0,0,.6)); }
.pin.past svg { opacity: .5; }
.marker-cluster-small, .marker-cluster-medium, .marker-cluster-large { background: rgba(28,31,34,.35); }
.marker-cluster div { background: #1c1f22; color: #fff; font-weight: 600; }
.leaflet-popup-content { font: 13px/1.4 system-ui, sans-serif; color: #1c1f22; }
.leaflet-popup-content a { text-decoration: underline; text-underline-offset: 2px; }
:root[data-theme="dark"] .leaflet-tile-pane { filter: brightness(.78) contrast(1.05); }
:root[data-theme="grey"] .leaflet-tile-pane { filter: brightness(.85) contrast(1.02) saturate(.9); }

/* Tables */
.wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; }
table { border-collapse: collapse; width: 100%; min-width: 720px; }
th, td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--head); font-size: 13px; font-weight: 600; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
td.date, td.time { white-space: nowrap; font-variant-numeric: tabular-nums; }
td.loc { color: var(--muted); }
.tba { color: var(--muted); }
tr.mappable { cursor: pointer; }
tr.mappable:hover td { background: var(--head); }
tr.past .v { color: var(--muted); text-decoration: line-through; }   /* only the text values; pills, badges and links stay clear */
.links { display: inline-block; font-size: 13px; }   /* inline-block: not struck through in finished rows */
.links a { text-underline-offset: 2px; }
tr.past .links a { color: var(--fg); }
.linkbtn { font: inherit; font-size: 13px; color: inherit; background: none; border: 0; padding: 0; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 12px; color: #fff; white-space: nowrap; }
.tag svg { vertical-align: -1px; margin-right: 4px; }
.bbadge { display: inline-block; padding: 1px 8px; border: 1px solid currentColor; border-radius: 10px; font-size: 12px; white-space: nowrap; }
.b-listed { color: var(--ok); } .b-uncertain { color: var(--warn); }
.tm { display: block; white-space: nowrap; }
.tm small { display: block; }

/* Where to watch: compact, expandable */
.watch details { border: 1px solid var(--line); border-radius: 6px; margin: 0 0 6px; }
.watch summary { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 9px 12px; cursor: pointer; list-style: none; }
.watch summary::-webkit-details-marker { display: none; }
.watch summary::before { content: "\25B8"; color: var(--muted); }
.watch details[open] summary::before { content: "\25BE"; }
.watch .ws-home { font-weight: 700; }
.watch .ws-status { margin-left: auto; font-size: 13px; }
.watch .ws-body { padding: 0 12px 10px 28px; }
.watch .ws-body p { margin: 4px 0; }
.status-listed { color: var(--ok); } .status-last-season, .status-unknown { color: var(--warn); }

.foot { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
footer { margin-top: 32px; color: var(--muted); font-size: 13px; }

/* Bigger touch targets on touch screens */
@media (pointer: coarse) {
  .btn, .chip, select.chip { min-height: 44px; }
  .links a, .linkbtn { display: inline-block; padding: 12px 8px; }
  .watch summary { min-height: 48px; }
}

/* Phones: rows become stacked cards so nothing is hidden off-screen */
@media (max-width: 640px) {
  .flagbar { height: 72px; }
  #map { height: 300px; }
  h1 { font-size: 22px; }
  .wrap { border: 0; overflow: visible; }
  table.stack { min-width: 0; }
  .stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .stack, .stack tbody, .stack tr, .stack td, .stack caption { display: block; width: 100%; }
  .stack tr { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 8px; padding: 8px 10px; }
  .stack td { border: 0; padding: 2px 0; display: flex; gap: 10px; align-items: flex-start; }
  .stack td::before { content: attr(data-label); flex: 0 0 84px; color: var(--muted); font-size: 13px; font-weight: 600; padding-top: 2px; }
  .stack td.race::before, .stack td.date::before { display: none; }
  .stack td.race { font-weight: 600; display: block; }
  .stack td.date { color: var(--muted); }
  .stack tr:last-child td { border: 0; }
}
