/*
  panel.css: the options, as a bottom sheet on a phone and a column beside the car from 900px.
  On a phone the sheet is laid out at its full height (just under the top bar) and pushed down
  by --sheet-shift to one of three stops (js/ui/sheet.js): peek (grip, name, total), half (the
  tabs and a few rows) or full. Owns the dock (grip, head with the total, body), the tab row, the option rows (colour dots,
  word chips, notes; the ambient control is ambient.css) and the Summary build sheet. Every row is one line
  on a phone, a sideways rail that a thumb drags; on the column layout the rows wrap and the
  colour dots gain their names and prices. Siblings: base.css (tokens), stage.css (the frame).
*/

/* ---------- The dock ---------- */

.dock {
  position: absolute;
  top: calc(var(--bar-h) + env(safe-area-inset-top, 0px) + 8px);
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  border-radius: var(--r-panel) var(--r-panel) 0 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  transform: translateY(var(--sheet-shift));
  transition: transform .4s var(--ease), opacity .5s var(--ease) .15s, visibility 0s;
}
.cfg.is-dragging .dock { transition: none; }
/* Raised to full, the sheet is a page of options: the car behind it stays a shadow, not a pattern under the words. */
.dock.glass[data-sheet="full"] { background: rgba(22, 22, 21, .95); }

