/* Bahrain Drift — main stylesheet */
:root {
  --bg: #08080a;
  --bg-2: #0a0a0c;
  --panel: #0f0f12;
  --card: #141418;
  --line: #1c1c20;
  --line-2: #26262b;
  --line-3: #2e2e34;
  --red: #e1121b;
  --red-hover: #ff2630;
  --red-text: #ff4b52;
  --white: #ffffff;
  --text: #f4f4f5;
  --text-2: #e4e4e7;
  --muted: #a1a1aa;
  --muted-2: #8b8b93;
  --font-display: 'Barlow Condensed', sans-serif;
  --font-label: 'Saira', sans-serif;
  --font-body: 'Barlow', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; overflow-x: hidden; background: var(--bg); }
/* Arabic visitors: the page stays hidden (dark background only) for the moment until js/main.js
   has put the Arabic text in, so the English page never flashes. Set by the line in each page's
   <head>; it lifts itself after 3 seconds at most. */
html.i18n-wait body { visibility: hidden; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  overflow-x: hidden;
  /* At least the screen's height, as a column, so the footer sits at the bottom of short
     pages (see .site-footer). Every page under it has only header, main and footer;
     the photo / video viewers are position: fixed, so they are not part of the column. */
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
a { color: var(--white); text-decoration: none; }
a:hover { color: var(--red-text); }
img { max-width: 100%; }

.container { max-width: 1440px; margin: 0 auto; }

/* ---------- Shared bits ---------- */
.eyebrow {
  margin: 0;
  font-family: var(--font-label);
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--red-text);
}
.heading {
  margin: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 800;
  font-size: 32px;
  line-height: 0.95;
  text-transform: uppercase;
  color: var(--white);
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-label);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.6px;
  transition: background 0.15s, border-color 0.15s;
}
.btn-red { background: var(--red); color: var(--white); padding: 14px 24px; }
.btn-red:hover { background: var(--red-hover); color: var(--white); }
.btn-ghost { border: 1.5px solid var(--muted); color: var(--white); padding: 13px 22px; }
.btn-ghost:hover { border-color: var(--red-text); color: var(--white); }
.slant { clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%); }
.text-link {
  align-self: flex-start;
  padding-inline-start: 10px;
  border-inline-start: 2px solid var(--red);
  font-family: var(--font-label);
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--red-text);
}
.deco { position: absolute; pointer-events: none; }

