/* RaceTraceTiming site chrome and results tables.
   Every colour comes from shared/css/variables.css — nothing hardcoded here,
   so the palette stays changeable in one place. */

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-family);
  color: var(--gray-700);
  background: var(--white);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { color: var(--gray-900); line-height: 1.15; margin: 0 0 .5em; font-weight: 700; }
h1 { font-size: clamp(1.9rem, 4.5vw, 2.9rem); letter-spacing: -.022em; }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); letter-spacing: -.015em; }
a { color: var(--primary); }

.wrap { max-width: var(--max-width); margin: 0 auto; padding: 0 20px; }
.narrow { max-width: 760px; }

/* ------------------------------------------------------------------ header */

.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--white) 90%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--gray-200);
}
.site-header .wrap { display: flex; align-items: center; gap: 24px; height: 60px; }

.brand {
  display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 1.1rem;
  color: var(--gray-900); text-decoration: none; letter-spacing: -.02em; white-space: nowrap;
}
/* Blue mark on the page's own ground — the same treatment as the app icon and
   the Timer tab, so the glyph reads identically wherever it appears. */
.brand-mark {
  width: 24px; height: 24px; flex: none;
  display: grid; place-items: center; color: var(--primary);
}
.brand-mark svg { width: 24px; height: 24px; display: block; }

.nav { display: flex; gap: 2px; margin-left: auto; align-items: center; }
.nav a {
  color: var(--gray-700); text-decoration: none; font-size: .92rem; font-weight: 500;
  padding: 7px 12px; border-radius: var(--radius);
}
.nav a:hover { background: var(--gray-100); color: var(--gray-900); }
.nav a.active { color: var(--primary); font-weight: 600; }

/* `.nav a` is more specific than `.btn-primary`, so without this the call to
   action in the header inherits the nav's grey and renders unreadable on its
   own background. Restate the button colours at matching specificity. */
.nav a.btn-primary { color: var(--white); background: var(--primary); }
.nav a.btn-primary:hover { background: var(--primary-dark); color: var(--white); }
.nav a.btn-secondary { color: var(--gray-900); }

.nav-toggle {
  display: none; margin-left: auto; background: none; border: 1px solid var(--gray-200);
  border-radius: var(--radius); padding: 7px 10px; cursor: pointer; color: var(--gray-900);
}
@media (max-width: 820px) {
  .nav-toggle { display: block; }
  .nav {
    position: absolute; top: 60px; left: 0; right: 0; flex-direction: column;
    align-items: stretch; gap: 0; background: var(--white);
    border-bottom: 1px solid var(--gray-200); padding: 8px; box-shadow: var(--shadow-lg);
  }
  .nav:not(.open) { display: none; }
  .nav a { padding: 12px; }
  .nav .btn { margin-top: 6px; text-align: center; }
}

/* ----------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius); font-weight: 600; font-size: .94rem;
  text-decoration: none; cursor: pointer; border: 1px solid transparent; font-family: inherit;
  transition: background .15s ease, border-color .15s ease;
}
.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--white); color: var(--gray-900); border-color: var(--gray-300); }
.btn-secondary:hover { border-color: var(--gray-500); }
.btn-lg { padding: 13px 24px; font-size: 1rem; }
.btn-sm { padding: 7px 13px; font-size: .85rem; }
.btn[disabled] { opacity: .45; pointer-events: none; }

/* -------------------------------------------------------------------- hero */

.hero { padding: 64px 0 48px; text-align: center; }
.hero .eyebrow {
  display: inline-block; background: var(--primary-lightest); color: var(--primary-dark);
  font-family: var(--font-mono); font-size: .72rem; font-weight: 600; letter-spacing: .14em;
  text-transform: uppercase; padding: 6px 12px; border-radius: var(--radius-sm); margin-bottom: 18px;
}
.hero .lede { font-size: 1.15rem; max-width: 620px; margin: 0 auto 26px; color: var(--gray-700); }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.code-lookup { display: flex; gap: 8px; max-width: 430px; margin: 30px auto 0; }
.code-lookup input {
  flex: 1; padding: 12px 16px; font-size: 1.05rem; font-family: var(--font-mono);
  text-transform: uppercase; letter-spacing: .14em; text-align: center;
  border: 2px solid var(--gray-200); border-radius: var(--radius);
  background: var(--white); color: var(--gray-900);
}
.code-lookup input:focus { outline: none; border-color: var(--primary); }

/* ------------------------------------------------------------------ layout */

section { padding: 52px 0; }
section.alt { background: var(--gray-50); border-block: 1px solid var(--gray-200); }
.section-head { text-align: center; max-width: 660px; margin: 0 auto 40px; }
.section-head p { color: var(--gray-600); font-size: 1.03rem; }

