/*
  Portada 3D "Precisión clínica"
  Capa aislada sobre la portada existente. El contenido sigue siendo legible
  sin JavaScript; Three.js sólo reemplaza el póster cuando está listo.
*/

:root {
  --z-story-canvas: 2;
  --z-story-atmosphere: 1;
  --z-story-content: 4;
  --z-story-controls: 5;
  --story-night: var(--noche);
  --story-cyan: var(--champan);
  --story-brass: var(--champan);
  --story-paper: var(--porcelana);
}

.tooth-story {
  position: relative;
  isolation: isolate;
  min-height: max(780px, 100dvh);
  overflow: clip;
  background:
    radial-gradient(ellipse at 78% 42%, rgba(17, 42, 57, 0.34), transparent 27%),
    radial-gradient(ellipse at 62% 15%, rgba(201, 169, 110, 0.18), transparent 19%),
    linear-gradient(128deg, var(--noche) 0%, var(--noche) 48%, var(--noche) 100%);
  color: var(--white);
}

.tooth-story::before {
  position: absolute;
  z-index: 0;
  inset: 0;
  background-image:
    radial-gradient(circle at 7% 17%, rgba(201, 169, 110, 0.95) 0 1px, transparent 1.8px),
    radial-gradient(circle at 16% 73%, rgba(246, 244, 238, 0.58) 0 1px, transparent 1.8px),
    radial-gradient(circle at 35% 9%, rgba(201, 169, 110, 0.7) 0 1.2px, transparent 2px),
    radial-gradient(circle at 45% 51%, rgba(255, 255, 255, .58) 0 1px, transparent 1.8px),
    radial-gradient(circle at 58% 24%, rgba(201, 169, 110, 0.62) 0 1px, transparent 1.8px),
    radial-gradient(circle at 88% 18%, rgba(246, 244, 238, 0.65) 0 1px, transparent 1.8px),
    radial-gradient(circle at 92% 79%, rgba(201, 169, 110, 0.5) 0 1px, transparent 1.8px);
  content: "";
  opacity: .8;
  pointer-events: none;
}

.tooth-story__sticky {
  position: relative;
  min-height: max(780px, 100dvh);
}

.js .tooth-story:not(.is-static) {
  min-height: 300vh;
}

.js .tooth-story:not(.is-static) .tooth-story__sticky {
  position: sticky;
  top: 0;
  height: 100dvh;
  min-height: 0;
}

.tooth-story__constellation {
  position: absolute;
  z-index: var(--z-story-atmosphere);
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  opacity: .85;
  pointer-events: none;
}

.tooth-story__constellation-lines {
  fill: none;
  stroke: rgba(201, 169, 110, 0.38);
  stroke-width: 1.15;
  vector-effect: non-scaling-stroke;
}

.tooth-story__constellation-stars {
  fill: var(--story-brass);
  filter: drop-shadow(0 0 5px rgba(201, 169, 110, 0.35));
}

.tooth-story__orbit {
  position: absolute;
  z-index: 1;
  top: 50%;
  right: clamp(-180px, -7vw, -48px);
  width: min(55vw, 760px);
  aspect-ratio: 1;
  border: 1px solid rgba(201, 169, 110, 0.24);
  border-radius: 50%;
  box-shadow: inset 0 0 80px rgba(31, 107, 102, 0.08);
  transform: translateY(-50%);
  pointer-events: none;
}

.tooth-story__orbit::before,
.tooth-story__orbit::after {
  position: absolute;
  border: 1px solid rgba(201, 169, 110, 0.16);
  border-radius: 50%;
  content: "";
}

.tooth-story__orbit::before { inset: 12%; }
.tooth-story__orbit::after { inset: 27%; }

.tooth-scene {
  position: absolute;
  z-index: var(--z-story-canvas);
  inset: 0;
  margin: 0;
  overflow: hidden;
}

.tooth-scene__poster,
.tooth-scene__poster img,
.tooth-scene__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.tooth-scene__canvas[hidden], html:not(.js) .tooth-scene__canvas { display: none; }

.tooth-scene__poster {
  display: block;
  z-index: 0;
  background: transparent;
  transition: opacity .35s var(--ease-out);
}

.tooth-scene__poster img {
  object-fit: contain;
  object-position: 70% 50%;
  filter: drop-shadow(0 28px 44px rgba(0, 0, 0, .24));
  transform: translateX(19%) scale(.82);
  transform-origin: center;
}

.tooth-scene__canvas {
  z-index: 1;
  display: block;
  opacity: 0;
  outline: none;
  touch-action: pan-y;
  transition: opacity .42s var(--ease-out);
}

