/* Homepage only: hero, the sample-visit scene and its controls.
   Shared parts (header, footer, actions, eyebrow, bubble badge, stage cards) are in styles.css. */

.home {
  /* Space above the scene frame. The hero's top follows it, so the eyebrow lines up with the
     top of the stage badge's ring (badge box top + 0.3rem). */
  --scene-pad: 1.75rem;
  padding-top: .5rem; overflow-x: clip;
}

/* ---------- Hero copy (.hero-title and .lead are shared, in styles.css) ---------- */
/* Hand-set line breaks. Desktop: "See one / outpatient visit / from start to finish".
   Phone: "See one / outpatient / visit from / start to finish". */
.hero-title .br::after,
.hero-title .br-3::after { content: "\A"; white-space: pre; }
.actions { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 2.25rem; }
.note {
  display: flex; align-items: flex-start; gap: .5rem; margin-top: 1rem;
  font-size: var(--type-small); line-height: var(--leading-small); color: var(--ink-muted);
}
.note .icon { width: 1.125rem; height: 1.125rem; margin-top: 1px; stroke-width: 1.6; }

/* ---------- Scene: render, stage badge, tether and the mini queue ---------- */
.scene {
  /* The queue card hangs off the frame's lower right. It may only cover the right third of the
     frame to keep the patient's face and task visible, so the frame narrows as the card's
     share of the column grows. --overlap is how far the card rises into the frame, as a share of
     the column width: frame width × 0.714 × 0.28 puts its top at 72% of the frame. */
  --frame-w: 80%;
  --card-w: 17.5rem;
  --overlap: 16%;
  position: relative; margin: 0;
  padding-top: var(--scene-pad);
}
.scene-glow {
  position: absolute; inset: -8% -6% -10% -12%; z-index: 0; pointer-events: none;
  /* Pre-blurred: each ellipse fades to transparent well inside the box, so no edge shows. */
  background:
    radial-gradient(38% 36% at 58% 36%, rgb(182 185 255 / .46), rgb(182 185 255 / .14) 55%, rgb(182 185 255 / 0) 100%),
    radial-gradient(30% 24% at 34% 72%, rgb(255 241 199 / .9), rgb(255 241 199 / 0) 100%);
}
.scene-frame {
  position: relative; z-index: 1;
  width: var(--frame-w);
  border-radius: var(--radius-scene); background: var(--scene-bg);
  box-shadow: var(--shadow-scene);
}
.scene-render {
  position: relative; aspect-ratio: 1260 / 900;
  border-radius: inherit; overflow: hidden;
}
.scene-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);
}
.scene-img {
  position: absolute; left: 0; top: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: 50% 50%;
  /* Hidden renders stay painted at zero opacity so they are decoded before they are needed;
     home-motion.js keeps aria-hidden on all but the current one. The outgoing render stays fully
     painted under the incoming one until the fade ends, then drops, so the frame never dims. */
  opacity: 0; transform: scale(1.03);
  transition: opacity 0s linear var(--dur-scene), transform 0s linear var(--dur-scene);
}
/* A render that is not needed yet (home-motion.js releases it) is not displayed, so it does not load. */
.scene-img[data-defer] { display: none; }
[data-stage="0"] .scene-img[data-for="0"],
[data-stage="1"] .scene-img[data-for="1"],
[data-stage="2"] .scene-img[data-for="2"] {
  z-index: 1; opacity: 1; transform: none;
  transition: opacity var(--dur-scene) var(--ease-out), transform var(--dur-scene) var(--ease-out);
}
.bubble-anchor {
  position: absolute; z-index: 4; left: -1.5rem; top: -1.625rem;
}
.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"] .bubble > .icon[data-for="0"],
[data-stage="1"] .bubble > .icon[data-for="1"],
[data-stage="2"] .bubble > .icon[data-for="2"] { opacity: 1; transform: none; }

