/* ==========================================================================
   Homepage
   ========================================================================== */

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden;
  margin-top: calc(-1 * var(--header-h));
  padding-top: calc(var(--header-h) + clamp(3.5rem, 2rem + 6vw, 7rem));
  background:
    radial-gradient(70% 55% at 50% 100%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg) 40%, var(--surface) 100%);
}
.hero-inner { position: relative; z-index: 2; min-width: 0; text-align: center; display: grid; justify-items: center; }
.hero-badge { max-width: 100%; margin-bottom: 28px; padding: 6px 14px 6px 6px; font-size: var(--fs-caption); font-weight: 500; color: var(--text-secondary); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.hero-badge .pill { padding: 3px 9px; }
.hero-badge-copy { min-width: 0; }
.hero h1 { max-width: 13ch; }
.hero .lead { margin-top: 24px; max-width: 36ch; }
.hero-actions { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 14px 22px; margin-top: 36px; }


.hero-stage {
  position: relative; z-index: 1;
  margin-top: clamp(3.5rem, 2.5rem + 4vw, 6rem);
  padding-bottom: clamp(4rem, 3rem + 4vw, 7rem);
  perspective: 2000px;
  animation: stage-in 1600ms var(--ease-out) 450ms both;
}
@keyframes stage-in { from { opacity: 0; transform: translate3d(0, 60px, 0); } }

.hero-glow {
  position: absolute; left: 50%; top: 18%; width: min(1100px, 120%); aspect-ratio: 2.4; z-index: -1;
  transform: translateX(-50%);
  background: radial-gradient(50% 50% at 50% 50%, color-mix(in srgb, var(--accent) 34%, transparent), transparent 70%);
  filter: blur(40px); opacity: 0.7;
  animation: glow-breathe 9s var(--ease-in-out) infinite alternate;
}
@keyframes glow-breathe { to { opacity: 0.45; transform: translateX(-50%) scale(1.06); } }

/* Cockpit display: an original infotainment composition */
.cockpit {
  --tilt: 0;
  position: relative; width: min(1080px, 100%); margin-inline: auto;
  transform: rotateX(calc(var(--tilt) * 16deg)) scale(calc(1 - var(--tilt) * 0.06));
  transform-origin: 50% 100%;
  will-change: transform;
}
.cockpit-bezel {
  position: relative; padding: 10px; border-radius: 34px;
  background: linear-gradient(180deg, #2a2a2d, #0d0d0e 40%, #050506);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.14), inset 0 0 0 1px rgb(255 255 255 / 0.05),
    0 50px 100px -30px light-dark(rgb(0 30 80 / 0.35), rgb(0 0 0 / 0.9)),
    0 20px 40px -20px rgb(0 0 0 / 0.4);
}
html[data-theme="dark"] .cockpit-bezel { box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.14), inset 0 0 0 1px rgb(255 255 255 / 0.07), 0 0 0 1px rgb(255 255 255 / 0.06), 0 40px 120px -20px rgb(41 151 255 / 0.25); }
.cockpit-screen {
  position: relative; overflow: hidden; border-radius: 25px;
  aspect-ratio: 21 / 9;
  display: grid; grid-template-columns: 1fr 300px; grid-template-rows: auto 1fr; gap: 10px;
  padding: 14px;
  background: #050506; color: #f5f5f7; text-align: left;
  font-size: 13px; letter-spacing: -0.01em;
}
.cockpit-screen::after {
  /* glass reflection */
  content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background: linear-gradient(115deg, rgb(255 255 255 / 0.09) 0%, rgb(255 255 255 / 0.02) 28%, transparent 40%);
}
.cockpit-status {
  grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between;
  padding: 0 6px; color: rgb(245 245 247 / 0.72); font-size: 12px; font-weight: 600;
}
.cockpit-status div { display: flex; align-items: center; gap: 10px; }
.cockpit-status .icon { width: 14px; height: 14px; stroke-width: 2; }

.cockpit-map { position: relative; overflow: hidden; border-radius: 18px; background: #0d0f12; }
.cockpit-map > svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.map-route { stroke-dasharray: 1400; stroke-dashoffset: 1400; animation: route-draw 2600ms var(--ease-in-out) 1300ms forwards; }
@keyframes route-draw { to { stroke-dashoffset: 0; } }
.map-puck { transform-box: fill-box; transform-origin: center; }
.map-pulse { transform-box: fill-box; transform-origin: center; animation: puck-pulse 2.4s var(--ease-out) infinite; }
@keyframes puck-pulse { from { transform: scale(0.6); opacity: 0.7; } to { transform: scale(2.4); opacity: 0; } }

.nav-card {
  position: absolute; top: 14px; left: 14px; display: flex; align-items: center; gap: 12px;
  padding: 12px 16px 12px 12px; border-radius: 16px;
  background: rgb(28 28 30 / 0.82); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.08);
}
.nav-card-icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: #2997ff; color: #fff; }
.nav-card-icon .icon { width: 22px; height: 22px; stroke-width: 2.2; }
.nav-card strong { display: block; font-size: 17px; font-weight: 650; letter-spacing: -0.02em; }
.nav-card span { color: rgb(245 245 247 / 0.6); font-size: 12px; }
.eta-card {
  position: absolute; left: 14px; bottom: 14px; display: flex; gap: 18px;
  padding: 10px 16px; border-radius: 14px; background: rgb(28 28 30 / 0.82);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.08);
}
.eta-card div { display: grid; }
.eta-card strong { font-size: 15px; font-weight: 650; }
.eta-card span { font-size: 11px; color: rgb(245 245 247 / 0.55); }
.eta-card div:first-child strong { color: #30d158; }

.cockpit-side { display: grid; grid-template-rows: 1fr 1fr; gap: 10px; min-height: 0; }
.widget {
  position: relative; overflow: hidden; border-radius: 18px; padding: 16px;
  background: #151517; box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.05);
  display: flex; flex-direction: column; min-height: 0;
}
.widget-label { display: flex; align-items: center; gap: 6px; color: rgb(245 245 247 / 0.55); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.widget-label .icon { width: 13px; height: 13px; stroke-width: 2.2; }
.widget-check { margin-top: auto; display: grid; gap: 7px; }
.widget-check li { display: flex; align-items: center; gap: 8px; color: rgb(245 245 247 / 0.86); font-size: 12.5px; }
.widget-check .icon { width: 15px; height: 15px; color: #30d158; stroke-width: 2.4; }
.widget-check li.pending .icon { color: #2997ff; animation: spin 2.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.widget-gauge { margin-top: auto; display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.widget-gauge strong { display: block; font-size: 30px; font-weight: 650; letter-spacing: -0.04em; line-height: 1; }
.widget-gauge span { font-size: 11px; color: rgb(245 245 247 / 0.55); }
.gauge-bars { display: flex; align-items: flex-end; gap: 4px; height: 48px; }
.gauge-bars i { width: 6px; border-radius: 3px; background: linear-gradient(180deg, #5ac8fa, #2997ff); transform-origin: bottom; animation: bar 1.8s var(--ease-in-out) infinite alternate; animation-delay: calc(var(--b) * -0.25s); height: calc(var(--h) * 1%); opacity: 0.9; }
@keyframes bar { to { transform: scaleY(0.55); } }

.cockpit-reflection {
  position: absolute; left: 6%; right: 6%; bottom: -36px; height: 60px; z-index: -1;
  background: radial-gradient(50% 50% at 50% 0%, light-dark(rgb(0 0 0 / 0.18), rgb(41 151 255 / 0.25)), transparent 70%);
  filter: blur(14px);
}

/* ---------- Services ---------- */
.services-section .section-head { margin-bottom: clamp(2.5rem, 2rem + 2vw, 3.5rem); }

/* ---------- Featured products ---------- */
.featured-head-note { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.product-grid--featured { grid-template-columns: 1.25fr 1fr; grid-template-rows: auto auto; gap: 20px; }
.product-grid--featured .product-card:first-child { grid-row: span 2; }
.product-grid--featured .product-card:first-child .product-visual { min-height: 440px; }
.product-grid--featured .product-card:first-child .product-orb { width: 148px; height: 148px; border-radius: 42px; }
.product-grid--featured .product-card:first-child .product-orb .icon { width: 64px; height: 64px; }
.product-grid--featured .product-card:first-child .product-rings { width: 300px; height: 300px; }
.product-grid--featured .product-card:first-child .product-body h3 { font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem); }
.product-grid--featured .product-card:not(:first-child) .product-visual { min-height: 190px; }
.product-grid--featured .product-card:not(:first-child) .product-orb { width: 84px; height: 84px; border-radius: 24px; }
.product-grid--featured .product-card:not(:first-child) .product-orb .icon { width: 38px; height: 38px; }
.product-grid--featured .product-card:not(:first-child) .product-rings { width: 160px; height: 160px; }
.demo-note { margin-top: 28px; justify-content: center; text-align: center; background: transparent; color: var(--text-secondary); font-size: var(--fs-caption); }

/* ---------- Why FlashXCode: light panel in light mode, dark in dark mode ---------- */
.why-panel {
  position: relative; overflow: hidden; isolation: isolate;
  display: grid; grid-template-columns: 1.05fr 1fr; gap: clamp(2.5rem, 1rem + 5vw, 6rem); align-items: center;
  padding: clamp(2rem, 1rem + 5vw, 5.5rem);
  border-radius: var(--radius-xl);
  background: light-dark(#ffffff, #111113); color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line), light-dark(0 30px 80px -40px rgb(0 40 120 / 0.25), none);
}
.why-panel::before {
  content: ""; position: absolute; z-index: -1; width: 900px; height: 900px; right: -340px; top: -400px;
  background: radial-gradient(closest-side, light-dark(rgb(0 104 255 / 0.10), rgb(41 151 255 / 0.30)), transparent);
}
.why-panel::after {
  content: ""; position: absolute; z-index: -1; width: 700px; height: 700px; left: -300px; bottom: -440px;
  background: radial-gradient(closest-side, light-dark(rgb(94 92 230 / 0.08), rgb(94 92 230 / 0.24)), transparent);
}
.why-panel .lead { color: var(--text-secondary); margin-top: 20px; }
.why-points { display: grid; gap: 26px; margin-top: 40px; }
.why-point { display: grid; grid-template-columns: 40px 1fr; gap: 16px; align-items: start; }
.why-point .icon-tile { --tile-size: 40px; box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.28); }
.why-point .icon-tile .icon { width: 19px; height: 19px; }
.why-point h3 { font-size: var(--fs-body); font-weight: 600; letter-spacing: -0.016em; }
.why-point p { margin-top: 3px; color: var(--text-secondary); font-size: var(--fs-small); text-wrap: pretty; }
.why-link { margin-top: 32px; }

/* Brand card: centred logo with a rotating ring and soft pulses; figures count up on reveal */
.brand-card {
  position: relative; display: grid; justify-items: center; text-align: center; padding: clamp(28px, 2vw + 16px, 44px); border-radius: 28px;
  background: light-dark(linear-gradient(180deg, #f8f9fc, #f1f3f8), linear-gradient(180deg, rgb(255 255 255 / 0.08), rgb(255 255 255 / 0.03)));
  box-shadow: inset 0 0 0 1px var(--line), light-dark(0 24px 60px -30px rgb(0 40 120 / 0.25), 0 40px 80px -30px rgb(0 0 0 / 0.6));
}
.brand-orbit { position: relative; display: grid; place-items: center; width: 180px; height: 180px; margin-bottom: 18px; }
.brand-pulse { position: absolute; inset: 40px; border-radius: 50%; border: 1.5px solid color-mix(in srgb, var(--accent) 45%, transparent); animation: brand-pulse 3.6s var(--ease-out) infinite; }
.brand-pulse:nth-child(2) { animation-delay: 1.2s; }
.brand-pulse:nth-child(3) { animation-delay: 2.4s; }
.brand-ring { position: absolute; inset: 26px; border-radius: 50%; padding: 2px;
  background: conic-gradient(from 0deg, transparent 0 55%, #2997ff 75%, #e5372c 88%, transparent 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
  animation: brand-spin 4s linear infinite; }
.brand-card-logo {
  position: relative; display: grid; place-items: center; width: 100px; height: 100px; border-radius: 30px;
  background: light-dark(#ffffff, #1d1d1f); box-shadow: inset 0 0 0 1px var(--line), 0 16px 40px -12px rgb(0 104 255 / 0.5);
  animation: brand-float 5s var(--ease-in-out) infinite alternate;
}
.brand-card-logo img { width: 66px; height: 66px; object-fit: contain; }
.brand-name { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.03em; }
.brand-tagline { margin-top: 4px; color: var(--text-secondary); font-size: var(--fs-small); }
@keyframes brand-pulse { 0% { transform: scale(0.85); opacity: 0.9; } 100% { transform: scale(1.9); opacity: 0; } }
@keyframes brand-spin { to { transform: rotate(360deg); } }
@keyframes brand-float { to { transform: translateY(-6px); } }
.brand-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; width: 100%; margin: 26px 0 0; border-radius: 18px; overflow: hidden; background: var(--line); }
.brand-stats > div { padding: 18px 20px; background: light-dark(#ffffff, #18181a); }
.brand-stats dt { color: var(--text-secondary); font-size: var(--fs-caption); }
.brand-stats dd { margin: 4px 0 0; font-size: clamp(1.6rem, 1.2rem + 1vw, 2.1rem); font-weight: 700; letter-spacing: -0.035em; font-variant-numeric: tabular-nums; }
.brand-stars { margin-left: 8px; font-size: 0.95rem; letter-spacing: 1px; vertical-align: middle; }
.brand-stars i { font-style: normal; color: #ffb800; display: inline-block; }
.js .brand-card:not(.is-visible) .brand-stars i { opacity: 0.2; transform: scale(0.5); }
.js .brand-card .brand-stars i { transition: opacity 300ms ease, transform 500ms var(--ease-spring); transition-delay: calc(900ms + var(--s) * 140ms); }
@media (prefers-reduced-motion: reduce) { .brand-pulse, .brand-ring, .brand-card-logo { animation: none; } .brand-pulse { display: none; } }

/* ---------- FAQ ---------- */
.faq-layout { display: grid; grid-template-columns: 0.8fr 1.2fr; gap: clamp(2.5rem, 1rem + 6vw, 7rem); align-items: start; }
.faq-layout .section-head { position: sticky; top: calc(var(--header-h) + 40px); margin-bottom: 0; }

/* ---------- Closing CTA ---------- */
.cta { text-align: center; }
.cta .h1 { max-width: 16ch; margin-inline: auto; }
.cta .lead { margin: 22px auto 0; }
.cta .hero-actions { margin-top: 34px; }

/* ---------- Hero v2: iD4 → iD6 + CarPlay comparison ----------
   Sizes use cqw (percent of the screen width) so the picture scales as one. */
.idrive {
  --pos: 50;
  position: relative; overflow: hidden; border-radius: 25px; aspect-ratio: 1287 / 677;
  container-type: inline-size; background: #050506; color: #f5f5f7; text-align: left;
  cursor: ew-resize; touch-action: pan-y; user-select: none; -webkit-user-select: none;
}
.idrive::after {
  content: ""; position: absolute; inset: 0; z-index: 3; pointer-events: none; border-radius: inherit;
  background: linear-gradient(115deg, rgb(255 255 255 / 0.08) 0%, rgb(255 255 255 / 0.02) 28%, transparent 40%);
}
.idrive-layer { position: absolute; inset: 0; }
.idrive .icon { width: 1em; height: 1em; }
.idrive-new { clip-path: inset(0 0 0 calc(var(--pos) * 1%)); }

/* Both screens are the owner's photos, cropped to the same 2.66:1 screen */
.idrive-layer img, .idrive-layer .id4 { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.idrive-new { background: #000; }
.cp-slide { position: absolute; inset: 0; opacity: 0; transition: opacity 900ms var(--ease-in-out); }
.cp-slide.is-active { opacity: 1; }
/* Screens narrower than the display keep their whole picture, centred on black like a non-widescreen CarPlay */
.idrive-layer .cp-slide--fit { object-fit: contain; }
@media (prefers-reduced-motion: reduce) { .cp-slide { transition: none; } }

/* Divider, handle and labels */
.idrive-handle { position: absolute; z-index: 2; top: 0; bottom: 0; left: calc(var(--pos) * 1%); width: 2px; margin-left: -1px; background: #fff; box-shadow: 0 0 12px rgb(0 0 0 / 0.5); pointer-events: none; }
.idrive-handle span {
  position: absolute; top: 50%; left: 50%; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  transform: translate(-50%, -50%); background: rgb(255 255 255 / 0.92); color: #1d1d1f; box-shadow: 0 6px 20px rgb(0 0 0 / 0.35);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) ease;
}
.idrive-handle .icon { width: 22px; height: 22px; stroke-width: 2.4; }
.idrive.is-dragging .idrive-handle span { transform: translate(-50%, -50%) scale(1.08); }
.idrive:has(.idrive-range:focus-visible) .idrive-handle span { box-shadow: 0 6px 20px rgb(0 0 0 / 0.35), var(--focus-ring); }
.idrive-tag {
  position: absolute; z-index: 2; bottom: 2cqw; padding: 6px 12px; border-radius: var(--radius-pill); pointer-events: none;
  font: 600 12px/1 var(--font-sans); color: #fff; background: rgb(0 0 0 / 0.55); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.14); transition: opacity var(--dur) ease;
}
.idrive-tag--old { left: 2cqw; opacity: clamp(0, (var(--pos) - 14) / 8, 1); }
.idrive-tag--new { right: 2cqw; opacity: clamp(0, (86 - var(--pos)) / 8, 1); }
.idrive-range { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .cockpit-screen { grid-template-columns: 1fr 240px; aspect-ratio: 16 / 8; }
  .why-panel { grid-template-columns: 1fr; }
  .faq-layout { grid-template-columns: 1fr; }
  .faq-layout .section-head { position: static; margin-bottom: 8px; }
}
@media (max-width: 760px) {
  .why-panel { padding-inline: 20px; }
  .cockpit-bezel { padding: 6px; border-radius: 24px; }
  .idrive { border-radius: 19px; }
  .idrive-handle span { width: 36px; height: 36px; }
  .idrive-tag { padding: 5px 9px; font-size: 10.5px; }
  .cockpit-screen { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; aspect-ratio: 4 / 4.6; border-radius: 19px; padding: 10px; gap: 8px; }
  .cockpit-side { grid-template-rows: none; grid-template-columns: 1fr 1fr; }
  .cockpit-side .widget { padding: 12px; min-height: 120px; }
  .widget-check li:nth-child(n+3) { display: none; }
  .widget-gauge strong { font-size: 24px; }
  .gauge-bars { height: 34px; }
  .nav-card { top: 10px; left: 10px; padding: 9px 12px 9px 9px; gap: 10px; }
  .nav-card-icon { width: 32px; height: 32px; border-radius: 9px; }
  .nav-card strong { font-size: 14px; }
  .eta-card { left: 10px; bottom: 10px; gap: 14px; padding: 8px 12px; }
  .product-grid--featured { grid-template-columns: 1fr; }
  .product-grid--featured .product-card:first-child { grid-row: auto; }
  .product-grid--featured .product-card:first-child .product-visual { min-height: 300px; }
  .product-grid--featured .product-card .product-visual { min-height: 220px; }
  .why-panel { border-radius: var(--radius-lg); }
}
@media (max-width: 480px) {
  .hero { padding-top: calc(var(--header-h) + 3rem); }
  .hero-inner, .hero-stage { width: 100%; min-width: 0; padding-inline: 12px; }
  .hero-badge { display: flex; justify-content: center; width: fit-content; max-width: 100%; gap: 7px; white-space: normal; text-align: center; }
  .hero-badge-copy { overflow-wrap: anywhere; }
  .hero h1 { max-width: 11ch; }
  .hero .lead { max-width: 22ch; margin-top: 20px; }
  .hero-actions { width: 100%; flex-direction: column; }
  .hero-actions .button { width: 100%; }
  .cockpit-status .cockpit-status-extra { display: none; }
}

/* Key figures under the Why panel */
.stat-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; margin-top: clamp(2.5rem, 1.5rem + 3vw, 4rem); text-align: center; }
.stat-row strong { display: block; font-size: clamp(2.6rem, 1.8rem + 2.6vw, 4rem); font-weight: 700; line-height: 1; letter-spacing: -0.045em;
  background: linear-gradient(180deg, var(--text), color-mix(in srgb, var(--text) 55%, var(--accent))); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat-row span { display: block; margin-top: 10px; font-size: var(--fs-title); font-weight: 600; letter-spacing: var(--tracking-title); }
.stat-row p { max-width: 24ch; margin: 6px auto 0; color: var(--text-secondary); font-size: var(--fs-small); line-height: 1.45; }
@media (max-width: 760px) { .stat-row { grid-template-columns: 1fr 1fr; gap: 32px 16px; } }
.faq-highlight { color: var(--accent); }
.brand-rating { display: inline-flex; align-items: center; gap: 8px; margin-top: 10px; padding: 6px 14px; border-radius: var(--radius-pill); background: light-dark(#fff, rgb(255 255 255 / 0.06)); box-shadow: inset 0 0 0 1px var(--line); font-size: var(--fs-small); }
.brand-rating .brand-stars { margin: 0; font-size: 1rem; }
.brand-rating b { font-weight: 700; }
.brand-rating > span:last-child { color: var(--text-secondary); }

/* Logo inside the hero badge */
.hero-badge-brand { display: inline-flex; align-items: center; gap: 6px; }
.hero-badge-logo { width: 18px; height: 18px; flex: none; border-radius: 4px; object-fit: contain; }
