/* Amadeo Medical Group: scroll story, keyhole reveal, specialty rail.
   Idea: the keyhole. One round lens runs through the page, the way a surgeon's
   camera does. Plain stacked layout by default; .motion-on (set by js/motion.js)
   turns on the pinned, scroll-driven version. Colours are main.css tokens. */

/* GSAP blocked or failed: main.js cannot fade .reveal content in, so show it. */
.no-gsap .reveal, .no-gsap .reveal--left, .no-gsap .reveal--right, .no-gsap .reveal--scale { opacity: 1; transform: none; }

/* ---------- Hero story ---------- */
.story { position: relative; background: var(--blue-deeper); color: var(--white); overflow: hidden; }
.story::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(60% 70% at 78% 45%, rgba(43, 124, 179, 0.55), transparent 70%),
    radial-gradient(40% 50% at 10% 100%, rgba(26, 90, 135, 0.6), transparent 70%);
}
.story__pin {
  position: relative; display: grid; align-items: center; gap: var(--space-2xl);
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  max-width: var(--container-wide); margin: 0 auto;
  padding: calc(var(--nav-height) + var(--space-xl)) var(--space-xl) var(--space-3xl);
}
.story__scenes { position: relative; display: grid; gap: var(--space-3xl); }
.scene { max-width: 40rem; }
.scene__eyebrow {
  display: inline-flex; align-items: center; gap: 0.6em; margin-bottom: var(--space-md);
  font-size: 0.8rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold-light);
}
.scene__eyebrow::before { content: ""; width: 2rem; height: 1px; background: currentColor; }
.scene h1, .scene h2 {
  font-family: var(--font-display); font-weight: 500; color: var(--white);
  font-size: clamp(2.3rem, 4.4vw, 4rem); line-height: 1.04; letter-spacing: -0.02em;
  margin-bottom: var(--space-lg); text-wrap: balance;
}
.scene p { color: rgba(255, 255, 255, 0.86); font-size: clamp(1rem, 1.25vw, 1.18rem); line-height: 1.7; max-width: 32rem; }
.scene__actions { display: flex; flex-wrap: wrap; gap: var(--space-md); margin-top: var(--space-lg); }
.scene__actions .btn { white-space: nowrap; }
.scene__desk { margin-top: var(--space-md); font-size: 0.95rem; color: rgba(255, 255, 255, 0.82); }
.scene__desk a { color: var(--white); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

.open-line {
  display: inline-flex; align-items: center; gap: 0.6em; margin-top: var(--space-lg);
  padding: 0.7em 1.2em; border-radius: 999px; font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.1); color: var(--white);
}
.open-line::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--gray-300); flex: none; }
.open-line.is-open::before { background: var(--accent-green); }

/* The lens */
.story__lens { position: sticky; top: calc(var(--nav-height) + var(--space-xl)); align-self: start; display: grid; place-items: center; }
.motion-on .story__lens { position: relative; top: auto; align-self: center; }
.lens {
  --open: 50%;
  position: relative; width: min(100%, 68vh, 620px); aspect-ratio: 1;
  clip-path: circle(var(--open) at 50% 50%);
}
.lens__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.lens__img + .lens__img { display: none; }
.lens__ring {
  position: absolute; width: min(108%, 73vh, 668px); aspect-ratio: 1; border-radius: 50%;
  border: 1px dashed rgba(255, 255, 255, 0.32); pointer-events: none;
}
.lens__ring::after {
  content: ""; position: absolute; top: -5px; left: 50%; width: 9px; height: 9px;
  margin-left: -5px; border-radius: 50%; background: var(--gold-light);
}

.story__dots { display: none; }

/* Pinned version */
.motion-on .story__pin { height: 100vh; height: 100svh; padding-bottom: var(--space-4xl); }
.motion-on .story__scenes { display: block; height: 100%; }
.motion-on .scene { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; }
.motion-on .scene + .scene { opacity: 0; visibility: hidden; }
.motion-on .lens__img + .lens__img { display: block; opacity: 0; visibility: hidden; }
.motion-on .story__dots {
  position: absolute; left: var(--space-xl); bottom: var(--space-lg);
  display: flex; gap: var(--space-xl); margin: 0; padding: 0; list-style: none; z-index: 2;
}
.story__dot {
  display: flex; flex-direction: row-reverse; align-items: center; gap: 0.7em;
  background: none; border: 0; padding: 0.35em 0; cursor: pointer;
  font: 600 0.72rem var(--font-body); letter-spacing: 0.12em; text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55); transition: color var(--transition-base);
}
.story__dot::after { content: ""; width: 1.4rem; height: 2px; background: currentColor; transition: width var(--transition-base); }
.story__dot.is-active, .story__dot:hover, .story__dot:focus-visible { color: var(--white); }
.story__dot.is-active::after { width: 2.6rem; background: var(--gold-light); }
.story__dot:focus-visible { outline: 2px solid var(--gold-light); outline-offset: 4px; }

