/* =====================================================================
   PRODUCTO · MEDICINA · SECCIÓN "SISTEMA DE CAPTURA EN TIEMPO REAL"
   ---------------------------------------------------------------------
   Sección propia de la familia MEDICINA. Estructura:
     1) Encabezado centrado (título + subtítulo + párrafo).
     2) DEMO: línea de tiempo animada (barra + progreso + cursor + pines
        con miniaturas) sobre un visor con el video del estudio.
     3) Banda gris clara con la galería de capturas ya guardadas.
     4) Nota legal al pie.

   Namespacing g-pmcap-*. Consume SOLO tokens de g-colors.css.
   Grilla, spacing y alineados: Bootstrap 4 (row, col-N, mb-N).

   MEJORA PROGRESIVA — estado por defecto (SIN JS):
     todo se ve completo y quieto: pines marcados, miniaturas visibles,
     galería completa y barra de progreso al 100%. El JS añade la clase
     .g-pmcap--js al contenedor de la demo y RECIÉN AHÍ se activa el modo
     "se va revelando". Bajo prefers-reduced-motion el JS NO añade esa
     clase, así que el usuario ve todo de una y sin movimiento.
   ===================================================================== */

.g-pmcap {
    padding: var(--g-section-y) 0;       /* ritmo vertical estándar (token global) */
}

/* =====================================================================
   ENCABEZADO (centrado, columna angosta para lectura cómoda)
   ===================================================================== */
.g-pmcap__head {
    max-width: 820px;
    /* El aire real hasta las miniaturas NO es solo este margen: la línea de
       tiempo reserva arriba el alto de las miniaturas colgantes
       (.g-pmcap-timeline padding-top). Por eso este margen se mantiene bajo. */
    margin: 0 auto 20px;
    text-align: center;
}

.g-pmcap__title {
    color: var(--g-dark);
    font-size: 30px;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 14px;
}

.g-pmcap__subtitle {
    color: var(--g-primary);
    font-size: 19px;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 16px;
}

.g-pmcap__text {
    color: var(--g-text);
    font-size: 16px;
    line-height: 1.65;
    margin-bottom: 0;
}

/* =====================================================================
   DEMO (línea de tiempo + visor)
   ---------------------------------------------------------------------
   Ancho común para que la barra quede EXACTAMENTE alineada con el visor.
   ===================================================================== */
.g-pmcap-demo {
    max-width: 560px;
    margin: 0 auto;
}

/* =====================================================================
   LÍNEA DE TIEMPO
   ---------------------------------------------------------------------
   Reserva de espacio: las miniaturas cuelgan HACIA ARRIBA del riel y el
   timestamp cae hacia abajo, ambos en position:absolute. El padding del
   wrapper es el que evita que se solapen con lo que hay alrededor.
   ===================================================================== */
.g-pmcap-timeline {
    padding-top: 86px;        /* alto reservado para las miniaturas colgantes (mínimo ~84px: 30px de offset + 54px de miniatura) */
    padding-bottom: 40px;     /* alto reservado para los timestamps */
}

/* ---------- Riel gris ---------- */
.g-pmcap-timeline__track {
    position: relative;
    height: 6px;
    border-radius: var(--g-radius-pill);
    background-color: var(--g-border);
}

/* ---------- MEJORA 1 · Progreso relleno en color de marca ----------
   Sustituye al riel "todo gris" del original: la parte ya reproducida
   se pinta con el azul de marca. Sin JS queda al 100% (estado final). */
.g-pmcap-timeline__progress {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: var(--g-radius-pill);
    background-image: linear-gradient(90deg,
                      var(--g-primary-darker) 0%,
                      var(--g-primary) 100%);
}

/* ---------- MEJORA 2 · Cursor (playhead) con halo y punto ----------
   El original era un bloque negro de 5px. Acá es una línea fina de
   marca, con un punto superior y un halo que late. */
.g-pmcap-timeline__playhead {
    position: absolute;
    top: 50%;
    left: 100%;
    width: 3px;
    height: 22px;
    margin-left: -1.5px;
    transform: translateY(-50%);
    border-radius: var(--g-radius-pill);
    background-color: var(--g-primary);
    box-shadow: 0 0 0 4px rgba(var(--g-primary-rgb), .18);
}

.g-pmcap-timeline__playhead::after {
    content: "";
    position: absolute;
    top: -9px;
    left: 50%;
    width: 11px;
    height: 11px;
    transform: translateX(-50%);
    border-radius: var(--g-radius-pill);
    background-color: var(--g-primary);
    box-shadow: 0 0 0 3px var(--g-white),
                0 2px 8px rgba(var(--g-primary-rgb), .55);
}

