/* ==========================================================================
   Cidar configurator — studio white, petrol ink.
   The car carries the colour; the interface is typography and hairlines.
   Petrol (#042F30) is the one ink and accent. Mint is reserved for focus.
   ========================================================================== */

:root {
  /* palette */
  --white:      #FFFFFF;
  --petrol:     #042F30;   /* ink, selection, the call to action */
  --petrol-hi:  #0B4547;   /* CTA hover */
  --ink:        #0A1F20;
  --ink-2:      #56686A;   /* secondary text */
  --ink-3:      #8D9B9C;   /* tertiary, labels */
  --hair:       #E4E9E9;   /* hairline rules */
  --hair-2:     #CDD5D5;   /* hover rings, input edges */
  --mint:       #C7EDCF;   /* focus only */

  /* type */
  --display: "Outfit", ui-sans-serif, system-ui, sans-serif;
  --body:    "Figtree", ui-sans-serif, system-ui, sans-serif;
  --label:   "Space Grotesk", ui-monospace, monospace;

  --panel-w: clamp(360px, 27vw, 430px);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --slow: cubic-bezier(0.16, 1, 0.3, 1);

  /* stage chrome, flipped for dark scenes */
  --stage-ink:   var(--ink);
  --stage-ink-2: #6E7E7F;
  --stage-fade:  #FFFFFF;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--white);
  color: var(--ink);
  font-family: var(--body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; padding: 0; }
[hidden] { display: none !important; }
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }

:focus-visible { outline: 2px solid var(--mint); outline-offset: 3px; }

/* Small tracked capitals: every label, tab and view name */
.label,
.slot__name,
.tabs button,
.seg button,
.views button,
.caption__label {
  font-family: var(--label);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

/* ---- Layout ------------------------------------------------------------- */

.cfg {
  display: grid;
  grid-template-columns: 1fr var(--panel-w);
  height: 100dvh;
}

.stage {
  position: relative;
  overflow: hidden;
  min-height: 0;
  background: var(--stage-bg, #fff);
  transition: background 0.6s var(--ease);
}

.stage[data-tone="dark"] {
  --stage-ink: #F2F4F3;
  --stage-ink-2: rgba(242, 244, 243, 0.62);
  --stage-fade: #061314;
}

#viewport {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#viewport:active { cursor: grabbing; }

/* Inside the cabin the set is busy (seats, dash, windows), so the chrome turns
   white and sits on soft scrims at the top and bottom edges: legible over any
   trim colour, still no boxes */
.stage::before,
.stage::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s var(--ease);
}
.stage::before { top: 0; height: 140px; background: linear-gradient(rgba(4, 10, 10, 0.62), rgba(4, 10, 10, 0)); }
.stage::after { bottom: 0; height: 170px; background: linear-gradient(rgba(4, 10, 10, 0), rgba(4, 10, 10, 0.7)); }
.stage[data-mode="interior"]::before,
.stage[data-mode="interior"]::after { opacity: 1; }
.stage[data-mode="interior"] {
  --stage-ink: #FFFFFF;
  --stage-ink-2: rgba(255, 255, 255, 0.78);
}
.stage[data-mode="interior"] .logo--dark { display: none; }
.stage[data-mode="interior"] .logo--light { display: block; }
.stage[data-mode="interior"] :is(.seg button, .views button, .tool, .hint, .caption) {
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.45);
}
.stage[data-mode="interior"] .tool svg { filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.45)); }

/* ---- Stage chrome: type on the set, no containers ----------------------- */

.bar, .views, .tools, .hint, .caption { position: absolute; z-index: 2; }

.bar {
  top: 28px; left: 36px; right: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}
.bar > * { pointer-events: auto; }

.bar__mark { display: block; }
.logo { width: 92px; }
.logo--light { display: none; }
.stage[data-tone="dark"] .logo--dark { display: none; }
.stage[data-tone="dark"] .logo--light { display: block; }

