/* Deeploy Tech: entries, race control, team plate, footer, motion and every
   breakpoint. Loaded last so the media queries win the cascade. */

/* ---------- Entries ---------- */

.entries,
.control,
.team-plate {
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(80px, 10vw, 136px) var(--gutter) 0;
}

/* A speed streak: a wedge that thickens toward the direction of travel and
   ends in the team's three slashes. */
.streak {
  position: relative;
  display: block;
  height: 14px;
  max-width: 820px;
  margin-top: 18px;
}
.streak::before {
  content: "";
  position: absolute;
  inset: 0 78px 0 0;
  background: var(--orange);
  clip-path: polygon(0 64%, 100% 0, 100% 100%, 0 100%);
}
.streak::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 66px;
  height: 100%;
  background: var(--slashes-orange) right center / contain no-repeat;
}

.entries > .streak { margin-bottom: clamp(32px, 4.4vw, 56px); }

.entry {
  display: grid;
  grid-template-columns: clamp(150px, 16vw, 230px) minmax(0, 1fr) minmax(260px, 0.62fr);
  border: 1px solid var(--track);
  background: var(--pit);
  scroll-margin-top: 24px;
}
.entry + .entry { margin-top: 16px; }
.entry:focus { outline: none; }
.entry:target { border-color: var(--livery); }

.entry__no {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 28px 0 12px;
  background: var(--livery);
  color: var(--graphite);
  clip-path: polygon(0 0, 100% 0, calc(100% - 36px) 100%, 0 100%);
  font-style: italic;
  font-weight: 900;
  font-stretch: 125%;
  font-size: clamp(3.5rem, 6vw, 5.5rem);
  line-height: 1;
}

.entry__body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 30px clamp(20px, 3vw, 40px);
}
.entry__name {
  color: var(--ink);
  font-style: italic;
  font-weight: 900;
  font-stretch: 125%;
  font-size: clamp(1.5rem, 2.6vw, 2.25rem);
  line-height: 0.96;
  text-transform: uppercase;
  text-wrap: balance;
}
.entry__body p { max-width: 62ch; }

/* The same label grid on every entry, so entries compare at a glance. */
.entry__label {
  display: grid;
  grid-template-columns: auto 1fr;
  align-content: center;
  padding: 24px clamp(20px, 2.4vw, 32px);
  border-left: 1px solid var(--track);
}
.entry__label > div { display: contents; }
.entry__label dt,
.entry__label dd {
  padding: 9px 0;
  border-top: 1px solid var(--track);
}
.entry__label > div:first-child dt,
.entry__label > div:first-child dd { border-top: 0; }
.entry__label dt {
  padding-right: 22px;
  color: var(--ink-quiet);
  font-style: italic;
  font-weight: 700;
  font-stretch: 112%;
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  line-height: 1.9;
}
.entry__label dd {
  color: var(--ink);
  font-weight: 600;
}

.state {
  display: inline-block;
  width: 12px;
  height: 14px;
  margin-right: 10px;
  vertical-align: -1px;
  transform: skewX(var(--slant));
  border: 2px solid var(--livery);
}
.state--live { background: var(--livery); }
.state--beta { background: linear-gradient(var(--livery), var(--livery)) bottom / 100% 50% no-repeat; }

/* ---------- Race control ---------- */

.control {
  display: grid;
  grid-template-columns: clamp(64px, 9vw, 132px) minmax(0, 1fr);
  gap: clamp(28px, 5vw, 72px);
}

.control__flag {
  min-height: 100%;
  /* Race control's flag: chequered, cut to lean into the direction of travel. */
  background: repeating-conic-gradient(var(--decal) 0 25%, var(--graphite) 0 50%) 0 0 / 32px 32px;
  clip-path: polygon(0 0, 100% 36px, 100% 100%, 0 calc(100% - 36px));
}

.control__body {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 8px 0;
}
.control__lead {
  font-size: clamp(1.125rem, 1.4vw, 1.375rem);
  color: var(--ink);
  max-width: 60ch;
}

.rules {
  display: grid;
  gap: 0;
  margin-top: 8px;
}
.rules li {
  position: relative;
  padding: 18px 0 18px 64px;
  border-top: 1px solid var(--track);
  color: var(--ink);
  font-size: clamp(1.125rem, 1.6vw, 1.5rem);
  font-weight: 500;
  line-height: 1.35;
  text-wrap: pretty;
}
.rules li > span { display: block; max-width: 38em; }
.rules li:last-child { border-bottom: 1px solid var(--track); }
.rules li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 40px;
  height: 16px;
  margin-top: -8px;
  background: var(--slashes-orange) left center / contain no-repeat;
}

.control__coverage {
  max-width: 58ch;
  color: var(--ink-quiet);
}

/* ---------- Team plate + close ---------- */

