/* =========================================================
   formula.bessonic.ru — design tokens
   Direction: editorial motorsport / broadcast graphics.
   Black canvas + white content bands + red as the single,
   disciplined accent (numbers, links, active states only).
   Signature motif: thin checkered-flag divider between bands.
   ========================================================= */

:root {
  color-scheme: dark;

  /* Canvas (dark bands) */
  --bg: #0a0a0a;
  --surface-1: #121212;
  --surface-2: #181818;
  --surface-elevated: #1f1f1f;
  --border-dark: rgba(255, 255, 255, 0.1);

  /* Canvas (light bands) */
  --bg-light: #ffffff;
  --surface-light-2: #f4f4f4;
  --border-light: rgba(10, 10, 10, 0.12);

  /* Text on dark */
  --text-on-dark: #f5f5f5;
  --text-on-dark-muted: #a8a8a8;
  --text-on-dark-subtle: #707070;

  /* Text on light */
  --text-on-light: #0b0b0b;
  --text-on-light-muted: #4a4a4a;
  --text-on-light-subtle: #767676;

  /* Accent — racing red, used sparingly */
  --red: #e10600;
  --red-hover: #ff2418;
  --red-active: #b80500;
  --on-red: #ffffff;

  /* Type */
  --font-body: 'Titillium Web', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --text-xs: 0.6875rem;
  --text-sm: 0.8125rem;
  --text-base: 1rem;
  --text-lg: 1.1875rem;
  --text-xl: 1.4375rem;
  --text-2xl: 1.75rem;
  --text-3xl: 2.0625rem;
  --text-4xl: 2.5rem;
  --text-5xl: 3.25rem;
  --text-6xl: 4.25rem;

  --leading-tight: 1.1;
  --leading-snug: 1.3;
  --leading-normal: 1.55;

  --tracking-tight: -0.02em;
  --tracking-normal: 0em;
  --tracking-wide: 0.02em;
  --tracking-caps: 0.09em;

  /* Space (base line-height 24px) */
  --space-3xs: 6px;
  --space-2xs: 12px;
  --space-xs: 16px;
  --space-sm: 24px;
  --space-md: 48px;
  --space-lg: 72px;
  --space-xl: 112px;

  --radius: 3px;
  --container: 1180px;
}

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

html {
  color-scheme: dark;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-on-dark);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; display: block; }

a { color: inherit; text-decoration: none; }

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--space-sm);
}

h1, h2, h3, h4 {
  font-weight: 900;
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  text-wrap: balance;
  margin: 0;
}

.eyebrow, .card-number, .card-link, nav a, .site-footer .foot-links a {
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
}

/* -------------------- Header -------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(10, 10, 10, 0.88);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-dark);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding-block: var(--space-2xs);
}

.logo {
  display: inline-block;
  font-weight: 900;
  font-size: clamp(0.75rem, 0.58rem + 1vw, 1.1875rem); /* scales so the full domain fits on mobile */
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  white-space: nowrap;
  color: #ffffff;
  transform: skewX(-12deg);
}

.main-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.main-nav a {
  position: relative;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-on-dark-muted);
  padding-block: var(--space-3xs);
}

.main-nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--red);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.18s ease;
}

.main-nav a:hover,
.main-nav a[aria-current="page"] {
  color: var(--text-on-dark);
}

.main-nav a:hover::after,
.main-nav a[aria-current="page"]::after {
  transform: scaleX(1);
}

/* -------------------- Checkered divider -------------------- */

.checker-divider {
  height: 10px;
  background-image:
    linear-gradient(45deg, #000 25%, transparent 25%, transparent 75%, #000 75%, #000),
    linear-gradient(45deg, #000 25%, #fff 25%, #fff 75%, #000 75%, #000);
  background-position: 0 0, 5px 5px;
  background-size: 10px 10px;
}

/* -------------------- Hero video banner -------------------- */

.hero-media {
  position: relative;
  width: 100%;
  /* fixed, viewport-scaled banner height — no longer tied to the clip's native ratio */
  height: clamp(220px, 28vw, 340px);
  overflow: hidden;
  background: #000;
}

.hero-media video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(11px); /* 50% blur */
  transform: scale(1.1); /* hide the soft edge the blur radius creates */
  opacity: 0;
  transition: opacity 0.2s ease; /* swap itself is instant — the blackout below sells the transition */
}

.hero-media video.is-active {
  opacity: 1;
}

.hero-media::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  /* darken for text contrast, then fade smoothly into the hero's black canvas */
  background: linear-gradient(
    to bottom,
    rgba(10, 10, 10, 0.35) 0%,
    rgba(10, 10, 10, 0.45) 55%,
    var(--bg) 100%
  );
}

.hero-media-blackout {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease; /* 0.5s in + 0.5s out = 1s blackout transition */
}

