/* ═══ Portal QR — experiencia desktop premium ═══ */

/* Escudo: interactivo solo en pantallas grandes */
.sp-shield-qr-gate {
    border: none;
    background: transparent;
    padding: 0;
    margin: 0;
    font: inherit;
    color: inherit;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    z-index: 6;
}
.sp-shield-qr-gate .sp-shield-img {
    pointer-events: none;
    transition: filter 0.35s ease, transform 0.35s ease;
}
.sp-shield-qr-gate .sp-qr-hint {
    display: none !important;
}
@media (max-width: 1023px) {
    .sp-shield-qr-gate {
        pointer-events: none;
        cursor: default;
    }
}
@media (min-width: 1024px) {
    .sp-shield-qr-gate--on {
        cursor: pointer;
    }
    .sp-shield-qr-gate--on:hover .sp-shield-img,
    .sp-shield-qr-gate--on:focus-visible .sp-shield-img {
        filter: drop-shadow(0 0 32px rgba(0, 229, 255, 0.75)) drop-shadow(0 0 48px rgba(255, 200, 0, 0.45));
        transform: scale(1.04);
    }
    .sp-shield-qr-gate--on:focus-visible {
        outline: 2px solid rgba(0, 229, 255, 0.65);
        outline-offset: 6px;
        border-radius: 20px;
    }
}

.qr-portal {
    --qr-aura-x: 50%;
    --qr-stack-y: -6px;
    --qr-hub-x: 0px;
    --qr-hub-y: 0px;
    position: fixed;
    inset: 0;
    z-index: 12050;
    display: none;
    align-items: center;
    justify-content: center;
    padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right))
        max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
    background: #010308;
    box-sizing: border-box;
    overflow: hidden;
}
.qr-portal.is-open {
    display: flex !important;
}
.qr-portal[hidden]:not(.is-open) {
    display: none !important;
}

.qr-portal-bg {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    transition: background 0.9s ease;
}
.qr-portal-bg-loop {
    position: absolute;
    inset: -8%;
    z-index: 0;
    opacity: 0;
    background-image: image-set(
        url('../img/ui/qr-portal/qp-tunnel-loop.jpg') 1x,
        url('../img/ui/qr-portal/qp-tunnel-4k.jpg') 2x
    );
    background-position: center center;
    background-size: cover;
    background-repeat: no-repeat;
    transform: scale(1);
    transform-origin: 50% 50%;
    transition: opacity 1.1s ease, transform 1.1s ease;
    pointer-events: none;
    will-change: transform, opacity;
    image-rendering: auto;
}
.qr-portal-bg-loop-b {
    z-index: 0;
    mix-blend-mode: screen;
    filter: saturate(1.25) hue-rotate(-8deg);
}
.qr-portal-bg-loop-a {
    z-index: 0;
}
.qr-portal--loading .qr-portal-bg-loop-a {
    opacity: 0.88;
    animation: qrTunnelLoopA var(--qr-tunnel-speed, 14s) ease-in-out infinite alternate;
}
.qr-portal--loading .qr-portal-bg-loop-b {
    opacity: 0.42;
    animation: qrTunnelLoopB calc(var(--qr-tunnel-speed, 14s) * 0.72) linear infinite;
}
.qr-portal--ready .qr-portal-bg-loop {
    opacity: 0;
    transform: scale(calc(var(--qr-tunnel-zoom, 1.15) * 1.08));
    animation: none;
    transition: none;
}
@keyframes qrTunnelLoopA {
    0% { transform: scale(1); filter: brightness(0.95); }
    100% { transform: scale(var(--qr-tunnel-zoom, 1.22)); filter: brightness(1.08); }
}
@keyframes qrTunnelLoopB {
    0% { transform: scale(1.08) rotate(0deg); }
    100% { transform: scale(1.28) rotate(1.5deg); }
}

.qr-portal--ready .qr-portal-bg {
    background: #010308;
}