.team-plate {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(32px, 6vw, 96px);
  align-items: center;
  padding-bottom: clamp(80px, 10vw, 136px);
}

/* A scrutineering plate: decal white, cut corner, riveted label grid. */
.plate {
  position: relative;
  padding: 30px clamp(22px, 3vw, 40px) 26px;
  background: var(--decal);
  color: var(--graphite);
  clip-path: polygon(0 0, calc(100% - 34px) 0, 100% 34px, 100% 100%, 0 100%);
  box-shadow: 0 0 0 1px var(--decal);
}
.plate::after {
  content: "";
  position: absolute;
  right: 22px;
  bottom: 22px;
  width: 54px;
  height: 22px;
  background: var(--slashes-orange) center / contain no-repeat;
}
.plate__title {
  margin-bottom: 18px;
  font-style: italic;
  font-weight: 900;
  font-stretch: 125%;
  font-size: 1.375rem;
  text-transform: uppercase;
  line-height: 1;
}
.plate__fields {
  display: grid;
  grid-template-columns: auto 1fr;
}
.plate__fields > div { display: contents; }
.plate__fields dt,
.plate__fields dd {
  padding: 9px 0;
  border-top: 1.5px solid var(--graphite);
}
.plate__fields dt {
  padding-right: 24px;
  color: #3b4148;
  font-style: italic;
  font-weight: 800;
  font-stretch: 112%;
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  line-height: 1.9;
}
.plate__fields dd {
  font-weight: 700;
  overflow-wrap: anywhere;
}
.plate a {
  color: var(--graphite);
  text-decoration-color: var(--orange);
  text-decoration-thickness: 2px;
}
.plate a:focus-visible { outline-color: var(--orange); }

.close {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 22px;
  align-self: stretch;
  justify-content: center;
  margin-right: calc(var(--gutter) * -1);
  padding: clamp(36px, 4.4vw, 64px) var(--gutter) clamp(36px, 4.4vw, 64px) clamp(56px, 7vw, 104px);
  background: var(--yellow);
  color: #2a2f20;
  clip-path: polygon(clamp(28px, 3.4vw, 48px) 0, 100% 0, 100% 100%, 0 100%);
}
.close .display { color: var(--graphite); }
.close p {
  max-width: 40ch;
  font-size: 1.125rem;
}
.close__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
  padding-left: 8px;
}

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

.foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px 40px;
  max-width: var(--max);
  margin: 0 auto;
  padding: 28px var(--gutter) 40px;
  border-top: 1px solid var(--track);
  color: var(--ink-quiet);
  font-size: 0.875rem;
}
.foot p:first-child { max-width: 64ch; }
.foot a { color: var(--ink); }

/* ---------- Motion ---------- */

@keyframes streak {
  0% { opacity: 1; transform: scaleX(0); }
  60% { opacity: 1; transform: scaleX(1); }
  100% { opacity: 0; transform: scaleX(1); }
}

@keyframes snap {
  from { clip-path: polygon(17% 0, 17% 0, 0 100%, 0 100%); }
  to { clip-path: polygon(17% 0, 100% 0, 100% 100%, 0 100%); }
}

@keyframes dock {
  from { transform: translateX(-56px) rotate(4deg); filter: blur(6px); }
  to { transform: rotate(4deg); filter: blur(0); }
}

@keyframes settle {
  from { filter: blur(5px); transform: translateX(-6px); }
  to { filter: blur(0); transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation: none !important;
    transition-duration: 1ms !important;
  }
}

/* ---------- Narrower tracks ---------- */

@media (max-width: 1100px) {
  .grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "pitch"
      "livery"
      "hud";
  }
  .livery { min-height: 520px; }
  .entry { grid-template-columns: clamp(120px, 18vw, 180px) minmax(0, 1fr); }
  .entry__label {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--track);
  }
}

/* The nav and the corner CTA stop fitting on one row here. */
@media (max-width: 1180px) {
  .bar {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 0;
  }
  .team { align-self: center; }
  .bar__nav {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: flex-start;
    gap: 22px;
    padding: 4px 0 8px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .bar__cta {
    --bar-h: 72px;
    grid-column: 2;
    grid-row: 1;
    padding-left: 40px;
  }
}

/* Below this width the seven columns no longer fit: each city becomes its own
   readout block, two to a row, then one. */
@media (max-width: 1200px) {
  .readout thead { display: none; }
  .readout { display: block; }
  .readout tbody {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: clamp(20px, 3vw, 40px);
  }
  .readout tr {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: 6px;
    row-gap: 6px;
    padding: 14px 0 16px;
    border-top: 1px solid var(--hud-line);
  }
  .readout tbody th,
  .readout td {
    padding: 0;
    border: 0;
  }
  .readout tbody th { grid-column: 1 / -1; margin-bottom: 4px; }
  .readout [data-k="wind"],
  .readout [data-k="gust"],
  .readout [data-k="score"] {
    width: auto;
    min-width: 0;
    padding: 10px 10px 9px;
    background: var(--hud-cell);
    font-size: 1.5rem;
  }
  .readout td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 6px;
    color: var(--hud-soft);
    font-style: italic;
    font-weight: 700;
    font-stretch: 112%;
    font-size: 0.6875rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
  }
  .readout [data-k="verdict"],
  .readout [data-k="source"],
  .readout [data-k="age"] { padding-top: 6px; }
  .readout [data-k="verdict"] { grid-column: 1 / -1; white-space: normal; }
  .readout [data-k="source"] { grid-column: 1 / 3; }
  .readout [data-k="age"] { grid-column: 3; }
  .readout [data-k="verdict"]::before { display: none; }
  /* The unit moves from the column heading to the value. */
  .readout [data-k="wind"]::after,
  .readout [data-k="gust"]::after {
    content: "m/s";
    margin-left: 4px;
    color: var(--hud-soft);
    font-size: 0.8125rem;
    font-weight: 700;
    font-stretch: 100%;
  }
}

