/* Big Plum Connect v2: "WhatsApp, por el canal oficial" (prefijo x2-)
   Dos luces que se hablan a través del agua (portada). La escena cuenta el viaje de un mensaje: la plantilla se escribe,
   una luz la recorre mientras Meta la revisa, se enciende al aprobarse, baja por el cable hasta el teléfono y, al final,
   el número y los datos se borran del panel: solo queda la plantilla y el identificador del envío */

.x2 { --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace; }
/* A: la lámpara de señales del muelle (63 %, 40 %) y, a la derecha, la casa que contesta. En móvil se encuadran las dos */
.x2-cover { --cover-focus: 63% 40%; --cover-stack-pos: 88% 50%; }

/* Dos luces que se hablan: la lámpara lanza un pulso y, al poco, la ventana de la casa contesta con dos destellos.
   Cada luz es la propia foto sumada sobre sí misma (screen) y recortada con una máscara sacada de la foto (su haz, su ventana),
   con la misma geometría cover que la imagen, así que no hay trazos encima ni bordes. Ciclo de 9 s */
.x2-pulse {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    mix-blend-mode: screen;
    pointer-events: none;
    -webkit-mask-size: cover;
    mask-size: cover;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: 50% 50%;
    mask-position: 50% 50%;
    animation: 9s ease-in-out 1.8s infinite both;
}

.x2-pulse--send { -webkit-mask-image: url(/assets/img/connect-v2/mascara-senal.webp); mask-image: url(/assets/img/connect-v2/mascara-senal.webp); animation-name: x2Send; }
.x2-pulse--reply { -webkit-mask-image: url(/assets/img/connect-v2/mascara-respuesta.webp); mask-image: url(/assets/img/connect-v2/mascara-respuesta.webp); animation-name: x2Reply; }
.x2-pulse--halo { background: rgb(255, 204, 140); -webkit-mask-image: url(/assets/img/connect-v2/mascara-halo.webp); mask-image: url(/assets/img/connect-v2/mascara-halo.webp); animation-name: x2Halo; }

@keyframes x2Send { 0% { opacity: 0; } 6% { opacity: .62; } 17% { opacity: .62; } 36% { opacity: 0; } 100% { opacity: 0; } }
@keyframes x2Reply { 0%, 40% { opacity: 0; } 43% { opacity: 1; } 47% { opacity: .1; } 51% { opacity: 1; } 57% { opacity: 0; } 100% { opacity: 0; } }
@keyframes x2Halo { 0%, 40% { opacity: 0; } 43% { opacity: .32; } 47% { opacity: .04; } 51% { opacity: .32; } 59% { opacity: 0; } 100% { opacity: 0; } }

@media (max-width: 820px) {
    .x2-pulse { -webkit-mask-position: var(--cover-stack-pos, 50% 50%); mask-position: var(--cover-stack-pos, 50% 50%); }
}

@media (prefers-reduced-motion: reduce) {
    .x2-pulse { animation: none; opacity: 0; }
}

/* ---------- La escena ---------- */

.x2-flow { position: relative; height: 560svh; background: var(--carbon-2); }

.x2-flow__stage {
    position: sticky;
    top: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 31rem);
    gap: clamp(3rem, 7vw, 7rem);
    align-items: center;
    height: 100svh;
    padding: 6rem max(var(--gutter), calc((100% - 82rem) / 2)) 4rem;
    overflow: hidden;
}

.x2-flow__text { position: relative; align-self: stretch; display: grid; align-content: center; }
.x2-flow__text > .v3-kicker { position: absolute; top: clamp(2rem, 8vh, 5rem); }

.x2-say {
    grid-area: 1 / 1;
    max-width: 30rem;
    opacity: 0;
    transform: translateY(26px);
    transition: opacity .8s ease, transform 1s var(--ease-out);
    pointer-events: none;
}

.x2-say.is-on { opacity: 1; transform: none; transition-delay: .18s; pointer-events: auto; }
.x2-say.is-past { transform: translateY(-26px); }

.x2-say__n { margin: 0 0 1.2rem; color: rgba(var(--luz), .8); font-family: var(--mono); font-size: .72rem; letter-spacing: .1em; }

.x2-say__title {
    margin: 0;
    font-family: var(--serif);
    font-size: clamp(2.3rem, 4vw, 4rem);
    font-weight: 300;
    letter-spacing: -.025em;
    line-height: 1.04;
}