.qr-portal-arena {
    position: absolute;
    inset: 0;
    z-index: 2;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.6s ease;
}
.qr-portal--ready .qr-portal-arena {
    opacity: 1;
}
.qr-portal-arena-img {
    position: absolute;
    inset: 0;
    background: url('../img/ui/qr-portal/qp-arena-desktop.jpg') center / cover no-repeat;
    image-rendering: auto;
    transform: none;
    filter: saturate(1.08) contrast(1.04);
}
.qr-portal-arena-cyber {
    display: none !important;
}
.qr-portal-arena-hud {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(
            circle at var(--qr-aura-x) calc(50% + var(--qr-stack-y)),
            rgba(0, 229, 255, 0.14) 0%,
            rgba(123, 47, 255, 0.06) 28%,
            transparent 52%
        );
    animation: qrArenaHudPulse 4.2s ease-in-out infinite;
}
.qr-portal-arena-glint {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        repeating-linear-gradient(
            0deg,
            transparent 0,
            transparent 2px,
            rgba(255, 255, 255, 0.022) 2px,
            rgba(255, 255, 255, 0.022) 3px
        );
    mix-blend-mode: screen;
    opacity: 0.45;
    animation: qrArenaGlint 4s ease-in-out infinite;
}
.qr-portal-arena-fx {
    position: absolute;
    inset: 0;
    z-index: 5;
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
    opacity: 0.92;
}
@keyframes qrArenaCyberGrid {
    0% { background-position: 0 0; opacity: 0.38; }
    100% { background-position: 40px 40px; opacity: 0.62; }
}
@keyframes qrArenaHudPulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}
@keyframes qrArenaGlint {
    0%, 100% { opacity: 0.35; }
    45% { opacity: 0.72; }
    55% { opacity: 0.5; }
}
.qr-portal-bits {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    z-index: 1;
    transform-origin: 50% 50%;
    transition: opacity 0.95s ease, transform 0.95s ease, filter 0.95s ease;
}
.qr-portal-bg::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background: radial-gradient(ellipse 52% 52% at 50% 50%, transparent 0%, rgba(1, 3, 8, 0.55) 100%);
    transition: opacity 0.7s ease;
}
.qr-portal--loading .qr-portal-bg::after {
    opacity: 0.22;
}
.qr-portal--loading .qr-portal-bits {
    opacity: 0.72;
    mix-blend-mode: screen;
}
.qr-portal--ready .qr-portal-bg::after {
    z-index: 1;
    opacity: 0.28;
    background:
        radial-gradient(ellipse 80% 60% at 50% 50%, rgba(0, 229, 255, 0.08), transparent 72%),
        radial-gradient(ellipse 120% 100% at 50% 50%, transparent 50%, rgba(1, 3, 8, 0.35) 100%);
}
.qr-portal--revealing .qr-portal-bits {
    opacity: 0.45;
    transform: scale(1.1);
    filter: blur(5px) saturate(1.15);
}
.qr-portal--ready .qr-portal-bits {
    opacity: 0;
    visibility: hidden;
    transform: scale(1.14);
    filter: blur(10px);
}

.qr-portal-flash {
    position: absolute;
    inset: 0;
    z-index: 4;
    pointer-events: none;
    background: #fff;
    opacity: 0;
}
.qr-portal--flash .qr-portal-flash {
    animation: qrPortalFlash var(--qr-flash-ms, 520ms) cubic-bezier(0.33, 0, 0.2, 1) forwards;
}
@keyframes qrPortalFlash {
    0% { opacity: 0; }
    12% { opacity: 0.92; }
    28% { opacity: 1; }
    100% { opacity: 0; }
}

.qr-portal-stage {
    position: relative;
    z-index: 3;
    width: min(100%, 460px);
    text-align: center;
}

.qr-portal--loading .qr-portal-stage {
    position: fixed;
    left: 50%;
    top: 50%;
    bottom: auto;
    transform: translate(-50%, -50%);
    width: min(460px, 94vw);
    pointer-events: none;
    visibility: hidden;
}
.qr-portal--ready .qr-portal-stage {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: none;
    transform: none;
    visibility: visible;
    pointer-events: none;
}