.dock__grip {
  position: relative;
  display: grid;
  place-items: center;
  height: 22px;
  touch-action: none;
}
/* The bar stays slim; the target reaches 22px up over the stage, so a thumb gets 44px. */
.dock__grip::before {
  content: "";
  position: absolute;
  inset: -22px 0 0;
}
.dock__grip span {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--line-2);
}
.dock__head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 var(--gutter) 6px;
  touch-action: none;
}
/* The name over the starting price, beside the live total. */
.dock__label {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.dock__from {
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
}
.dock__title {
  min-width: 0;
  font-size: 14px;
  font-weight: 560;
  font-stretch: 110%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dock__total {
  font-size: 16px;
  font-weight: 600;
  font-stretch: 105%;
  letter-spacing: .01em;
}
.dock__chev {
  width: 18px;
  height: 18px;
  flex: none;
  color: var(--text-3);
  transition: transform .3s var(--ease);
}
.dock[data-sheet="peek"] .dock__chev { transform: rotate(180deg); }
.dock__body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
}
/* Lowered, the rows are out of reach of focus and touch; a drag shows them coming up. */
.dock[data-sheet="peek"] .dock__body { visibility: hidden; transition: visibility 0s linear .4s; }
.cfg.is-dragging .dock__body { visibility: visible; transition: none; }

/* ---------- Tabs ---------- */

.tabs {
  display: flex;
  overflow-x: auto;
  padding: 0 calc(var(--gutter) - 10px);
  border-bottom: 1px solid var(--line);
  flex: none;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scroll-padding-inline: 6px;
}
/* Soft edges only on a side that hides a tab (rails.js watchEdges), so a row that fits is never
   dimmed and a tab running past the edge fades out rather than being sliced. */
.tabs[data-more="end"] {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent);
}
.tabs[data-more="start"] {
  -webkit-mask-image: linear-gradient(to right, transparent, #000 36px);
  mask-image: linear-gradient(to right, transparent, #000 36px);
}
.tabs[data-more="both"] {
  -webkit-mask-image: linear-gradient(to right, transparent, #000 36px, #000 calc(100% - 36px), transparent);
  mask-image: linear-gradient(to right, transparent, #000 36px, #000 calc(100% - 36px), transparent);
}
.tabs::-webkit-scrollbar, .rail::-webkit-scrollbar { display: none; }
.tab {
  position: relative;
  flex: 1 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 9px;
  scroll-snap-align: start;
  font-size: 14px;
  font-weight: 520;
  color: var(--text-3);
  white-space: nowrap;
  transition: color .2s;
}
.tab::after {
  content: "";
  position: absolute;
  left: 9px;
  right: 9px;
  bottom: -1px;
  height: 1.5px;
  background: var(--brass);
  transform: scaleX(0);
  transition: transform .3s var(--ease);
}
.tab[aria-selected="true"] { color: var(--text); }
.tab[aria-selected="true"]::after { transform: scaleX(1); }

/* ---------- Panels and rows ---------- */

/* On a phone the rows fill the sheet; at the half stop the part below the screen is padded
   (--sheet-hidden, set by sheet.js), so the last row of a long tab still scrolls into view.
   Moving between tabs never moves the sheet, so it never moves the car. */
.panels {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}
.panel:focus { outline: none; }
.panel { padding-bottom: calc(8px + var(--sheet-hidden, 0px)); }
/* The camera views have their own buttons over the car on a phone (nav.css), so the Views tab
   keeps the doors, the windows and the kerb moments. */
.row[data-row="view"] { display: none; }
/* Six tabs in under 400px: a touch tighter, so most phones show them all. */
@media (max-width: 420px) {
  .tabs { padding-inline: 4px; }
  .tab { padding-inline: 6px; font-size: 13.5px; }
  .tab::after { left: 6px; right: 6px; }
}

.row { padding-top: 12px; }
.row[hidden] { display: none; }
.row__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0 var(--gutter);
}
.row__label {
  flex: none;
  font-size: 13px;
  font-weight: 560;
  color: var(--text-2);
}
.row__value {
  min-width: 0;
  font-size: 13px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rail {
  display: flex;
  gap: 8px;
  padding: 6px var(--gutter) 2px;
  overflow-x: auto;
  scroll-padding-inline: var(--gutter);
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}
.rail.is-dragging { cursor: grabbing; user-select: none; -webkit-user-select: none; }
.rail.is-dragging > * { pointer-events: none; }
.rail--swatch { gap: 4px; padding-inline: calc(var(--gutter) - 6px); }

/* ---------- Options ---------- */

.opt { flex: none; transition: border-color .2s, background-color .2s, color .2s, opacity .2s; }
/* An option the shown cabin does not take (a colourway made for other cabins). */
.opt[hidden] { display: none; }
.opt[aria-disabled="true"] { opacity: .42; }

.opt--chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-chip);
  font-size: 14px;
  color: var(--text-2);
  white-space: nowrap;
}
.opt--chip[aria-pressed="true"] {
  border-color: var(--brass);
  background: rgba(200, 172, 122, .1);
  color: var(--text);
}
/* A cabin still on its way (ui/waiting.js): a hairline travels along the foot of its button.
   The button stays live; the mark sits inside the border, so nothing moves. */
.opt--chip[data-loading] { position: relative; overflow: hidden; }
.opt--chip[data-loading]::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 40%;
  height: 1px;
  background: var(--brass);
  animation: travel 1.6s var(--ease) infinite;
}
@media (prefers-reduced-motion: reduce) {
  .opt--chip[data-loading]::after { animation: none; left: 14px; right: 14px; width: auto; opacity: .6; }
}
.opt__meta { font-size: 12.5px; color: var(--text-3); }
.opt--chip[aria-pressed="true"] .opt__meta { color: var(--text-2); }
.opt__icon { width: 18px; height: 18px; margin-left: -4px; }
.opt__thumb { width: 30px; height: 30px; margin-left: -10px; border-radius: 50%; object-fit: cover; }

/* A colour dot inside a 44px target; the pressed one gets a brass ring with a gap of the panel. */
.opt--swatch {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
}
.opt__dot {
  position: relative;
  display: block;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14);
}
.opt__ring {
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 1.5px solid transparent;
  transition: border-color .2s;
}
.opt--swatch[aria-pressed="true"] .opt__ring { border-color: var(--brass); }
/* Leather and colourway dots carry their contrast stitch as a dashed line just inside the edge. */
.opt__ring[data-stitch]::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  border: 1px dashed var(--stitch);
  opacity: .8;
}
.opt--swatch .opt__text {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Notes ---------- */

.row--note {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 14px var(--gutter) 4px;
}
.note__text { font-size: 13.5px; color: var(--text-2); max-width: 34ch; text-wrap: pretty; }
.note__btn, .act {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-chip);
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
}
.note__btn:active, .act:active { background: var(--press); }
.act svg { width: 18px; height: 18px; color: var(--text-2); }

