/* SECTION / 360° design viewer
   Desktop (Figma 1920 frame, content column 1440 => px / 19.2):
     "Section — Design 360°" 1440x1096 = 64 padding, Wrapper 100
     (title 36/36 700, yellow divider 220x4, body 28/28 400), 32, then a
     1000-wide column 32 apart: toggle 56 (2x210 tabs, 18/24 600), viewer
     1000x600 over #f5f4f0 with the drag cue centred, caption 28, swatches 56.
   Mobile (Figma 402 frame, project convention => px / 3.75):
     402x611.5 = 32/16/48 padding, divider 160x4, 16 gaps, toggle 370x40,
     viewer 370x277.5, caption 26, swatches 40. */

.c360 {
  background: var(--page-bg);
  color: var(--page-ink);
}

.c360__container {
  padding: 3.3333vw; /* 64 */
}

/* ---------- heading ---------- */
.c360__head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8333vw; /* 16 */
}

.c360__title {
  margin: 0;
  font-family: var(--f-bold);
  font-weight: 700;
  font-size: 1.875vw; /* 36 */
  line-height: 1; /* 36 */
  text-align: center;
}

/* Figma "Yellow Accent" 220x4 */
.c360__rule {
  display: block;
  width: 11.4583vw; /* 220 */
  height: 0.2083vw; /* 4 */
  background: var(--brand-accent);
}

.c360__body {
  margin: 0;
  font-family: var(--f-regular);
  font-weight: 400;
  font-size: 1.4583vw; /* 28 */
  line-height: 1; /* 28 */
  text-align: center;
}

.c360__body-m {
  display: none;
}

/* ---------- the viewer column — Figma "Design 360°" 1000x836 ---------- */
.c360__picker {
  display: flex;
  flex-direction: column;
  gap: 1.6667vw; /* 32 */
  width: 52.0833vw; /* 1000 */
  margin: 1.6667vw auto 0; /* 32 */
}

/* Figma: the pill hugs its two 210 halves (420 total) and centres over the
   1000 viewer — it does NOT stretch the column width. */
.c360__toggle {
  display: flex;
  width: fit-content;
  align-self: center;
  border: 0.0521vw solid #e8e8e6; /* 1 */
  border-radius: 100px;
  background: #fafafa;
  overflow: hidden;
  box-sizing: border-box;
}

.c360__tab {
  width: 10.9375vw; /* 210 */
  padding: 0.8333vw 0; /* 16 */
  border: 0;
  background: transparent;
  color: var(--muted-ink);
  font-family: var(--f-semibold);
  font-weight: 600;
  font-size: 0.9375vw; /* 18 */
  line-height: 1.3333; /* 24 */
  letter-spacing: 0.026vw; /* 0.5 */
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease;
}

.c360__tab.is-active {
  background: var(--brand-accent);
  color: var(--brand-accent-ink);
}

/* ---------- viewer ---------- */
.c360__viewer {
  position: relative;
  height: 31.25vw; /* 600 */
  background: #f5f4f0;
  overflow: hidden;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
}

.c360__viewer.is-dragging {
  cursor: grabbing;
}

