/* ==========================================================================
   NEWSON — Hero 3D con máscara expansible
   ========================================================================== */

.n-x { position: relative; height: 230vh; background: linear-gradient(180deg, #fbfbfc 0%, var(--bg) 100%); }
.n-x__sticky { position: sticky; top: 0; height: 100vh; min-height: 640px; overflow: hidden; }
.n-x .n-hero__glow { right: -120px; top: -260px; }

/* Máscara: la escena ocupa todo el viewport y el clip-path revela solo el marco */
.n-x__frame {
  --it: 88px; --ir: 40px; --ib: 28px; --il: 50%; --rad: 32px;
  position: absolute; inset: 0; z-index: 1;
  clip-path: inset(var(--it) var(--ir) var(--ib) var(--il) round var(--rad));
  background:
    radial-gradient(60% 55% at 55% 45%, #ffffff 0%, rgba(255,255,255,0) 70%),
    radial-gradient(40% 40% at 70% 85%, rgba(234,145,8,.10), transparent 70%),
    linear-gradient(180deg, #f3f4f7 0%, #eceef2 100%);
  cursor: grab;
  will-change: clip-path;
}
.n-x__frame.is-dragging { cursor: grabbing; }
.n-x__frame::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(rgba(24,40,72,.06) 1px, transparent 1px), linear-gradient(90deg, rgba(24,40,72,.06) 1px, transparent 1px);
  background-size: 40px 40px; background-position: center;
  -webkit-mask-image: radial-gradient(ellipse 70% 70% at 60% 50%, #000 20%, transparent 80%);
  mask-image: radial-gradient(ellipse 70% 70% at 60% 50%, #000 20%, transparent 80%);
}
/* Borde del marco que sigue a la máscara */
.n-x__frame::after {
  content: ""; position: absolute; pointer-events: none;
  top: var(--it); right: var(--ir); bottom: var(--ib); left: var(--il);
  border-radius: var(--rad); box-shadow: inset 0 0 0 1px rgba(10,13,18,.08), inset 0 1px 0 rgba(255,255,255,.9);
}

.n-x__canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: 0; transition: opacity 1.2s var(--ease); touch-action: pan-y; }
.n-x.is-3d .n-x__canvas { opacity: 1; }

/* Respaldo sin WebGL */
.n-x__fallback { position: absolute; top: var(--it); right: var(--ir); bottom: var(--ib); left: var(--il); display: grid; place-items: center; transition: opacity .8s; }
.n-x.is-3d .n-x__fallback { opacity: 0; pointer-events: none; }
.n-x__fallback span { position: absolute; width: 60%; aspect-ratio: 1; border-radius: 50%; border: 1px solid rgba(10,13,18,.1); }
.n-x__fallback span:nth-child(2) { width: 42%; border-style: dashed; border-color: rgba(234,145,8,.4); animation: nSpin 30s linear infinite; }
.n-x__fallback span:nth-child(3) { width: 24%; background: #fff; box-shadow: 0 20px 50px -20px rgba(234,145,8,.5); }
.n-x__fallback img { position: relative; width: 12%; }

/* HUD que acompaña a la máscara */
.n-x__hud { position: absolute; top: var(--it); right: var(--ir); bottom: var(--ib); left: var(--il); pointer-events: none; z-index: 2; }
.n-x__hud .n-cross--tl { left: 18px; top: calc(64px + var(--hud-pad, 0px)); } .n-x__hud .n-cross--tr { right: 18px; top: calc(64px + var(--hud-pad, 0px)); }
.n-x__hud .n-cross--bl { left: 18px; bottom: 76px; } .n-x__hud .n-cross--br { right: 18px; bottom: 76px; }
.n-x__hud-top, .n-x__hud-bottom { position: absolute; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 22px; color: var(--muted); }
.n-x__hud-top { top: var(--hud-pad, 0px); }
.n-x__hud-bottom { bottom: 0; align-items: flex-end; justify-content: flex-end; }
.n-x__hud-bottom .n-x__readout { order: 2; }
.n-x__hud .n-mono { font-size: 10.5px; }
.n-x__hud-title { color: var(--ink-2); }
.n-x__rec { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--brand); margin-right: 8px; vertical-align: 1px; animation: nBlink 1.4s steps(2) infinite; }
@keyframes nBlink { 50% { opacity: .2; } }
.n-x__status { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 500; color: var(--ink-2); padding: 5px 11px 5px 9px; border-radius: 999px; background: rgba(255,255,255,.75); border: 1px solid var(--line); }
.n-x__readout { display: grid; grid-template-columns: auto auto; align-items: end; column-gap: 12px; row-gap: 8px; padding: 12px 16px; border-radius: 14px; background: rgba(255,255,255,.78); border: 1px solid var(--line); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); box-shadow: var(--sh-2); }
.n-x__readout b { white-space: nowrap; font-family: var(--mono); font-size: 22px; font-weight: 500; color: var(--ink); line-height: 1; min-width: 2.4ch; }
.n-x__bar { grid-column: 1 / -1; display: block; width: 150px; height: 3px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.n-x__bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), #ffb84d); transform-origin: left; transform: scaleX(.5); }
.n-x__hint { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 999px; background: rgba(255,255,255,.7); border: 1px solid var(--line); }

/* Hotspots proyectados desde la escena 3D */
.n-x__hotspots { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.n-hot { position: absolute; left: 0; top: 0; display: block; pointer-events: auto; transition: opacity .35s var(--ease); will-change: transform; }
.n-hot.is-hidden { opacity: 0; pointer-events: none; }
.n-hot__dot { position: absolute; left: -7px; top: -7px; width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3px solid var(--brand); box-shadow: 0 0 0 4px rgba(234,145,8,.18); }
.n-hot__dot::after { content: ""; position: absolute; inset: -9px; border-radius: 50%; border: 1px solid var(--brand); animation: nPulse 2.4s var(--ease) infinite; }
.n-hot__line { position: absolute; top: 0; width: 46px; height: 1px; background: linear-gradient(90deg, var(--brand), rgba(234,145,8,.2)); }
.n-hot[data-eff="r"] .n-hot__line { left: 10px; }
.n-hot[data-eff="l"] .n-hot__line { right: 10px; transform: scaleX(-1); }
.n-hot__card { position: absolute; top: -24px; display: grid; gap: 1px; padding: 8px 12px; border-radius: 12px; white-space: nowrap; background: rgba(255,255,255,.88); border: 1px solid var(--line); box-shadow: var(--sh-2); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); transition: transform .3s var(--ease), border-color .3s, box-shadow .3s; }
.n-hot[data-eff="r"] .n-hot__card { left: 58px; }
.n-hot[data-eff="l"] .n-hot__card { right: 58px; text-align: right; }
.n-hot__card small { font-size: 9.5px; color: var(--brand-700); }
.n-hot__card b { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.n-hot:hover .n-hot__card { border-color: var(--brand); box-shadow: 0 12px 30px -12px rgba(234,145,8,.5); transform: translateY(-2px); }
.n-hot:hover .n-hot__dot { background: var(--brand); }

/* Texto principal sobre la escena */
.n-x__copy { position: relative; z-index: 4; height: 100%; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; padding-top: 72px; will-change: transform, opacity; }
.n-x__copy > * { max-width: min(560px, 46vw); }
.n-x__copy h1 { font-size: clamp(40px, 4.6vw, 68px); line-height: 1.02; letter-spacing: -.045em; font-weight: 600; margin: 24px 0 20px; }
.n-x__copy .n-accent { background: linear-gradient(92deg, var(--brand) 10%, #f5b041 90%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.n-x__copy .n-hero__trust { margin-top: 40px; }

/* Texto que aparece cuando la máscara se expande */
.n-x__outro { position: absolute; z-index: 4; left: max(var(--gutter), calc((100vw - var(--container)) / 2)); top: 50%; margin-top: -150px; width: min(390px, calc(100vw - 2 * var(--gutter))); padding: 22px 24px 24px; border-radius: 20px; background: rgba(255,255,255,.82); border: 1px solid var(--line); box-shadow: var(--sh-3); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); opacity: 0; pointer-events: none; will-change: transform, opacity; }
.n-x__outro h2 { font-size: clamp(22px, 1.9vw, 28px); letter-spacing: -.035em; line-height: 1.12; margin: 14px 0 10px; }
.n-x__outro .n-eyebrow { font-size: 10px; padding: 5px 11px 5px 9px; gap: 8px; }
.n-x__outro .n-btn { --bh: 42px; padding: 0 18px; font-size: 14px; }
.n-x__outro p { color: var(--muted); font-size: 14.5px; line-height: 1.55; margin-bottom: 18px; }
@media (max-height: 760px) { .n-x__outro { margin-top: -175px; } .n-x__outro p { display: none; } }

/* Indicador de scroll */
.n-x__cue { position: absolute; z-index: 4; left: max(var(--gutter), calc((100vw - var(--container)) / 2)); bottom: 30px; display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: 10.5px; pointer-events: none; }
.n-x__cue i { position: relative; width: 22px; height: 34px; border-radius: 12px; border: 1px solid var(--line-2); }
.n-x__cue i::after { content: ""; position: absolute; left: 50%; top: 7px; width: 3px; height: 7px; margin-left: -1.5px; border-radius: 3px; background: var(--brand); animation: nCue 1.8s var(--ease) infinite; }
@keyframes nCue { 0% { transform: translateY(0); opacity: 1; } 80% { transform: translateY(12px); opacity: 0; } 100% { opacity: 0; } }

.n-x + .n-marquee { margin-top: 0; }

/* ---------- Tablet y móvil: sin fijación, marco en flujo ---------- */
@media (max-width: 1024px) {
  .n-x { height: auto; }
  .n-x__sticky { position: relative; height: auto; min-height: 0; display: flex; flex-direction: column; padding: calc(var(--nav-h) + 36px) 0 40px; }
  .n-x__copy { order: 1; height: auto; padding-top: 0; transform: none !important; opacity: 1 !important; pointer-events: auto !important; }
  .n-x__copy > * { max-width: 640px; }
  .n-x__frame {
    --it: 0px; --ir: 0px; --ib: 0px; --il: 0px; --rad: 26px;
    order: 2; position: relative; inset: auto; margin: 36px var(--gutter) 0; height: min(118vw, 620px);
    clip-path: none; border-radius: 26px; overflow: hidden; box-shadow: var(--sh-2);
  }
  .n-x__outro { display: none; }
  .n-x__cue { display: none; }
}
@media (max-width: 640px) {
  .n-x__copy h1 { font-size: clamp(36px, 10.5vw, 48px); }
  .n-x__hud-top { padding: 14px 16px; }
  .n-x__hud-title { display: none; }
  .n-x__hud-bottom { padding: 14px; }
  .n-x__hint { display: none; }
  .n-x__bar { width: 110px; }
  .n-x__hud .n-cross { display: none; }
  .n-hot__card { padding: 6px 9px; }
  .n-hot__card b { font-size: 12px; }
  .n-hot__line { width: 22px; }
  .n-hot[data-eff="r"] .n-hot__card { left: 34px; }
  .n-hot[data-eff="l"] .n-hot__card { right: 34px; }
}
@media (prefers-reduced-motion: reduce) {
  .n-x__cue i::after, .n-x__rec { animation: none; }
}

/* ---------- Selector de especialidades 3D ---------- */
.n-x__hud-bottom { justify-content: space-between !important; pointer-events: none; }
.n-x__tabs { display: flex; align-items: center; gap: 4px; padding: 5px; border-radius: 999px; background: rgba(255,255,255,.82); border: 1px solid var(--line); box-shadow: var(--sh-2); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); pointer-events: auto; }
.n-x__tab { position: relative; display: inline-flex; align-items: center; gap: 0; height: 38px; min-width: 38px; padding: 0 11px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font: 500 13.5px var(--font); cursor: pointer; overflow: hidden; transition: background .3s var(--ease), color .3s var(--ease), padding .4s var(--ease), gap .4s var(--ease); }
.n-x__tab i { font-size: 14px; width: 16px; text-align: center; flex: none; }
.n-x__tab span { max-width: 0; opacity: 0; white-space: nowrap; transition: max-width .45s var(--ease), opacity .3s var(--ease); }
.n-x__tab:hover { color: var(--ink); background: var(--surface-2); }
.n-x__tab.is-active { color: #fff; background: var(--ink); gap: 8px; padding: 0 16px 0 13px; }
.n-x__tab.is-active span { max-width: 160px; opacity: 1; }
.n-x__tab.is-active i { color: var(--brand); }
.n-x__tabprog { position: absolute; left: 14px; right: 14px; bottom: 5px; height: 2px; border-radius: 2px; background: var(--brand); transform-origin: left; transform: scaleX(0); opacity: 0; }
.n-x__tab.is-active .n-x__tabprog { opacity: .9; transform: scaleX(var(--tab-prog, 0)); }
.n-x__frame.is-manual .n-x__tabprog { opacity: 0 !important; }
.n-x__tab:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.n-x__hud-bottom .n-x__readout { order: 2; }

.n-hot.is-off { display: none; }
.n-x__hotspots.is-switching .n-hot { opacity: 0 !important; pointer-events: none; }

@media (max-width: 1180px) and (min-width: 1025px) {
  .n-x__tab.is-active span { max-width: 0; opacity: 0; }
  .n-x__tab.is-active { gap: 0; padding: 0 11px; }
}
@media (max-width: 640px) {
  .n-x__hud-bottom { flex-direction: column-reverse; align-items: stretch !important; gap: 10px; }
  .n-x__tabs { justify-content: space-between; }
  .n-x__tab { padding: 0; width: 38px; justify-content: center; }
  .n-x__tab.is-active { padding: 0; gap: 0; }
  .n-x__tab.is-active span { max-width: 0; opacity: 0; }
  .n-x__readout { align-self: flex-end; }
}
/* ---------- Interacción: etiqueta de pieza y controles de vista ---------- */
.n-x__frame.is-pickable { cursor: crosshair; }
.n-x__frame.is-tool-hover { cursor: grab; }
.n-x__frame.is-tool-dragging { cursor: grabbing; }
.n-x__frame.is-tool-dragging .n-x__canvas { touch-action: none; }
.n-x__frame.is-dragging { cursor: grabbing; }
.n-x__frame:focus-visible { outline: none; }
.n-x__frame:focus-visible::after { box-shadow: inset 0 0 0 2px var(--brand), inset 0 0 0 6px rgba(234,145,8,.18); }

.n-x__tip {
  position: absolute; left: 0; top: 0; z-index: 5; pointer-events: none; display: grid; gap: 1px;
  padding: 8px 12px; border-radius: 12px; white-space: nowrap;
  background: rgba(10,13,18,.88); color: #fff; box-shadow: var(--sh-3);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  opacity: 0; transition: opacity .18s var(--ease);
}
.n-x__tip.is-on { opacity: 1; }
.n-x__tip b { font-size: 13.5px; font-weight: 600; letter-spacing: -.01em; }
.n-x__tip small { font-size: 11px; color: #ffc98a; font-family: var(--mono); letter-spacing: .06em; text-transform: uppercase; }
.n-x__frame.is-pinned .n-x__tip { box-shadow: 0 0 0 2px var(--brand), var(--sh-3); }

.n-x__toolhint {
  position: absolute; z-index: 4; left: 50%; top: calc(var(--it) + var(--hud-pad, 0px) + 62px);
  display: flex; align-items: center; gap: 10px; padding: 9px 13px 9px 11px;
  border: 1px solid rgba(234,145,8,.28); border-radius: 14px;
  background: rgba(255,255,255,.9); box-shadow: 0 12px 30px -18px rgba(10,13,18,.55);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  color: var(--ink-2); pointer-events: none; opacity: 0;
  transform: translate3d(-50%, -8px, 0); transition: opacity .3s var(--ease), transform .3s var(--ease);
}
.n-x__toolhint > i { color: var(--brand-700); font-size: 13px; }
.n-x__toolhint span { display: grid; gap: 1px; white-space: nowrap; }
.n-x__toolhint b { font-size: 11.5px; font-weight: 650; }
.n-x__toolhint small { color: var(--muted); font: 9.5px var(--mono); letter-spacing: .02em; }
.n-x__frame:is([data-model="cirugia"], [data-model="neurocirugia"]):not(.is-tool-used) .n-x__toolhint { opacity: 1; transform: translate3d(-50%, 0, 0); }
.n-x__frame.is-tool-dragging .n-x__toolhint { opacity: 0; }

.n-x__tools { display: flex; align-items: center; gap: 2px; margin-left: 8px; padding: 4px; border-radius: 999px; background: rgba(255,255,255,.82); border: 1px solid var(--line); box-shadow: var(--sh-2); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); pointer-events: auto; }
.n-x__tool { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 11px; cursor: pointer; transition: background .25s var(--ease), color .25s var(--ease); }
.n-x__tool:hover { background: var(--surface-2); color: var(--ink); }
.n-x__tool:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.n-x__tool .fa-play { display: none; }
.n-x__frame.is-paused .n-x__tool[data-auto-toggle] .fa-play { display: block; }
.n-x__frame.is-paused .n-x__tool[data-auto-toggle] .fa-pause { display: none; }
.n-x__tool[data-auto-toggle] { color: var(--brand-700); }

.n-x__usehint { display: none; align-items: center; gap: 8px; color: var(--faint); }
@media (min-width: 1360px) { .n-x__usehint { display: inline-flex; } }
@media (max-width: 640px) {
  .n-x__toolhint { top: 58px; padding: 8px 11px; }
  .n-x__toolhint b { font-size: 10.5px; }
  .n-x__toolhint small { font-size: 8.5px; }
  .n-x__tools { margin-left: 0; }
  .n-x__tool { width: 30px; height: 30px; }
  .n-x__tool[data-zoom-in], .n-x__tool[data-zoom-out] { display: none; }
}