.grid { display: grid; gap: 18px; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.card {
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg); padding: 24px;
}
.card h3 { display: flex; align-items: center; gap: 10px; font-size: 1.05rem; }
.card p:last-child { margin-bottom: 0; }
.card .icon {
  width: 32px; height: 32px; border-radius: var(--radius-sm); display: grid; place-items: center;
  background: var(--primary-lightest); color: var(--primary); font-size: 1rem; flex: none;
}

/* ------------------------------------------------------------------ tables */

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--gray-200); }
th {
  font-family: var(--font-mono); font-size: .68rem; text-transform: uppercase;
  letter-spacing: .12em; color: var(--gray-500); font-weight: 600; white-space: nowrap;
  position: sticky; top: 0; background: var(--white); z-index: 1;
}
td.num, th.num { text-align: right; }
td.time { white-space: nowrap; color: var(--gray-900); }
tbody tr:hover { background: var(--gray-50); }
.place { font-weight: 700; color: var(--gray-900); }
.place-1, .place-2, .place-3 { color: var(--primary); }

.pill {
  display: inline-block; padding: 2px 8px; border-radius: var(--radius-sm);
  font-family: var(--font-mono); font-size: .66rem; font-weight: 600; letter-spacing: .07em;
}
.pill-ok { background: var(--success-light); color: var(--success-dark); }
.pill-dnf { background: var(--warning-light); color: var(--warning); }
.pill-dns { background: var(--gray-100); color: var(--gray-500); }
.pill-dsq { background: var(--danger-light); color: var(--danger); }
.pill-live { background: var(--danger); color: var(--white); }
.pill-live::before {
  content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--white); margin-right: 5px; vertical-align: middle;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .pill-live::before { animation: none; } }

/* ----------------------------------------------------------------- results */

.results-header { border-bottom: 1px solid var(--gray-200); padding: 24px 0 18px; background: var(--gray-50); }
.results-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.results-meta { color: var(--gray-600); font-size: .9rem; margin-top: 4px; }
.results-meta span + span::before { content: '·'; margin: 0 8px; }

.toolbar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  padding: 14px 0; border-bottom: 1px solid var(--gray-200);
}
.toolbar input[type=search], .toolbar select {
  padding: 8px 12px; border: 1px solid var(--gray-200); border-radius: var(--radius);
  background: var(--white); color: var(--gray-900); font-family: inherit; font-size: .9rem;
}
.toolbar input[type=search] { min-width: 190px; }
.toolbar .spacer { margin-left: auto; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--gray-200); overflow-x: auto; }
.tab {
  padding: 11px 16px; border: none; background: none; cursor: pointer; font-family: inherit;
  font-size: .92rem; font-weight: 600; color: var(--gray-500);
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab:hover { color: var(--gray-900); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.empty { text-align: center; padding: 60px 20px; color: var(--gray-600); }
.empty .big { font-size: 2.4rem; margin-bottom: 12px; }

.skeleton {
  background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-50) 50%, var(--gray-100) 75%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite;
  border-radius: var(--radius-sm); height: 14px;
}
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* ------------------------------------------------------------------ footer */

.site-footer {
  border-top: 1px solid var(--gray-200); background: var(--gray-50);
  padding: 36px 0; margin-top: 56px; font-size: .89rem; color: var(--gray-600);
}
.footer-grid { display: flex; gap: 40px; flex-wrap: wrap; justify-content: space-between; }
.footer-links { display: flex; gap: 26px; flex-wrap: wrap; }
.footer-links a { color: var(--gray-600); text-decoration: none; }
.footer-links a:hover { color: var(--gray-900); }

/* ------------------------------------------------------------------- prose */

.prose { max-width: 720px; }
.prose h2 { margin-top: 1.8em; }
.prose ul { padding-left: 1.3em; }
.prose li { margin-bottom: .4em; }

.faq-item { border-bottom: 1px solid var(--gray-200); padding: 16px 0; }
.faq-item summary {
  cursor: pointer; font-weight: 600; color: var(--gray-900); font-size: 1.01rem;
  list-style: none; display: flex; justify-content: space-between; gap: 16px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: '+'; color: var(--gray-500); font-size: 1.25rem; line-height: 1; }
.faq-item[open] summary::after { content: '\2212'; }
.faq-item p { margin: 10px 0 0; }

.notice {
  background: var(--primary-lightest);
  border: 1px solid var(--primary-light);
  border-radius: var(--radius); padding: 14px 18px; font-size: .92rem; color: var(--gray-800);
}
.error-box {
  background: var(--danger-light); border: 1px solid var(--danger);
  color: var(--danger-dark); border-radius: var(--radius); padding: 14px 18px;
}