.seg { display: flex; gap: 28px; }
.seg button,
.views button {
  position: relative;
  padding: 6px 0;
  color: var(--stage-ink-2);
  transition: color 0.25s var(--ease);
}
.seg button::after,
.views button::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.45s var(--slow);
}
.seg button:hover,
.views button:hover { color: var(--stage-ink); }
.seg button[aria-selected="true"],
.views button[aria-pressed="true"] { color: var(--stage-ink); }
.seg button[aria-selected="true"]::after,
.views button[aria-pressed="true"]::after { transform: scaleX(1); }

.views {
  left: 36px;
  bottom: 30px;
  display: flex;
  gap: 24px;
  max-width: calc(100% - 340px);
  overflow-x: auto;
  scrollbar-width: none;
}
.views::-webkit-scrollbar { display: none; }
.views button { flex: none; white-space: nowrap; }

.tools {
  right: 28px;
  bottom: 22px;
  display: flex;
  align-items: center;
  gap: 2px;
}
.tools .sep { width: 1px; height: 18px; margin: 0 10px; background: var(--stage-ink-2); opacity: 0.35; }

.tool {
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: var(--stage-ink-2);
  transition: color 0.2s var(--ease);
}
.tool svg { width: 20px; height: 20px; }
.tool:hover { color: var(--stage-ink); }
.tool[aria-pressed="true"] { color: var(--stage-ink); }
.tool[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  bottom: 3px;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: currentColor;
}
.tool[disabled] { opacity: 0.3; cursor: default; }
.tool[data-tip]:hover::before {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  white-space: nowrap;
  padding: 6px 10px;
  background: var(--petrol);
  color: #fff;
  font-family: var(--label);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  pointer-events: none;
}

.hint {
  top: 34px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  font-size: 12px;
  color: var(--stage-ink-2);
  transition: opacity 0.8s var(--ease);
  pointer-events: none;
}
.hint.is-hidden { opacity: 0; }

/* Signature: the last choice, captioned like a studio photograph */
.caption {
  left: 36px;
  bottom: 74px;
  display: grid;
  gap: 6px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.7s var(--slow), transform 0.9s var(--slow);
}
.caption.is-on { opacity: 1; transform: none; }
.caption__label { color: var(--stage-ink-2); }
.caption__name {
  font-family: var(--display);
  font-weight: 200;
  font-size: clamp(30px, 3.4vw, 52px);
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--stage-ink);
}

/* Cross-fade between inside and outside the car */
.fade {
  position: absolute;
  inset: 0;
  z-index: 3;
  background: var(--stage-fade);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.32s var(--ease);
}
.fade.is-on { opacity: 1; }

.loader {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 26px;
  background: #fff;
  color: var(--ink-3);
  transition: opacity 0.9s var(--ease), visibility 0.9s;
}
.loader img { width: 120px; }
.loader__track { width: 160px; height: 1px; background: var(--hair); overflow: hidden; }
.loader__fill { height: 100%; width: 0; background: var(--petrol); transition: width 0.3s linear; }
.loader.is-done { opacity: 0; visibility: hidden; }
.loader.is-error .loader__fill { background: #B4412F; width: 100%; }

/* ---- Panel ---------------------------------------------------------------- */

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--white);
  border-left: 1px solid var(--hair);
}

.panel__head { padding: 30px 32px 0; }
.panel__head .label { color: var(--ink-3); }
.panel__title {
  margin-top: 8px;
  font-family: var(--display);
  font-weight: 300;
  font-size: 34px;
  line-height: 1;
  letter-spacing: -0.025em;
}

.tabs {
  display: flex;
  gap: 26px;
  margin: 26px 32px 0;
  border-bottom: 1px solid var(--hair);
}
.tabs button {
  position: relative;
  padding: 0 0 14px;
  color: var(--ink-3);
  transition: color 0.2s var(--ease);
}
.tabs button::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: var(--petrol);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.45s var(--slow);
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); }
.tabs button[aria-selected="true"]::after { transform: scaleX(1); }

.panel__body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 32px 32px;
  scrollbar-width: thin;
  scrollbar-color: var(--hair-2) transparent;
}

.slot {
  padding: 26px 0 28px;
  border-bottom: 1px solid var(--hair);
}
.slot:last-child { border-bottom: 0; }

