/* ==========================================================================
   Demo del portal (portada, #demo) — reproductor propio (video-demo.js)
   Usa los tokens de styles.css y las curvas de ux.css.
   ========================================================================== */

#demo { padding: var(--space-3xl) var(--page-gutter); }
.vd-hdr { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--space-lg); margin-bottom: var(--space-lg); }
.vd-hdr .s-title { margin-top: 12px; }
.vd-lead { max-width: 440px; font-size: 16px; font-weight: 300; line-height: 1.8; color: rgba(255,255,255,0.55); }

/* ── Marco ─────────────────────────────────────────────────────── */
.vd-player {
  --vd-bar: clamp(44px, 5.2cqw, 56px);
  --vd-ease: var(--ux-expo, cubic-bezier(.16, 1, .3, 1));
  position: relative;
  container-type: inline-size;
  max-width: 1400px;
  margin: 0 auto;
  aspect-ratio: var(--vd-ratio, 1920 / 946);
  background: var(--black);
  border: 1px solid var(--gray-3);
  overflow: hidden;
  isolation: isolate;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; user-select: none;
}
/* Esquinas rojas tipo visor de cámara */
.vd-player::before, .vd-player::after {
  content: ''; position: absolute; z-index: 2; width: 22px; height: 22px; pointer-events: none;
  border: 2px solid var(--red);
}
.vd-player::before { top: 10px; left: 10px; border-right: 0; border-bottom: 0; }
.vd-player::after  { bottom: 10px; right: 10px; border-left: 0; border-top: 0; }
.vd-player.is-started::before, .vd-player.is-started::after { opacity: 0; transition: opacity .4s; }

.vd-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: var(--black); display: block; }
.vd-player:not(.vd-on) .vd-video { position: static; height: 100%; }

/* ── Portada con botón de reproducir ───────────────────────────── */
.vd-start {
  position: absolute; inset: 0; z-index: 4;
  display: grid; place-content: center; justify-items: center; gap: clamp(10px, 1.6cqw, 18px);
  background: radial-gradient(ellipse at center, rgba(0,0,0,.2), rgba(0,0,0,.72));
  color: var(--white);
  transition: opacity .45s var(--vd-ease), visibility 0s .45s;
}
.vd-start-i {
  display: grid; place-items: center;
  width: clamp(56px, 8cqw, 92px); aspect-ratio: 1;
  background: var(--red);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.14), 0 0 0 0 rgba(204,0,0,.5);
  animation: vd-ring 2.4s ease-out infinite;
  transition: transform .45s var(--vd-ease), background .25s;
}
.vd-start-i svg { width: 40%; height: 40%; fill: var(--white); margin-left: 6%; }
.vd-start:hover .vd-start-i { transform: scale(1.06); background: var(--red-dark); }
.vd-start-l { font-family: var(--font-condensed); font-size: clamp(11px, 1.25cqw, 14px); letter-spacing: .32em; text-transform: uppercase; }
.vd-start-l b { color: var(--red); font-weight: 600; }
.is-started .vd-start { opacity: 0; visibility: hidden; pointer-events: none; }