@media (max-width: 860px) {
  .team-plate { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 640px) {
  /* On a phone the livery and the telemetry come up into the first screen;
     the entry selector moves down to sit directly above the readout it paints. */
  .grid { display: flex; flex-direction: column; gap: 24px; }
  .pitch { display: contents; }
  .pitch .display { font-size: min(6rem, 11vw); font-stretch: 112%; }
  .pitch .display .hl::after { display: none; }
  .livery { order: 1; }
  .selector { order: 2; margin-top: 0; }
  .hud { order: 3; }
  .pitch__actions { flex-direction: column; align-items: flex-start; }
  .selector { grid-template-columns: minmax(0, 1fr); }

  .livery { min-height: 440px; }
  .livery__field { inset: 0 0 40px 0; clip-path: polygon(12% 0, 100% 0, 100% 100%, 0 100%); }
  .livery__decal { right: 16px; font-size: 1rem; gap: 10px; }
  .livery__decal img { width: 40px; height: 40px; border-radius: 10px; }
  .livery__plate { right: 16px; top: calc(9% + 52px); }
  .livery__hull { right: 16px; width: 44%; bottom: 18%; }
  .livery__stripes { right: 16px; width: 40%; }
  .cockpit { left: 12px; top: 22px; width: 152px; border-radius: 26px; padding: 5px; }
  .cockpit img { border-radius: 21px; }

  .team { gap: 10px; }
  .team__mark { width: 44px; height: 28px; }
  .team__name { font-size: 1.0625rem; }
  .bar__cta { gap: 8px; padding: 0 14px 0 28px; font-size: 0.8125rem; letter-spacing: 0.02em; }
  .bar__cta::after { display: none; }
  .bar__nav { gap: 2px 14px; flex-wrap: wrap; }
  .bar__nav a { font-size: 0.75rem; letter-spacing: 0.06em; }

  .readout tbody { grid-template-columns: minmax(0, 1fr); }

  .pitch__actions { padding-left: 6px; }
  .decal { min-height: 52px; padding: 0 22px 0 24px; font-size: 0.9375rem; }

  .plate__fields { grid-template-columns: minmax(0, 1fr); }
  .plate__fields dt { padding: 10px 0 0; }
  .plate__fields dd { padding: 0 0 10px; border-top: 0; }
  .plate__fields > div:first-child dt { padding-top: 0; }

  .hud { margin-top: 0; }

  .entry { grid-template-columns: minmax(0, 1fr); }
  .entry__no {
    justify-content: flex-start;
    padding: 6px 20px;
    clip-path: polygon(0 0, 100% 0, calc(100% - 28px) 100%, 0 100%);
    width: 58%;
    font-size: 3.25rem;
  }
  .entry__body { padding: 22px 20px 18px; }
  .entry__label { padding: 8px 20px 18px; border-top: 0; }

  .control { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .control__flag {
    min-height: 48px;
    background-size: 24px 24px;
    clip-path: polygon(0 0, 100% 0, calc(100% - 24px) 100%, 0 100%);
  }
  .rules li { padding-left: 54px; }

  .foot { flex-direction: column; }
}

/* The smallest phones: decals shrink so their slanted ends stay on screen. */
@media (max-width: 400px) {
  .decal { gap: 10px; padding: 0 18px 0 20px; font-size: 0.8125rem; }
  .close {
    padding-left: 32px;
    clip-path: polygon(18px 0, 100% 0, 100% 100%, 0 100%);
  }
  .close__actions { padding-left: 6px; }
  .close .decal { padding: 0 16px 0 18px; font-size: 0.75rem; }
  .team__name { font-size: 0.9375rem; }
  .bar__cta { --bar-h: 64px; padding: 0 14px 0 24px; }
  .bar__cta .decal__arrow { display: none; }
}