/* =====================================================================
   MARCAS DE CAPTURA (pin + miniatura + timestamp)
   ===================================================================== */
.g-pmcap-mark {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
}

/* ---------- MEJORA 4 · Pin fino (reemplaza el bloque de 5px) ---------- */
.g-pmcap-mark__pin {
    display: block;
    width: 2px;
    height: 20px;
    margin: 0 auto;
    border-radius: var(--g-radius-pill);
    background-color: var(--g-text-muted);
}

.g-pmcap-mark__pin::before {
    content: "";
    position: absolute;
    top: -6px;
    left: 50%;
    width: 8px;
    height: 8px;
    transform: translateX(-50%) rotate(45deg);
    border-radius: 2px;
    background-color: var(--g-text-muted);
}

/* ---------- MEJORA 4bis · Timestamp bajo cada pin ---------- */
.g-pmcap-mark__time {
    position: absolute;
    top: 28px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--g-text-muted);
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    letter-spacing: .02em;
    white-space: nowrap;
}

/* ---------- Miniatura colgante ---------- */
.g-pmcap-mark__thumb {
    position: absolute;
    bottom: 30px;
    left: 50%;
    display: block;
    width: 64px;
    padding: 3px;
    transform: translateX(-50%);
    border-radius: var(--g-radius-md);
    background-color: var(--g-white);
    box-shadow: 0 4px 14px rgba(0, 0, 0, .18);
}

.g-pmcap-mark__thumb img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 9px;   /* radio anidado: --g-radius-md (12px) − 3px de padding */
}

/* ---------- MEJORA 5 · Estado ACTIVO (la captura recién tomada) ---------- */
.g-pmcap-mark.is-active .g-pmcap-mark__pin,
.g-pmcap-mark.is-active .g-pmcap-mark__pin::before {
    background-color: var(--g-primary);
}

.g-pmcap-mark.is-active .g-pmcap-mark__time {
    color: var(--g-primary);
}

.g-pmcap-mark.is-current .g-pmcap-mark__thumb {
    box-shadow: 0 0 0 3px rgba(var(--g-primary-rgb), .55),
                0 6px 18px rgba(0, 0, 0, .22);
}

/* =====================================================================
   MODO JS · "se va revelando"
   ---------------------------------------------------------------------
   Solo cuando el JS confirma que puede animar. Antes de su momento, la
   marca está tenue y su miniatura no se ve; al capturarse entra con
   scale + fade (MEJORA 3) y el progreso avanza suave.
   ===================================================================== */
.g-pmcap--js .g-pmcap-timeline__progress {
    width: 0;
}

.g-pmcap--js .g-pmcap-timeline__playhead {
    left: 0;
}

.g-pmcap--js .g-pmcap-mark__thumb {
    opacity: 0;
    transform: translateX(-50%) translateY(8px) scale(.72);
    transform-origin: 50% 100%;
    transition: opacity .32s ease-out, transform .38s cubic-bezier(.2, .9, .3, 1.25);
}

.g-pmcap--js .g-pmcap-mark.is-active .g-pmcap-mark__thumb {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
}

.g-pmcap--js .g-pmcap-mark__pin,
.g-pmcap--js .g-pmcap-mark__pin::before,
.g-pmcap--js .g-pmcap-mark__time {
    opacity: .5;
    transition: opacity .3s ease-out, background-color .3s ease-out, color .3s ease-out;
}

.g-pmcap--js .g-pmcap-mark.is-active .g-pmcap-mark__pin,
.g-pmcap--js .g-pmcap-mark.is-active .g-pmcap-mark__pin::before,
.g-pmcap--js .g-pmcap-mark.is-active .g-pmcap-mark__time {
    opacity: 1;
}

/* Pulso del cursor: solo en modo JS (es el que indica "grabando"). */
.g-pmcap--js .g-pmcap-timeline__playhead::after {
    animation: g-pmcap-pulse 1.6s ease-in-out infinite;
}

@keyframes g-pmcap-pulse {
    0%, 100% { box-shadow: 0 0 0 3px var(--g-white), 0 0 0 0 rgba(var(--g-primary-rgb), .5); }
    60%      { box-shadow: 0 0 0 3px var(--g-white), 0 0 0 9px rgba(var(--g-primary-rgb), 0); }
}

