/* Motorsport Avenue: one stylesheet, no framework. Mobile first. */

:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #efede7;
  --text: #17191d;
  --muted: #5d6169;
  --border: #dcd9d1;
  --control-border: #878a91; /* form fields: at least 3:1 against the page (WCAG 1.4.11) */
  --accent: #c2410c;
  --accent-ink: #ffffff;
  --accent-soft: #fde7dc;
  --link: #b23c0b;
  --open: #1f7a3d;
  --open-soft: #ddf2e3;
  --soon: #a33a00;
  --soon-soft: #ffe3cc;
  --upcoming: #1d5fa8;
  --upcoming-soft: #dceafa;
  --closed: #5d6169;
  --closed-soft: #e8e7e3;
  --tbc: #6b4fa0;
  --tbc-soft: #ece5f7;
  --danger: #b42318;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 2px 8px rgb(0 0 0 / 0.04);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --nav-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1c1f24;
    --surface-2: #252931;
    --text: #eceae4;
    --muted: #a3a7af;
    --border: #2f343c;
    --control-border: #737983;
    --accent: #ff6b2c;
    --accent-ink: #14161a;
    --accent-soft: #3a2216;
    --link: #ff9566;
    --open: #6fd08f;
    --open-soft: #173022;
    --soon: #ffab6b;
    --soon-soft: #3d2513;
    --upcoming: #7fb5f0;
    --upcoming-soft: #172a40;
    --closed: #a3a7af;
    --closed-soft: #262a31;
    --tbc: #c3a9f0;
    --tbc-soft: #2a2238;
    --danger: #ff8a80;
    --shadow: none;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--font);
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}

a { color: var(--link); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5rem; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.7rem, 5vw, 2.5rem); }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 0.75rem; }

.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.lead { font-size: 1.1rem; color: var(--muted); max-width: 46rem; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; }

.icon {
  width: 1.25em; height: 1.25em; flex: none; vertical-align: -0.25em;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* ---- Header and navigation ---- */

.site-header {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.site-header::before {
  /* chequered strip */
  content: ""; display: block; height: 4px;
  background: repeating-conic-gradient(var(--text) 0 25%, transparent 0 50%) 0 0 / 8px 8px;
  opacity: 0.85;
}
.header-inner { display: flex; align-items: center; gap: 12px; min-height: 56px; }
.brand {
  display: flex; align-items: center; gap: 10px; margin-right: auto;
  color: var(--text); text-decoration: none; font-weight: 700; letter-spacing: -0.01em;
}
.brand img { border-radius: 7px; }
.lang-switch {
  font-weight: 700; font-size: 0.85rem; text-decoration: none; color: var(--text);
  border: 1.5px solid var(--border); border-radius: 999px; padding: 4px 10px;
}
.lang-switch:hover { border-color: var(--accent); }

/* Mobile: app-style tab bar at the bottom */
.main-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.main-nav ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); }
.main-nav a {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; height: var(--nav-h); font-size: 0.72rem; font-weight: 600;
  color: var(--muted); text-decoration: none;
}
.main-nav a .icon { width: 24px; height: 24px; }
.main-nav a[aria-current="page"] { color: var(--accent); }
.main-nav .count {
  position: absolute; top: 8px; left: calc(50% + 6px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: var(--accent-ink); font-size: 0.7rem; line-height: 18px; text-align: center;
}

@media (min-width: 760px) {
  body { padding-bottom: 0; }
  .main-nav { position: static; background: none; border: 0; padding: 0; }
  .main-nav ul { display: flex; gap: 4px; }
  .main-nav a {
    flex-direction: row; height: 40px; padding: 0 12px; gap: 8px;
    font-size: 0.95rem; border-radius: 999px; color: var(--text);
  }
  .main-nav a .icon { width: 18px; height: 18px; }
  .main-nav a:hover { background: var(--surface-2); }
  .main-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--text); }
  .main-nav .count { position: static; }
  /* Only on desktop: a backdrop filter would trap the fixed mobile tab bar inside the header. */
  .site-header {
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: saturate(1.4) blur(10px);
    -webkit-backdrop-filter: saturate(1.4) blur(10px);
  }
}

/* ---- Banners ---- */