.tooth-scene__canvas:focus-visible {
  outline: 3px solid var(--story-brass);
  outline-offset: -8px;
}

.tooth-story.is-webgl-ready .tooth-scene__canvas { opacity: 1; }
.tooth-story.is-webgl-ready .tooth-scene__poster { opacity: 0; }
.tooth-story.is-clinic-chapter .tooth-scene__canvas { opacity: .22; }
.tooth-story.is-clinic-chapter .tooth-scene__poster { opacity: 0; }
.tooth-story:not(.is-webgl-ready) .tooth-story__controls { visibility: hidden; opacity: 0; }

.tooth-story__content {
  position: relative;
  z-index: var(--z-story-content);
  display: grid;
  min-height: max(780px, 100dvh);
  align-content: center;
  padding-top: 108px;
  padding-bottom: 86px;
  pointer-events: none;
}

.tooth-story__chapter {
  max-width: min(630px, 52vw);
  pointer-events: auto;
}

.tooth-story__chapter + .tooth-story__chapter { margin-top: 64px; }

.js .tooth-story.is-animated .tooth-story__chapter {
  position: absolute;
  top: 50%;
  left: 0;
  width: min(630px, 52vw);
  margin: 0;
  opacity: 0;
  pointer-events: none;
  transform: translate3d(0, calc(-50% + 22px), 0);
  transition: opacity .35s var(--ease-out), transform .35s var(--ease-out);
}

.js .tooth-story.is-animated .tooth-story__chapter.is-active {
  opacity: 1;
  pointer-events: auto;
  transform: translate3d(0, -50%, 0);
}

.tooth-story .eyebrow { color: var(--story-brass); }

.tooth-story h1,
.tooth-story__chapter-title {
  max-width: 690px;
  margin: 0;
  font-family: var(--display);
  font-size: clamp(3.5rem, 7.2vw, 7.1rem);
  font-weight: 600;
  letter-spacing: -.06em;
  line-height: .82;
  text-wrap: balance;
}

.tooth-story h1 em { color: var(--story-brass); font-weight: 400; }

.tooth-story__chapter-title {
  font-size: clamp(3rem, 6vw, 5.9rem);
}

.tooth-story__lede {
  max-width: 520px;
  margin: 28px 0 0;
  color: var(--texto-claro-78);
  font-size: clamp(1rem, 2vw, 1.16rem);
  text-wrap: pretty;
}

.tooth-story__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 32px;
}

.tooth-story__actions .button { min-height: 50px; }
.tooth-story__actions .button--primary { background: var(--story-brass); color: var(--ink-deep); }
.tooth-story__actions .button--primary:hover { background: var(--white); }

.tooth-story__details {
  display: flex;
  flex-wrap: wrap;
  gap: 18px 28px;
  margin-top: 42px;
  color: var(--texto-claro-78);
  font-size: .75rem;
  font-variant-numeric: tabular-nums;
}