/* =====================================================================
   VISOR (video del estudio + destello de captura)
   ---------------------------------------------------------------------
   El visor es MÁS ANGOSTO que la línea de tiempo (igual que en la
   referencia): la barra ocupa el ancho completo de .g-pmcap-demo y el
   visor se centra dentro con su propio max-width. Ese max-width es el
   ÚNICO número que gobierna su tamaño en desktop.
   ===================================================================== */
.g-pmcap-viewer {
    position: relative;
    max-width: 420px;
    margin: 0 auto;
    overflow: hidden;
    border-radius: var(--g-radius-lg);
    background-color: var(--g-black);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .16);
}

.g-pmcap-viewer__video {
    display: block;
    width: 100%;
    height: auto;
}

/* Destello blanco al tomar una captura (equivalente al #flash original). */
.g-pmcap-viewer__flash {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--g-white);
    opacity: 0;
    pointer-events: none;
    transition: opacity .12s ease;
}

.g-pmcap-viewer__flash.is-on {
    opacity: .85;
    transition: none;
}

/* =====================================================================
   GALERÍA DE CAPTURAS GUARDADAS (banda gris clara)
   ===================================================================== */
.g-pmcap-gallery {
    margin-top: 40px;
    padding: 24px;
    border-radius: var(--g-radius-lg);
    background-color: var(--g-bg-light);
}

.g-pmcap-gallery__item {
    position: relative;
    display: block;
    overflow: hidden;
    border-radius: var(--g-radius-md);
    background-color: var(--g-neutral);
}

.g-pmcap-gallery__item img {
    display: block;
    width: 100%;
    height: auto;
}

/* Modo JS: cada captura aparece cuando el estudio pasa por su momento.
   Lo que se revela es la IMAGEN, no el contenedor: así la banda muestra
   los cuatro "slots" vacíos desde el principio (se entiende que se van
   llenando) y no hay salto de layout al aparecer cada captura. */
.g-pmcap--js .g-pmcap-gallery__item {
    box-shadow: inset 0 0 0 1px var(--g-border);
    transition: box-shadow .3s ease-out;
}

.g-pmcap--js .g-pmcap-gallery__item img {
    opacity: 0;
    transform: scale(.94);
    transition: opacity .35s ease-out, transform .4s cubic-bezier(.2, .9, .3, 1.2);
}

.g-pmcap--js .g-pmcap-gallery__item.is-active img {
    opacity: 1;
    transform: scale(1);
}

/* MEJORA 5 · anillo de marca en la captura que se acaba de tomar. */
.g-pmcap-gallery__item.is-current {
    box-shadow: 0 0 0 3px rgba(var(--g-primary-rgb), .6);
}

/* =====================================================================
   NOTA LEGAL
   ===================================================================== */
.g-pmcap__nota {
    max-width: 820px;
    margin: 28px auto 0;
    color: var(--g-text-muted);
    font-size: 13px;
    line-height: 1.6;
    text-align: center;
}

/* =====================================================================
   RESPONSIVE
   ===================================================================== */
@media (max-width: 575.98px) {
    .g-pmcap__title    { font-size: 25px; }
    .g-pmcap__subtitle { font-size: 17px; }
    .g-pmcap__head     { margin-bottom: 32px; }

    .g-pmcap-timeline  { padding-top: 68px; padding-bottom: 30px; }

    .g-pmcap-mark__thumb { width: 46px; }
    .g-pmcap-mark__time  { font-size: 10px; }

    .g-pmcap-gallery   { padding: 16px; }
}

/* =====================================================================
   ACCESIBILIDAD · movimiento reducido
   ---------------------------------------------------------------------
   Cinturón y tirantes: el JS ya evita el modo animado, pero si la clase
   llegara igual (p. ej. el usuario cambia la preferencia con la página
   abierta) acá se neutraliza todo: se ve el estado final, sin animación.
   ===================================================================== */
@media (prefers-reduced-motion: reduce) {
    .g-pmcap--js .g-pmcap-timeline__progress { width: 100%; }
    .g-pmcap--js .g-pmcap-timeline__playhead { left: 100%; animation: none; }
    .g-pmcap--js .g-pmcap-timeline__playhead::after { animation: none; }

    .g-pmcap--js .g-pmcap-mark__thumb {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
        transition: none;
    }

    .g-pmcap--js .g-pmcap-gallery__item img {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .g-pmcap--js .g-pmcap-mark__pin,
    .g-pmcap--js .g-pmcap-mark__pin::before,
    .g-pmcap--js .g-pmcap-mark__time {
        opacity: 1;
        transition: none;
    }

    .g-pmcap-viewer__flash { display: none; }
}