/* ---------- Header ---------- */
.site-header {
  overflow: hidden;
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
}
.site-header .deco-corner {
  left: -30px; top: -10px; width: 90px; height: 90px;
  background: var(--red);
  transform: skewX(-24deg);
  clip-path: polygon(0 0, 100% 0, 30% 100%, 0 100%);
}
.nav {
  position: relative;
  padding-block: 8px;
  padding-inline: 96px 32px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 28px;
}
.nav-logo img { height: 46px; width: auto; display: block; }
@media (min-width: 901px) { .nav-logo img { height: 60px; } }
.nav-links {
  flex: 1 1 560px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0 30px;
  font-family: var(--font-label);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.8px;
}
.nav-links a { color: var(--text-2); padding: 18px 0 14px; border-bottom: 2px solid transparent; }
.nav-links a:hover { color: var(--red-text); }
.nav-links a.active { color: var(--red-text); border-bottom-color: var(--red); }
.nav-actions { display: flex; align-items: center; gap: 14px; }
.lang { display: flex; align-items: center; font-family: var(--font-label); font-size: 13px; }
.lang .sep { color: #52525b; }
.lang button {
  background: transparent; border: none; cursor: pointer; font: inherit;
  color: var(--muted); padding: 10px 6px; min-height: 44px;
}
.lang button[aria-pressed="true"] { color: var(--white); font-weight: 600; }
.account {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-inline-end: 1px solid #3f3f46; padding-inline-end: 8px;
}
.nav-actions .btn-red { padding: 12px 26px; }

/* ---------- Hero ---------- */
.hero { position: relative; overflow: hidden; border-bottom: 1px solid var(--line); }
.hero-bg {
  position: absolute; inset-inline-end: 0; top: 0; bottom: 0; width: 64%;
  background: url(../images/hero.jpg) center 40% / cover no-repeat;
}
.hero-fade-left {
  inset: 0;
  background: linear-gradient(90deg, var(--bg-2) 30%, rgba(10,10,12,0.85) 40%, rgba(10,10,12,0) 58%);
}
.hero-fade-bottom {
  left: 0; right: 0; bottom: 0; height: 120px;
  background: linear-gradient(0deg, var(--bg-2), rgba(10,10,12,0));
}
.hero-stripe {
  left: -70px; top: 0; bottom: 0; width: 110px;
  background: linear-gradient(180deg, var(--red), #8a0a10);
  transform: skewX(-8deg); opacity: 0.9;
}
.hero-inner {
  position: relative;
  padding-block: 56px 40px;
  padding-inline: 72px 32px;
  min-height: 520px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.hero-kicker {
  display: flex; align-items: center; gap: 18px;
  font-family: var(--font-label); font-size: 12px; letter-spacing: 6px; color: var(--text-2);
}
.hero-kicker::after { content: ""; height: 2px; width: 56px; background: var(--red); }
.hero h1 { margin: 0; }
.hero h1 picture { display: block; }
.hero h1 img { width: min(527px, 100%); height: auto; display: block; }
.hero-tagline {
  margin: 0;
  font-family: var(--font-label); font-weight: 600; font-size: 16px; letter-spacing: 4px; color: var(--white);
  white-space: pre-wrap;
}
.hero-location { margin: 0; display: flex; align-items: center; gap: 10px; font-size: 15px; color: var(--text-2); white-space: pre-wrap; }
.hero-ctas { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 4px; }
/* Hero buttons: 14px, the same as the sponsor box button (the general .btn stays 13px) */
.hero-ctas .btn { font-size: 14px; }

/* Countdown */
.countdown {
  margin-top: 28px;
  align-self: flex-start;
  max-width: 100%;
  display: flex; flex-wrap: wrap; align-items: center; gap: 24px 40px;
  background: linear-gradient(90deg, rgba(14,14,17,0.96), rgba(14,14,17,0.85));
  border: 1px solid #5a1015;
  padding-block: 22px;
  padding-inline: 28px 36px;
  clip-path: polygon(14px 0, calc(100% - 40px) 0, 100% 100%, 0 100%, 0 14px);
}
.countdown-label {
  margin: 0 0 14px; display: flex; align-items: center; gap: 12px;
  font-family: var(--font-label); font-size: 11px; letter-spacing: 1.5px; color: var(--text-2);
}
.countdown-units { display: flex; }
.unit {
  display: flex; flex-direction: column; align-items: center;
  min-width: 80px; padding: 0 16px;
}
.unit + .unit { border-inline-start: 1px solid #3f3f46; }
.unit-value {
  font-family: var(--font-display); font-style: italic; font-weight: 800;
  font-size: 34px; line-height: 1; color: var(--white);
  font-variant-numeric: tabular-nums;
}
.unit-label { font-family: var(--font-label); font-size: 10px; letter-spacing: 2.5px; color: #d4d4d8; margin-top: 8px; }
.notfound .page-hero-inner { min-height: 52vh; justify-content: center; }
.notfound-cta { align-self: flex-start; margin-top: 10px; }
.countdown[hidden], .countdown-units[hidden], .countdown-label[hidden], .countdown-live[hidden] { display: none; }
/* During the event days the numbers give way to "Live now" (about the same height, so nothing jumps) */
.countdown-live {
  margin: 0; min-height: 88px; display: flex; align-items: center; gap: 12px;
  font-family: var(--font-display); font-style: italic; font-weight: 800; font-size: 30px; color: var(--white);
}
.live-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--red); flex: none; animation: live-pulse 1.4s ease-out infinite; }
@keyframes live-pulse {
  0% { box-shadow: 0 0 0 0 rgba(225, 18, 27, 0.7); }
  100% { box-shadow: 0 0 0 12px rgba(225, 18, 27, 0); }
}
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }

/* ---------- Panels ---------- */
.panels { position: relative; padding: 18px 0 22px; overflow: hidden; }
.panels .deco-left {
  left: -40px; bottom: -10px; width: 120px; height: 140px;
  background: var(--red); transform: skewX(-30deg);
  clip-path: polygon(0 40%, 100% 100%, 0 100%); opacity: 0.85;
}
/* One row of equal panels on computers: four, or three while there are no announcements (the
   hidden panel takes no column). Two per row on tablets, one under the other on phones (below). */
.panels-grid {
  position: relative;
  padding: 0 32px;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 16px;
}
/* On wide screens the panels use more of the width than the rest of the page (1440px) */
.panels-grid.container { max-width: 1840px; }
.panel {
  position: relative;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line-2);
  min-height: 290px;
}
.panel-body { position: relative; display: flex; flex-direction: column; gap: 14px; }

.panel-about { clip-path: polygon(12px 0, 100% 0, 100% 100%, 0 100%, 0 12px); }
.panel-about .panel-img {
  position: absolute; inset-inline-end: 0; top: 0; bottom: 0; width: 46%;
  background: url(../images/about.jpg) center / cover no-repeat;
}
.panel-about .panel-fade { inset: 0; background: linear-gradient(90deg, var(--panel) 50%, rgba(15,15,18,0) 70%); }
.panel-about .panel-body { padding-block: 22px 26px; padding-inline: 34px 26px; max-width: 300px; }
.panel-about p.copy { margin: 0; font-size: 14px; line-height: 1.6; color: var(--text-2); }
.panel-about .btn-red {
  align-self: flex-start; margin-top: 6px; padding: 11px 22px; font-size: 12px;
  clip-path: polygon(0 0, 100% 0, calc(100% - 10px) 100%, 0 100%);
}
/* Sponsors box (js/sponsors.js) in the same panel: hidden for the moment until the data is in */
.panel-about[data-wait] > * { visibility: hidden; }
.sponsor-box[hidden], .about-default[hidden] { display: none; }
.panel-about.has-sponsors { transition: border-color 0.2s; }
.panel-about.has-sponsors:has(a.sponsor-slide.is-active:hover) { border-color: var(--red); }
.sponsor-box { position: relative; height: 100%; min-height: 290px; display: flex; flex-direction: column; }
.sponsor-ad {
  position: absolute; top: 10px; inset-inline-end: 14px; z-index: 2;
  font-family: var(--font-label); font-size: 12px; letter-spacing: 1.5px; color: var(--muted-2); opacity: 0.8;
}
.sponsor-slides { flex: 1; display: grid; }
.sponsor-slide {
  grid-area: 1 / 1; display: flex; align-items: stretch; min-height: 100%;
  opacity: 0; visibility: hidden; transition: opacity 0.6s ease, visibility 0s linear 0.6s;
  color: inherit; text-decoration: none;
}
.sponsor-slide.is-active { opacity: 1; visibility: visible; transition: opacity 0.6s ease, visibility 0s; }
.sponsor-text {
  flex: 1 1 56%; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 12px;
  padding-block: 26px 34px; padding-inline: 28px 18px;
}
.sponsor-name { overflow-wrap: anywhere; }
/* Computers and tablets: the name's size follows the screen, two lines at most (then "…").
   (.heading.sponsor-name inside the box, so the Arabic heading size does not win over it) */
@media (min-width: 701px) {
  .sponsor-box .heading.sponsor-name {
    font-size: clamp(20px, 1.6vw, 28px);
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
  }
}
.sponsor-text .copy { margin: 0; font-size: 14px; line-height: 1.6; color: var(--text-2); }
.sponsor-text .btn-red {
  align-self: flex-start; padding: 14px 22px; font-size: 14px;
  clip-path: polygon(0 0, 100% 0, calc(100% - 10px) 100%, 0 100%);
}
.sponsor-logo {
  flex: 0 0 38%; display: flex; align-items: center; justify-content: center; padding: 18px;
  background: linear-gradient(135deg, #1d1d23 0%, #0b0b0e 100%);
}
.sponsor-logo img { display: block; max-width: 100%; max-height: 120px; object-fit: contain; }
.sponsor-logo-empty::after { content: ""; width: 70%; max-width: 200px; height: 80px; border: 1px dashed #3a3a40; }
.sponsor-progress { position: absolute; inset-inline: 0; bottom: 0; height: 2px; background: rgba(255,255,255,0.06); }
.sponsor-progress span { display: block; height: 100%; background: var(--red); transform: scaleX(0); transform-origin: left; }
[dir="rtl"] .sponsor-progress span { transform-origin: right; }
.sponsor-dots { position: absolute; bottom: 12px; inset-inline-start: 34px; display: flex; gap: 2px; z-index: 2; }
.sponsor-dots button {
  width: 24px; height: 24px; padding: 0; border: 0; background: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.sponsor-dots button::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #4a4a52; transition: background 0.2s; }
.sponsor-dots button[aria-current="true"]::before { background: var(--red); }
@media (prefers-reduced-motion: reduce) {
  .sponsor-slide, .sponsor-slide.is-active { transition: none; }
}
/* Phones: the logo on top, the text under it */
@media (max-width: 700px) {
  .sponsor-slide { flex-direction: column-reverse; justify-content: flex-end; }
  .sponsor-logo { flex: none; min-height: 120px; padding: 20px; }
  .sponsor-logo img { max-width: 70%; max-height: 80px; }
  /* "Your logo here" card: no empty dashed box on phones, so the card is shorter
     (real sponsors keep their logo) */
  .sponsor-call .sponsor-logo-empty { display: none; }
  /* Links like "View full schedule": a 44px tall tap area on phones. The red bar is drawn
     by ::before at the text's height, so the link looks the same as before. */
  a.text-link {
    position: relative; display: inline-flex; align-items: center; min-height: 44px;
    border-inline-start: none; padding-inline-start: 12px;
  }
  a.text-link::before {
    content: ""; position: absolute; inset-inline-start: 0; top: 50%;
    width: 2px; height: 1.3em; transform: translateY(-50%); background: var(--red);
  }
  .sponsor-text { flex: none; padding-block: 18px 44px; padding-inline: 24px; }
}

.panel-drivers {
  padding: 22px 16px 18px;
  display: flex; flex-direction: column; gap: 14px;
  clip-path: polygon(12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 12px);
}
.panel-drivers .eyebrow, .panel-drivers .heading, .panel-drivers .text-link { margin-inline-start: 4px; }
.panel-drivers .heading { display: flex; align-items: center; gap: 18px; }
.panel-drivers .heading .arrow { color: var(--red); font-style: normal; font-size: 24px; }
.driver-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; }
.driver { background: var(--card); border: 1px solid var(--line-3); display: flex; flex-direction: column; transition: border-color 0.15s; }
.driver:hover { border-color: var(--red); }
.driver img { width: 100%; aspect-ratio: 148 / 70; object-fit: cover; display: block; }
.driver-info { padding: 10px 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.driver-num { font-family: var(--font-display); font-style: italic; font-weight: 700; font-size: 18px; color: var(--red-text); line-height: 1; }
.driver-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.driver-name { font-weight: 600; font-size: 14px; color: var(--white); overflow-wrap: anywhere; }
.driver-car { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
/* Homepage drivers box: narrow cards, so the flag goes under the name and the name breaks
   between words; max-width: 100% keeps a single long word (e.g. Abdulrahman) inside the card,
   since in a column with align-items: flex-start the name is otherwise as wide as that word */
.panel-drivers .driver-row { flex-direction: column; align-items: flex-start; gap: 4px; }
.panel-drivers .driver-name { overflow-wrap: break-word; word-break: normal; font-size: 13px; max-width: 100%; }
.flag { flex: none; }
/* Champion badge (typed in the panel): red top edge and, next to the number, a trophy with a
   short fixed word (homepage) or the full badge text (drivers page). A long text goes under the
   number instead of out of the card. */
.driver.is-champ { border-top: 3px solid var(--red); }
.champ-icon { flex: none; color: var(--red-text); }
.driver-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 6px; }
.champ-tag { display: inline-flex; align-items: center; gap: 4px; min-width: 0; font-size: 11px; color: var(--red-text); overflow-wrap: anywhere; }
.driver-list .champ-tag { font-size: 12px; }

.panel-schedule { container-type: inline-size; clip-path: polygon(0 0, 100% 0, 100% 100%, 12px 100%, 0 calc(100% - 12px)); }
/* Start lights (SVG in index.html). Absolute, so they never change the panel's size. */
.panel-schedule .panel-img {
  position: absolute; inset-inline-end: 0; top: 0; bottom: 0; width: 38%; overflow: hidden;
}
.panel-schedule .panel-img svg { display: block; width: 100%; height: 100%; overflow: visible; transition: filter .6s ease; }
/* Hidden until the schedule is known, so the lights don't jump from full size to small.
   Off (grey) while hidden, so an empty schedule shows them off at once with no red flash. */
.panel-schedule:not(:has(.dates.dyn-ready)) .panel-img svg { visibility: hidden; filter: grayscale(1) brightness(.45); }
/* Empty schedule: lights off. They turn red again once dates are added in the panel. */
.panel-schedule:has(.dates-empty:not([hidden])) .panel-img svg { filter: grayscale(1) brightness(.45); }
@media (prefers-reduced-motion: reduce) { .panel-schedule .panel-img svg { transition: none; } }
/* Narrow panel with a schedule: smaller lights, and a long title wraps before reaching them */
@container (max-width: 380px) {
  .panel-schedule:has(.dates > li) .panel-img { width: 30%; }
  .panel-schedule:has(.dates > li) .panel-img svg { max-width: 56px; margin-inline: auto; }
  .panel-schedule:has(.dates > li) .dates { padding-inline-end: calc(15cqw + 14px); }
}
.panel-schedule .panel-body { padding: 22px 26px; gap: 12px; }
.dates { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.dates li { display: flex; align-items: center; gap: 20px; }
/* Empty schedule: one line instead of the list (js/content.js renderPage). On the homepage card
   it stays clear of the start lights (38% wide) and wraps; full width on the event page. */
.dates-empty {
  margin: 0; color: var(--muted); font-size: 15px; line-height: 1.7;
  border-inline-start: 2px solid var(--red); padding-inline-start: 12px;
}
.panel-schedule .dates-empty { max-width: 58%; }
.dates[hidden], .dates-empty[hidden], .text-link[hidden] { display: none; }
.date-box {
  /* min sizes, not fixed ones: longer Arabic months (e.g. "سبتمبر") make the box a little wider */
  flex: none; min-width: 46px; min-height: 36px; padding: 3px 6px; background: #d10f19;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.date-day { font-family: var(--font-display); font-weight: 700; font-size: 20px; line-height: 0.9; color: var(--white); }
.date-mon { font-family: var(--font-label); font-size: 12px; letter-spacing: 0.5px; color: var(--white); }
.date-text { display: flex; flex-direction: column; gap: 2px; }
.date-title { font-weight: 500; font-size: 14px; color: var(--white); }
.date-time { font-size: 12px; color: var(--muted); }

/* Announcements: the homepage panel and announcements.html */
.panel-news { border-top: 3px solid var(--red); }
.panel-news .panel-body { padding: 22px 26px; gap: 12px; height: 100%; }
.panel-news .text-link { margin-top: auto; }
.news-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.news-item { padding: 10px 0; display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--line-2); }
.news-item:first-child { border-top: 0; padding-top: 2px; }
/* Urgent: a light red band across the whole panel and a red line at the start */
.panel-news .news-item.is-hot { margin-inline: -26px; padding-inline: 23px 26px; }
.news-item.is-hot { background: rgba(225, 18, 27, 0.08); border-inline-start: 3px solid var(--red); }
.panel-news .news-item.is-hot:first-child { padding-top: 10px; }
.news-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.news-badge {
  display: inline-flex; align-items: center; gap: 7px; padding: 2px 8px;
  font-family: var(--font-label); font-size: 13px; font-weight: 600; letter-spacing: 1px; white-space: nowrap;
}
.news-badge .live-dot { width: 7px; height: 7px; animation-name: news-pulse; }
@keyframes news-pulse {
  0% { box-shadow: 0 0 0 0 rgba(225, 18, 27, 0.7); }
  100% { box-shadow: 0 0 0 6px rgba(225, 18, 27, 0); }
}
.news-tags { display: inline-flex; align-items: center; gap: 6px; }
/* Pinned: a small red pin (SVG, js/content.js) beside the badge */
.news-pin { display: inline-flex; color: var(--red-text); }
.news-urgent { color: var(--red-text); background: rgba(225, 18, 27, 0.14); }
.news-update { color: #7cb4ff; background: rgba(59, 130, 246, 0.14); }
.news-info { color: #c4c4cc; background: rgba(161, 161, 170, 0.14); }
.news-time { font-size: 13px; color: var(--muted); white-space: nowrap; }
.news-text { margin: 0; font-size: 13px; line-height: 1.55; color: var(--text-2); overflow-wrap: anywhere; }
.news-page { max-width: 760px; gap: 10px; }
.news-page .news-item { background: var(--panel); border: 1px solid var(--line-2); padding: 14px 18px; }
.news-page .news-item.is-hot { background: rgba(225, 18, 27, 0.08); border-inline-start: 3px solid var(--red); }
.news-page .news-text { font-size: 15px; }
html[lang="ar"] .news-badge { font-size: 13px; line-height: 1.5; }
html[lang="ar"] .news-time { font-size: 13px; }

/* ---------- Partners + footer ---------- */
.partners { position: relative; overflow: hidden; border-top: 1px solid var(--line); background: var(--bg-2); }
.partners .deco-right {
  right: -50px; bottom: 0; width: 110px; height: 90px;
  background: var(--red); transform: skewX(-30deg);
  clip-path: polygon(100% 0, 100% 100%, 0 100%); opacity: 0.85;
}
.partners-inner {
  position: relative;
  padding: 18px 64px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 16px 36px;
}
.label-sm { font-family: var(--font-label); font-size: 10px; letter-spacing: 1.5px; color: #d4d4d8; }
.partners-title { padding-inline-end: 30px; border-inline-end: 1px solid var(--line-3); line-height: 56px; }
.partner-logos {
  flex: 1 1 560px; min-width: 0;
  display: flex; flex-wrap: nowrap; align-items: center; justify-content: center; gap: 14px 28px;
}
/* Partners strip (js/sponsors.js): the logos, still in the middle when they fit, otherwise moving */
.partner-logos[hidden], .partners-title[hidden], .partner-viewport[hidden], .partner-cta[hidden] { display: none; }
.partner-viewport { flex: 0 1 auto; min-width: 0; overflow: hidden; }
.partner-viewport.is-moving {
  flex: 1 1 auto;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 48px, #000 calc(100% - 48px), transparent);
  mask-image: linear-gradient(90deg, transparent, #000 48px, #000 calc(100% - 48px), transparent);
}
.partner-track { display: flex; align-items: center; justify-content: center; gap: 40px; width: max-content; max-width: 100%; }
.partner-track.is-moving { max-width: none; justify-content: flex-start; animation: partner-move var(--partner-duration, 30s) linear infinite; }
.partner-viewport:hover .partner-track { animation-play-state: paused; }
/* One set moves out (half the track: two identical sets, 40px apart), then it starts over */
@keyframes partner-move { from { transform: translateX(0); } to { transform: translateX(calc(-50% - 20px)); } }
[dir="rtl"] .partner-track.is-moving { animation-name: partner-move-rtl; }
@keyframes partner-move-rtl { from { transform: translateX(0); } to { transform: translateX(calc(50% + 20px)); } }
.partner-logo { flex: none; display: flex; align-items: center; height: 44px; opacity: 0.85; transition: opacity 0.2s; }
.partner-logo:hover, .partner-logo:focus-visible { opacity: 1; }
.partner-logo img { display: block; height: 32px; width: auto; max-width: 160px; object-fit: contain; }
.partner-cta {
  flex: none; font-family: var(--font-label); font-size: 11px; letter-spacing: 1.5px; color: var(--text-2);
  border: 1px dashed #4a4a52; padding: 10px 16px; white-space: nowrap; transition: border-color 0.2s, color 0.2s;
}
.partner-cta:hover, .partner-cta:focus-visible { border-color: var(--red-text); color: var(--white); }
.partners.only-follow .social { border-inline-start: none; padding-inline-start: 0; }
@media (prefers-reduced-motion: reduce) {
  .partner-track { flex-wrap: wrap; width: auto; }
  .partner-track.is-moving { animation: none; }
}
.social { display: flex; align-items: center; gap: 4px; padding-inline-start: 30px; border-inline-start: 1px solid var(--line-3); }
.social .label-sm { margin-inline-end: 14px; }
.social a { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; }

/* margin-top: auto: pushed to the bottom of the screen on short pages (body is a column) */
.site-footer { background: var(--bg-2); border-top: 1px solid var(--line); margin-top: auto; }
.footer-inner {
  padding: 16px 64px;
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px 24px;
  font-size: 13px; color: var(--muted);
}
.footer-info { display: flex; flex-direction: column; gap: 6px; }
.footer-location { margin: 0; display: flex; align-items: center; gap: 8px; color: var(--text-2); }
.footer-legal { margin: 0; }
/* "Independent event" line under the rights line: same grey and font (from .footer-inner);
   the 6px above it is .footer-info's gap */
.footer-indep { margin: 0; font-size: 13px; }
.footer-legal a { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; }
.footer-legal a:hover { color: var(--text-2); }
/* "· link" pairs: the dot never stays alone at the end of a line */
.footer-item { white-space: nowrap; }
.footer-sep { padding-inline: 0.4em; }
/* "Contact us" is the last link of the legal line, in red, no underline */
.footer-legal .footer-contact { color: var(--red-text); text-decoration: none; }
.footer-legal .footer-contact:hover { color: var(--white); }
.footer-actions { display: flex; align-items: center; gap: 16px; }
.footer-social { display: flex; gap: 4px; }
.footer-social a { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; color: var(--muted); white-space: nowrap; }
.footer-social a:hover { color: var(--red-text); }
/* Home already shows these icons in the "Follow us" bar right above the footer, so the
   icons box is empty there: hide it so it leaves no gap */
html[data-page="home"] .footer-actions { display: none; }
@media (max-width: 700px) {
  .footer-inner { flex-direction: column; align-items: stretch; }
  .footer-actions { justify-content: space-between; }
  /* Phones: the rights line on its own line, and no "·" at the start of the next one */
  .footer-rights { display: block; }
  .footer-rights + .footer-item .footer-sep { display: none; }
  /* Phones: a 44px-tall area to tap on each footer link (Contact us included); font, colour and underline stay the same */
  .footer-legal a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px; }
}

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .site-header { position: relative; }
  .nav { padding-inline: 72px 16px; }
  .hero-bg { width: 100%; opacity: 0.45; }
  .hero-fade-left { background: linear-gradient(90deg, rgba(10,10,12,0.85), rgba(10,10,12,0.3)); }
  .hero-inner { padding-block: 40px 32px; padding-inline: 40px 16px; min-height: 0; }
  .panel-about .panel-img { opacity: 0.35; }
  .panels-grid { padding: 0 16px; }
  .partners-inner, .footer-inner { padding-inline: 16px; }
  .partners-title { border-inline-end: none; padding-inline-end: 0; line-height: 1.4; flex-basis: 100%; }
  .social { border-inline-start: none; padding-inline-start: 0; }
}
@media (max-width: 560px) {
  .nav-links { gap: 0 18px; font-size: 12px; }
  .hero-kicker { letter-spacing: 3px; font-size: 10px; }
  .hero-tagline { letter-spacing: 2px; font-size: 13px; }
  .unit { min-width: 0; padding: 0 10px; }
  .unit-value { font-size: 28px; }
  .countdown { padding: 18px; }
  .driver-grid { grid-template-columns: 1fr 1fr; }
  .partner-logos { justify-content: center; gap: 10px 16px; flex-wrap: wrap; }
}

/* Homepage panels: in one row on computers the drivers stay three across;
   two panels per row on tablets (three panels: the last takes the whole row), one on phones */
@media (min-width: 1200px) {
  .panel-drivers .driver-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
}
@media (max-width: 1199px) {
  .panels-grid { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panels-grid:has(> .panel-news[hidden]) > .panel:last-child { grid-column: 1 / -1; }
}
@media (max-width: 700px) {
  .panels-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Arabic + right-to-left ---------- */
.lang button[lang="ar"] { font-family: 'Cairo', sans-serif; }
/* Arabic: Changa (square, heavy, sporty) for headings, menu, buttons and labels, to match the
   condensed English display font; Cairo stays for paragraphs and forms, where it reads best. */
html[lang="ar"] {
  --font-display: 'Changa', 'Cairo', sans-serif;
  --font-label: 'Changa', 'Cairo', sans-serif;
  --font-body: 'Cairo', system-ui, sans-serif;
}
/* Arabic letters join, so no letter-spacing, and it has no true italic */
html[lang="ar"] body, html[lang="ar"] body * { letter-spacing: 0 !important; font-style: normal !important; }
html[lang="ar"] .heading { font-size: 28px; font-weight: 800; line-height: 1.2; }
html[lang="ar"] .page-title { font-weight: 800; }
html[lang="ar"] .eyebrow,
html[lang="ar"] .text-link,
html[lang="ar"] .label-sm,
html[lang="ar"] .countdown-label { font-size: 13px; font-weight: 600; }
html[lang="ar"] .btn { font-weight: 700; }
html[lang="ar"] .hero-kicker { font-size: 14px; }
html[lang="ar"] .hero-tagline { font-size: 18px; font-weight: 700; }
html[lang="ar"] .nav-links { font-size: 15px; font-weight: 600; }
html[lang="ar"] .field label, html[lang="ar"] .choice-group legend { font-weight: 600; }
/* Arabic letters rise and dip further than Latin ones, so "normal" line spacing makes every
   line taller. Tighter spacing keeps the cards and hero close to the English heights. */
html[lang="ar"] .heading { line-height: 1.12; }
html[lang="ar"] .eyebrow, html[lang="ar"] .text-link { line-height: 1.3; }
html[lang="ar"] .panel-body, html[lang="ar"] .panel-drivers { gap: 10px; }
html[lang="ar"] .panel-about p.copy { line-height: 1.55; }
html[lang="ar"] .dates { gap: 8px; }
html[lang="ar"] .date-title { line-height: 1.3; }
html[lang="ar"] .date-time { line-height: 1.25; }
html[lang="ar"] .driver-info { gap: 2px; }
html[lang="ar"] .driver-name, html[lang="ar"] .driver-car { line-height: 1.3; }
html[lang="ar"] .unit-value { line-height: 1.05; }
html[lang="ar"] .countdown-label, html[lang="ar"] .unit-label { line-height: 1.3; }
html[lang="ar"] .hero-tagline, html[lang="ar"] .hero-location { line-height: 1.4; }
html[lang="ar"] .unit-value { line-height: 1.15; }
html[lang="ar"] .unit-label { font-size: 12px; margin-top: 4px; }
html[lang="ar"] .driver-car { font-size: 13px; }
html[lang="ar"] .date-time { font-size: 12px; }
html[lang="ar"] .date-mon { font-size: 12px; line-height: 1.2; }
html[lang="ar"] .date-day { line-height: 1; }

/* Mirror the decorations and one-sided shapes */
[dir="rtl"] .site-header .deco-corner {
  left: auto; right: -30px;
  transform: skewX(24deg);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 70% 100%);
}
[dir="rtl"] .hero-fade-left {
  background: linear-gradient(270deg, var(--bg-2) 30%, rgba(10,10,12,0.85) 40%, rgba(10,10,12,0) 58%);
}
/* A mirrored copy of the hero photo (lettering on the car put back the right way round),
   so in Arabic the car faces the text, as it does in English */
[dir="rtl"] .hero-bg { background-image: url(../images/hero-rtl.jpg); }
[dir="rtl"] .hero-stripe { left: auto; right: -70px; transform: skewX(8deg); }
[dir="rtl"] .countdown {
  background: linear-gradient(270deg, rgba(14,14,17,0.96), rgba(14,14,17,0.85));
  clip-path: polygon(40px 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 0 100%);
}
[dir="rtl"] .panels .deco-left {
  left: auto; right: -40px; transform: skewX(30deg);
  clip-path: polygon(100% 40%, 100% 100%, 0 100%);
}
[dir="rtl"] .panel-about { clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 0 100%); }
[dir="rtl"] .panel-about .panel-fade { background: linear-gradient(270deg, var(--panel) 50%, rgba(15,15,18,0) 70%); }
[dir="rtl"] .panel-about .btn-red { clip-path: polygon(0 0, 100% 0, 100% 100%, 10px 100%); }
[dir="rtl"] .panel-drivers {
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px));
}
[dir="rtl"] .panel-drivers .heading .arrow { transform: scaleX(-1); }
[dir="rtl"] .panel-schedule { clip-path: polygon(0 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%); }
[dir="rtl"] .partners .deco-right {
  right: auto; left: -50px; transform: skewX(30deg);
  clip-path: polygon(0 0, 100% 100%, 0 100%);
}
@media (max-width: 960px) {
  [dir="rtl"] .hero-fade-left { background: linear-gradient(270deg, rgba(10,10,12,0.85), rgba(10,10,12,0.3)); }
}

/* ---------- Mobile menu ---------- */
.site-header { min-height: 67px; }
.nav-toggle {
  display: none; margin-inline-start: auto;
  width: 44px; height: 44px; align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--line-3); color: var(--white); cursor: pointer;
}
/* The menu has eight links plus three actions: keep it on one row */
@media (min-width: 1301px) {
  .nav { gap: 12px 16px; padding-inline: 88px 20px; }
  .nav-links { flex-basis: 440px; gap: 0 18px; font-size: 12px; letter-spacing: 0.5px; }
  .nav-actions { gap: 10px; }
  .nav-actions .btn-red { padding: 11px 18px; font-size: 12px; }
}
@media (max-width: 1300px) {
  .nav-toggle { display: flex; }
  .nav-links, .nav-actions { display: none; }
  .nav.open .nav-links {
    display: flex; flex: 0 0 100%; flex-direction: column; flex-wrap: nowrap;
    justify-content: flex-start; gap: 0; font-size: 14px;
  }
  .nav.open .nav-links a { padding: 13px 0; border-bottom: 1px solid var(--line); }
  .nav.open .nav-links a.active { border-bottom-color: var(--red); }
  .nav.open .nav-actions { display: flex; flex: 0 0 100%; flex-wrap: wrap; justify-content: space-between; padding-bottom: 8px; }
  /* Open menu = a layer over the whole page. A grid, not wrapping flex rows, so the first row
     (logo | X) always sits at the very top, the same in English and Arabic (end = left in RTL). */
  .nav.open {
    position: fixed; inset: 0; z-index: 100; max-width: none; margin: 0;
    display: grid; grid-template-columns: auto minmax(0, 1fr); grid-auto-rows: auto;
    align-content: start; align-items: center; gap: 12px 0;
    background: var(--bg-2); overflow-y: auto; overscroll-behavior: contain;
  }
  .nav.open .nav-toggle { grid-column: 2; justify-self: end; margin: 0; }
  .nav.open .nav-links, .nav.open .nav-actions { grid-column: 1 / -1; }
  /* The red corner stays visible above the layer */
  .site-header:has(.nav.open) .deco-corner { position: fixed; z-index: 101; }
  /* The page behind the open menu does not scroll: js/layout.js sets body's top to minus the
     scrolled distance, so the page stays exactly where it was */
  html.nav-locked body { position: fixed; inset-inline: 0; width: 100%; }
}

/* ---------- Inner pages ---------- */
.page-hero { position: relative; overflow: hidden; background: var(--bg-2); border-bottom: 1px solid var(--line); }
.page-hero::before {
  content: ""; position: absolute; inset-inline-start: -70px; top: 0; bottom: 0; width: 110px;
  background: linear-gradient(180deg, var(--red), #8a0a10); transform: skewX(-8deg); opacity: 0.9;
}
[dir="rtl"] .page-hero::before { transform: skewX(8deg); }
.page-hero-inner {
  position: relative;
  padding-block: 44px 40px; padding-inline: 72px 32px;
  display: flex; flex-direction: column; gap: 12px;
}
.page-title {
  margin: 0;
  font-family: var(--font-display); font-style: italic; font-weight: 900;
  font-size: clamp(40px, 6vw, 64px); line-height: 0.95; text-transform: uppercase; color: var(--white);
}
.page-lead { margin: 0; max-width: 640px; font-size: 16px; line-height: 1.6; color: var(--text-2); }
/* Event page: one bold line under the title saying what the event is (red line at the start side) */
.event-tagline { margin: 0 0 12px; font-size: 17px; font-weight: 700; color: var(--white); border-inline-start: 3px solid var(--red); padding-inline-start: 12px; }
/* Registration page: the current event's name under the title (only as wide as its text) */
.event-badge {
  align-self: flex-start; margin: 0; padding: 6px 16px;
  background: var(--red); color: var(--white);
  font-family: var(--font-label); font-size: 12px; letter-spacing: 1.5px;
  clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
}
html[lang="ar"] .event-badge { font-size: 14px; font-weight: 700; letter-spacing: 0; }

.section { padding: 32px 0; }
.section + .section { border-top: 1px solid var(--line); }
.section-inner { padding-inline: 72px 32px; display: flex; flex-direction: column; gap: 18px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.grid-fit { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.actions { display: flex; flex-wrap: wrap; gap: 16px; }

.card {
  background: var(--panel); border: 1px solid var(--line-2);
  padding: 20px; display: flex; flex-direction: column; gap: 10px;
}
.card-featured { border-color: var(--red); }
.card h3 {
  margin: 0;
  font-family: var(--font-display); font-style: italic; font-weight: 800;
  font-size: 22px; line-height: 1.1; text-transform: uppercase; color: var(--white);
}
.card p { margin: 0; font-size: 14px; line-height: 1.6; color: var(--text-2); }
.card .num { font-family: var(--font-display); font-style: italic; font-weight: 800; font-size: 28px; line-height: 1; color: var(--red-text); }
.card .price { font-family: var(--font-display); font-weight: 700; font-size: 30px; line-height: 1.1; color: var(--white); }
.card .btn { align-self: flex-start; margin-top: auto; }
.btn.is-disabled { color: var(--muted); border-color: var(--line-3); cursor: default; }
.note {
  margin: 0; max-width: 720px;
  border-inline-start: 3px solid var(--red); background: var(--panel);
  padding: 12px 16px; font-size: 14px; line-height: 1.6; color: var(--text-2);
}

.driver-list .driver-info { padding: 14px 14px 16px; gap: 6px; }
.driver-list .driver-num { font-size: 24px; }
.driver-list .driver-name { font-size: 15px; }
.driver-list .driver-car { font-size: 13px; }

.dates-wide { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.dates-wide li { background: var(--panel); border: 1px solid var(--line-2); padding: 14px 16px; }
.dates-wide .date-title { font-size: 14px; }
.dates-wide .date-time { font-size: 12px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line-2); }
.data { width: 100%; min-width: 520px; border-collapse: collapse; font-size: 14px; }
.data th {
  text-align: start; padding: 12px 16px; background: var(--card);
  font-family: var(--font-label); font-weight: 600; font-size: 11px; letter-spacing: 1.5px; color: var(--muted);
}
.data td { padding: 12px 16px; border-top: 1px solid var(--line-2); color: var(--text-2); }
/* Results on phones: each row becomes a small card (position | number + driver / car | score) */
@media (max-width: 599px) {
  .table-wrap:has(.data) { border: none; overflow: visible; }
  .data { min-width: 0; }
  .data thead { display: none; }
  .data, .data tbody { display: block; }
  .data tr {
    display: grid; grid-template-columns: 44px auto minmax(0, 1fr) auto; align-items: center; gap: 2px 10px;
    grid-template-areas: "pos num name score" "pos car car score";
    background: var(--panel); border: 1px solid var(--line-2); padding: 12px 14px; margin-bottom: 10px;
  }
  .data td { display: block; padding: 0; border: 0; min-width: 0; }
  .data .r-pos { grid-area: pos; font-family: var(--font-display); font-style: italic; font-weight: 800; font-size: 26px; color: var(--red-text); text-align: center; }
  .data .r-num { grid-area: num; font-weight: 700; color: var(--white); }
  .data .r-name { grid-area: name; font-weight: 600; color: var(--white); overflow-wrap: anywhere; }
  .data .r-car { grid-area: car; font-size: 13px; color: var(--muted); }
  .data .r-score { grid-area: score; text-align: end; font-weight: 700; color: var(--white); }
  .data .r-score::before { content: attr(data-label); display: block; font-size: 10px; font-weight: 400; color: var(--muted); }
}

.gallery-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.gallery-grid a { display: block; border: 1px solid var(--line-2); transition: border-color 0.15s; background: linear-gradient(135deg, #1d1d23 0%, #2a1518 100%); }
.gallery-grid a:hover { border-color: var(--red); }
.gallery-grid img { width: 100%; height: auto; aspect-ratio: 4 / 5; object-fit: cover; display: block; }
/* Year buttons above the gallery (js/gallery.js): the chosen one red, the others outlined */
.gallery-years { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.gallery-years button {
  min-height: 44px; padding: 0 16px; cursor: pointer;
  background: transparent; border: 1px solid var(--line-3); color: var(--text-2);
  font-family: var(--font-label); font-size: 13px; letter-spacing: 0.5px;
}
.gallery-years button:hover { border-color: var(--red); color: var(--white); }
.gallery-years button[aria-pressed="true"] { background: var(--red); border-color: var(--red); color: var(--white); }
.gallery-years button:focus-visible { outline: 2px solid var(--red-text); outline-offset: 2px; }

.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; max-width: 760px; }
/* Registration: two columns (one on phones), so the mobile and emergency fields sit in the same
   column with the same width, and the country code list has room for its longest name */
.form[data-form="register"] { grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; position: relative; }
.form .full { grid-column: 1 / -1; }
.field label { font-family: var(--font-label); font-size: 12px; letter-spacing: 1px; color: var(--text-2); }
.field input, .field textarea {
  width: 100%; background: var(--card); border: 1px solid var(--line-3); color: var(--white);
  padding: 12px 14px; font: inherit; font-size: 16px;
}
.field input:focus-visible, .field textarea:focus-visible { outline: 2px solid var(--red-text); outline-offset: 1px; }
.form button.btn { border: none; cursor: pointer; justify-self: start; }
/* Registration: group headings, hint, category choice and car photo */
.form-group {
  margin: 14px 0 -4px; padding-bottom: 8px; border-bottom: 1px solid var(--line-2);
  font-size: 18px; color: var(--white);
}
.form-group:first-of-type { margin-top: 0; }
.form-group .optional { font-size: 13px; font-weight: 400; color: var(--text-2); }
.field-hint { font-size: 12px; color: var(--text-2); }
/* Mobile and emergency: Gulf country code list + number, left to right in both languages:
   the list on the left (as wide as its longest name, never cut), the number on the right */
.phone-row { display: flex; flex-direction: row; direction: ltr; gap: 8px; }
.phone-row select {
  order: 1; flex: 0 0 auto; width: auto; background: var(--card); border: 1px solid var(--line-3); color: var(--white);
  padding: 12px 10px; font: inherit; font-size: 16px; direction: ltr;
}
.phone-row select:focus-visible { outline: 2px solid var(--red-text); outline-offset: 1px; }
.phone-row select option { background: var(--card); color: var(--white); }
.phone-row input { order: 2; flex: 1 1 auto; min-width: 6em; }
html[lang="ar"] .field .phone-row input[dir="ltr"] { text-align: left; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.choice-group { margin: 0; padding: 0; border: 0; min-width: 0; }
.choice-group legend { font-family: var(--font-label); font-size: 12px; letter-spacing: 1px; color: var(--text-2); padding: 0; margin-bottom: 6px; }
/* The three categories always sit side by side, on one row */
.choices { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 520px) { .choices { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.choice {
  min-width: 0; white-space: nowrap; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 10px; background: var(--card); border: 1px solid var(--line-3); color: var(--white); cursor: pointer; font-size: 15px;
}
.choice input { accent-color: var(--red); width: 18px; height: 18px; margin: 0; }
.choice:has(input:checked) { border-color: var(--red); background: rgba(225, 18, 27, 0.12); }
.choice:has(input:focus-visible) { outline: 2px solid var(--red-text); outline-offset: 1px; }
.photo-pick {
  display: flex; align-items: center; gap: 14px; padding: 14px; cursor: pointer;
  background: var(--card); border: 1px dashed var(--line-3); color: var(--white);
}
.photo-pick:hover { border-color: var(--red); }
.photo-pick-text::before { content: "＋ "; color: var(--red-text); font-weight: 700; }
.photo-field { display: flex; flex-direction: column; gap: 8px; }
.photo-chosen { display: flex; align-items: center; gap: 12px; padding: 8px; background: var(--card); border: 1px solid var(--line-3); }
.photo-chosen[hidden] { display: none; }
.photo-preview { height: 80px; width: auto; max-width: 140px; object-fit: cover; border: 1px solid var(--line-2); flex: none; }
.photo-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.photo-name { color: var(--white); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.photo-size { color: var(--muted); font-size: 12px; align-self: flex-start; }
.photo-remove {
  flex: none; width: 36px; height: 36px; border: 1px solid var(--line-3); background: transparent;
  color: var(--white); font-size: 22px; line-height: 1; cursor: pointer;
}
.photo-remove:hover { border-color: var(--red); color: var(--red-text); }
.photo-remove:focus-visible { outline: 2px solid var(--red-text); outline-offset: 1px; }
.field-error { margin: 0; font-size: 13px; color: var(--red-text); }
.field-error[hidden] { display: none; }
/* Registration: a wrong field after "send" (js/main.js): red border, message under it */
.field input[aria-invalid="true"], .phone-row select[aria-invalid="true"] { border-color: var(--red); }
.choice-group.is-invalid .choice:not(:has(input:checked)) { border-color: var(--red); }
.field.is-invalid .photo-pick { border-color: var(--red); border-style: solid; }
/* Registration sent: this card takes the form's place */
.reg-done {
  max-width: 760px; padding: 28px 26px; display: flex; flex-direction: column; align-items: flex-start; gap: 12px;
  background: var(--panel); border: 1px solid var(--line-2); border-inline-start: 3px solid #2fa866;
}
.reg-done:focus { outline: none; }
.reg-done:focus-visible { outline: 2px solid var(--red-text); outline-offset: 2px; }
.reg-done .heading, .reg-done .copy { margin: 0; }
.reg-done .copy { font-size: 15px; line-height: 1.6; color: var(--text-2); }
/* The real file input stays reachable for the browser's "required" check but is drawn as the box above */
.photo-input { position: absolute; width: 1px; height: 1px; opacity: 0; clip-path: inset(50%); }
.field:has(.photo-input:focus-visible) .photo-pick { outline: 2px solid var(--red-text); outline-offset: 1px; }
.form-note[hidden] { display: none; }
.form-privacy { margin: 0; font-size: 13px; color: var(--muted); }

html[lang="ar"] .page-title { font-size: clamp(34px, 5vw, 54px); line-height: 1.25; }
html[lang="ar"] .card h3 { font-size: 20px; line-height: 1.35; }
html[lang="ar"] .field label, html[lang="ar"] .data th { font-size: 13px; }
html[lang="ar"] .field input[dir="ltr"] { text-align: right; }

@media (max-width: 960px) {
  .page-hero-inner { padding-block: 32px 28px; padding-inline: 40px 16px; }
  .section-inner { padding-inline: 16px; }
}

/* Keep the red stripes clear of the text on small screens */
@media (max-width: 960px) {
  .hero-stripe { left: -100px; }
  [dir="rtl"] .hero-stripe { left: auto; right: -100px; }
  .page-hero::before { inset-inline-start: -90px; }
}

/* ---------- Live forms and admin-managed content ---------- */
/* Hidden in place: moving it off-screen to the left makes right-to-left pages scroll sideways */
.hp { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); opacity: 0; pointer-events: none; }
.form-ok { border-inline-start-color: #2fa866; }
.form button.btn:disabled { opacity: 0.6; cursor: default; }
[hidden] { display: none !important; }
.driver-noimg {
  aspect-ratio: 148 / 70; display: flex; align-items: center; justify-content: center;
  background: var(--bg-2); color: var(--line-3);
  font-family: var(--font-display); font-style: italic; font-weight: 800; font-size: 28px;
}
.dyn-ready > .driver-skeleton { display: none; }
.driver-country { font-family: var(--font-label); font-size: 10px; color: var(--muted); }
/* Computers and tablets: taller photos (the img's height="70" made a thin strip) and at most
   four drivers per row on the drivers page, spread over the whole width. Phones: see below.
   Kept after .grid and .driver-noimg so it wins over them. */
@media (min-width: 701px) {
  .driver img, .driver-noimg { height: auto; aspect-ratio: 4 / 3; }
  .driver-list { grid-template-columns: repeat(auto-fit, minmax(max(240px, calc((100% - 48px) / 4)), 1fr)); }
}
/* Phones, drivers page only: the img's height="70" made a thin strip; the homepage
   (.driver-grid in .panel-drivers) keeps its small 148/70 photos. */
@media (max-width: 700px) {
  .driver-list .driver img, .driver-list .driver-noimg { height: auto; aspect-ratio: 16 / 10; }
}

/* ---------- Gallery viewer ---------- */
.lightbox-open { overflow: hidden; }
.lightbox {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 56px 12px 44px; background: rgba(5, 5, 7, 0.96);
}
.lb-img { flex: 0 1 auto; min-width: 0; max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.lb-btn {
  flex: none; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center;
  background: rgba(20, 20, 24, 0.85); border: 1px solid var(--line-3); color: var(--white); cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
/* Red on hover only with a mouse: on touch screens :hover sticks to the last button tapped */
@media (hover: hover) {
  .lb-btn:hover { background: var(--red); border-color: var(--red); }
}
/* Red while pressed, touch or mouse; it goes back as soon as the press ends */
.lb-btn:not(:disabled):active { background: var(--red); border-color: var(--red); transition: none; }
.lb-btn:focus-visible { outline: 2px solid var(--red-text); outline-offset: 2px; }
.lb-close { position: absolute; top: 8px; inset-inline-end: 12px; width: 44px; height: 44px; }
/* The chevrons are drawn for left-to-right; flip them when the page runs right to left */
[dir="rtl"] .lb-prev svg, [dir="rtl"] .lb-next svg { transform: scaleX(-1); }
.lb-count {
  position: absolute; bottom: 10px; left: 0; right: 0; margin: 0; text-align: center;
  font-family: var(--font-label); font-size: 13px; letter-spacing: 1px; color: var(--text-2);
}
.gallery-grid a { cursor: zoom-in; }
.lb-btn[hidden] { display: none; }
/* "Load more" under the gallery grid (js/gallery.js): only when there are more than 24 photos */
.gallery-more { margin-top: 28px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.gallery-more[hidden], .gallery-more .btn[hidden] { display: none; }
.gallery-more-count { margin: 0; color: var(--text-2); font-size: 14px; }
.gallery-more .btn { background: none; min-height: 44px; cursor: pointer; }
/* The photo viewer's bottom bar: photographer, Download / Share, the counter (the videos viewer has none) */
.lightbox.lb-photos { padding-bottom: 124px; }
.lb-bar {
  position: absolute; left: 0; right: 0; bottom: 8px; padding: 0 12px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.lb-photos .lb-count { position: static; }
.lb-credit { margin: 0; font-size: 14px; color: var(--text-2); text-align: center; overflow-wrap: anywhere; }
.lb-credit svg { vertical-align: -4px; margin-inline-end: 6px; }
.lb-credit[hidden], .lb-note[hidden] { display: none; }
.lb-credit a { color: var(--white); text-decoration: underline; text-underline-offset: 3px; }
@media (hover: hover) {
  .lb-credit a:hover { color: var(--red-text); }
}
.lb-credit a:focus-visible { outline: 2px solid var(--red-text); outline-offset: 2px; }
.lb-actions { display: flex; gap: 10px; }
.lb-btn.lb-act {
  width: auto; height: 44px; min-width: 44px; padding: 0 16px; gap: 8px;
  font-family: var(--font-label); font-weight: 600; font-size: 13px; letter-spacing: 0.6px;
}
.lb-btn.lb-act:disabled { opacity: 0.6; cursor: progress; }
.lb-note {
  position: absolute; bottom: 100%; margin: 0 0 8px; max-width: calc(100% - 24px);
  padding: 8px 14px; background: rgba(20, 20, 24, 0.95); border: 1px solid var(--line-3);
  color: var(--white); font-size: 14px; text-align: center; overflow-wrap: anywhere; user-select: text;
}

/* ---------- Terms (waiver page) ---------- */
.terms { max-width: 820px; margin-bottom: 32px; line-height: 1.8; }
.terms h2 { font-size: 24px; margin: 0 0 8px; }
.terms > p { color: var(--text-2); margin: 0 0 16px; }
.terms ol { margin: 0; padding-inline-start: 24px; }
.terms ol > li { margin-bottom: 12px; padding-inline-start: 4px; }
.terms ol > li::marker { color: var(--red-text); font-weight: 700; }
.terms ul { margin: 6px 0 0; padding-inline-start: 20px; color: var(--text-2); }
.terms ul li { margin-bottom: 4px; }
/* Privacy policy page: sections with headings and bullet lists */
.privacy-policy h2 { margin-top: 28px; }
.privacy-policy > ul { margin: 0 0 16px; }
.privacy-policy .policy-updated { color: var(--muted); font-size: 14px; margin-bottom: 18px; }

/* The same terms in a window over the registration form */
.terms-modal {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(5, 5, 7, 0.88);
}
.terms-modal[hidden] { display: none; }
.terms-panel {
  position: relative; width: min(760px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column;
  background: #111115; border: 1px solid var(--line-2); padding: 24px 24px 20px;
}
.terms-body { overflow-y: auto; padding-inline-end: 6px; scrollbar-color: #444 transparent; scrollbar-width: thin; }
.terms-body .terms { margin: 0; }
.terms-close { position: absolute; top: 10px; inset-inline-end: 10px; width: 40px; height: 40px; }
.terms-ok { align-self: flex-start; margin-top: 16px; }

/* ---------- Videos ---------- */
.video-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.video-card { display: block; color: var(--white); text-decoration: none; }
.video-thumb {
  position: relative; display: flex; align-items: center; justify-content: center;
  aspect-ratio: 16 / 9; overflow: hidden; background: #15151a; border: 1px solid var(--line-2); transition: border-color 0.15s;
}
.video-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.video-play {
  position: relative; width: 64px; height: 44px; border-radius: 10px; background: var(--red); color: var(--white);
  display: flex; align-items: center; justify-content: center; transition: transform 0.15s;
}
.video-card:hover .video-thumb { border-color: var(--red); }
.video-card:hover .video-play { transform: scale(1.08); }
.video-card:focus-visible { outline: 2px solid var(--red-text); outline-offset: 3px; }
.video-title { display: block; margin-top: 10px; font-size: 15px; line-height: 1.4; }
.video-empty { color: var(--text-2); text-align: center; padding: 40px 0; }
.page-switch { margin: 28px 0 0; text-align: center; }
.page-switch a { color: var(--red-text); font-weight: 600; text-decoration: none; }
.page-switch a:hover { text-decoration: underline; }
.lb-video { flex: 0 1 auto; width: min(100%, calc((100vh - 110px) * 16 / 9)); aspect-ratio: 16 / 9; background: #000; }
.lb-video iframe { width: 100%; height: 100%; border: 0; display: block; }
@media (max-width: 700px) {
  .lightbox { padding-inline: 0; gap: 0; }
  /* Both viewers: the arrows sit on the "1 / N" line at the bottom, one each side of it, off the
     photo or video. The counter line is as tall as the arrows (44px) so they line up with it.
     inline-start/end put "previous" on the left in English and on the right in Arabic. */
  .lightbox.lb-photos { padding-bottom: 148px; }
  .lightbox:not(.lb-photos) { padding-bottom: 64px; }
  .lb-count { line-height: 44px; }
  .lightbox:not(.lb-photos) .lb-count { bottom: 8px; }
  .lb-prev, .lb-next { position: absolute; bottom: 8px; width: 44px; height: 44px; z-index: 1; }
  .lb-prev { inset-inline-start: calc(50% - 96px); }
  .lb-next { inset-inline-end: calc(50% - 96px); }
  /* Videos viewer: the counter also holds the video's title ("2 / 2 · title"), so the arrows go to
     the edges and the text sits between them, wrapping to two lines when long */
  .lightbox:not(.lb-photos) .lb-prev { inset-inline-start: 12px; }
  .lightbox:not(.lb-photos) .lb-next { inset-inline-end: 12px; }
  .lightbox:not(.lb-photos) .lb-count {
    padding-inline: 64px; min-height: 44px; line-height: 1.4;
    display: flex; align-items: center; justify-content: center; overflow-wrap: anywhere;
  }
}

/* ---------- Registration: privacy box and consents ---------- */
.privacy-box {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 16px 18px; background: var(--bg-2); border: 1px solid var(--line-2);
}
.privacy-box svg { flex: none; margin-top: 2px; }
.privacy-title {
  margin: 0 0 6px; font-family: var(--font-label); font-weight: 600; font-size: 14px;
  letter-spacing: 1px; text-transform: uppercase; color: var(--white);
}
.privacy-copy { margin: 0; font-size: 14px; line-height: 1.7; color: var(--text-2); }
.consents {
  margin: 0; min-width: 0; padding: 6px 18px 16px;
  border: 1px solid var(--line-2); display: flex; flex-direction: column;
}
.consents legend {
  padding: 0 8px; font-family: var(--font-label); font-weight: 600; font-size: 13px;
  letter-spacing: 1px; text-transform: uppercase; color: var(--white);
}
.consent { display: flex; align-items: flex-start; gap: 14px; padding: 14px 0; cursor: pointer; }
.consent + .consent { border-top: 1px solid var(--line); }
.consent input {
  flex: none; width: 24px; height: 24px; margin: 1px 0 0;
  accent-color: var(--red); color-scheme: dark; cursor: pointer;
}
.consent-text { min-width: 0; font-size: 14px; line-height: 1.7; color: var(--text-2); }
.badge {
  display: inline-block; margin-inline-end: 6px; padding: 1px 9px; vertical-align: 1px;
  font-family: var(--font-label); font-weight: 600; font-size: 11px; letter-spacing: 0.5px; line-height: 1.6;
}
.badge-required { background: var(--red); color: var(--white); }
.badge-optional { background: #3a3a40; color: var(--text-2); }
.inline-link { color: var(--red-text); text-decoration: underline; }

/* Register page FAQ (<details>, no JS): one line under each question, red + / − at the
   end side (left in Arabic, right in English), no animation */
#faq { scroll-margin-top: 90px; } /* the "See the FAQ" link does not hide the title under the sticky header */
.faq-list { max-width: 820px; }
.faq-list details { border-bottom: 1px solid var(--line); padding-block: 14px; }
.faq-list summary {
  list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  min-height: 44px; cursor: pointer; font-size: 16px; font-weight: 700; color: var(--white);
}
.faq-list summary::-webkit-details-marker { display: none; }
.faq-list summary::after { content: "+"; flex: none; color: var(--red); font-size: 22px; line-height: 1; }
.faq-list details[open] > summary::after { content: "\2212"; }
.faq-list summary:focus-visible { outline: 2px solid var(--red-text); outline-offset: 2px; }
.faq-list details p { margin: 8px 0 0; font-size: 15px; line-height: 1.8; color: var(--text-2); }
/* "Have a question? See the FAQ" at the top of the form (hidden with the form) */
.faq-jump { margin: 0; font-size: 14px; color: var(--text-2); }
/* Contact page: line under the lead pointing to the FAQ */
.page-note { margin: 12px 0 0; max-width: 640px; font-size: 15px; line-height: 1.6; color: var(--text-2); }
.form button.btn:disabled { background: #3a3a40; color: var(--muted); opacity: 1; cursor: not-allowed; }
.submit-hint { margin: -6px 0 0; font-size: 13px; color: var(--muted); }
/* A small note under a field (registration: where the result is sent) */
.input-note { margin: 0; font-size: 13px; color: var(--muted); }
.soon {
  margin: 0; font-family: var(--font-display); font-style: italic; font-weight: 800;
  font-size: 40px; line-height: 1.1; text-transform: uppercase; color: var(--muted-2);
}
html[lang="ar"] .privacy-title, html[lang="ar"] .consents legend { font-size: 15px; }
html[lang="ar"] .badge { font-size: 12px; }
@media (max-width: 560px) {
  .privacy-box { padding: 14px; gap: 12px; }
  .consents { padding: 4px 14px 12px; }
  .consent input { width: 26px; height: 26px; }
}

/* ---------- Registration closed ---------- */
.closed-box {
  width: 100%; max-width: 760px; align-self: center; padding: 40px 24px; display: flex; flex-direction: column; align-items: center; gap: 14px;
  text-align: center; background: var(--panel); border: 1px solid var(--line-2);
}
.closed-box .actions { justify-content: center; margin-top: 8px; }
.closed-box [hidden] { display: none; }
.closed-box button.btn { border: none; cursor: pointer; }
.closed-box .copy a[data-contact-email] { color: var(--red-text); }
/* Registration page, while it asks the server whether registration is open */
.reg-loading {
  width: 100%; max-width: 760px; align-self: center; padding: 40px 24px; display: flex; align-items: center; justify-content: center; gap: 12px;
  color: var(--muted);
}
.reg-loading[hidden] { display: none; }
.reg-loading .spinner {
  width: 18px; height: 18px; flex: none; border: 2px solid var(--line-2); border-top-color: var(--red); border-radius: 50%;
  animation: reg-spin 0.8s linear infinite;
}
@keyframes reg-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .reg-loading .spinner { animation: none; } }

/* ---------- Homepage hero: full-width background video ----------
   Placed last so it wins over the photo layout above. Behind the video (while it loads, or when the
   phone blocks it) .hero-bg shows the video's own first frame, so the start looks seamless. Same
   picture in both languages: the video isn't mirrored. Replace images/hero-video-poster.jpg
   together with the video. images/hero.jpg is still the link-preview picture (og:image). */
.hero-bg { width: 100%; opacity: 1; overflow: hidden; }
.hero-bg, [dir="rtl"] .hero-bg { background: url(../images/hero-video-poster.jpg) center / cover no-repeat; }
.hero-bg::after { content: ""; position: absolute; inset: 0; background: rgba(8,8,10,0.55); }
.hero-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: saturate(1.05) contrast(1.05); }
.hero-fade-left { background: linear-gradient(90deg, rgba(10,10,12,0.75), rgba(10,10,12,0.1) 65%); }
[dir="rtl"] .hero-fade-left { background: linear-gradient(270deg, rgba(10,10,12,0.75), rgba(10,10,12,0.1) 65%); }
.hero-inner { min-height: 600px; padding-bottom: 64px; }
@media (max-width: 960px) {
  .hero-bg { opacity: 1; }
  .hero-inner { min-height: 0; }
}
@media (max-width: 560px) {
  /* Phones: lighter video, buttons and countdown the same width, tagline on one line */
  .hero-bg::after { background: rgba(8,8,10,0.3); }
  .hero-fade-left, [dir="rtl"] .hero-fade-left { background: linear-gradient(180deg, rgba(10,10,12,0.55), rgba(10,10,12,0.25) 55%, rgba(10,10,12,0.6)); }
  .hero-inner { padding-bottom: 40px; }
  .hero-ctas { flex-direction: column; gap: 12px; }
  .hero-ctas .btn { width: 100%; justify-content: center; }
  .countdown { align-self: stretch; justify-content: center; }
  html[lang="ar"] .hero-tagline { font-size: 15px; letter-spacing: 0; }
}
/* People who ask for less motion get the still photo */
@media (prefers-reduced-motion: reduce) { .hero-video { display: none; } }

/* Schedule / drivers / results: the sample content in the HTML stays hidden (space kept)
   until js/content.js has drawn the real data, so a refresh does not swap photos or dates */
[data-dyn]:not(.dyn-ready) { visibility: hidden; }

/* Story card (drivers page, js/story-card.js): the button under a driver with a photo, shown only
   while the panel's switch is on, and the "Your card is ready" window */
.story-btn {
  align-self: flex-start; margin-top: 6px; padding: 6px 10px; background: transparent; color: var(--white);
  border: 1px solid var(--line-3); font-family: var(--font-label); font-size: 11px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; cursor: pointer; transition: border-color 0.15s;
}
.story-btn:hover, .story-btn:focus-visible { border-color: var(--red-text); }
.story-btn:focus-visible { outline: 2px solid var(--red-text); outline-offset: 2px; }
html.story-open { overflow: hidden; }
.story-modal {
  position: fixed; inset: 0; z-index: 1000; background: rgba(0, 0, 0, 0.82);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.story-box {
  background: var(--panel); border: 1px solid var(--line-3); width: 100%; max-width: 360px;
  max-height: 100%; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 14px;
}
.story-title { margin: 0; font-family: var(--font-display); font-size: 22px; font-weight: 700; color: var(--white); }
.story-preview {
  aspect-ratio: 9 / 16; width: 100%; max-height: 62vh; margin: 0 auto; background: var(--bg-2);
  display: flex; align-items: center; justify-content: center;
}
.story-preview img { width: 100%; height: 100%; object-fit: contain; display: block; }
.story-status, .story-note { margin: 0; font-size: 13px; color: var(--muted); text-align: center; padding: 0 12px; }
.story-actions { display: flex; gap: 10px; }
.story-actions button {
  flex: 1; padding: 12px; font-family: var(--font-label); font-size: 13px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; cursor: pointer; border: 1px solid var(--line-3);
}
.story-save { background: var(--red); border-color: var(--red) !important; color: var(--white); }
.story-save:hover:not(:disabled) { background: var(--red-hover); }
.story-save:disabled { opacity: 0.5; cursor: default; }
.story-close { background: transparent; color: var(--white); }
.story-actions button:focus-visible { outline: 2px solid var(--red-text); outline-offset: 2px; }
