/*
 * cars.xjk.yt - Immersive launch showroom.
 * The model is the surface: there is deliberately no card around the WebGL
 * stage. Copy and controls float in the same visual field as the car.
 */

/* ---------- Overview / launch ---------- */

.launch {
  position: relative;
  isolation: isolate;
  min-height: clamp(650px, 76vh, 760px);
  padding: 10px 0 20px;
}

.launch::before {
  position: absolute;
  z-index: -2;
  top: -12px;
  right: calc(50% - 50vw + var(--cars-sidenav-half));
  bottom: 0;
  left: -8vw;
  background:
    radial-gradient(ellipse at 73% 43%, rgba(249, 115, 22, 0.14), transparent 34%),
    radial-gradient(ellipse at 58% 58%, rgba(31, 179, 255, 0.08), transparent 40%),
    linear-gradient(105deg, rgba(2, 4, 6, 0.98) 9%, rgba(2, 4, 6, 0.66) 38%, transparent 72%);
  content: "";
  pointer-events: none;
}

.launch::after {
  position: absolute;
  z-index: -1;
  right: calc(50% - 50vw + var(--cars-sidenav-half));
  bottom: -8%;
  width: min(82vw, 1080px);
  height: 42%;
  background: radial-gradient(ellipse at center, rgba(249, 115, 22, 0.09), transparent 68%);
  content: "";
  pointer-events: none;
}

/* Both atmospheric layers are finite boxes. Fade their alpha to zero before
   that shared right edge so even wide viewports never reveal the box boundary. */