/* ── Subtítulos con formato de marca ───────────────────────────── */
.vd-sub {
  position: absolute; z-index: 3; left: 50%; bottom: 5cqw; width: min(88%, 60em);
  transform: translateX(-50%);
  text-align: center; text-wrap: balance; pointer-events: none;
  opacity: 0; transition: opacity .18s ease, bottom .35s var(--vd-ease);
}
.vd-sub.is-on { opacity: 1; }
.vd-player.is-started:not(.is-idle) .vd-sub { bottom: calc(var(--vd-bar) + 2cqw); }
.vd-sub-t {
  font-family: var(--font-body), system-ui, sans-serif;
  font-weight: 500;
  font-size: clamp(13px, 2.05cqw, 28px);
  line-height: 1.5;
  color: var(--white);
  background: rgba(0,0,0,.8);
  border-inline-start: 3px solid var(--red);
  padding: .16em .62em .2em;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
.vd-h { color: var(--red); }

/* ── Botones de acción dentro del video ────────────────────────── */
.vd-ctas { position: absolute; z-index: 5; top: clamp(10px, 2.2cqw, 26px); right: clamp(10px, 2.2cqw, 26px); }
/* Nunca coinciden dos a la vez: ocupan el mismo lugar y el oculto no empuja al otro */
.vd-cta {
  position: absolute; top: 0; right: 0;
  display: inline-flex; align-items: center; gap: .65em;
  min-height: 40px; padding: .9em 1.35em;
  font-family: var(--font-condensed); font-size: clamp(11px, 1.3cqw, 15px); font-weight: 600;
  letter-spacing: .16em; text-transform: uppercase; text-decoration: none; white-space: nowrap;
  color: var(--white); background: var(--red); border: 1px solid var(--red);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.14), 0 12px 30px rgba(0,0,0,.5);
  opacity: 0; visibility: hidden; transform: translateX(18px);
  transition: opacity .35s ease, transform .5s var(--vd-ease), background .25s, visibility 0s .5s;
}
.vd-cta.is-on { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
.vd-cta svg { width: 1.3em; height: 1.3em; fill: currentColor; flex-shrink: 0; }
.vd-cta:hover { background: var(--red-dark); }
.vd-cta-wa { background: rgba(0,0,0,.78); border-color: var(--gray-3); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.vd-cta-wa svg { fill: var(--red); }
.vd-cta-wa:hover { background: rgba(0,0,0,.92); border-color: var(--red); }
/* Cierre del guion: el botón crece y late */
.vd-cta-call.is-final { font-size: clamp(12px, 1.6cqw, 18px); animation: vd-ring 1.8s ease-out infinite; }

.vd-player.is-away .vd-start-i, .vd-player.is-away .vd-cta-call.is-final { animation-play-state: paused; }

@keyframes vd-ring {
  0%   { box-shadow: inset 0 1px 0 rgba(255,255,255,.14), 0 0 0 0 rgba(204,0,0,.55); }
  70%, 100% { box-shadow: inset 0 1px 0 rgba(255,255,255,.14), 0 0 0 16px rgba(204,0,0,0); }
}

/* ── Rótulo de contexto (momentos { id: 'note' }) ──────────────── */
.vd-tag {
  position: absolute; z-index: 4; top: clamp(10px, 2.2cqw, 26px); left: clamp(10px, 2.2cqw, 26px); max-width: 55%;
  padding: .55em 1em;
  font-family: var(--font-condensed), system-ui, sans-serif; font-size: clamp(11px, 1.3cqw, 15px); font-weight: 600;
  letter-spacing: .16em; text-transform: uppercase; color: var(--white);
  background: rgba(0,0,0,.8); border-inline-start: 3px solid var(--red);
  opacity: 0; transform: translateX(-14px); pointer-events: none;
  transition: opacity .35s ease, transform .5s var(--vd-ease);
}
.vd-tag.is-on { opacity: 1; transform: none; }

/* ── Pantalla final ────────────────────────────────────────────── */
.vd-end {
  position: absolute; inset: 0; z-index: 6;
  display: grid; place-content: center; justify-items: center; gap: clamp(10px, 2cqw, 24px);
  padding: 4cqw; text-align: center;
  background: rgba(0,0,0,.86);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  opacity: 0; visibility: hidden; transition: opacity .45s ease, visibility 0s .45s;
}
.vd-end.is-on { opacity: 1; visibility: visible; transition-delay: 0s; }
.vd-end-t { font-family: var(--font-display); font-size: clamp(22px, 4.6cqw, 62px); line-height: 1; max-width: 16em; text-wrap: balance; }
.vd-end-acts { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.vd-end .btn-p, .vd-end .btn-wa { padding: clamp(11px, 1.3cqw, 15px) clamp(18px, 2.6cqw, 34px); }
.vd-replay, .vd-x {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px;
  font-family: var(--font-condensed); font-size: 12px; letter-spacing: .24em; text-transform: uppercase;
  color: var(--muted); transition: color .25s;
}
.vd-replay svg { width: 16px; height: 16px; fill: currentColor; }
.vd-replay:hover, .vd-x:hover { color: var(--white); }

/* ── Cargando ──────────────────────────────────────────────────── */
.vd-spin {
  position: absolute; z-index: 3; top: 50%; left: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px;
  border: 2px solid rgba(255,255,255,.15); border-top-color: var(--red); border-radius: 50%;
  opacity: 0; pointer-events: none; transition: opacity .2s;
  animation: vd-spin .8s linear infinite;
}
.vd-player.is-wait .vd-spin { opacity: 1; transition-delay: .25s; }
@keyframes vd-spin { to { transform: rotate(360deg); } }

/* ── Controles ─────────────────────────────────────────────────── */
.vd-bar {
  position: absolute; z-index: 7; left: 0; right: 0; bottom: 0; height: var(--vd-bar);
  display: flex; align-items: center; gap: 2px; padding: 0 clamp(4px, 1.2cqw, 16px);
  background: linear-gradient(to top, rgba(0,0,0,.88), rgba(0,0,0,.55) 60%, rgba(0,0,0,0));
  transition: opacity .3s ease, transform .35s var(--vd-ease);
}
.vd-player:not(.is-started) .vd-bar,
.vd-player.is-idle .vd-bar { opacity: 0; transform: translateY(10px); pointer-events: none; }
.vd-b { display: grid; place-items: center; width: 40px; height: 40px; flex-shrink: 0; color: var(--white); transition: color .2s; }
.vd-b svg { width: 22px; height: 22px; fill: currentColor; }
.vd-b[hidden] { display: none; }
.vd-b:hover, .vd-ccb.is-on { color: var(--red); }
.vd-b:focus-visible, .vd-prog:focus-visible, .vd-cta:focus-visible, .vd-start:focus-visible .vd-start-i,
.vd-mi:focus-visible, .vd-chip input:focus-visible + span, .vd-replay:focus-visible, .vd-x:focus-visible {
  outline: 2px solid var(--red); outline-offset: 2px;
}
.vd-speed { width: auto; min-width: 40px; padding: 0 6px; font-family: var(--font-condensed); font-size: 14px; font-weight: 600; letter-spacing: .04em; }
.vd-time {
  padding: 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 38%;
  font-family: var(--font-condensed); font-size: 13px; letter-spacing: .06em; color: rgba(255,255,255,.88);
  font-variant-numeric: tabular-nums;
}
.vd-dur { color: var(--muted); }
.vd-chn:not(:empty)::before { content: '·'; margin: 0 .6em; color: var(--red); }

.vd-prog { position: relative; flex: 1; min-width: 60px; height: 32px; display: flex; align-items: center; touch-action: none; }
.vd-track { position: relative; width: 100%; height: 3px; background: rgba(255,255,255,.18); transition: height .15s; }
.vd-prog:hover .vd-track, .vd-prog.is-drag .vd-track { height: 5px; }
.vd-buf, .vd-fill { position: absolute; top: 0; bottom: 0; left: 0; width: 0; }
.vd-buf { background: rgba(255,255,255,.26); }
.vd-fill { background: var(--red); }
.vd-marks i { position: absolute; top: 0; bottom: 0; width: 3px; margin-left: -1.5px; background: var(--black); }
.vd-thumb {
  position: absolute; top: 50%; left: 0; width: 13px; height: 13px;
  background: var(--red); box-shadow: 0 0 12px var(--red-glow);
  transform: translate(-50%, -50%) scale(0); transition: transform .15s;
}
.vd-prog:hover .vd-thumb, .vd-prog.is-drag .vd-thumb, .vd-prog:focus-visible .vd-thumb { transform: translate(-50%, -50%) scale(1); }
.vd-tip {
  position: absolute; bottom: calc(100% + 4px); left: 0; transform: translateX(-50%);
  padding: 6px 10px; white-space: nowrap; pointer-events: none;
  font-family: var(--font-condensed); font-size: 12px; letter-spacing: .06em;
  background: rgba(0,0,0,.92); border: 1px solid var(--gray-3);
  opacity: 0; transition: opacity .15s;
}
.vd-tip.is-on { opacity: 1; }
.vd-tip-t { margin-inline-start: .6em; color: var(--red); font-variant-numeric: tabular-nums; }

/* ── Menús (subtítulos, idiomas, capítulos) ────────────────────── */
.vd-menu {
  position: absolute; inset: auto clamp(4px, 1.2cqw, 16px) calc(var(--vd-bar) + 6px) auto; z-index: 8;
  margin: 0; padding: 6px; width: 260px; max-height: calc(100% - var(--vd-bar) - 24px); overflow: auto;
  color: var(--white); background: rgba(10,10,10,.96); border: 1px solid var(--gray-3);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  overscroll-behavior: contain;
}
.vd-menu.is-sheet {
  position: fixed; inset: auto 0 0 0; width: 100%; max-width: none; max-height: 70dvh;
  padding: 10px 12px calc(14px + env(safe-area-inset-bottom));
  border-width: 1px 0 0;
}
.vd-menu::backdrop, .vd-sched::backdrop { background: rgba(0,0,0,.62); }
.vd-menu-h { padding: 8px 10px 6px; font-family: var(--font-condensed); font-size: 11px; letter-spacing: .32em; text-transform: uppercase; color: var(--red); }
.vd-menu-st:not(:empty) { padding: 0 10px 6px; font-size: 13px; color: var(--muted); }
.vd-mi {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; min-height: 40px; padding: 8px 10px;
  font-family: var(--font-body), system-ui, sans-serif; font-size: 14px; text-align: start; color: rgba(255,255,255,.8);
  transition: background .15s, color .15s;
}
.vd-mi:hover, .vd-mi:focus-visible { background: var(--gray-2); color: var(--white); }
.vd-mi small { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.vd-mi[aria-checked="true"] { color: var(--white); }
.vd-mi[aria-checked="true"]::after { content: ''; width: 8px; height: 8px; flex-shrink: 0; background: var(--red); }
.vd-mi[aria-checked="true"] small { display: none; }

/* ── Agendar llamada ───────────────────────────────────────────── */
.vd-sched {
  width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto;
  margin: auto; padding: clamp(24px, 4vw, 40px);
  color: var(--white); background: var(--gray); border: 1px solid var(--gray-3); border-top: 2px solid var(--red);
  box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
.vd-sched[open] { animation: vd-in .45s var(--vd-ease); }
@keyframes vd-in { from { opacity: 0; transform: translateY(14px); } }
.vd-x { position: absolute; top: 10px; right: 10px; width: 44px; justify-content: center; }
.vd-x svg { width: 20px; height: 20px; }
.vd-sched-t { margin: 4px 0 22px; font-family: var(--font-display); font-weight: 400; font-size: clamp(30px, 6vw, 42px); line-height: 1; text-wrap: balance; }
.vd-sched fieldset { border: 0; margin: 0 0 18px; padding: 0; min-width: 0; }
.vd-sched legend, .vd-field > span {
  display: block; margin-bottom: 8px;
  font-family: var(--font-condensed); font-size: 12px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted);
}
.vd-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.vd-chip { position: relative; }
.vd-chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.vd-chip span {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px;
  font-family: var(--font-condensed); font-size: 15px; font-weight: 600; letter-spacing: .04em;
  color: rgba(255,255,255,.75); border: 1px solid var(--gray-3); background: var(--black);
  transition: border-color .2s, color .2s, background .2s;
}
.vd-chip span:first-letter { text-transform: uppercase; }
.vd-chip input:checked + span { color: var(--white); border-color: var(--red); background: rgba(204,0,0,.14); }
.vd-field { display: block; margin-bottom: 22px; }
.vd-field input {
  width: 100%; min-height: 48px; padding: 0 14px;
  font: 400 16px var(--font-body), system-ui, sans-serif; color: var(--white);
  background: var(--black); border: 1px solid var(--gray-3); border-radius: 0;
}
.vd-field input:focus { outline: none; border-color: var(--red); }
.vd-sched-acts { display: flex; flex-wrap: wrap; gap: 10px; }
.vd-sched-acts a { flex: 1 1 auto; justify-content: center; text-align: center; }
.vd-note { margin-top: 14px; font-size: 13px; color: var(--muted); }

/* ── Pantalla completa ─────────────────────────────────────────── */
.vd-player:fullscreen { max-width: none; width: 100%; height: 100%; aspect-ratio: auto; border: 0; }
.vd-player:-webkit-full-screen { max-width: none; width: 100%; height: 100%; aspect-ratio: auto; border: 0; }
.vd-player.is-pseudo {
  position: fixed; inset: 0; z-index: 1000; max-width: none; width: 100vw; height: 100vh; height: 100dvh;
  aspect-ratio: auto; border: 0; margin: 0;
}
/* Cada sección del sitio es su propio contexto de apilamiento (z-index: 2): la del demo sube con el reproductor */
#demo:has(.is-pseudo) { z-index: 1001; }
.vd-lock, .vd-lock body { overflow: hidden; }
/* Celular en vertical: subtítulos y botones pegados al video, no al borde de la pantalla.
   --vd-half = media altura del video en cqw (946/1920/2 → 24.6; un video 16:9 usa 28.125) */
@media (orientation: portrait) {
  .vd-player.is-pseudo .vd-sub.vd-sub { bottom: calc(50% - var(--vd-half, 24.6cqw) + 2.5cqw); }
  .vd-player.is-pseudo .vd-ctas { top: calc(50% - var(--vd-half, 24.6cqw) + 10px); }
}
/* En pantalla completa el cursor propio del sitio queda fuera: se usa el del sistema */
.vd-player.is-fs, .vd-player.is-fs * { cursor: auto; }
.vd-player.is-fs :is(button, a, .vd-prog, .vd-chip) { cursor: pointer; }
.vd-player.is-fs.is-idle, .vd-player.is-fs.is-idle * { cursor: none; }
.vd-player.is-fs::before, .vd-player.is-fs::after { display: none; }

/* ── Reproductor angosto (celular) ─────────────────────────────── */
@container (max-width: 640px) {
  .vd-speed, .vd-mute, .vd-chn, .vd-dur { display: none; }
  .vd-b { width: 38px; }
  .vd-b svg { width: 20px; height: 20px; }
  .vd-time { padding: 0 4px; font-size: 12px; }
  .vd-cta { min-height: 36px; padding: .75em 1.05em; letter-spacing: .1em; }
  .vd-end { gap: 10px; }
  .vd-end-t { font-size: 20px; }
  .vd-end .btn-p, .vd-end .btn-wa { padding: 10px 14px; font-size: 11px; letter-spacing: 2px; }
  .vd-replay { min-height: 32px; }
}
@container (max-width: 420px) {
  .vd-end-t { display: none; }
  .vd-end-wa span { display: none; }
  .vd-player::before, .vd-player::after { width: 14px; height: 14px; top: 6px; left: 6px; }
  .vd-player::after { top: auto; left: auto; bottom: 6px; right: 6px; }
}

@media (max-width: 768px) {
  #demo { padding-left: var(--page-gutter); padding-right: var(--page-gutter); }
  .vd-hdr { flex-direction: column; align-items: flex-start; gap: var(--space-md); }
  /* A todo el ancho en celular: cada píxel cuenta en una grabación de pantalla */
  .vd-player { margin-left: calc(var(--page-gutter) * -1); margin-right: calc(var(--page-gutter) * -1); border-left: 0; border-right: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .vd-start-i, .vd-cta-call.is-final, .vd-sched[open] { animation: none; }
  .vd-cta, .vd-tag, .vd-sub, .vd-bar, .vd-end, .vd-start { transition-duration: .01s; }
}