.x2-say.is-on .v3-lit { --on: 1; }
.x2-say__line { max-width: 27rem; margin: 1.4rem 0 0; color: rgba(245, 244, 241, .68); font-size: clamp(.98rem, 1.05vw, 1.08rem); font-weight: 300; line-height: 1.7; }

.x2-flow__steps { position: absolute; bottom: clamp(1rem, 5vh, 3rem); left: 0; display: flex; gap: 1.4rem; margin: 0; padding: 0; list-style: none; }
.x2-flow__steps li { color: rgba(245, 244, 241, .3); font-family: var(--mono); font-size: .66rem; transition: color .6s ease; }
.x2-flow__steps li.is-on { color: rgb(var(--luz-core)); }
.x2-flow__steps b { font-weight: 500; }

/* El dispositivo: la plantilla, el cable y el teléfono */
.x2-device { position: relative; }

.x2-card {
    position: relative;
    overflow: hidden;
    padding: 1.4rem 1.6rem 1.5rem;
    border: 1px solid rgba(245, 244, 241, .1);
    border-radius: 1rem;
    background: #1c1b21;
    transition: border-color 1.2s var(--glow-ease), box-shadow 1.2s var(--glow-ease);
}

.x2-flow.is-approved .x2-card {
    border-color: rgba(var(--luz), .55);
    box-shadow: 0 0 0 1px rgba(var(--luz), .12), 0 30px 70px -34px rgba(var(--luz), .45);
}

.x2-card__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; color: rgba(245, 244, 241, .45); font-size: .58rem; font-weight: 600; letter-spacing: .24em; text-transform: uppercase; }

.x2-pill {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .3rem .7rem;
    border: 1px solid rgba(245, 244, 241, .18);
    border-radius: 999px;
    color: rgba(245, 244, 241, .6);
    font-family: var(--mono);
    font-size: .62rem;
    font-weight: 500;
    letter-spacing: .08em;
    transition: color .8s ease, border-color .8s ease, background-color .8s ease;
}

.x2-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .6; transition: background-color .8s ease, box-shadow .8s ease, opacity .8s ease; }
.x2-flow.is-pending .x2-pill { border-color: rgba(var(--luz), .35); color: rgba(var(--luz), .85); }
.x2-flow.is-pending .x2-pill::before { animation: x2Wait 1.6s ease-in-out infinite; }
.x2-flow.is-approved .x2-pill { border-color: rgba(var(--luz), .7); color: rgb(var(--luz-core)); background: rgba(var(--luz), .14); }
.x2-flow.is-approved .x2-pill::before { opacity: 1; background: rgb(var(--luz-core)); box-shadow: 0 0 8px 1px rgba(var(--luz), .7); animation: none; }

@keyframes x2Wait { 50% { opacity: .15; } }

.x2-card__name { margin: 0; color: var(--hueso); font-family: var(--mono); font-size: .95rem; }
.x2-card__meta { margin: .3rem 0 0; color: rgba(245, 244, 241, .45); font-family: var(--mono); font-size: .68rem; letter-spacing: .04em; }

.x2-card__body {
    min-height: 4.5em;
    margin: 1.2rem 0 0;
    color: rgba(245, 244, 241, .86);
    font-family: var(--serif);
    font-size: clamp(1.05rem, 1.3vw, 1.2rem);
    font-weight: 300;
    line-height: 1.55;
}

/* Variables: la marca {{n}} hasta que se rellenan, y vuelve cuando el dato se borra. Se alternan (no se superponen) para que
   la frase no deje huecos del ancho de la otra */
.x2-var { opacity: 0; transition: opacity .5s ease; }
.x2-var.is-typed { opacity: 1; }
.x2-var > i { padding: 0 .3em; border-radius: .3rem; color: rgba(var(--luz), .9); background: rgba(var(--luz), .1); font-family: var(--mono); font-size: .78em; font-style: normal; line-height: 1.7; }
.x2-var > em { display: none; color: var(--hueso); font-style: italic; }
.x2-flow.is-filled .x2-var > i { display: none; }
.x2-flow.is-filled .x2-var > em { display: inline; animation: x2Focus .9s ease both; }
.x2-flow.is-filled.is-erased .x2-var > em { display: none; }
.x2-flow.is-filled.is-erased .x2-var > i { display: inline; animation: x2Focus .9s ease both; }