.hero-media-blackout.is-active {
  opacity: 1;
}

.hero-media-text {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding-inline: var(--space-sm);
}

.hero-media-credit {
  position: absolute;
  top: var(--space-2xs);
  left: var(--space-xs);
  z-index: 4;
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: var(--tracking-wide);
  color: rgba(255, 255, 255, 0.65);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, color 0.15s ease;
}

.hero-media-credit.is-active {
  opacity: 1;
  pointer-events: auto;
}

.hero-media-credit:hover {
  color: #ffffff;
  text-decoration: underline;
}

.hero-media-text p {
  margin: 0;
  width: 100%;
  max-width: 50ch;
  color: #ffffff;
  font-weight: 700;
  font-size: clamp(1.4375rem, 1.1rem + 1.6vw, 2.0625rem); /* 23px → 33px */
  line-height: var(--leading-snug);
  text-wrap: balance;
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.5);
}

.hero-media-text .domain {
  display: block;
  margin-top: var(--space-2xs);
  font-weight: 900;
  font-size: clamp(1.75rem, 1.2rem + 2.5vw, 2.5rem); /* 28px → 40px */
  letter-spacing: var(--tracking-wide);
  color: #ffffff;
  text-wrap: balance;
}

@media (max-width: 640px) {
  .hero-media { height: clamp(200px, 46vw, 260px); }
}

/* -------------------- Hero (dark band) -------------------- */

.hero {
  padding-block: var(--space-xl) var(--space-lg);
  border-bottom: 1px solid var(--border-dark);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--red);
  margin-bottom: var(--space-sm);
}

.eyebrow::before {
  content: "";
  width: 20px;
  height: 2px;
  background: var(--red);
}

.hero h1 {
  font-size: var(--text-6xl);
  max-width: 16ch;
}

.hero .lead {
  margin-top: var(--space-sm);
  max-width: 62ch;
  font-size: var(--text-lg);
  font-weight: 400;
  color: var(--text-on-dark-muted);
  text-wrap: pretty;
}

.page-hero {
  padding-block: var(--space-lg) var(--space-md);
  border-bottom: 1px solid var(--border-dark);
}

.page-hero h1 { font-size: var(--text-5xl); }

.page-hero .lead {
  margin-top: var(--space-xs);
  max-width: 62ch;
  font-size: var(--text-lg);
  font-weight: 400;
  color: var(--text-on-dark-muted);
  text-wrap: pretty;
}

.breadcrumb {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-on-dark-subtle);
  margin-bottom: var(--space-sm);
}

.breadcrumb a { color: var(--text-on-dark-muted); }
.breadcrumb a:hover { color: var(--red); }

/* -------------------- Section band (light) -------------------- */

.section-light {
  background: var(--bg-light);
  color: var(--text-on-light);
  padding-block: var(--space-lg);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
}

.section-head h2 {
  font-size: var(--text-3xl);
}

.section-head .section-sub {
  color: var(--text-on-light-muted);
  font-size: var(--text-base);
  max-width: 46ch;
}

/* Card grid: 4 top-level sections */

.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border-light);
  border: 1px solid var(--border-light);
}

.card {
  background: var(--bg-light);
  padding: var(--space-md) var(--space-sm) var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  transition: background 0.15s ease;
}

.card:hover { background: var(--surface-light-2); }

.card-number {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--red);
}

.card h2 {
  font-size: var(--text-xl);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

.card p {
  margin: 0;
  color: var(--text-on-light-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  flex-grow: 1;
}

.card-link {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-on-light);
}

.card:hover .card-link { color: var(--red); }

/* Entry grid: used on subpages (eras / tracks / drivers / teams) */

.entry-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-sm);
}

.entry {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border-light);
  transition: transform 0.35s ease, box-shadow 0.35s ease;
  will-change: transform;
}

.entry:hover,
.entry:focus-within {
  transform: scale(1.07);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.3);
  z-index: 2;
}

.entry-photo {
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: 0;
  transition: opacity 0.45s ease;
}

.entry:hover .entry-photo,
.entry:focus-within .entry-photo {
  opacity: 1;
}

.entry-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.entry-photo::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.88) 0%,
    rgba(0, 0, 0, 0.6) 45%,
    rgba(0, 0, 0, 0.2) 100%
  );
}

.entry-content {
  position: relative;
  z-index: 1;
  padding: var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
}

.entry-tag {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--red);
}

.entry h3 {
  font-size: var(--text-xl);
  letter-spacing: var(--tracking-normal);
  transition: color 0.3s ease;
}

.entry .entry-meta {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-on-light-subtle);
  transition: color 0.3s ease;
}

.entry p {
  margin: 0;
  color: var(--text-on-light-muted);
  font-size: var(--text-sm);
  transition: color 0.3s ease;
}

.entry:hover h3,
.entry:focus-within h3 {
  color: #ffffff;
}