.launch::before,
.launch::after {
  -webkit-mask-image: linear-gradient(90deg, #000 0 78%, rgba(0, 0, 0, 0.72) 84%, transparent 100%);
  mask-image: linear-gradient(90deg, #000 0 78%, rgba(0, 0, 0, 0.72) 84%, transparent 100%);
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
}

.launch-copy {
  position: absolute;
  z-index: 10;
  top: clamp(56px, 9vh, 94px);
  left: 0;
  display: grid;
  justify-items: start;
  gap: 18px;
  width: min(35%, 390px);
}

.launch-title {
  font-family: Inter, "IBM Plex Sans Condensed", system-ui, sans-serif;
  font-size: clamp(32px, 3.4vw, 50px);
  font-weight: 650;
  line-height: 0.98;
  letter-spacing: -0.05em;
  text-wrap: balance;
}

.launch-summary {
  max-width: 38ch;
  color: var(--text-muted);
  font-family: "IBM Plex Sans Condensed", Inter, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  text-wrap: pretty;
}

.launch-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 10px;
  width: 100%;
}

.action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 42px;
  padding: 9px 13px;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: var(--text-main);
  background: rgba(0, 0, 0, 0.38);
  text-align: center;
  cursor: pointer;
  transition:
    border-color 150ms ease,
    background 150ms ease,
    color 150ms ease,
    transform 150ms ease;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.action:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.action:hover {
  border-color: var(--border-medium);
  background: rgba(255, 255, 255, 0.055);
  transform: translateY(-1px);
}

.action--file {
  position: relative;
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  min-height: 66px;
  padding: 14px 14px 14px 16px;
  overflow: hidden;
  border-color: rgba(249, 115, 22, 0.62);
  color: var(--text-main);
  background: linear-gradient(100deg, rgba(249, 115, 22, 0.14), transparent 62%), rgba(0, 0, 0, 0.5);
  box-shadow:
    inset 3px 0 0 rgba(249, 115, 22, 0.88),
    inset 0 1px 0 rgba(255, 255, 255, 0.045);
  text-align: left;
  text-decoration: none;
}

.action--file:hover {
  border-color: var(--accent);
  background: linear-gradient(100deg, rgba(249, 115, 22, 0.2), transparent 72%), rgba(0, 0, 0, 0.54);
  box-shadow:
    inset 3px 0 0 var(--accent),
    0 12px 34px rgba(0, 0, 0, 0.24);
}

.plugin-file-copy {
  display: flex;
  align-items: center;
  min-width: 0;
}

.plugin-file-name {
  overflow-wrap: anywhere;
  color: var(--accent);
  font-family: "IBM Plex Sans Condensed", Inter, system-ui, sans-serif;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: 0.005em;
  line-height: 1.15;
}

.plugin-file-download {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 9px;
  border: 1px solid rgba(249, 115, 22, 0.28);
  border-radius: 3px;
  color: var(--accent);
  background: rgba(249, 115, 22, 0.08);
  font-family: "Space Mono", monospace;
  font-size: 8px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition:
    color 150ms ease,
    background 150ms ease,
    border-color 150ms ease;
}

.plugin-file-download b {
  font-size: 14px;
  line-height: 1;
}

.action--file:hover .plugin-file-download {
  border-color: var(--accent);
  color: #090604;
  background: var(--accent);
}

.action--cars-download {
  grid-column: 1 / -1;
  justify-content: space-between;
  width: 100%;
  min-height: 48px;
  border-color: rgba(101, 216, 231, 0.38);
  color: #b8f5ff;
  background: linear-gradient(100deg, rgba(101, 216, 231, 0.1), transparent 72%), rgba(0, 0, 0, 0.42);
  font-family: "Space Mono", monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-decoration: none;
  text-transform: uppercase;
}

.action--cars-download:hover {
  border-color: #65d8e7;
  color: #effdff;
  background: linear-gradient(100deg, rgba(101, 216, 231, 0.17), transparent 78%), rgba(0, 0, 0, 0.48);
}

.action--cars-download b {
  font-size: 16px;
  line-height: 1;
}

.action-icon--file {
  position: relative;
  flex: 0 0 auto;
  width: 24px;
  height: 30px;
  border: 2px solid currentcolor;
  border-radius: 2px;
}

.action-icon--file::before {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 9px;
  height: 9px;
  border-bottom: 2px solid currentcolor;
  border-left: 2px solid currentcolor;
  background: var(--bg-panel-solid);
  content: "";
}

.action-icon--file::after {
  position: absolute;
  right: 4px;
  bottom: 5px;
  left: 4px;
  height: 2px;
  background: currentcolor;
  box-shadow: 0 -5px currentcolor;
  content: "";
}

/* Controls whose backing service is not live yet stay visible but inert. */
.action[data-state="soon"] {
  cursor: not-allowed;
  opacity: 0.66;
}

/* ---------- Borderless WebGL showroom ---------- */

.render {
  position: relative;
  z-index: 1;
  min-width: 0;
  margin: -16px calc(50% - 50vw + var(--cars-sidenav-half)) 0 clamp(265px, 22vw, 330px);
  transition: margin-right 200ms ease;
}

.render-shell {
  position: relative;
  display: grid;
  gap: 2px;
  min-width: 0;
}

.render-stage {
  position: relative;
  isolation: isolate;
  aspect-ratio: 16 / 10;
  min-height: 470px;
  overflow: hidden;
  /* Atmosphere belongs to .launch::before, which spans beyond the stage.
     Keeping this box unpainted prevents its clipped edges becoming seams. */
  background: transparent;
}

.showroom-grid {
  position: absolute;
  z-index: 0;
  right: 0;
  bottom: 0;
  left: 0;
  height: 54%;
  opacity: 0.18;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
  background-size: 44px 34px;
  transform: perspective(360px) rotateX(62deg);
  transform-origin: top center;
  -webkit-mask-image: radial-gradient(
    ellipse closest-side at 54% 52%,
    #000 12%,
    rgba(0, 0, 0, 0.82) 46%,
    transparent 100%
  );
  mask-image: radial-gradient(ellipse closest-side at 54% 52%, #000 12%, rgba(0, 0, 0, 0.82) 46%, transparent 100%);
}

.showroom-model-name {
  --showroom-name-opacity: 0.13;

  position: absolute;
  z-index: 1;
  top: 5%;
  right: clamp(18px, 2.5vw, 44px);
  left: 8%;
  overflow: visible;
  color: color-mix(in srgb, var(--showroom-tone, #f97316), white 36%);
  font-family: Inter, system-ui, sans-serif;
  font-size: clamp(82px, 10.5vw, 158px);
  font-weight: 850;
  letter-spacing: -0.085em;
  line-height: 0.76;
  opacity: var(--showroom-name-opacity);
  text-align: right;
  text-transform: uppercase;
  transform: translate3d(0, 0, 0);
  transition:
    opacity 240ms ease,
    filter 240ms ease,
    transform 240ms cubic-bezier(0.55, 0.05, 0.78, 0.3);
  white-space: nowrap;
  will-change: filter, opacity, transform;
  -webkit-text-stroke: 1px rgba(255, 255, 255, 0.24);
  text-shadow: 0 0 54px color-mix(in srgb, var(--showroom-tone, #f97316), transparent 72%);
}

.showroom-model-name[data-name-size="long"] {
  font-size: clamp(60px, 7.4vw, 112px);
}

.render-stage[data-showroom-transition="out"] .showroom-model-name {
  filter: blur(5px);
  opacity: 0;
}

.render-stage[data-showroom-direction="forward"][data-showroom-transition="out"] .showroom-model-name {
  transform: translate3d(-18%, 0, 0) scale(0.97);
}

.render-stage[data-showroom-direction="backward"][data-showroom-transition="out"] .showroom-model-name {
  transform: translate3d(18%, 0, 0) scale(0.97);
}

.render-stage[data-showroom-direction="forward"][data-showroom-transition="in"] .showroom-model-name {
  animation: showroom-name-in-forward 440ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.render-stage[data-showroom-direction="backward"][data-showroom-transition="in"] .showroom-model-name {
  animation: showroom-name-in-backward 440ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes showroom-name-in-forward {
  from {
    filter: blur(8px);
    opacity: 0;
    transform: translate3d(18%, 0, 0) scale(0.97);
  }

  to {
    filter: blur(0);
    opacity: var(--showroom-name-opacity);
    transform: translate3d(0, 0, 0) scale(1);
  }
}

@keyframes showroom-name-in-backward {
  from {
    filter: blur(8px);
    opacity: 0;
    transform: translate3d(-18%, 0, 0) scale(0.97);
  }

  to {
    filter: blur(0);
    opacity: var(--showroom-name-opacity);
    transform: translate3d(0, 0, 0) scale(1);
  }
}

/* The CSS plinth remains as a loading fallback; WebGL replaces it when ready. */
.showroom-podium {
  position: absolute;
  z-index: 1;
  right: 7%;
  bottom: 13%;
  left: 18%;
  height: 25%;
  border-radius: 50%;
  background: linear-gradient(180deg, #323b3e 0 13%, #14191c 17% 50%, #07090b 74%, #020304 100%);
  box-shadow:
    0 34px 55px rgba(0, 0, 0, 0.78),
    inset 0 2px 0 rgba(255, 255, 255, 0.1),
    inset 0 -6px 12px rgba(0, 0, 0, 0.78),
    0 0 42px color-mix(in srgb, var(--showroom-tone, #f97316), transparent 86%);
  transition: opacity 180ms ease;
}

.render-stage[data-showroom-state="ready"] .showroom-podium {
  opacity: 0;
}

.showroom-podium::before {
  position: absolute;
  inset: -5% 1% 31%;
  border: 1px solid rgba(255, 255, 255, 0.085);
  border-radius: 50%;
  background:
    radial-gradient(ellipse at 47% 37%, rgba(255, 255, 255, 0.1), transparent 35%),
    radial-gradient(ellipse at 50% 65%, #1c2427, #080a0c 74%);
  content: "";
}

.showroom-podium::after {
  position: absolute;
  right: 14%;
  bottom: 17%;
  left: 14%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--showroom-tone, var(--accent)), transparent);
  box-shadow: 0 0 18px var(--showroom-tone, var(--accent));
  content: "";
}

.showroom-canvas {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  cursor: grab;
  touch-action: none;
  transition: opacity 180ms ease;
}

.showroom-canvas:active {
  cursor: grabbing;
}

.showroom-canvas:focus-visible {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.showroom-loading,
.showroom-error {
  position: absolute;
  z-index: 8;
  top: 48%;
  left: 57%;
  display: none;
  align-items: center;
  gap: 9px;
  width: max-content;
  max-width: calc(100% - 32px);
  margin: 0;
  padding: 8px 11px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  color: var(--text-dim);
  background: rgba(3, 5, 7, 0.8);
  font-family: "Space Mono", ui-monospace, monospace;
  font-size: 9px;
  letter-spacing: 0.06em;
  text-align: center;
  text-transform: uppercase;
  transform: translate(-50%, -50%);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.render-stage.is-loading .showroom-loading {
  display: inline-flex;
}

.showroom-loading-indicator {
  width: 12px;
  height: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: showroom-loading 720ms linear infinite;
}

.render-stage.has-error .showroom-error:not([hidden]) {
  display: block;
  color: var(--warn);
}

.render-stage.has-error .showroom-canvas {
  opacity: 0.18;
}