@keyframes x2Focus { from { opacity: 0; filter: blur(5px); } }

.x2-card__to {
    display: flex;
    gap: 1rem;
    align-items: baseline;
    margin-top: 1.2rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(245, 244, 241, .08);
    opacity: 0;
    transition: opacity .8s ease;
}

.x2-card__to span { color: rgba(245, 244, 241, .45); font-size: .58rem; font-weight: 600; letter-spacing: .24em; text-transform: uppercase; }
.x2-card__to em { color: var(--hueso); font-family: var(--mono); font-size: .85rem; font-style: normal; transition: opacity .9s ease, filter .9s ease; }
.x2-flow.is-filled .x2-card__to { opacity: 1; }

/* Al final, el número se borra del panel */
.x2-flow.is-erased .x2-card__to em { opacity: 0; filter: blur(7px); }

/* La luz que recorre la plantilla mientras Meta la revisa (JS: --x y opacidad) */
.x2-scan { position: absolute; top: 0; bottom: 0; left: var(--x, 0%); width: 1px; opacity: 0; pointer-events: none; }
.x2-scan .v3-beam { --fill: 400px; }

/* El cable: la luz baja de la plantilla al teléfono */
.x2-wire { position: relative; width: 1px; height: clamp(3.5rem, 11vh, 7rem); margin-left: 72%; background: rgba(245, 244, 241, .1); }

.x2-phone {
    width: 80%;
    margin-left: auto;
    padding: 1rem;
    border: 1px solid rgba(245, 244, 241, .1);
    border-radius: 1.3rem;
    background: #141318;
}

.x2-phone__bubble {
    position: relative;
    max-width: 92%;
    margin: 0;
    padding: .8rem 1rem 1.4rem;
    border-radius: .9rem .9rem .9rem .25rem;
    color: var(--carbon);
    background: var(--hueso);
    font-size: .88rem;
    font-weight: 400;
    line-height: 1.5;
    opacity: 0;
    transform: translateY(10px) scale(.98);
    transform-origin: 0 100%;
    transition: opacity .7s ease, transform .9s var(--ease-out);
}

.x2-phone__bubble small { position: absolute; right: .8rem; bottom: .45rem; color: rgba(17, 17, 17, .45); font-size: .66rem; }
.x2-flow.is-delivered .x2-phone__bubble { opacity: 1; transform: none; }

.x2-receipt {
    position: absolute;
    left: 0;
    top: var(--receipt-top, 50%);
    display: grid;
    gap: .3rem;
    max-width: 62%;
    margin: 0;
    opacity: 0;
    transition: opacity .8s ease;
}

.x2-receipt span { color: rgba(var(--luz), .8); font-size: .56rem; font-weight: 600; letter-spacing: .22em; text-transform: uppercase; }
.x2-receipt code { overflow: hidden; color: rgba(245, 244, 241, .7); font-family: var(--mono); font-size: .66rem; text-overflow: ellipsis; white-space: nowrap; }
.x2-flow.is-delivered .x2-receipt { opacity: 1; }

.x2-device__note { margin: 1rem 0 0; color: rgba(245, 244, 241, .32); font-size: .56rem; font-weight: 600; letter-spacing: .22em; text-align: right; text-transform: uppercase; }

/* ---------- Qué hace (sección clara con v3-includes) ---------- */

