/* Global shell and shared structural primitives. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
}

body {
  min-height: 100vh;
  min-height: 100svh;
  font-family: var(--body);
  font-size: 15px;
  color: var(--text);
  background: radial-gradient(circle at 8% -10%, #f4f7fc 0%, var(--bg) 38%, var(--bg) 100%);
  line-height: 1.5;
}

html[data-theme='dark'] body {
  background-color: #141d2c;
  background-image: none;
}

html[data-theme='dark'] {
  background-color: #141d2c;
}

.ambient {
  display: none;
}

[hidden] {
  display: none !important;
}

.back-to-top {
  position: fixed;
  right: 1.05rem;
  bottom: 1.05rem;
  z-index: 280;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent) 36%, var(--border));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  color: var(--accent-strong);
  font-family: var(--mono);
  font-size: 0.92rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease, border-color 0.16s ease, background-color 0.16s ease;
}

.back-to-top--visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.back-to-top:hover {
  border-color: var(--accent-strong);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}

.app {
  width: min(1040px, calc(100vw - 2rem));
  margin: 0 auto;
  padding: 1.35rem 0 3rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}

.hero {
  padding: 1rem 1.15rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem;
  border-top: 2px solid var(--accent);
}

.hero-main {
  min-width: 0;
}

.hero--minimal h1 {
  margin: 0;
  font-size: clamp(1.35rem, 3.2vw, 2rem);
}

.hero-minimal-subtitle {
  margin: 0.12rem 0 0;
  font-size: 0.74rem;
  color: var(--muted);
}

.hero-controls {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-left: auto;
  flex-shrink: 0;
}

.hero-updated {
  display: grid;
  justify-items: end;
  gap: 0.08rem;
}

.hero-updated-label {
  font-family: var(--mono);
  font-size: 0.58rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-updated-value {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--text-soft);
}

.theme-switch-wrap {
  line-height: 0;
}

.eyebrow {
  margin: 0 0 0.3rem;
  font-family: var(--mono);
  font-size: 0.67rem;
  color: var(--accent-strong);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.55rem, 3.6vw, 2.4rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
}

.meta {
  display: grid;
  gap: 0.2rem;
  min-width: 165px;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.meta-label {
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

.meta strong {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--text-soft);
}

.stats {
  margin-top: 0.75rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
}

.stat {
  padding: 0.9rem 0.95rem;
  border-radius: var(--r-md);
  display: grid;
  gap: 0.28rem;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

.stat:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.stat-label {
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stat-value {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.65rem;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--text);
}

.stat-value--small {
  display: grid;
  gap: 0.22rem;
  font-size: 0.87rem;
  line-height: 1.35;
}

.next-race-name {
  font-weight: 600;
  color: var(--text);
}

.next-race-date {
  font-family: var(--mono);
  font-size: 0.64rem;
  color: var(--muted);
}

.next-race-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.next-distance-tag {
  font-size: 0.58rem;
  padding: 0.1rem 0.34rem;
}

.next-distance-more {
  font-family: var(--mono);
  font-size: 0.58rem;
  color: var(--muted);
}