/* Dotted tether from the focused queue row to the patient in the scene. Drawn by home-motion.js. */
.tether {
  position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%;
  overflow: visible; pointer-events: none;
  opacity: 0; transition: opacity var(--dur-state) ease;
}
.tether.is-on { opacity: 1; }
.tether-line { fill: none; stroke: var(--plum); stroke-opacity: .62; stroke-width: 1.5; stroke-dasharray: .5 5; stroke-linecap: round; }
.tether-halo { fill: rgb(182 185 255 / .55); }
.tether-pin { fill: var(--white); stroke: var(--plum); stroke-width: 2; }

/* Mini reception queue (fictional) */
.queue {
  position: relative; z-index: 3;
  width: var(--card-w); max-width: 100%;
  margin: calc(-1 * var(--overlap)) 0 0 auto;
  padding: .5rem;
  border-radius: var(--radius-card); background: var(--raised);
  box-shadow: inset 0 0 0 1px rgb(48 36 67 / .05), var(--shadow-3);
}
.queue-head { display: flex; align-items: center; gap: .625rem; padding: .375rem .5rem .625rem; }
.monogram {
  display: grid; place-items: center; width: 2.25rem; height: 2.25rem; flex: none; border-radius: .75rem;
  font: 700 .875rem/1.25rem var(--font-body); letter-spacing: .02em;
  color: var(--plum); background: var(--soft-iris);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .7), inset 0 0 0 1px rgb(48 36 67 / .06);
}
.queue-title { font-weight: 700; letter-spacing: -.01em; }
.queue-head .tag { margin-left: auto; }
.queue-rows { list-style: none; padding: .25rem 0 0; border-top: 1px solid var(--hairline); }
.queue-row {
  display: grid; grid-template-columns: 2.5rem 1.75rem minmax(0, 1fr) auto; align-items: center; gap: .5rem;
  min-height: 2.875rem; padding: 0 .375rem 0 .5rem; border-radius: 1rem;
  font-size: var(--type-small); line-height: var(--leading-small);
}
.queue-row + .queue-row { margin-top: .125rem; }
.queue-time { color: var(--ink-muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.queue-name { font-weight: 650; }
.initial {
  display: grid; place-items: center; width: 1.75rem; height: 1.75rem; border-radius: 50%;
  font: 700 .875rem/1.25rem var(--font-body); color: var(--plum);
  box-shadow: inset 0 0 0 1px rgb(48 36 67 / .07), inset 0 1px 0 rgb(255 255 255 / .8);
}
.tint-butter { background: radial-gradient(100% 100% at 30% 25%, #fffaf0, var(--butter) 60%, #fbdcbd); }
.tint-iris { background: radial-gradient(100% 100% at 30% 25%, #f4f4ff, #cfd1ff 70%); }
.tint-soft { background: var(--avatar-fill); }
/* The followed patient: Soft iris row plus a weight change on the time. */
.queue-row.is-focus { background: var(--selection-row); }
.queue-row.is-focus .queue-time { color: var(--plum); font-weight: 650; }
.queue-row .chip { justify-self: end; }
.chip-next::after { content: ""; width: .4375rem; height: .4375rem; margin-left: .125rem; border-radius: 50%; background: var(--poppy); }
.chip-swap { display: grid; justify-items: end; }
.chip-swap .chip {
  grid-area: 1 / 1;
  /* Hidden chips leave the accessibility tree too, so the card always reads one status. */
  opacity: 0; visibility: hidden; transform: translateY(4px) scale(.96);
  transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-state) var(--ease-out), visibility 0s linear var(--dur-state);
}
[data-stage="0"] .chip-swap [data-for="0"],
[data-stage="1"] .chip-swap [data-for="1"],
[data-stage="2"] .chip-swap [data-for="2"] {
  opacity: 1; visibility: visible; transform: none;
  transition: opacity var(--dur-state) var(--ease-out) 80ms, transform var(--dur-state) var(--ease-out) 80ms, visibility 0s;
}

/* ---------- Sample visit: controls ---------- */
.visit-head { display: flex; align-items: center; gap: .75rem; margin-top: 4.5rem; margin-bottom: 1.5rem; }
.tour-link { justify-self: start; margin-top: 1.25rem; }
.play-toggle .i-play,
.play-toggle[data-state="paused"] .i-pause { display: none; }
.play-toggle[data-state="paused"] .i-play { display: block; }

/* Progress: a CSS fill that runs while the visit auto-advances and freezes while it is held. */
.stage-progress i, .seg-fill { transform: scaleX(1); }
.is-running .stage-progress i,
.seg.is-running .seg-fill { animation: fill var(--cycle) linear both; }
[data-cycle="hold"] .is-running .stage-progress i,
[data-cycle="hold"] .seg.is-running .seg-fill { animation-play-state: paused; }
@keyframes fill { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* Phones: pill segments directly under the picture, the current stage's name beside them and
   pause at the end. The current segment widens: a named exception to transform-only motion
   (brand.md), because three small buttons share one row and nothing below them moves.
   The row is lifted above the scene glow (z-index 0), so the glow never veils the stage label. */
.visit-controls { position: relative; z-index: 1; display: flex; align-items: center; gap: .25rem; margin-top: .5rem; }
.segments { display: flex; margin-left: -.25rem; }
.seg {
  position: relative; width: 2.75rem; height: 2.75rem; padding: 0; border: 0; border-radius: .75rem;
  background: none; cursor: pointer;
  transition: width var(--dur-state) var(--ease-out);
}
.seg[aria-current="step"] { width: 4.25rem; }
.seg::before, .seg-fill {
  content: ""; position: absolute; left: .75rem; right: .75rem; top: 50%;
  height: 6px; margin-top: -3px; border-radius: var(--radius-pill);
  transition: left var(--dur-state) var(--ease-out), right var(--dur-state) var(--ease-out);
}
.seg[aria-current="step"]::before, .seg[aria-current="step"] .seg-fill { left: .25rem; right: .25rem; }
.seg::before { background: var(--control-track); }
@media (hover: hover) { .seg:hover::before { background: var(--ink-muted); } }
.seg .seg-fill { background: var(--plum); transform-origin: left center; transform: scaleX(0); }
.seg.is-done .seg-fill, .seg[aria-current="step"] .seg-fill { transform: scaleX(1); }
.seg.is-running .seg-fill { transform: scaleX(0); }
.seg-label { margin-left: .25rem; font: 650 var(--type-small)/var(--leading-small) var(--font-body); color: var(--plum); }
.visit-controls .play-toggle { margin-left: auto; }

/* ---------- Wide: two columns; the visit row spans both ---------- */
@media (min-width: 64rem) {
  .home {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.02fr);
    grid-template-rows: auto auto auto; column-gap: 2.5rem;
  }
  .hero {
    grid-column: 1; grid-row: 1; align-self: start; position: relative; z-index: 1;
    margin-top: calc(var(--scene-pad) - 1.625rem + .3rem);
  }
  .visit {
    grid-column: 1 / -1; grid-row: 1 / 4;
    display: grid; grid-template-columns: subgrid; grid-template-rows: subgrid;
    pointer-events: none;
  }
  .visit > * { pointer-events: auto; }
  .scene { grid-column: 2; grid-row: 1; }
  .visit-head { grid-column: 1; grid-row: 2; margin-top: 6.5rem; }
  .tour-link { grid-column: 2; grid-row: 2; justify-self: end; align-self: center; margin: 6.5rem -.25rem 1.5rem 0; }
  .stage-list { grid-column: 1 / -1; grid-row: 3; }
}
/* 1280–1407: give the copy just enough room for "from start to finish" at 72 px. */
@media (min-width: 80rem) and (max-width: 87.99rem) {
  .home { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
  .scene { --frame-w: 74%; --overlap: 14.8%; }
}
/* 1024–1279: the hero steps down to 56 / 60 (shared, styles.css) so it keeps the same three lines
   and both actions share one row. The frame takes the whole column and the queue card hangs below
   its lower right, rising 6% into it, clear of the patient in every stage. */
@media (min-width: 64rem) and (max-width: 79.99rem) {
  .home { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
  .actions { margin-top: 2rem; }
  .scene { --frame-w: 100%; --overlap: 4.3%; }
}
/* Short laptop screens: the first screen should end on a complete row, with the pause control in
   view. At 1024 × 768 the heading and pause end the screen and the cards start just below it;
   at 1280 × 800 and 1366 × 768 the space above the heading closes to 56 px so the cards fit.
   Screens 900 px tall or more keep 104 px. */
@media (min-width: 64rem) and (max-height: 52rem) {
  .home { --scene-pad: 1rem; padding-top: 0; }
  .hero-title { margin-top: 1.25rem; }
}
@media (min-width: 80rem) and (max-height: 52rem) {
  .visit-head { margin: 3.5rem 0 1rem; }
  .tour-link { margin-top: 3.5rem; margin-bottom: 1rem; }
}
@media (min-width: 80rem) and (max-height: 48.5rem) {
  .hero-title { margin-top: 1rem; }
  .actions { margin-top: 1.75rem; }
  .visit-head, .tour-link { margin-top: 3rem; }
}

/* ---------- Tablet: one column ---------- */
@media (max-width: 63.99rem) {
  .scene { width: 100%; max-width: 46rem; margin: 3.5rem 0 0; }
  .visit { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 1rem; }
  .scene { grid-column: 1 / -1; grid-row: 1; }
  .visit-head { grid-column: 1; grid-row: 2; margin-top: 4.5rem; }
  .tour-link { grid-column: 2; grid-row: 2; align-self: center; margin: 4.5rem -.25rem 1.5rem 0; }
  .stage-list { grid-column: 1 / -1; grid-row: 3; }
}
@media (min-width: 48rem) { .visit-controls { display: none; } }

/* ---------- Phone ---------- */
/* At 390 × 844 the top of the render, with the patient at the kiosk, shows on the first screen.
   At 360 × 640 the first screen is the words and both actions by design; the picture follows. */
@media (max-width: 47.99rem) {
  .home { padding-top: .25rem; }
  .eyebrow { padding-right: .875rem; }
  .hero-title .br-3::after { content: none; }
  .hero-title .br-4::after { content: "\A"; white-space: pre; }
  .actions { flex-direction: column; gap: .25rem; margin-top: 1rem; }
  .actions .btn { width: 100%; }
  /* The demo request becomes a quiet link so both actions and the note fit a 360 × 640 screen. */
  .actions .btn-secondary {
    min-height: 2.75rem; padding: 0; justify-content: flex-start;
    background: none; box-shadow: none; border-radius: .375rem;
    text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: .35em;
    text-decoration-color: var(--periwinkle);
  }
  .actions .btn-secondary:hover { transform: none; box-shadow: none; text-decoration-color: var(--plum); }
  .note { margin-top: .25rem; }

  .scene { --card-w: 100%; --scene-pad: 1.125rem; margin-top: 2rem; }
  .scene-glow { inset: 0 -1rem; }
  .scene-frame { width: 100%; border-radius: var(--radius-card); scroll-margin-top: 1.5rem; }
  .bubble-anchor { left: -.5rem; top: -1.125rem; }
  .bubble { --bubble-size: 3.75rem; }
  .tether { display: none; }
  .queue { width: 100%; margin: .5rem 0 0; }
  .visit { grid-template-columns: minmax(0, 1fr); }
  .visit-head { margin-top: 3rem; margin-bottom: 1rem; }
  .visit-head .play-toggle { display: none; }
  .tour-link { grid-column: 1; grid-row: 4; justify-self: start; margin: 1.25rem 0 0; }
}

/* ---------- Forced colours ---------- */
/* Contrast themes drop fills and shadows: the queue card keeps a system edge, the phone segments
   keep a GrayText track with a Highlight fill, and the phone's quiet demo link stays a link
   (its underline marks it) instead of taking the shared secondary pill's box. */
@media (forced-colors: active) {
  .queue { border: 1px solid CanvasText; }
  .seg::before { forced-color-adjust: none; background: GrayText; }
  .seg .seg-fill { forced-color-adjust: none; background: Highlight; }
}
@media (forced-colors: active) and (max-width: 47.99rem) {
  .actions .btn-secondary { border: 0; }
}