.qr-portal-hub {
    position: fixed;
    left: 50%;
    top: calc(50% + var(--qr-stack-y));
    transform: translate(calc(-50% + var(--qr-hub-x)), calc(-50% + var(--qr-hub-y)));
    width: min(340px, 88vw);
    z-index: 5;
    pointer-events: auto;
}
.qr-portal-hub[hidden],
.qr-portal-meta[hidden] {
    display: none !important;
}
.qr-portal-meta {
    position: fixed;
    left: 50%;
    top: calc(50% + var(--qr-stack-y) + min(168px, 38vw));
    transform: translateX(-50%);
    width: min(460px, 94vw);
    z-index: 5;
    pointer-events: none;
    text-align: center;
}

.qr-portal-loader {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px 18px;
    border-radius: 16px;
    background: rgba(2, 8, 22, 0.78);
    border: 1px solid rgba(0, 229, 255, 0.2);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.04);
    animation: qrHudIn 0.5s ease both;
    transition: opacity 0.45s ease, transform 0.45s ease;
}
.qr-portal-loader--out {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
}
.qr-portal-loader[hidden],
.qr-portal-reveal[hidden] {
    display: none !important;
}

.qr-portal-loader-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.qr-portal-loader-tag {
    font-family: ui-monospace, monospace;
    font-size: 0.58rem;
    font-weight: 800;
    letter-spacing: 0.22em;
    color: rgba(0, 229, 255, 0.7);
}
.qr-portal-loader-pct {
    font-family: ui-monospace, monospace;
    font-size: 0.58rem;
    color: rgba(255, 255, 255, 0.35);
}

.qr-portal-bit-ticker {
    font-family: ui-monospace, Consolas, monospace;
    font-size: 0.58rem;
    letter-spacing: 0.12em;
    color: rgba(0, 229, 255, 0.45);
    overflow: hidden;
    white-space: nowrap;
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(0, 229, 255, 0.12);
}