/* ---------- Summary ---------- */

.sheet { padding: 14px var(--gutter) 6px; }
.sheet__model {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 15px;
  font-weight: 560;
  font-stretch: 110%;
}
.sheet__base { font-weight: 430; font-stretch: 100%; color: var(--text-2); }
.sheet__lines { margin-top: 8px; }
.sheet__line {
  display: grid;
  grid-template-columns: 6.6rem 1fr;
  gap: 8px;
  padding: 7px 0;
  border-top: 1px solid var(--line);
  font-size: 13.5px;
}
.sheet__line dt { color: var(--text-3); }
.sheet__line dd { display: flex; justify-content: space-between; gap: 10px; min-width: 0; }
.sheet__value { min-width: 0; }
.sheet__price { flex: none; color: var(--text-2); }
.sheet__total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-top: 10px;
  border-top: 1px solid var(--line-2);
  font-size: 18px;
  font-weight: 600;
  font-stretch: 108%;
}
.sheet__fine { margin-top: 4px; font-size: 12px; color: var(--text-3); }
.sheet__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

/* ---------- The column beside the car ---------- */

@media (min-width: 900px) and (min-height: 600px) {
  .dock {
    left: auto;
    top: calc(var(--bar-h) + 4px);
    right: var(--edge);
    bottom: var(--edge);
    width: var(--dock-w);
    border-radius: var(--r-panel);
    padding-bottom: 0;
    transform: none;
    overflow: hidden;
  }
  .dock__grip, .dock__chev { display: none; }
  /* No sheet here: the rows always show, whatever stop the phone layout last had. */
  .dock[data-sheet] .dock__body { visibility: visible; }
  .dock__head { min-height: 58px; padding: 6px 20px 4px; touch-action: auto; }
  .dock__title { font-size: 15px; }
  .dock__total { font-size: 18px; }
  .dock__body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
  /* Six tabs share the column's width, so none of them hides past the edge. */
  .tabs { flex: none; justify-content: space-between; padding-inline: 12px; -webkit-mask-image: none; mask-image: none; }
  .tab { padding-inline: 7px; font-size: 13.5px; }
  .tab::after { left: 7px; right: 7px; }
  .panels { flex: 1; height: auto; min-height: 0; }
  .panel { padding-bottom: 8px; }
  .row[data-row="view"]:not([hidden]) { display: block; }
  .tab { flex: none; scroll-snap-align: none; }

  :root { --gutter: 20px; }
  .row { padding-top: 16px; }
  .rail { flex-wrap: wrap; overflow: visible; padding-top: 8px; }
  .rail--swatch {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    padding-inline: calc(var(--gutter) - 8px);
  }
  .opt--swatch {
    display: flex;
    justify-content: flex-start;
    gap: 12px;
    width: auto;
    height: auto;
    min-height: 48px;
    padding: 6px 8px;
    border-radius: 10px;
    text-align: left;
  }
  .opt__dot { flex: none; width: 28px; height: 28px; }
  .opt__ring { inset: -4px; }
  .opt--swatch .opt__text {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    white-space: normal;
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.25;
  }
  .opt--swatch .opt__name { font-size: 13.5px; color: var(--text-2); }
  .opt--swatch[aria-pressed="true"] .opt__name { color: var(--text); }
  .opt--swatch .opt__meta { font-size: 12px; }
}

@media (hover: hover) {
  .tab:hover { color: var(--text-2); }
  .opt--chip:hover:not([aria-pressed="true"]):not([aria-disabled="true"]) { border-color: rgba(236, 231, 222, .4); color: var(--text); }
  .opt--swatch:hover:not([aria-pressed="true"]) .opt__ring { border-color: var(--line-2); }
  .note__btn:hover, .act:hover { background: var(--press); }
}