.entry:hover .entry-meta,
.entry:focus-within .entry-meta {
  color: rgba(255, 255, 255, 0.75);
}

.entry:hover p,
.entry:focus-within p {
  color: rgba(255, 255, 255, 0.9);
}

.note-card {
  margin-top: var(--space-md);
  border: 1px dashed var(--border-light);
  padding: var(--space-sm);
  color: var(--text-on-light-muted);
  font-size: var(--text-sm);
}

.note-card strong { color: var(--text-on-light); }

/* Track list: stacked rows, photo docked to the right */

.track-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.track-row {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border-light);
  overflow: hidden;
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

.track-row:hover {
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.18);
  border-color: var(--border-strong, var(--border-light));
}

.track-content {
  flex: 1 1 auto;
  min-width: 0;
  padding: var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
  justify-content: center;
}

.track-tag {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--red);
}

.track-meta {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-on-light-subtle);
}

.track-row h3 {
  font-size: var(--text-xl);
  letter-spacing: var(--tracking-normal);
}

.track-row p {
  margin: 0;
  color: var(--text-on-light-muted);
  font-size: var(--text-sm);
  max-width: 60ch;
}

.track-row p + p {
  margin-top: 2px;
}

.track-facts {
  font-size: var(--text-xs) !important;
  color: var(--text-on-light-subtle) !important;
  font-weight: 600;
}

.track-facts strong {
  color: var(--text-on-light);
  font-weight: 700;
}

.track-stats {
  margin-top: var(--space-3xs);
  padding-top: var(--space-2xs);
  border-top: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.track-stat {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--text-on-light-muted);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
}

.track-stat-label {
  flex: 0 0 auto;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--red);
}

.track-stat-time {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--text-on-light);
}

.track-photo {
  flex: 0 0 260px;
}

.track-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (max-width: 720px) {
  .track-row { flex-direction: column; }
  .track-photo { flex-basis: auto; height: 200px; order: -1; }
}

/* Track row hover background photo (currently used on Monza) */

.track-row--hover-photo {
  position: relative;
}

.track-row--hover-photo > .track-content,
.track-row--hover-photo > .track-photo {
  position: relative;
  z-index: 1;
}

.track-row-photo {
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s ease;
}

.track-row-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.track-row-photo::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72); /* darken so white text stays legible */
}

.track-row--hover-photo:hover .track-row-photo,
.track-row--hover-photo:focus-within .track-row-photo {
  opacity: 1;
}

.track-row--hover-photo:hover .track-photo,
.track-row--hover-photo:focus-within .track-photo {
  opacity: 0.85;
}

.track-row--hover-photo:hover h3,
.track-row--hover-photo:focus-within h3,
.track-row--hover-photo:hover .track-row > p,
.track-row--hover-photo:hover p,
.track-row--hover-photo:focus-within p {
  color: #ffffff;
}

.track-row--hover-photo:hover .track-meta,
.track-row--hover-photo:focus-within .track-meta {
  color: rgba(255, 255, 255, 0.75);
}

.track-row--hover-photo:hover .track-facts,
.track-row--hover-photo:focus-within .track-facts {
  color: rgba(255, 255, 255, 0.75) !important;
}

.track-row--hover-photo:hover .track-facts strong,
.track-row--hover-photo:focus-within .track-facts strong {
  color: #ffffff;
}

.track-row--hover-photo:hover .track-stat,
.track-row--hover-photo:focus-within .track-stat {
  color: rgba(255, 255, 255, 0.75);
}

.track-row--hover-photo:hover .track-stat-time,
.track-row--hover-photo:focus-within .track-stat-time {
  color: #ffffff;
}

.track-row--hover-photo:hover .track-stats,
.track-row--hover-photo:focus-within .track-stats {
  border-top-color: rgba(255, 255, 255, 0.25);
}

/* -------------------- Footer -------------------- */

.site-footer {
  background: var(--bg);
  border-top: 1px solid var(--border-dark);
  padding-block: var(--space-md);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.site-footer p {
  margin: 0;
  color: var(--text-on-dark-subtle);
  font-size: var(--text-sm);
}

.foot-links {
  display: flex;
  gap: var(--space-sm);
}

.foot-links a {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-on-dark-muted);
}

.foot-links a:hover { color: var(--red); }

/* -------------------- Responsive -------------------- */

@media (max-width: 980px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .entry-grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: var(--text-5xl); }
}

@media (max-width: 640px) {
  .grid { grid-template-columns: 1fr; }
  .header-inner { flex-direction: column; align-items: flex-start; gap: var(--space-2xs); }
  .main-nav { gap: var(--space-sm); }
  .hero { padding-block: var(--space-lg) var(--space-md); }
  .hero h1 { font-size: var(--text-4xl); }
  .section-head { flex-direction: column; }
}