.tooth-story__detail {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tooth-story__detail svg { width: 16px; height: 16px; color: var(--story-brass); }
.tooth-story__detail strong { color: var(--white); font-weight: 800; }

.tooth-story__microcopy {
  max-width: 370px;
  margin: 24px 0 0;
  color: var(--texto-claro-60);
  font-size: .87rem;
}

.tooth-story__alicia {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  max-width: 458px;
  margin-top: 28px;
  padding: 13px 16px 13px 13px;
  border: 1px solid rgba(201, 169, 110, 0.34);
  background: rgba(10, 27, 38, 0.52);
  box-shadow: 16px 20px 0 rgba(201, 169, 110, 0.12);
}

.tooth-story__alicia img {
  width: 108px;
  height: 128px;
  object-fit: cover;
  object-position: center top;
  filter: saturate(.84) contrast(1.04);
}

.tooth-story__alicia p { margin: 0; color: var(--texto-claro-78); font-size: .85rem; }
.tooth-story__alicia strong { display: block; margin-bottom: 4px; color: var(--white); font-size: .95rem; }

.tooth-story__controls {
  position: absolute;
  z-index: var(--z-story-controls);
  right: max(106px, calc((100vw - 1160px) / 2 + 92px));
  bottom: 24px;
  display: flex;
  gap: 8px;
  align-items: center;
  max-width: min(380px, calc(100% - 44px));
}

.tooth-story__controls button {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 13px;
  border: 1px solid rgba(201, 169, 110, 0.58);
  border-radius: 999px;
  background: rgba(10, 27, 38, 0.76);
  box-shadow: 0 12px 28px rgba(0, 0, 0, .22);
  color: var(--white);
  font-size: .7rem;
  font-weight: 800;
  transition: transform .2s var(--ease-out), background-color .2s ease, color .2s ease;
}

.tooth-story__controls button:hover { background: var(--story-brass); color: var(--ink-deep); transform: translateY(-1px); }
.tooth-story__controls button:active { transform: scale(.98); }
.tooth-story__controls button:focus-visible { outline: 3px solid var(--white); outline-offset: 3px; }

.tooth-story__status {
  position: absolute;
  z-index: var(--z-story-content);
  right: max(22px, calc((100vw - 1160px) / 2));
  bottom: 86px;
  max-width: 240px;
  margin: 0;
  color: var(--texto-claro-60);
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-align: right;
}

.tooth-story.is-webgl-ready .tooth-story__status { opacity: 0; transition: opacity .25s ease .8s; }

/* Eight service routes are real links, not a decorative carousel. */
.service-atlas {
  position: relative;
  overflow: hidden;
  padding: clamp(84px, 11vw, 144px) 0;
  background:
    radial-gradient(circle at 92% 16%, rgba(201, 169, 110, 0.17), transparent 18%),
    radial-gradient(circle at 8% 80%, rgba(201, 169, 110, 0.2), transparent 22%),
    var(--story-night);
  color: var(--white);
}

.service-atlas::before {
  position: absolute;
  top: -20%;
  right: -8%;
  width: min(52vw, 660px);
  aspect-ratio: 1;
  border: 1px solid rgba(201, 169, 110, 0.2);
  border-radius: 50%;
  content: "";
}

.service-atlas .shell { position: relative; }
.service-atlas .eyebrow { color: var(--story-brass); }
.service-atlas .section-heading { color: var(--white); }
.service-atlas__intro { display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, .48fr); gap: 44px; align-items: end; margin-bottom: 52px; }
.service-atlas__intro p:not(.eyebrow) { max-width: 430px; margin: 0; color: var(--texto-claro-60); }

.service-atlas__list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 clamp(28px, 7vw, 112px);
  margin: 0;
  padding: 0;
  list-style: none;
}

.service-atlas__item {
  min-width: 0;
  border-top: 1px solid rgba(201, 169, 110, 0.25);
}

.service-atlas__item a {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 20px;
  min-height: 82px;
  align-items: center;
  gap: 12px;
  color: var(--white);
  text-decoration: none;
  transition: color .2s ease, transform .2s var(--ease-out);
}

.service-atlas__item a:hover { color: var(--story-brass); transform: translateX(5px); }
.service-atlas__item a:focus-visible { outline: 2px solid var(--story-brass); outline-offset: 6px; }
.service-atlas__item span:first-child { color: rgba(201, 169, 110, 0.68); font-size: .68rem; font-weight: 800; letter-spacing: .12em; }
.service-atlas__item strong { font-family: var(--display); font-size: clamp(1.45rem, 2.3vw, 2.1rem); font-weight: 600; letter-spacing: -.035em; line-height: 1; }
.service-atlas__item span:last-child { color: rgba(201, 169, 110, 0.78); font-size: 1.2rem; }

/* Green remains recognizably WhatsApp while dark copy keeps AA contrast. */
.mobile-whatsapp { color: var(--ink-deep); }

/* The document remains complete when JavaScript, WebGL, or animation is unavailable. */
html:not(.js) .tooth-story,
.js .tooth-story.is-static { min-height: auto; }

html:not(.js) .tooth-story__sticky,
.js .tooth-story.is-static .tooth-story__sticky { position: relative; height: auto; min-height: 100dvh; }

html:not(.js) .tooth-scene,
.js .tooth-story.is-static .tooth-scene { position: absolute; inset: 0 0 auto; height: 100dvh; min-height: 0; }

html:not(.js) .tooth-story__content,
.js .tooth-story.is-static .tooth-story__content { display: block; min-height: 0; }

html:not(.js) .tooth-story__chapter,
.js .tooth-story.is-static .tooth-story__chapter { width: auto; max-width: 660px; margin: 0 0 46px; opacity: 1; pointer-events: auto; transform: none; }

html:not(.js) .tooth-story__chapter:first-child,
.js .tooth-story.is-static .tooth-story__chapter:first-child { display: grid; min-height: calc(100dvh - 194px); align-content: center; }

html:not(.js) .tooth-story__controls,
html:not(.js) .tooth-story__status,
.js .tooth-story.is-static .tooth-story__controls,
.js .tooth-story.is-static .tooth-story__status { display: none; }

@media (max-width: 900px) {
  .js .tooth-story:not(.is-static) { min-height: 278vh; }
  .tooth-story__orbit { right: -23vw; width: 82vw; }
  .tooth-story__chapter,
  .js .tooth-story.is-animated .tooth-story__chapter { max-width: min(570px, 60vw); width: min(570px, 60vw); }
  .tooth-story__controls { right: 106px; }
}