.qr-portal-progress {
    height: 3px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.06);
    overflow: hidden;
}
.qr-portal-progress-bar {
    display: block;
    height: 100%;
    width: 0%;
    border-radius: 3px;
    background: linear-gradient(90deg, #00e5ff, #5b8cff 45%, #7b2fff);
    box-shadow: 0 0 14px rgba(0, 229, 255, 0.5);
}

.qr-portal-status {
    font-family: 'Courier New', ui-monospace, monospace;
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    color: rgba(255, 255, 255, 0.88);
    margin: 0;
    text-transform: uppercase;
    text-align: center;
}
.qr-portal-status-sub {
    font-family: ui-monospace, monospace;
    font-size: 0.54rem;
    color: rgba(0, 229, 255, 0.35);
    letter-spacing: 0.14em;
    margin: 0;
    text-align: center;
}

.qr-portal-reveal {
    opacity: 0;
    filter: blur(4px);
    transition: opacity 0.42s cubic-bezier(0.22, 1, 0.32, 1), filter 0.42s ease;
}
.qr-portal-reveal--in {
    opacity: 1;
    filter: blur(0);
}
.qr-portal--flash .qr-portal-reveal,
.qr-portal--flash .qr-portal-reveal--in {
    opacity: 1;
    filter: none;
    transition: none;
}

.qr-portal-frame {
    position: relative;
    width: 100%;
    margin: 0;
    background: transparent;
    isolation: isolate;
}
.qr-portal-qr-composite {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 0;
}
.qr-portal-qr-unit {
    position: relative;
    width: min(300px, 100%);
    aspect-ratio: 1;
    flex-shrink: 0;
}
.qr-portal-qr-well {
    position: relative;
    width: 100%;
    height: 100%;
    z-index: 2;
    padding: 0;
    border-radius: 20px;
    background: transparent;
    overflow: hidden;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qr-portal-qr-aura {
    display: none !important;
}
.qr-portal-qr-aura-grid {
    position: absolute;
    inset: -50%;
    background:
        linear-gradient(rgba(0, 229, 255, 0.2) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 229, 255, 0.14) 1px, transparent 1px);
    background-size: 14px 14px;
    animation: qrAuraGrid 2.8s linear infinite;
    opacity: 0.5;
}
.qr-portal-qr-aura-glow {
    position: absolute;
    inset: -15%;
    background:
        radial-gradient(circle at 50% 50%, rgba(0, 229, 255, 0.45), transparent 58%),
        radial-gradient(circle at 75% 70%, rgba(123, 47, 255, 0.28), transparent 52%);
    animation: qrAuraPulse 2.8s ease-in-out infinite;
}
.qr-portal-qr-aura-spin {
    position: absolute;
    inset: -45%;
    background: conic-gradient(
        from 0deg,
        transparent 0deg,
        rgba(0, 229, 255, 0.22) 40deg,
        transparent 80deg,
        rgba(255, 179, 71, 0.16) 140deg,
        transparent 200deg,
        rgba(123, 47, 255, 0.2) 280deg,
        transparent 360deg
    );
    animation: qrAuraSpin 10s linear infinite;
    opacity: 0.7;
}
@keyframes qrAuraGrid {
    0% { transform: translate(0, 0) rotate(0deg); }
    100% { transform: translate(14px, 14px) rotate(2deg); }
}

@media (prefers-reduced-motion: reduce) {
    .qr-portal-arena-cyber,
    .qr-portal-arena-hud,
    .qr-portal-arena-glint,
    .qr-portal-qr-aura-grid,
    .qr-portal-qr-aura-glow,
    .qr-portal-qr-aura-spin,
    .qr-portal-bg-loop {
        animation: none !important;
    }
}
@keyframes qrAuraPulse {
    0%, 100% { opacity: 0.5; transform: scale(0.98); }
    50% { opacity: 1; transform: scale(1.05); }
}
@keyframes qrAuraSpin {
    to { transform: rotate(360deg); }
}

.qr-portal-qr-display {
    position: relative;
    z-index: 2;
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-width: 100%;
    max-height: 100%;
    border-radius: inherit;
    image-rendering: auto;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
    filter: none;
    background: #fff;
}

.qr-portal-hint {
    font-family: ui-monospace, Consolas, 'Courier New', monospace;
    font-size: 0.78rem;
    color: rgba(0, 229, 255, 0.82);
    margin: 0;
    line-height: 1.5;
    max-width: 32ch;
    margin-inline: auto;
    min-height: 2.6em;
    letter-spacing: 0.04em;
    text-shadow: 0 0 12px rgba(0, 229, 255, 0.25);
    pointer-events: none;
}
.qr-portal-hint-caret {
    display: inline-block;
    margin-left: 1px;
    color: #00e5ff;
    animation: qrHintCaret 0.75s step-end infinite;
}
@keyframes qrHintCaret {
    50% { opacity: 0; }
}

.qr-portal-back {
    position: fixed;
    left: 50%;
    bottom: max(28px, calc(env(safe-area-inset-bottom) + 20px));
    transform: translateX(-50%);
    z-index: 6;
    border: 1px solid rgba(0, 229, 255, 0.4);
    background: linear-gradient(180deg, rgba(0, 229, 255, 0.12), rgba(0, 229, 255, 0.05));
    color: #00e5ff;
    font-family: 'Courier New', monospace;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    padding: 14px 28px;
    border-radius: 14px;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.qr-portal-back[hidden] {
    display: none !important;
}
.qr-portal-back:hover {
    border-color: rgba(0, 229, 255, 0.7);
    box-shadow: 0 0 24px rgba(0, 229, 255, 0.2);
}
.qr-portal-back:active {
    transform: translateX(-50%) scale(0.97);
}

.qr-portal-close {
    position: absolute;
    top: max(16px, env(safe-area-inset-top));
    right: max(16px, env(safe-area-inset-right));
    z-index: 5;
    width: 46px;
    height: 46px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 14px;
    background: rgba(4, 8, 20, 0.9);
    color: #fff;
    font-size: 1.3rem;
    cursor: pointer;
    line-height: 1;
    transition: background 0.2s, border-color 0.2s;
}
.qr-portal-close:hover {
    border-color: rgba(0, 229, 255, 0.45);
    background: rgba(8, 16, 36, 0.95);
}

@keyframes qrHudIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
/* Solo desktop: no mostrar portal en viewport chico aunque se abra por error */
@media (max-width: 1023px) {
    .qr-portal.is-open {
        display: none !important;
    }
}