.slot__head {
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.slot__name { color: var(--ink-3); font-weight: 500; }
.slot__focus {
  font-family: var(--label);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  opacity: 0;
  transition: opacity 0.2s var(--ease), color 0.2s var(--ease);
}
.slot:hover .slot__focus, .slot__focus:focus-visible { opacity: 1; }
.slot__focus:hover { color: var(--petrol); }
.slot__price {
  margin-left: auto;
  font-size: 12.5px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.slot__value {
  margin: 6px 0 18px;
  font-family: var(--display);
  font-weight: 300;
  font-size: 19px;
  letter-spacing: -0.01em;
  color: var(--ink);
}

/* swatches: the colour, a hairline, and a fine petrol ring when chosen */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }

.swatch {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
}
.swatch__fill {
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--sw, #ccc);
  box-shadow: inset 0 0 0 1px rgba(10, 31, 32, 0.12);
}
.swatch::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 1px transparent;
  transition: box-shadow 0.25s var(--ease);
}
.swatch:hover::after { box-shadow: 0 0 0 1px var(--hair-2); }
.swatch[aria-checked="true"]::after { box-shadow: 0 0 0 1px var(--petrol); }
.swatch__link {
  position: absolute;
  right: -3px; bottom: -3px;
  width: 16px; height: 16px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: #fff;
  color: var(--ink-2);
  box-shadow: 0 0 0 1px var(--hair);
}
.swatch__link svg { width: 9px; height: 9px; }