@media (max-width: 700px) {
  /* While the sticky story is on screen, Facebook lives in its own upper zone,
     rather than covering the full-width WhatsApp CTA. */
  body.has-tooth-story .social-dock { top: 132px; right: 14px; bottom: auto; }
  body.has-tooth-story.is-tooth-story-past .social-dock { top: auto; bottom: calc(104px + env(safe-area-inset-bottom)); }
  .tooth-story { min-height: max(720px, 100dvh); }
  .js .tooth-story:not(.is-static) { min-height: 205vh; }
  .tooth-story__sticky { min-height: max(720px, 100dvh); }
  /* A soft lower vignette protects hierarchy when the 3D object fills the frame. */
  .tooth-story__sticky::after {
    position: absolute;
    z-index: 3;
    inset: 0;
    background: linear-gradient(180deg, rgba(10, 27, 38, 0) 0%, rgba(10, 27, 38, 0.08) 23%, rgba(10, 27, 38, 0.45) 49%, rgba(10, 27, 38, 0.88) 72%, rgba(10, 27, 38, 0.98) 100%);
    content: "";
    pointer-events: none;
  }
  .tooth-story__orbit { top: 25%; right: -50vw; width: 100vw; transform: translateY(-50%); }
  .tooth-story__constellation { z-index: var(--z-story-atmosphere); opacity: .56; }
  .tooth-scene__poster img { object-position: 72% 18%; transform: translate(10%, -4%) scale(.9); }
  .tooth-story__content { min-height: max(720px, 100dvh); align-content: start; padding-top: clamp(280px, 45dvh, 348px); padding-bottom: 106px; }
  .tooth-story__chapter,
  .js .tooth-story.is-animated .tooth-story__chapter { width: 100%; max-width: 100%; }
  .js .tooth-story.is-animated .tooth-story__chapter { top: clamp(280px, 45dvh, 348px); left: 0; transform: translate3d(0, 22px, 0); }
  .js .tooth-story.is-animated .tooth-story__chapter.is-active { transform: translate3d(0, 0, 0); }
  .tooth-story h1,
  .tooth-story__chapter-title { font-size: clamp(3.35rem, 15vw, 4.7rem); line-height: .84; }
  .tooth-story__chapter-title { font-size: clamp(2.9rem, 13vw, 4.15rem); }
  .tooth-story__lede { margin-top: 20px; font-size: .95rem; }
  .tooth-story__actions { margin-top: 22px; }
  .tooth-story__actions .button { width: 100%; }
  .tooth-story__details { gap: 11px; margin-top: 24px; font-size: .68rem; }
  .tooth-story__detail { width: 100%; }
  .tooth-story__alicia { grid-template-columns: 80px minmax(0, 1fr); max-width: 100%; margin-top: 20px; }
  .tooth-story__alicia img { width: 80px; height: 104px; }
  /* Keep the manual reset reachable without competing with the persistent WhatsApp bar. */
  .tooth-story__controls { top: 76px; right: 12px; bottom: auto; max-width: none; }
  .tooth-story__controls button { min-height: 44px; padding: 0 12px; background: rgba(10, 27, 38, 0.76); font-size: .65rem; }
  .tooth-story__status { right: 18px; bottom: 79px; max-width: 180px; font-size: .54rem; }
  .service-atlas__intro { grid-template-columns: 1fr; gap: 20px; margin-bottom: 34px; }
  .service-atlas__list { grid-template-columns: 1fr; }
  .service-atlas__item a { min-height: 72px; }
}

@media (prefers-reduced-motion: reduce) {
  .js .tooth-story,
  .js .tooth-story:not(.is-static) { min-height: auto; }
  .js .tooth-story__sticky,
  .js .tooth-story:not(.is-static) .tooth-story__sticky { position: relative; height: auto; min-height: 0; }
  .tooth-scene { position: relative; height: min(62vw, 420px); min-height: 290px; }
  .tooth-scene__poster img { object-position: 50% center; }
  .tooth-story__content { display: block; min-height: 0; padding-top: 32px; }
  .js .tooth-story.is-animated .tooth-story__chapter,
  .tooth-story__chapter { position: relative; inset: auto; width: auto; max-width: 660px; margin: 0 0 46px; opacity: 1; pointer-events: auto; transform: none; }
  .tooth-story__controls,
  .tooth-story__status { display: none; }
  .tooth-scene__canvas { display: none; }
  .tooth-story__orbit { display: none; }
  .service-atlas__item a,
  .tooth-story__controls button,
  .tooth-scene__poster { transition: none; }
}
