/* Visit tour: the 3D clinic, its stage badge, the current stage and its desk.
   Shared parts (header, footer, actions, eyebrow, tag, bubble badge, stage cards) are in styles.css.
   scene/clinic.js draws into #clinic-model and adds .scene-ready to .clinic-stage once it has a frame. */

.tour {
  /* Room above the frame for the stage badge. On wide screens the eyebrow lines up with the top
     of the badge's ring (badge box top + 0.3rem). */
  --scene-pad: 1.75rem;
  padding-top: .5rem; overflow-x: clip;  /* the glow may reach past the gutter */
}

/* ---------- Intro ---------- */
.tour-intro .eyebrow { padding-right: .375rem; }
.tour-intro .eyebrow .tag { margin-left: .125rem; }
/* The tour is a marketing page beside an illustration, so its title takes the shared hero role
   and the lead keeps the homepage rhythm (.hero-title and .lead in styles.css). */

/* ---------- Scene: frame, render, badge ---------- */
.tour-scene { position: relative; margin-top: 2rem; padding-top: var(--scene-pad); }
.tour-glow {
  position: absolute; inset: -6% -6% -10% -10%; z-index: 0; pointer-events: none;
  /* Pre-blurred: each ellipse fades to transparent well inside the box, so no edge shows. */
  background:
    radial-gradient(40% 38% at 60% 36%, rgb(182 185 255 / .42), rgb(182 185 255 / .12) 55%, rgb(182 185 255 / 0) 100%),
    radial-gradient(32% 26% at 30% 74%, rgb(255 241 199 / .9), rgb(255 241 199 / 0) 100%);
}
.tour-frame {
  position: relative; z-index: 1;
  border-radius: var(--radius-scene); background: var(--scene-bg);
  box-shadow: var(--shadow-scene);
}
.tour-frame::after {
  content: ""; position: absolute; inset: 0; z-index: 2; border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 0 0 1px rgb(48 36 67 / .06), inset 0 1px 0 rgb(255 255 255 / .7);
}
/* The renders are 1260 × 900. The frame keeps at least that height for its width; when it is
   taller, the picture keeps its width and centres. clinic.js frames its camera the same way below
   a 1.62 aspect, so the static render and the live scene line up. */
.clinic-stage {
  position: relative; isolation: isolate;
  aspect-ratio: 1260 / 900;
  border-radius: inherit; overflow: hidden;
}
.clinic-stage img, .clinic-stage canvas {
  position: absolute; inset: 0; display: block; width: 100%; height: 100%;
}
.clinic-stage img { object-fit: contain; object-position: 50% 50%; }
/* The live scene fades in over the render, which stays fully painted until the fade ends, so the
   frame never dims. The render keeps its alt text for screen readers. */
.clinic-stage canvas {
  z-index: 1; opacity: 0; pointer-events: none;
  transition: opacity var(--dur-scene) var(--ease-out);
}
.clinic-stage.scene-ready canvas { opacity: 1; }
.clinic-stage.scene-ready img { opacity: 0; transition: opacity 0s linear var(--dur-scene); }
/* Without the live scene, a new render settles into place instead of cutting. */
.clinic-stage img.is-settling { animation: settle var(--dur-scene) var(--ease-out); }
@keyframes settle { from { transform: scale(1.025); } }

/* Stage badge: hangs off the frame's top left, its tail pointing into the clinic. No idle loop. */
.tour-badge { position: absolute; z-index: 4; left: -1.5rem; top: -1.625rem; }
.tour-badge .bubble > .icon {
  grid-area: 1 / 1;
  opacity: 0; transform: scale(.7) rotate(-12deg);
  transition: opacity var(--dur-state) var(--ease-out), transform var(--dur-scene) var(--ease-out);
}
[data-stage="0"] .tour-badge .bubble > .icon[data-for="0"],
[data-stage="1"] .tour-badge .bubble > .icon[data-for="1"],
[data-stage="2"] .tour-badge .bubble > .icon[data-for="2"] { opacity: 1; transform: none; }