/* material swatches */
.swatch__fill.tx-carbon {
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,0.08) 0 2px, transparent 2px 4px),
    repeating-linear-gradient(-45deg, rgba(0,0,0,0.45) 0 2px, transparent 2px 4px),
    #26282a;
}
.swatch__fill.tx-forged {
  background:
    radial-gradient(circle at 30% 30%, rgba(255,255,255,0.16) 0 18%, transparent 19%),
    radial-gradient(circle at 70% 60%, rgba(255,255,255,0.1) 0 22%, transparent 23%),
    conic-gradient(from 40deg, #1c1c1e, #3a3a3e, #141416, #2e2e31, #1c1c1e);
}
.swatch__fill.tx-leather { background: #4a4643; }
.swatch__fill.tx-alcantara { background: #3a3a3a; }
.swatch__fill.tx-fabric {
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,0.08) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(0,0,0,0.18) 0 1px, transparent 1px 3px),
    #8b8d8c;
}
.swatch__fill.tx-perforated {
  background: radial-gradient(circle, rgba(0,0,0,0.5) 0 1px, transparent 1.4px) 0 0 / 5px 5px, #5b5753;
}

.swatch--custom .swatch__fill {
  background: conic-gradient(from 90deg, #c94a3d, #d7b33f, #5aa36a, #3b8fa8, #4b5bb5, #9a4fa6, #c94a3d);
}
.swatch--custom input {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.chips {
  display: inline-flex;
  margin-top: 16px;
  border: 1px solid var(--hair-2);
}
.chip {
  padding: 8px 14px;
  font-family: var(--label);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-2);
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.chip + .chip { border-left: 1px solid var(--hair-2); }
.chip:hover { color: var(--ink); }
.chip[aria-checked="true"] { background: var(--petrol); color: #fff; }

/* designs (wheels): quiet rows rather than cards */
.tiles { display: grid; gap: 8px; }
.tile {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--hair);
  text-align: left;
  transition: border-color 0.25s var(--ease);
}
.tile svg { width: 34px; height: 34px; color: var(--ink-2); }
.tile__name { font-size: 14px; color: var(--ink); }
.tile__price { font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.tile:hover { border-color: var(--hair-2); }
.tile[aria-checked="true"] { border-color: var(--petrol); }
.tile[aria-checked="true"] svg { color: var(--petrol); }

/* ---- Summary --------------------------------------------------------------- */

.summary__title {
  margin: 30px 0 4px;
  font-family: var(--display);
  font-weight: 300;
  font-size: 26px;
  letter-spacing: -0.02em;
}
.summary__list { margin: 14px 0 28px; }
.summary__list .row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--hair);
  font-size: 13.5px;
}
.summary__list dt {
  grid-column: 1 / -1;
  font-family: var(--label);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.summary__list dd { margin: 0; }
.summary__list dd.num { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.summary__list .row--group { border: 0; padding: 22px 0 0; }
.summary__list .row--group dt { color: var(--ink); }
.summary__actions { display: grid; border-top: 1px solid var(--hair); }
.summary__actions .btn {
  justify-content: space-between;
  height: 48px;
  padding: 0;
  border-bottom: 1px solid var(--hair);
  font-size: 13.5px;
  font-weight: 400;
  color: var(--ink);
}
.summary__actions .btn::after { content: "→"; color: var(--ink-3); transition: transform 0.25s var(--ease); }
.summary__actions .btn:hover::after { transform: translateX(3px); color: var(--petrol); }
.summary__credit { margin-top: 20px; font-size: 11.5px; line-height: 1.55; color: var(--ink-3); }

/* ---- Footer ---------------------------------------------------------------- */

.panel__foot {
  display: grid;
  gap: 16px;
  padding: 20px 32px calc(24px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--hair);
  background: var(--white);
}
.price { display: grid; grid-template-columns: 1fr auto; align-items: baseline; row-gap: 2px; }
.price .label { color: var(--ink-3); }
.price strong {
  grid-row: span 2;
  font-family: var(--display);
  font-weight: 300;
  font-size: 30px;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.price__delta { font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  white-space: nowrap;
  transition: background 0.25s var(--ease), color 0.25s var(--ease);
}
.btn--primary {
  height: 54px;
  width: 100%;
  background: var(--petrol);
  color: #fff;
  font-family: var(--label);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.btn--primary svg { transition: transform 0.35s var(--slow); }
.btn--primary:hover { background: var(--petrol-hi); }
.btn--primary:hover svg { transform: translateX(4px); }

.toast {
  position: fixed;
  left: calc((100vw - var(--panel-w)) / 2);
  top: 28px;
  z-index: 10;
  transform: translate(-50%, -8px);
  padding: 11px 18px;
  background: var(--petrol);
  color: #fff;
  font-family: var(--label);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* Debug report (?debug) */
.debug {
  position: absolute;
  top: 80px; left: 36px;
  z-index: 5;
  max-width: 340px;
  max-height: 60%;
  overflow: auto;
  padding: 12px 14px;
  background: rgba(4, 47, 48, 0.94);
  color: #F2F4F3;
  font: 11px/1.5 var(--label);
  white-space: pre-wrap;
}

/* Embedded (?embed): the host page provides the brand */
.is-embed .bar__mark { visibility: hidden; }

/* ---- Small screens: stage on top, options below -------------------------- */

@media (max-width: 900px) {
  body { overflow: auto; }
  .cfg { grid-template-columns: 1fr; grid-template-rows: min(58dvh, 540px) 1fr; }
  .panel { border-left: 0; border-top: 1px solid var(--hair); }
  .bar { top: 18px; left: 18px; right: 18px; }
  .logo { width: 74px; }
  .seg { gap: 18px; }
  .views { left: 18px; bottom: 64px; gap: 18px; max-width: calc(100% - 36px); }
  .tools { left: 8px; right: 8px; bottom: 10px; justify-content: space-between; gap: 0; }
  .tool { width: 34px; }
  .tools .sep { margin: 0 4px; }
  .tool[data-tip]:hover::before { display: none; }
  .caption { left: 18px; bottom: 108px; }
  .caption__name { font-size: 22px; }
  .hint { top: 54px; }
  .panel__head { padding: 22px 18px 0; }
  .panel__title { font-size: 28px; }
  .tabs { margin: 20px 18px 0; }
  .panel__body { padding: 0 18px 24px; }
  .panel__foot { position: sticky; bottom: 0; padding-left: 18px; padding-right: 18px; }
  .toast { left: 50%; }
}

/* A slot set by another choice (e.g. aniline leather fixes the seat colour) */
.slot.is-locked .swatches,
.slot.is-locked .tiles,
.slot.is-locked .chips { opacity: 0.3; filter: grayscale(0.7); }
.slot.is-locked .slot__value { font-style: italic; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