.x2-does { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* ---------- Lo que no hace ---------- */

.x2-not {
    display: grid;
    grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
    gap: clamp(3rem, 7vw, 7rem);
    padding: clamp(6rem, 14vh, 9rem) max(var(--gutter), calc((100% - 82rem) / 2));
    background: var(--carbon);
}

.x2-not__head .v3-body { margin-top: 1.4rem; }
.x2-not__list { margin: 0; padding: 0; border-top: 1px solid rgba(245, 244, 241, .12); list-style: none; }
.x2-not__list li { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: .5rem 2rem; padding: 1.6rem 0; border-bottom: 1px solid rgba(245, 244, 241, .12); }
.x2-not__list h3 { margin: 0; font-family: var(--serif); font-size: clamp(1.2rem, 1.6vw, 1.5rem); font-weight: 300; line-height: 1.25; }
.x2-not__list p { margin: 0; color: rgba(245, 244, 241, .6); font-size: .92rem; font-weight: 300; line-height: 1.65; }

/* ---------- Datos ---------- */

.x2-data {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: clamp(3rem, 7vw, 7rem);
    align-items: start;
    padding: clamp(6rem, 14vh, 9rem) max(var(--gutter), calc((100% - 82rem) / 2));
    background: var(--carbon-2);
}

.x2-data__head .v3-body { margin-top: 1.4rem; }
.x2-data__links { display: flex; flex-wrap: wrap; gap: .6rem 1.8rem; margin: 2rem 0 0; }
.x2-data__list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 2.5rem; margin: 0; padding: 0; list-style: none; }
.x2-data__list li { padding: 1.6rem 0; border-top: 1px solid rgba(245, 244, 241, .12); }
.x2-data__list h3 { margin: 0 0 .6rem; font-family: var(--serif); font-size: clamp(1.25rem, 1.6vw, 1.5rem); font-weight: 300; line-height: 1.2; }
.x2-data__list p { margin: 0; color: rgba(245, 244, 241, .6); font-size: .9rem; font-weight: 300; line-height: 1.65; }

/* ---------- Cierre ---------- */

.x2-cta { display: grid; justify-items: start; gap: 1.6rem; padding: clamp(6rem, 14vh, 9rem) max(var(--gutter), calc((100% - 82rem) / 2)); background: var(--carbon); }
.x2-cta .v3-title { max-width: 16em; }

/* ---------- Responsive ---------- */

/* Pantallas grandes y altas: la escena crece (el dispositivo con una escala, para que sus medidas en px no cambien) */
@media (min-width: 1600px) and (min-height: 1100px) {
    .x2-device { transform: scale(1.3); transform-origin: 100% 50%; }
    .x2-say__title { font-size: clamp(4rem, 3.4vw, 5rem); }
    .x2-say__line { max-width: 31rem; font-size: 1.2rem; }
    .x2-say { max-width: 36rem; }
}

@media (max-width: 1180px) {
    .x2-does { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .x2-not, .x2-data { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .x2-flow { height: 620svh; }
    /* El dispositivo arriba y el texto debajo */
    .x2-flow__stage { grid-template-columns: 1fr; grid-template-rows: auto 1fr; gap: 1.4rem; align-items: start; padding: 5rem 1.5rem 1.6rem; }
    .x2-device { grid-row: 1; width: min(100%, 26rem); margin: 0 auto; }
    .x2-flow__text { grid-row: 2; align-content: start; }
    .x2-flow__text > .v3-kicker { display: none; }
    .x2-flow__steps { display: none; }
    .x2-card { padding: 1rem 1.1rem 1.1rem; }
    .x2-card__head { margin-bottom: .6rem; }
    .x2-card__body { min-height: 0; margin-top: .7rem; font-size: 1rem; }
    .x2-card__to { margin-top: .8rem; padding-top: .7rem; }
    .x2-wire { height: 2.6rem; }
    .x2-phone { padding: .7rem; }
    .x2-phone__bubble { font-size: .8rem; }
    .x2-device__note { display: none; }
    /* El cable es corto: el recibo va debajo del teléfono para no pisar la plantilla */
    .x2-receipt { position: static; max-width: 100%; margin-top: .7rem; }
    .x2-say__n { margin-bottom: .6rem; }
    .x2-say__title { font-size: clamp(1.9rem, 8.4vw, 2.6rem); }
    .x2-say__line { margin-top: .8rem; font-size: .92rem; line-height: 1.6; }
}

@media (max-width: 820px) {
    .x2-does { grid-template-columns: 1fr; }
    .x2-not, .x2-data, .x2-cta { padding: 5.5rem 1.5rem; }
    .x2-not__list li, .x2-data__list { grid-template-columns: 1fr; }
    .x2-cta .v3-button { width: 100%; justify-content: center; }
}

/* Sin movimiento: la historia entera, quieta y en orden */
@media (prefers-reduced-motion: reduce) {
    .x2-flow { height: auto; }
    .x2-flow__stage { position: static; height: auto; padding-block: 6rem; align-items: start; }
    .x2-flow__text { display: grid; gap: 2.4rem; }
    .x2-flow__text > .v3-kicker { position: static; }
    .x2-say, .x2-say.is-past { grid-area: auto; opacity: 1; transform: none; }
    .x2-flow__steps { display: none; }
}