/* ---------- The current stage and its desk ---------- */
.tour-detail { margin-top: 1.75rem; }
.detail-kicker {
  font: 650 var(--type-small)/var(--leading-small) var(--font-body);
  color: var(--ink-muted); font-variant-numeric: tabular-nums;
}
.tour-detail h2 { margin-top: .25rem; }
.detail-caption { margin-top: .5rem; max-width: 28rem; color: var(--ink-muted); text-wrap: pretty; }
.tour-detail .btn { margin-top: 1.5rem; }

/* ---------- Stage cards ---------- */
.tour .stage-list { margin-top: 2.5rem; }
/* The cards start disabled in the markup and visit-tour.js enables them. Without the script (or
   if it fails to load) they read as a plain numbered list of the three stages, flat with no card
   edge or lift, Check-in marked by its radiant tile and track, and offer nothing to press. Once
   the script enables them they settle into cards through the shared fill and shadow transition. */
.tour .stage-card:disabled { cursor: default; background: none; box-shadow: none; }
@media (hover: hover) {
  .tour .stage-card:disabled:hover { transform: none; box-shadow: none; }
}
@media (forced-colors: active) {
  .tour .stage-card:disabled { border-color: GrayText; }
}

/* ---------- Wide: copy beside the scene, stages below ---------- */
@media (min-width: 64rem) {
  .tour {
    display: grid; grid-template-columns: minmax(0, .78fr) minmax(0, 1.22fr);
    grid-template-rows: auto 1fr auto; column-gap: 4rem;
  }
  .tour-intro { grid-column: 1; grid-row: 1; margin-top: calc(var(--scene-pad) - 1.625rem + .3rem); }
  /* The copy is one continuous stack, as on the homepage: the stage detail follows the lead at a
     fixed 48 px, and any spare height beside a taller frame falls below the desk button. */
  .tour-scene { grid-column: 2; grid-row: 1 / 3; display: flex; flex-direction: column; margin-top: 0; }
  .tour-frame { flex: 1 0 auto; display: flex; flex-direction: column; }
  .clinic-stage { flex: 1 0 auto; }
  .tour-detail { grid-column: 1; grid-row: 2; align-self: start; margin-top: 3rem; }
  .tour .stage-list { grid-column: 1 / -1; grid-row: 3; margin-top: 3.5rem; }
  .tour .page-next { grid-column: 1 / -1; grid-row: 4; }
}
/* Short laptop screens (1366 × 768, 1280 × 720): the first screen should end on the complete row
   of stage cards, so the frame narrows with the viewport height and keeps its right edge. */
@media (min-width: 64rem) and (max-height: 52rem) {
  .tour-scene { justify-self: end; width: 100%; max-width: calc((100vh - 17rem) * 1.4); }
  .tour .stage-list { margin-top: 2.5rem; }
}
@media (min-width: 64rem) and (max-width: 79.99rem) {
  .tour { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); column-gap: 3rem; }
}

/* ---------- Tablet: one column, the desk button beside the caption ---------- */
@media (min-width: 48rem) and (max-width: 63.99rem) {
  .tour-intro { max-width: 40rem; }
  .tour-detail {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; column-gap: 2rem;
  }
  .tour-detail .btn { margin-top: 0; }
  .tour .stage-list { margin-top: 3rem; }
}

/* ---------- Phone ---------- */
@media (max-width: 47.99rem) {
  .tour { padding-top: .25rem; --scene-pad: 1.125rem; }
  .tour-scene { margin-top: 1.75rem; }
  .tour-glow { inset: 0 -1rem; }
  .tour-frame { border-radius: var(--radius-card); scroll-margin-top: 1.5rem; }
  .tour-badge { left: -.5rem; top: -1.125rem; }
  .tour-badge .bubble { --bubble-size: 3.75rem; }
  .tour-detail { margin-top: 1.5rem; }
  .tour-detail .btn { margin-top: 1.25rem; }
  .tour .stage-list { margin-top: 2rem; }
}
