/*
 * GoRaceCrew Phase 3 / Batch A — semantic foundation
 * Loaded once AFTER the legacy /test/app/design-system.css to establish stable
 * component roles while the large legacy stylesheet is retired in batches.
 * Never add one-off screen overrides here. All declarations should define
 * tokens or reusable component anatomy. Do not edit MapLibre vendor styles.
 *
 * Visual source of truth: test/reviews/PHASE-2-DESIGN-SYSTEM-SPEC.md
 */
:root {
  color-scheme: dark;
  /* Neutral Apple-style grouped surfaces; not direct UIKit UIColor bindings */
  --canvas: #000000;
  --surface-card: #1c1c1e;
  --surface-raised: #2c2c2e;
  --surface-higher: #3a3a3c;
  --text-primary: #ffffff;
  --text-secondary: #aeaeb2;
  --accent: #2f54eb;
  --on-accent: #ffffff;
  --action-link: #0a84ff;
  --success: #30d158;
  --semantic-divider: #38383a;
  --focus-ring: #0a84ff;
  --sheet-surface: #1c1c1e;
  --sheet-card-surface: #2c2c2e;
  --floating-surface: rgba(28,28,30,.97);
  --shadow-raised: 0 8px 26px rgba(0,0,0,.28);
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --page-gutter: 18px;
  --small-gap: var(--space-2);
  --card-gap: var(--space-3);
  --section-gap: var(--space-5);
  --card-padding: var(--space-4);
  --control-min-size: 44px;
  --radius-card: 20px;
  --radius-action: 999px;
  /* Compatibility aliases for the existing CSS. Screen rules migrate by batch. */
  --bg: var(--canvas);
  --surface: var(--surface-card);
  --surface2: var(--surface-raised);
  --field: var(--surface-raised);
  --text: var(--text-primary);
  --muted: var(--text-secondary);
  --blue: var(--accent);
  --link: var(--action-link);
  --green: var(--success);
  --line: var(--semantic-divider);
  --soft: var(--surface-card);
  --soft-line: var(--semantic-divider);
}
:root[data-appearance="light"] {
  color-scheme: light;
  --canvas: #f2f2f7;
  --surface-card: #ffffff;
  --surface-raised: #e5e5ea;
  --surface-higher: #d1d1d6;
  --text-primary: #000000;
  --text-secondary: #636366;
  --action-link: #007aff;
  --success: #248a3d;
  --semantic-divider: #d1d1d6;
  --focus-ring: #007aff;
  --sheet-surface: #f2f2f7;
  --sheet-card-surface: #ffffff;
  --floating-surface: rgba(255,255,255,.97);
  --shadow-raised: 0 8px 26px rgba(30,30,40,.13);
  --field: #ffffff;
}
/* Surfaces: the system separates content through color and rhythm, not
 * decorative outlines. Existing intentional dividers/focus require migration
 * before the legacy border-suppression rule can safely be removed. */
html, body { background: var(--canvas); color: var(--text-primary); }
#app.app-shell { background: var(--canvas); }
#app .appbar { background: var(--canvas); }
#app.app-shell:not(.map-page) .app-content {
  padding-inline: var(--page-gutter);
}
#app .card, #app .event-card, #app .home-page .next-card {
  background: var(--surface-card);
  border-color: transparent;
  border-radius: var(--radius-card);
}
#app.app-shell:not(.map-page) .card {
  padding: var(--card-padding);
  margin-bottom: var(--card-gap);
}
#app.app-shell:not(.map-page) .card.row-group {
  padding: 0 14px;
}
#dialog-root .sheet {
  background: var(--sheet-surface);
  border-color: transparent;
}
#dialog-root .sheet .card {
  background: var(--sheet-card-surface);
  border-color: transparent;
  border-radius: var(--radius-card);
}
#app .nav {
  background: var(--floating-surface);
  border-color: transparent;
  box-shadow: var(--shadow-raised);
}
#app .nav button[aria-current="page"] {
  background: var(--surface-higher);
}
:root[data-appearance="light"] #app .nav button[aria-current="page"] {
  background: var(--surface-raised);
}
#app .nav button.add-nav {
  background: var(--accent);
  color: var(--on-accent);
}
#app .primary, #dialog-root .primary {
  background: var(--accent);
  color: var(--on-accent);
  border-color: transparent;
  font-weight: 600;
}
#app .secondary, #dialog-root .secondary {
  background: var(--surface-raised);
  color: var(--text-primary);
  border-color: transparent;
}
:root[data-appearance="light"] #app .secondary,
:root[data-appearance="light"] #dialog-root .secondary {
  background: var(--surface-card);
}
#app .quiet, #dialog-root .quiet,
#app .text-btn, #dialog-root .text-btn {
  color: var(--action-link);
}
#app .icon-btn, #dialog-root .icon-btn {
  display: grid;
  place-items: center;
  background: var(--surface-raised);
  color: var(--text-primary);
  border-color: transparent;
}
:root[data-appearance="light"] #app .icon-btn,
:root[data-appearance="light"] #dialog-root .icon-btn {
  background: var(--surface-card);
}
#app .pill-btn, #dialog-root .pill-btn {
  background: var(--surface-raised);
  color: var(--text-primary);
  border-color: transparent;
}
#app .race-quick-actions button {
  background: var(--surface-card);
  color: var(--text-primary);
  border-color: transparent;
}
#app button:focus-visible, #app a:focus-visible,
#app input:focus-visible, #app select:focus-visible,
#dialog-root button:focus-visible, #dialog-root a:focus-visible,
#dialog-root input:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}
/* Shared semantic anatomy for new Batch B/C components. No screen patches. */
.ds-stack { display: flex; flex-direction: column; gap: var(--space-3); }
.ds-cluster { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); }
.ds-action { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: var(--control-min-size); padding: 10px var(--space-4); border-radius: var(--radius-action); font-weight: 600; }
.ds-action--primary { background: var(--accent); color: var(--on-accent); }
.ds-action--secondary { background: var(--surface-raised); color: var(--text-primary); }
.ds-selection { display: flex; align-items: center; gap: var(--space-3); min-height: 52px; padding: var(--space-3) var(--space-4); border-radius: 16px; background: var(--surface-card); color: var(--text-primary); }
.ds-selection .ds-selection__end { margin-inline-start: auto; }
.ds-empty { color: var(--text-secondary); font-size: 14px; line-height: 1.5; }
.ds-icon { display: block; flex: none; width: 24px; height: 24px; object-fit: contain; }
.ds-icon--sm { width: 20px; height: 20px; }
.ds-icon--lg { width: 32px; height: 32px; }
.ds-status--saved { color: var(--success); }
.ds-event--ended { opacity: .7; }