.story__hint {
  position: absolute; left: 50%; bottom: var(--space-lg); translate: -50% 0;
  font-size: 0.72rem; letter-spacing: 0.2em; text-transform: uppercase; color: rgba(255, 255, 255, 0.6);
  display: none;
}
.motion-on .story__hint { display: none; }

/* Word-by-word headings */
.word { display: inline-block; overflow: hidden; vertical-align: bottom; padding-bottom: 0.12em; margin-bottom: -0.12em; }
.word > span { display: inline-block; }

/* ---------- Keyhole ---------- */
.keyhole { position: relative; background: var(--warm-bg); }
.keyhole__pin { position: relative; display: grid; gap: var(--space-xl); padding: var(--space-4xl) var(--space-xl); max-width: var(--container-max); margin: 0 auto; }
.keyhole__media { --r: 150vmax; width: 100%; height: 60vh; object-fit: cover; border-radius: var(--border-radius-lg); }
.keyhole__before, .keyhole__after { max-width: 40rem; }
.keyhole h2 { font-family: var(--font-display); font-weight: 500; font-size: clamp(2.2rem, 5vw, 4.2rem); line-height: 1.05; letter-spacing: -0.02em; color: var(--blue-deeper); margin-bottom: var(--space-md); text-wrap: balance; }
.keyhole p { font-size: 1.12rem; line-height: 1.7; color: var(--gray-600); }
.keyhole__ops { display: flex; flex-wrap: wrap; gap: var(--space-sm); margin: var(--space-lg) 0 var(--space-xl); padding: 0; list-style: none; }
.keyhole__ops li { padding: 0.7em 1.2em; border-radius: 999px; border: 1px solid var(--gray-200); font-size: 0.92rem; color: var(--gray-700); }

.motion-on .keyhole__pin { display: block; height: 100vh; height: 100svh; max-width: none; padding: 0; overflow: hidden; }
.motion-on .keyhole__media { position: absolute; inset: 0; height: 100%; border-radius: 0; clip-path: circle(var(--r) at 50% 50%); }
.motion-on .keyhole__before { position: absolute; left: 0; right: 0; bottom: calc(50% + 72px); margin: 0 auto; width: min(92%, 46rem); max-width: none; text-align: center; }
.motion-on .keyhole__after { position: absolute; z-index: 2; left: max(var(--space-xl), calc((100% - var(--container-max)) / 2)); top: 50%; width: min(88%, 38rem); opacity: 0; visibility: hidden; }
.motion-on .keyhole__after h2 { color: var(--white); }
.motion-on .keyhole__after p { color: rgba(255, 255, 255, 0.9); }
.motion-on .keyhole__after .keyhole__ops li { border-color: rgba(255, 255, 255, 0.4); color: var(--white); }
.motion-on .keyhole__pin::after { content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none; opacity: var(--scrim, 0); background: linear-gradient(90deg, rgba(10, 30, 46, 0.92) 0%, rgba(10, 30, 46, 0.7) 50%, rgba(10, 30, 46, 0.25) 100%); }