.banner { padding: 8px 16px; text-align: center; font-size: 0.9rem; font-weight: 600; }
.banner-sample { background: repeating-linear-gradient(45deg, #ffd43b, #ffd43b 12px, #fcc419 12px, #fcc419 24px); color: #17191d; }
.banner-offline { background: var(--closed-soft); color: var(--text); }

/* ---- Layout blocks ---- */

main { padding-top: 24px; padding-bottom: 48px; }
.page-head { margin-bottom: 24px; }
.crumb { margin-bottom: 8px; font-size: 0.9rem; }
.section { margin-top: 40px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.panel.warn { border-color: var(--soon); background: var(--soon-soft); }
.split { display: grid; gap: 16px; }
@media (min-width: 760px) { .split { grid-template-columns: 1fr 1fr; } }
.steps { margin: 0 0 0.75rem; padding-left: 1.25rem; }
.steps li { margin-bottom: 0.4rem; }
.empty { color: var(--muted); padding: 16px 0; }
.empty-state { max-width: 40rem; }
.prose { max-width: 44rem; }
.prose h2 { margin-top: 2rem; }
.prose li { margin-bottom: 0.4rem; }

/* ---- Hero ---- */

.hero { padding: 16px 0 8px; }
.hero h1 { max-width: 20ch; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 16px 0; }
.stats {
  list-style: none; padding: 0; margin: 24px 0 0;
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
}
@media (min-width: 760px) { .stats { grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); } }
.stats li {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; color: var(--muted); font-size: 0.9rem; line-height: 1.3;
}
.stats strong { display: block; font-size: 1.6rem; color: var(--text); font-variant-numeric: tabular-nums; }

/* ---- Buttons ---- */

.button {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px;
  border-radius: 999px; border: 1.5px solid var(--border); background: var(--surface);
  color: var(--text); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.button:hover { border-color: var(--text); }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.button.primary:hover { filter: brightness(1.05); }
.button.danger { color: var(--danger); }
.button .icon { width: 18px; height: 18px; }
.link-button {
  background: none; border: 0; padding: 0; font: inherit; color: var(--link);
  text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
}

/* ---- Filters ---- */

.filters {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; margin-bottom: 16px; display: grid; gap: 10px;
}
.search input {
  width: 100%; min-height: 44px; padding: 0 14px; font: inherit; color: var(--text);
  background: var(--bg); border: 1.5px solid var(--control-border); border-radius: 10px;
}
.facets summary {
  cursor: pointer; font-weight: 600; padding: 4px 0; list-style: none;
  display: flex; align-items: center; gap: 6px;
}
.facets summary::-webkit-details-marker { display: none; }
.facets summary::after { content: "▾"; color: var(--muted); }
.facets:not([open]) summary::after { content: "▸"; }
.facet-grid { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); padding-top: 8px; }
@media (min-width: 760px) { .facet-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.facet { display: grid; gap: 4px; font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.facet select {
  min-height: 40px; padding: 0 8px; font: inherit; font-weight: 400; color: var(--text);
  background: var(--bg); border: 1.5px solid var(--control-border); border-radius: 8px; width: 100%;
}
.facet select.active { border-color: var(--accent); }
.sector-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.sector-tabs button {
  min-height: 44px; padding: 0 14px; font: inherit; font-weight: 600; color: var(--text);
  background: var(--bg); border: 1.5px solid var(--control-border); border-radius: 999px; cursor: pointer;
}
.sector-tabs button[aria-pressed="true"] { border-color: var(--accent); background: var(--surface); box-shadow: inset 0 0 0 1px var(--accent); }
.filter-status { display: flex; justify-content: space-between; align-items: center; font-size: 0.9rem; color: var(--muted); }

/* ---- Cards ---- */

.cards { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 12px; }
@media (min-width: 760px) { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1080px) { .cards-compact { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.card {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 6px; min-width: 0;
}
.card:target { outline: 3px solid var(--accent); }
.card.is-closed { opacity: 0.7; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; min-height: 24px; }
.card-title { margin: 0; overflow-wrap: anywhere; font-size: 1.05rem; }
.card-title a { color: var(--text); text-decoration: none; }
.card-title a:hover { text-decoration: underline; }
.card-sub { margin: 0; color: var(--muted); font-size: 0.92rem; }
.meta { margin: 4px 0 0; font-size: 0.82rem; color: var(--muted); }
.meta a { color: var(--muted); }
.salary { margin: 0; font-size: 0.92rem; }

/* Employer logo box (D40). White tile in both themes: most logos are drawn for white. A
   monogram tile (no logo file) gets its colour from --tile, set per employer in the HTML;
   every palette colour is AA against white text in both themes.
   Job and employer cards are a two-column grid, so the box sits left of the title and the
   sub-line without wrapper elements (the jobs page lists hundreds of cards). With no box
   (employer not in the registry) the title simply spans the card. */
.card.job, .card.employer {
  display: grid; grid-template-columns: 40px minmax(0, 1fr); column-gap: 12px; row-gap: 6px;
  align-items: start;
}
.card.employer { grid-template-columns: 48px minmax(0, 1fr); }
.card.job > *, .card.employer > * { grid-column: 1 / -1; }
.card .logo { grid-column: 1; grid-row: span 2; }
.card .logo + .card-title, .card .logo + .card-title + .card-sub { grid-column: 2; }
.logo {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 10px; overflow: hidden;
  background: #ffffff; border: 1px solid var(--border);
}
.logo img { display: block; width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.logo-dark { background: #14161a; }
.logo.monogram {
  background: var(--tile, #394150); color: #ffffff; border: 0;
  font-weight: 700; font-size: 0.9rem; letter-spacing: 0.03em; user-select: none;
}
.logo-m { width: 48px; height: 48px; }
.logo-m.monogram { font-size: 1.05rem; }
.logo-l { width: 64px; height: 64px; border-radius: 14px; }
.logo-l img { padding: 6px; }
.logo-l.monogram { font-size: 1.4rem; }
.page-head-row { display: flex; align-items: center; gap: 16px; }
.page-head-row > div { min-width: 0; }

.programme { border-left: 4px solid var(--border); }
.programme.state-open, .programme.state-deadline_ahead { border-left-color: var(--open); }
.programme.state-closing_soon { border-left-color: var(--soon); }
.programme.state-upcoming { border-left-color: var(--upcoming); }

.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.01em; white-space: nowrap;
}
.badge-open, .badge-deadline_ahead, .badge-new { background: var(--open-soft); color: var(--open); }
.badge-closing_soon { background: var(--soon-soft); color: var(--soon); }
.badge-upcoming { background: var(--upcoming-soft); color: var(--upcoming); }
.badge-closed, .badge-no_dates { background: var(--closed-soft); color: var(--closed); }
.badge-tbc { background: var(--tbc-soft); color: var(--tbc); }
.badge-segment-motorsport { background: var(--accent-soft); color: var(--text); }
.badge-segment-automotive { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--control-border); }
.group-title { margin-top: 24px; font-size: 1.05rem; }

.chips { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 0.78rem; padding: 2px 8px; border-radius: 6px;
  background: var(--surface-2); color: var(--text);
}
.chip-series { font-weight: 600; }
.chip-wheels { background: var(--accent-soft); }

.facts { margin: 6px 0 0; display: grid; gap: 4px; font-size: 0.9rem; }
.fact { display: grid; grid-template-columns: 7.5rem 1fr; gap: 8px; }
.fact dt { color: var(--muted); }
.fact dd { margin: 0; overflow-wrap: anywhere; }
.fact-closes dd { font-weight: 700; }

/* Save (star) button */
.save {
  flex: none; display: inline-grid; place-items: center; width: 40px; height: 40px; margin: -8px -8px 0 0;
  border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer;
}
.save:hover { background: var(--surface-2); color: var(--text); }
.save[aria-pressed="true"] { color: var(--accent); }
.save[aria-pressed="true"] .icon { fill: currentColor; }

/* ---- Employer page ---- */

.links-panel { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.links-panel p { margin: 0; }
.links-panel .meta { flex-basis: 100%; }

/* ---- My list ---- */

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.toolbar label.button { position: relative; }
/* The file input is visually hidden: show its focus on the label that looks like a button. */
.toolbar label.button:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
.saved-item .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.saved-item select, .saved-item textarea {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1.5px solid var(--control-border); border-radius: 8px;
}
.saved-item select { min-height: 40px; padding: 0 8px; }
.saved-item textarea { width: 100%; min-height: 64px; padding: 8px; resize: vertical; }
.saved-item .status-applied, .saved-item .status-interview { border-color: var(--upcoming); }
.saved-item .status-offer { border-color: var(--open); }

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

.site-footer { border-top: 1px solid var(--border); padding: 24px 0 32px; margin-top: 24px; }
.footer-brand { font-weight: 700; }
.footer-links { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 6px 16px; }

/* ---- Root language chooser ---- */

.root-choice { padding-top: 20vh; text-align: center; }
.root-choice .button { margin: 4px; }

@media (prefers-reduced-motion: no-preference) {
  .card, .button, .save { transition: border-color 0.15s, background-color 0.15s, color 0.15s; }
}