.c360__frame {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

/* The client frames are 4:3 studio shots with a wide white margin, so at 1:1
   the car reads about half the width of the viewer — the Figma has it filling
   the frame. Measured across all 24 frames the car never leaves x 154..846 /
   y 258..554 of the 1000x750 source, so 1.3 is the largest zoom that cannot
   clip it at either breakpoint. Presentation only: drop this line to go back
   to the untouched frame. */
.c360__frame {
  transform: scale(1.3);
}

/* ---------- interior panorama: a CSS 3D skybox ----------
   The client ships each interior as a cube map — six square faces that tile
   into one closed room. They are hung on a 0x0 cube at the centre of the
   viewer and the whole cube is pushed forward by exactly `--pano-p`, the
   perspective distance, so the CAMERA SITS AT THE CUBE'S CENTRE. That is what
   makes the look-around geometrically honest: every face is then the same
   distance from the eye and spans exactly 90°.

   `--pano-p` therefore also sets the field of view:
       horizontal FOV = 2 * atan(viewer_width / (2 * --pano-p))
   The viewer is 52.0833vw wide here, so 33.94vw gives ~75° — a natural
   interior lens. Widen the FOV by lowering it, narrow it by raising it.

   `--pano-h` (half the cube edge) cancels out of the projection, so it is just
   "comfortably bigger than the eye distance"; 2x keeps the faces clear of the
   eye plane. The 1.01 scale on each face overlaps the neighbours by half a
   percent so the seams do not show as hairlines. */
.c360__pano {
  position: absolute;
  inset: 0;
  display: none;
  background: #0d0d0d;
  perspective: 33.94vw;
  --pano-p: 33.94vw;
  --pano-h: calc(var(--pano-p) * 2);
}

.c360__cube {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  transform-style: preserve-3d;
  transform: translateZ(var(--pano-p)) rotateX(var(--pano-x, 0deg)) rotateY(var(--pano-y, 0deg));
  will-change: transform;
}

.c360__face {
  position: absolute;
  left: calc(var(--pano-h) * -1);
  top: calc(var(--pano-h) * -1);
  width: calc(var(--pano-h) * 2);
  height: calc(var(--pano-h) * 2);
  backface-visibility: hidden;
  pointer-events: none;
}

.c360__face--front { transform: translateZ(calc(var(--pano-h) * -1)) scale(1.01); }
.c360__face--back  { transform: rotateY(180deg) translateZ(calc(var(--pano-h) * -1)) scale(1.01); }
.c360__face--left  { transform: rotateY(90deg)  translateZ(calc(var(--pano-h) * -1)) scale(1.01); }
.c360__face--right { transform: rotateY(-90deg) translateZ(calc(var(--pano-h) * -1)) scale(1.01); }
.c360__face--up    { transform: rotateX(-90deg) translateZ(calc(var(--pano-h) * -1)) scale(1.01); }
.c360__face--down  { transform: rotateX(90deg)  translateZ(calc(var(--pano-h) * -1)) scale(1.01); }

/* ---------- drag cue — Figma: #d9d9d6 90%, 8 padding, 48 icon ---------- */
.c360__hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.4167vw; /* 8 */
  border-radius: 100px;
  background: #d9d9d6;
  opacity: 0.9;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.c360__hint img {
  display: block;
  width: 2.5vw; /* 48 */
  height: 2.5vw;
}

/* ---------- caption ---------- */
.c360__name {
  margin: 0;
  font-family: var(--f-regular);
  font-weight: 400;
  font-size: 1.4583vw; /* 28 */
  line-height: 1;
  text-align: center;
}

.c360__name-in {
  display: none;
}

/* ---------- colour picker ---------- */
.c360__swatches {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.625vw; /* 12 */
}

.c360__swatch {
  width: 2.9167vw; /* 56 */
  height: 2.9167vw;
  padding: 0;
  border: 0.0521vw solid var(--hairline); /* 1 */
  border-radius: 100px;
  background: transparent;
  overflow: hidden;
  cursor: pointer;
  box-sizing: border-box;
  transition: border-color 0.2s ease;
}

.c360__swatch.is-active {
  padding: 0.2083vw; /* 4 */
  border-width: 0.1042vw; /* 2 */
  border-color: var(--brand-accent);
}

.c360__chip {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 100px;
  object-fit: cover; /* the trim chips are 350x350 upholstery photos */
}

/* the trim row sits in the same slot as the paint row, and only one of the
   two is ever on screen */
.c360__trims {
  display: none;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.625vw; /* 12 */
}

/* ---------- interior tab: panorama instead of the spin ---------- */
.c360__picker.is-inside .c360__frame {
  display: none;
}

.c360__picker.is-inside .c360__pano {
  display: block;
}

.c360__picker.is-touched .c360__hint {
  opacity: 0;
}

.c360__picker.is-inside .c360__swatches {
  display: none;
}

.c360__picker.is-inside .c360__trims {
  display: flex;
}

.c360__picker.is-inside .c360__name-out {
  display: none;
}

.c360__picker.is-inside .c360__name-in {
  display: inline-block;
}


/* ============================== MOBILE ============================== */
@media (max-width: 768px) {

  .c360__container,
  .mobile .c360__container {
    padding: 8.5333vw var(--gutter) 12.8vw; /* 32 / 16 / 48 */
  }

  .c360__head,
  .mobile .c360__head {
    gap: 2.1333vw; /* 8 */
  }

  .c360__title,
  .mobile .c360__title {
    font-size: 9.6vw; /* 36 */
  }

  .c360__rule,
  .mobile .c360__rule {
    width: 42.6667vw; /* 160 */
    height: 1.0667vw; /* 4 */
  }

  .c360__body,
  .mobile .c360__body {
    font-size: 7.4667vw; /* 28 */
  }

  .c360__body-d,
  .mobile .c360__body-d {
    display: none;
  }

  .c360__body-m,
  .mobile .c360__body-m {
    display: inline;
  }

  .c360__picker,
  .mobile .c360__picker {
    width: 100%;
    gap: 4.2667vw; /* 16 */
    margin-top: 4.2667vw; /* 16 */
  }

  /* the mobile frame DOES stretch the pill to the 370 column */
  .c360__toggle,
  .mobile .c360__toggle {
    width: 100%;
    border-width: 0.2667vw; /* 1 */
  }

  .c360__tab,
  .mobile .c360__tab {
    flex: 1;
    width: auto;
    padding: 2.1333vw 0; /* 8 */
    font-size: 3.7333vw; /* 14 */
    line-height: 1.7143; /* 24 */
    letter-spacing: 0.1333vw; /* 0.5 */
  }

  .c360__viewer,
  .mobile .c360__viewer {
    height: 74vw; /* 277.5 */
  }

  /* Figma mobile cue frame 64x64 around the same 48 icon */
  .c360__hint,
  .mobile .c360__hint {
    padding: 2.1333vw; /* 8 */
  }

  .c360__hint img,
  .mobile .c360__hint img {
    width: 12.8vw; /* 48 */
    height: 12.8vw;
  }

  .c360__name,
  .mobile .c360__name {
    font-size: 6.9333vw; /* 26 */
  }

  /* the viewer is 91.4667vw wide here (100 minus the two gutters), so the
     perspective that keeps the same ~75° lens as desktop is 0.6516 of it */
  .c360__pano,
  .mobile .c360__pano {
    perspective: 59.6vw;
    --pano-p: 59.6vw;
  }

  .c360__swatches,
  .mobile .c360__swatches,
  .c360__trims,
  .mobile .c360__trims {
    gap: 3.2vw; /* 12 */
  }

  .c360__swatch,
  .mobile .c360__swatch {
    width: 10.6667vw; /* 40 */
    height: 10.6667vw;
    border-width: 0.2667vw; /* 1 */
  }

  .c360__swatch.is-active,
  .mobile .c360__swatch.is-active {
    padding: 1.0667vw; /* 4 */
    border-width: 0.5333vw; /* 2 */
  }
}
