/* XpengSound. Hex colours and conservative CSS on purpose: the target is an in-car
   Chromium of unknown age. */

@font-face {
  font-family: "Urbanist";
  src: url("../fonts/urbanist-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Urbanist";
  src: url("../fonts/urbanist-italic.woff2") format("woff2");
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}

:root {
  --ground: #FFFFFF;
  --floor: #EEF1F4;
  --card: #F4F6F8;
  --well: #E8EBEF;
  --raised: #FFFFFF;
  --ink: #17191C;
  --ink-2: #646B75;
  --line: #E1E5EA;
  --green: #2E9E4F;
  --green-ink: #1E7F3C;
  --green-soft: #E3F4E7;
  --on-green: #FFFFFF;
  --warn: #D98A00;
  --red: #E0432F;
  --shadow: 0 1px 2px rgba(20, 24, 30, 0.06), 0 6px 18px rgba(20, 24, 30, 0.06);
  --r-lg: 1.5rem;
  --r-md: 1rem;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0B0D10;
    --floor: #14181D;
    --card: #15191E;
    --well: #20252C;
    --raised: #2B313A;
    --ink: #F2F4F6;
    --ink-2: #9DA5B0;
    --line: #272D35;
    --green: #3FBF63;
    --green-ink: #5AD47C;
    --green-soft: #143320;
    --on-green: #06140B;
    --warn: #F2B33D;
    --red: #FF6450;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --ground: #0B0D10;
  --floor: #14181D;
  --card: #15191E;
  --well: #20252C;
  --raised: #2B313A;
  --ink: #F2F4F6;
  --ink-2: #9DA5B0;
  --line: #272D35;
  --green: #3FBF63;
  --green-ink: #5AD47C;
  --green-soft: #143320;
  --on-green: #06140B;
  --warn: #F2B33D;
  --red: #FF6450;
  --shadow: none;
}

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

html {
  font-size: 15px;
  font-size: clamp(15px, 0.55vw + 0.75vh, 24px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: "Urbanist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 1.05rem;
  font-weight: 500;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

::selection { background: var(--green); color: var(--on-green); }
h1, h2, p, dl, dd, dt { margin: 0; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
svg, img { display: block; }
a { color: var(--ink); text-underline-offset: 0.2em; }

:focus-visible { outline: 3px solid var(--green); outline-offset: 3px; }

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(25rem, 36%);
  height: 100vh;
  height: 100dvh;
}

/* ============================== hero ============================== */
.hero {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 1.5rem 2.2rem 1.2rem;
  padding-left: max(2.2rem, env(safe-area-inset-left));
  background: linear-gradient(180deg, var(--ground) 0%, var(--ground) 52%, var(--floor) 100%);
  overflow: hidden;
}

.hero-top { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 0.6rem 1rem; }

/* the thin readout from the car app */
.readout { display: flex; align-items: flex-start; gap: 0.5rem; }
.readout b { font-size: 5.2rem; font-size: clamp(3.6rem, 11.5vh, 7.4rem); font-weight: 300; line-height: 0.86; letter-spacing: -0.02em; }
.readout span { margin-top: 0.35rem; color: var(--ink-2); font-size: 1.05rem; font-weight: 600; }

.status { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; }
.gps { display: flex; align-items: center; gap: 0.4rem; height: 2.6rem; padding: 0 0.9rem 0 0.7rem; border-radius: 99rem; background: var(--card); color: var(--ink-2); font-size: 0.92rem; font-weight: 600; white-space: nowrap; }
.gps svg { width: 1.2rem; height: 1.2rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.gps[data-state="ok"], .gps[data-state="sim"] { background: var(--green-soft); color: var(--green-ink); }
.gps[data-state="bad"] { color: var(--red); }
.tool { display: flex; align-items: center; justify-content: center; width: 2.6rem; height: 2.6rem; padding: 0; border: 0; border-radius: 50%; background: var(--card); }
.tool svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tool:active { transform: scale(0.94); }

.model { display: flex; align-items: center; gap: 0.9rem; margin-top: 1.1rem; }
.logo { flex: none; width: 2.9rem; height: 2.9rem; background: var(--ink); -webkit-mask: center / contain no-repeat; mask: center / contain no-repeat; }
.logo.wide { width: 5.4rem; height: 1.5rem; }
.model h1 { font-size: 2.2rem; font-size: clamp(1.7rem, 4.6vh, 2.7rem); font-weight: 800; font-style: italic; line-height: 1; letter-spacing: -0.01em; text-transform: uppercase; }
.model p { margin-top: 0.3rem; color: var(--ink-2); font-size: 1rem; font-weight: 600; }

/* car standing on the floor: the cut-out is bottom-aligned so its tyres meet the shadow */
.car { position: relative; flex: 1; min-height: 0; margin: 0.6rem 0 1.4rem; }
.car::after { content: ""; position: absolute; left: 16%; right: 16%; bottom: -1.1rem; height: 2.6rem; border-radius: 50%; background: radial-gradient(closest-side, rgba(10, 14, 20, 0.3), rgba(10, 14, 20, 0)); }
.car img { position: absolute; z-index: 1; top: 0; left: 4%; width: 92%; height: 100%; object-fit: contain; object-position: 50% 100%; transition: opacity 0.3s var(--ease), transform 0.6s var(--ease); }
.car[data-swap="1"] img { opacity: 0; transform: translateX(2.5%); }

/* stat row, italic values like the model page */
.stats { display: grid; grid-template-columns: auto auto auto minmax(0, 1.3fr); gap: 0 2.4rem; align-items: end; padding: 0 0.2rem; }
.stats > div { display: flex; flex-direction: column; min-width: 0; }
.stats dd { font-size: 1.45rem; font-weight: 800; font-style: italic; line-height: 1.1; white-space: nowrap; }
.stats dt { margin-top: 0.15rem; color: var(--ink-2); font-size: 0.86rem; font-weight: 600; }
.firing dd { display: flex; align-items: center; gap: 0.7rem; }
#block { display: block; flex: none; height: 1.7rem; }
#block svg { height: 100%; width: auto; overflow: visible; }
#block .bore { fill: var(--well); stroke: var(--ink-2); stroke-width: 1.2; }
#block .fire { fill: var(--green); opacity: 0; }
#block .cast, #block .crank, #block text { display: none; }
#block .rotor { fill: none; stroke: var(--ink-2); stroke-width: 1.2; }
#order { overflow: hidden; text-overflow: ellipsis; font-size: 1.1rem; letter-spacing: 0.01em; }

/* rev band */
.rev { margin-top: 1rem; }
.rev-head { display: flex; align-items: flex-end; gap: 1.6rem; margin-bottom: 0.5rem; }
.rev-read { display: flex; align-items: baseline; gap: 0.4rem; min-width: 8.5rem; }
.rev-read b { font-size: 2.3rem; font-weight: 300; line-height: 0.95; }
.rev-read span { color: var(--ink-2); font-size: 0.95rem; font-weight: 600; }
.meters { display: flex; flex: 1; gap: 1.6rem; min-width: 0; padding-bottom: 0.3rem; }
.meter { display: grid; grid-template-columns: auto minmax(0, 1fr) 2.9rem; align-items: center; gap: 0.6rem; flex: 1; max-width: 17rem; color: var(--ink-2); font-size: 0.9rem; font-weight: 600; }
.meter-bar { height: 0.4rem; border-radius: 99rem; background: var(--well); overflow: hidden; }
.meter-bar i { display: block; height: 100%; border-radius: 99rem; background: var(--ink); transform-origin: 0 50%; transform: scaleX(0); will-change: transform; }
#boostBar { background: var(--warn); }
.meter b { color: var(--ink); font-weight: 700; text-align: right; }
.gear { display: flex; align-items: baseline; gap: 0.5rem; }
.gear span { color: var(--ink-2); font-size: 0.95rem; font-weight: 600; }
.gear b { min-width: 1.6rem; font-size: 2.3rem; font-weight: 800; font-style: italic; line-height: 0.95; text-align: right; }
.app[data-shift="1"] .gear b { color: var(--warn); }

.rev-track { position: relative; height: 1.5rem; border-radius: 99rem; background: var(--well); overflow: hidden; --r: 0; }
.rev-fill { position: absolute; top: 0; right: 0; bottom: 0; left: 0; background: var(--green); transform-origin: 0 50%; transform: scaleX(var(--r)); will-change: transform; }
.rev[data-zone="warn"] .rev-fill { background: var(--warn); }
.rev[data-zone="red"] .rev-fill { background: var(--red); }
.rev-red { position: absolute; top: 0; bottom: 0; right: 0; background: rgba(224, 67, 47, 0.3); }
.rev-ticks { position: absolute; top: 0; right: 0; bottom: 0; left: 0; pointer-events: none; }
.rev-ticks i { position: absolute; top: 0; bottom: 0; width: 1.5px; margin-left: -0.75px; background: var(--ground); opacity: 0.75; }
.rev-ticks i.minor { top: 62%; opacity: 0.5; }
.rev-labels { position: relative; height: 1.3rem; margin-top: 0.3rem; color: var(--ink-2); font-size: 0.85rem; font-weight: 600; }
.rev-labels span { position: absolute; top: 0; transform: translateX(-50%); }
.rev-labels span:first-child { transform: none; }
.rev-labels span.hot { color: var(--red); }

.notice { min-height: 1.35rem; margin-top: 0.35rem; color: var(--ink-2); font-size: 0.92rem; font-weight: 500; }
.notice[data-kind="bad"] { color: var(--red); }

/* ============================== side ============================== */
.side {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  min-height: 0;
  padding: 1.4rem 1.5rem 1rem 0.4rem;
  padding-right: max(1.5rem, env(safe-area-inset-right));
  background: linear-gradient(180deg, var(--ground) 0%, var(--ground) 52%, var(--floor) 100%);
}

.side-top { display: flex; flex-direction: column; gap: 1rem; }
.brand { font-size: 1.25rem; font-weight: 800; font-style: italic; letter-spacing: 0.01em; text-align: right; }

/* round actions with a label underneath */
.actions { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.3rem; }
.act { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; padding: 0.2rem 0; border: 0; background: none; font-size: 0.92rem; font-weight: 600; text-align: center; line-height: 1.15; }
.act i { display: flex; align-items: center; justify-content: center; width: 4rem; height: 4rem; border-radius: 50%; background: var(--card); box-shadow: inset 0 0 0 1.5px var(--line); transition: background 0.25s var(--ease), transform 0.2s var(--ease), box-shadow 0.25s var(--ease); }
.act svg { width: 1.7rem; height: 1.7rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#preview svg { fill: currentColor; stroke: none; }
.act:active i { transform: scale(0.93); }
.act[aria-pressed="true"] i { background: var(--green); color: var(--on-green); box-shadow: none; }
.act-main i { background: var(--ink); color: var(--ground); box-shadow: none; }
.act-main[aria-pressed="true"] i { background: var(--green); color: var(--on-green); }

.card { background: var(--card); border-radius: var(--r-lg); }
.sound { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 1rem; padding: 0.9rem 1rem 1rem; }
.row { display: flex; flex-direction: column; gap: 0.45rem; min-width: 0; }
.row-head { display: flex; align-items: baseline; justify-content: space-between; font-size: 0.92rem; font-weight: 700; }
.row-head output { color: var(--ink-2); font-weight: 600; }

.slider { position: relative; height: 2.9rem; border-radius: 99rem; background: var(--well); overflow: hidden; --p: 70%; }
.slider::before { content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: var(--p); min-width: 2.9rem; background: var(--ink); }
.slider svg { position: absolute; left: 0.75rem; top: 50%; width: 1.35rem; height: 1.35rem; margin-top: -0.675rem; fill: none; stroke: var(--ground); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.slider input { position: absolute; top: 0; left: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: ew-resize; touch-action: pan-y; }
.slider:focus-within { outline: 3px solid var(--green); outline-offset: 3px; }

.seg { display: flex; padding: 0.22rem; border-radius: 99rem; background: var(--well); }
.seg label { flex: 1; position: relative; }
.seg input { position: absolute; top: 0; left: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.seg span { display: flex; align-items: center; justify-content: center; height: 2.46rem; padding: 0 0.6rem; border-radius: 99rem; color: var(--ink-2); font-size: 0.95rem; font-weight: 700; transition: background 0.25s var(--ease), color 0.25s var(--ease); }
.seg input:checked + span { background: var(--raised); color: var(--ink); box-shadow: 0 1px 3px rgba(20, 24, 30, 0.16); }
.seg input:focus-visible + span { outline: 3px solid var(--green); outline-offset: 2px; }
.seg-sm { background: var(--card); }
.seg-sm span { height: 2.16rem; padding: 0 0.75rem; font-size: 0.9rem; }

/* test pedals: hold and slide, the same fill idiom as the volume bar */
.pedals { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); gap: 0.6rem; padding: 0.8rem; }
.pedals[hidden] { display: none; }
.pedal { position: relative; display: flex; align-items: center; justify-content: space-between; height: 4.6rem; padding: 0 1.1rem; border-radius: var(--r-md); background: var(--well); overflow: hidden; font-weight: 800; cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: none; }
.pedal i { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; background: var(--red); transform-origin: 0 50%; transform: scaleX(0); will-change: transform; }
.pedal-go i { background: var(--green); }
.pedal span, .pedal b { position: relative; }
.pedal b { font-weight: 700; }
.pedals p { grid-column: 1 / -1; color: var(--ink-2); font-size: 0.82rem; font-weight: 500; line-height: 1.3; }

/* engine picker: car tiles */
.garage { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.garage h2 { padding: 0.9rem 1.1rem 0.5rem; font-size: 1.05rem; font-weight: 800; }
.garage-list { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.55rem; align-content: start; padding: 0 0.7rem 0.8rem; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--well) transparent; }
.garage-list::-webkit-scrollbar { width: 6px; }
.garage-list::-webkit-scrollbar-thumb { background: var(--well); border-radius: 3px; }

.eng { position: relative; display: flex; flex-direction: column; min-width: 0; padding: 0.55rem 0.7rem 0.65rem; border: 0; border-radius: var(--r-md); background: var(--ground); text-align: left; box-shadow: inset 0 0 0 1.5px transparent; transition: box-shadow 0.25s var(--ease), transform 0.2s var(--ease); }
.eng:active { transform: scale(0.98); }
.eng-car { width: 100%; height: 4.6rem; object-fit: contain; object-position: center bottom; }
.eng-line { display: flex; align-items: center; gap: 0.45rem; min-width: 0; margin-top: 0.4rem; }
.eng-logo { flex: none; width: 1.25rem; height: 1.25rem; background: var(--ink); -webkit-mask: center / contain no-repeat; mask: center / contain no-repeat; }
.eng-logo.wide { width: 2.5rem; height: 0.7rem; }
.eng-name { min-width: 0; font-size: 0.98rem; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.eng-spec { margin-top: 0.1rem; color: var(--ink-2); font-size: 0.84rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.eng[aria-current="true"] { box-shadow: inset 0 0 0 2.5px var(--green); }
.eng[aria-current="true"]::after { content: ""; position: absolute; top: 0.6rem; right: 0.6rem; width: 1.5rem; height: 1.5rem; border-radius: 50%; background: var(--green) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 12.500l4 4 8-9'/%3E%3C/svg%3E") center / 62% no-repeat; }

.foot { color: var(--ink-2); font-size: 0.8rem; font-weight: 500; line-height: 1.35; }

/* ============================== responsive ============================== */
@media (max-height: 760px) and (min-width: 1001px) {
  .hero { padding-top: 1.1rem; }
  .model { margin-top: 0.6rem; }
  .act i { width: 3.5rem; height: 3.5rem; }
  .foot { display: none; }
  .pedal { height: 3.9rem; }
  .pedals p { display: none; }
}

@media (max-width: 1000px) {
  .app { grid-template-columns: minmax(0, 1fr); height: auto; }
  .hero { min-height: 100vh; min-height: 100svh; padding: 1.1rem 1.2rem 1rem; }
  .side { padding: 0.4rem 1.2rem 1.5rem; background: var(--floor); }
  .brand { text-align: left; }
  .garage { overflow: visible; }
  .garage-list { overflow: visible; grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  html { font-size: 16px; }
  .hero { min-height: 0; padding: 0.9rem 1rem 0.9rem; }
  .gps span { max-width: 8.5rem; overflow: hidden; text-overflow: ellipsis; }
  .readout b { font-size: 4rem; }
  .car { height: 12.5rem; flex: none; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.9rem 1.2rem; }
  .stats dd { font-size: 1.2rem; white-space: normal; }
  .rev-head { flex-wrap: wrap; gap: 0.6rem 1.2rem; }
  .meters { order: 3; flex-basis: 100%; }
  .gear { margin-left: auto; }
  .side { padding: 1rem 1rem 1.5rem; }
  .sound { grid-template-columns: minmax(0, 1fr); }
  .garage-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .act i { width: 3.4rem; height: 3.4rem; }
  .act { font-size: 0.8rem; }
}

/* ============================== credits page ============================== */
.doc { background: var(--ground); }
.doc-main { max-width: 58rem; margin: 0 auto; padding: 2rem 1.25rem 4rem; font-size: 1rem; line-height: 1.5; }
.doc-main h1 { margin: 1.5rem 0 0.75rem; font-size: 2rem; font-weight: 800; font-style: italic; }
.doc-main h2 { margin: 2.2rem 0 0.5rem; font-size: 1.2rem; font-weight: 800; }
.doc-main p { max-width: 68ch; }
.doc-main table { width: 100%; margin-top: 1.25rem; border-collapse: collapse; font-size: 0.92rem; }
.doc-main th, .doc-main td { padding: 0.6rem 0.75rem 0.6rem 0; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.doc-main th { color: var(--ink-2); font-weight: 700; }

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