/* ---------- Specialty rail ---------- */
.rail { background: var(--white); padding: var(--space-4xl) 0; overflow: hidden; }
.rail__head { max-width: var(--container-max); margin: 0 auto var(--space-2xl); padding: 0 var(--space-xl); }
.rail__head h2 { font-family: var(--font-display); font-weight: 500; font-size: clamp(2rem, 4.2vw, 3.4rem); line-height: 1.08; letter-spacing: -0.02em; color: var(--blue-deeper); max-width: 22ch; margin-bottom: var(--space-md); text-wrap: balance; }
.rail__head p { color: var(--gray-600); font-size: 1.08rem; line-height: 1.7; max-width: 44rem; }
.rail__view { overflow-x: auto; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.rail__view::-webkit-scrollbar { display: none; }
.rail__track { display: flex; gap: var(--space-lg); padding: var(--space-sm) max(var(--space-xl), calc((100vw - var(--container-max)) / 2 + var(--space-xl))) var(--space-lg); width: max-content; }
.rail__card {
  position: relative; flex: none; width: min(78vw, 360px); aspect-ratio: 3 / 4; overflow: hidden;
  border-radius: var(--border-radius-lg); scroll-snap-align: center; color: var(--white); text-decoration: none;
  display: flex; flex-direction: column; justify-content: flex-end; padding: var(--space-xl);
  background: var(--blue-deeper);
}
.rail__card img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform 900ms cubic-bezier(0.2, 0.7, 0.2, 1); }
.rail__card::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(10, 30, 46, 0.05) 30%, rgba(10, 30, 46, 0.9) 100%); }
.rail__card > span, .rail__card h3 { position: relative; z-index: 1; }
.rail__card h3 { font-family: var(--font-display); font-weight: 500; font-size: 1.7rem; line-height: 1.15; color: var(--white); margin-bottom: 0.35em; }
.rail__when { font-size: 0.95rem; line-height: 1.5; color: rgba(255, 255, 255, 0.9); }
.rail__how { margin-top: var(--space-md); font-size: 0.78rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold-light); }
.rail__card:hover img, .rail__card:focus-visible img { transform: scale(1.06); }
.rail__card:focus-visible { outline: 3px solid var(--accent-warm); outline-offset: 4px; }
.rail.is-pinned { height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: calc(var(--nav-height) + var(--space-md)) 0 var(--space-lg); }
.rail.is-pinned .rail__head { margin-bottom: var(--space-lg); }
.rail.is-pinned .rail__head h2 { font-size: clamp(1.8rem, 3.2vw, 2.8rem); max-width: none; }
.rail.is-pinned .rail__view { overflow: visible; }
.rail.is-pinned .rail__card { width: clamp(260px, 24vw, 360px); height: min(46vh, 440px); aspect-ratio: auto; }

/* ---------- Steps line ---------- */
.steps--line { --line: 1; position: relative; }
.steps--line::before {
  content: ""; position: absolute; left: 1.4rem; right: 12%; top: 1.35rem; height: 2px;
  background: var(--blue-pale); transform-origin: left; transform: scaleX(var(--line));
}
.steps--line li::before { z-index: 1; box-shadow: 0 0 0 6px var(--warm-bg); }

/* Open-now line on a light or blue section */
.open-line--blue { background: rgba(255, 255, 255, 0.14); }

@media (max-width: 900px) {
  .story__pin { grid-template-columns: 1fr; gap: var(--space-lg); padding: calc(var(--nav-height) + var(--space-sm)) var(--space-lg) var(--space-2xl); align-content: start; }
  .story__lens { order: -1; }
  .lens { width: min(48vw, 24vh); }
  .lens__ring { width: min(53vw, 26.5vh); }
  .scene h1, .scene h2 { font-size: clamp(1.9rem, 8vw, 2.6rem); margin-bottom: var(--space-sm); }
  .scene p { font-size: 0.98rem; line-height: 1.55; }
  .scene__actions { margin-top: var(--space-md); gap: var(--space-sm); }
  .scene__actions .btn { width: 100%; justify-content: center; }
  .open-line { margin-top: var(--space-md); }
  .story__lens { position: relative; top: auto; }
  .motion-on .story__pin { display: flex; flex-direction: column; align-items: stretch; padding-bottom: var(--space-lg); }
  .motion-on .story__lens { align-self: center; flex: none; }
  .motion-on .story__scenes { height: auto; flex: 1; width: 100%; position: relative; }
  .motion-on .scene { justify-content: flex-start; max-width: none; }
  .scene__eyebrow { margin-bottom: var(--space-xs); font-size: 0.7rem; }
  .scene__desk { margin-top: var(--space-sm); font-size: 0.88rem; }
  .scene__actions .btn--lg { padding-top: 0.8rem; padding-bottom: 0.8rem; }
  .motion-on .story__dots, .motion-on .story__hint { display: none; }
  .steps--line::before { display: none; }
  .motion-on .keyhole__after { bottom: 9vh; }
}
@media (prefers-reduced-motion: reduce) {
  .rail__card img { transition: none; }
}

/* A dashed ring marks the keyhole before it opens */
.motion-on .keyhole__pin::before {
  content: ""; position: absolute; left: 50%; top: 50%; width: 84px; height: 84px; margin: -42px 0 0 -42px;
  border-radius: 50%; border: 1px dashed var(--blue-primary);
}

/* Short phones: keep both buttons inside the first screen */
@media (max-width: 900px) and (max-height: 720px) {
  .lens { width: min(40vw, 20vh); }
  .lens__ring { width: min(45vw, 22.5vh); }
  .motion-on .scene__desk { display: none; }
}
