/* ===========================================
   Iframe Viewer — DATALAB kiosk demonstrator viewer
   Opens external demos in a large in-page overlay so the
   kiosk never navigates away. Graceful fallback (QR + open
   extern) when a site refuses framing or is mixed-content.
   =========================================== */

.iframe-viewer {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 11000;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
    padding: 2vmin;
    box-sizing: border-box;
}

.iframe-viewer.active {
    display: flex;
    animation: iv-fade 0.25s ease-out;
}

@keyframes iv-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.iv-shell {
    display: flex;
    flex-direction: column;
    width: 94vw;
    height: 90vh;
    max-width: 1600px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
    animation: iv-pop 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
}

@keyframes iv-pop {
    from { opacity: 0; transform: translateY(20px) scale(0.985); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Top bar ── */
.iv-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px 10px 18px;
    background: var(--nav-bg);
    border-bottom: 1px solid var(--border-color);
    flex: 0 0 auto;
}

.iv-title {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.iv-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--han-pink);
    box-shadow: 0 0 10px rgba(229, 0, 86, 0.7);
    flex: 0 0 auto;
}

.iv-title-meta {
    min-width: 0;
    line-height: 1.25;
}

.iv-title-text {
    font-family: 'Inter', system-ui, sans-serif;
    font-weight: 600;
    font-size: 15px;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.iv-url {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 11px;
    opacity: 0.5;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.iv-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.iv-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 14px;
    font-weight: 600;
    padding: 0 16px;
    min-height: 44px;            /* touch target */
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-color);
    cursor: pointer;
    transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

.iv-btn:hover {
    border-color: var(--han-pink);
    color: var(--han-pink);
}

.iv-btn:active {
    transform: scale(0.96);
}

.iv-btn.iv-primary,
.iv-btn.iv-close {
    background: var(--han-pink);
    color: #fff;
    border-color: var(--han-pink);
}

.iv-btn.iv-primary:hover,
.iv-btn.iv-close:hover {
    background: #cc004c;
    color: #fff;
}

/* ── Stage (iframe + overlays) ── */
.iv-stage {
    position: relative;
    flex: 1 1 auto;
    background: #ffffff;
    min-height: 0;
}

.iv-frame {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
    background: #ffffff;
}

.iframe-viewer[data-state="fallback"] .iv-frame {
    visibility: hidden;
}

/* Loading state */
.iv-loading {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    background: var(--card-bg);
    color: var(--text-color);
    font-family: 'Inter', system-ui, sans-serif;
}

.iframe-viewer[data-state="loading"] .iv-loading {
    display: flex;
}

.iv-spinner {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 4px solid var(--border-color);
    border-top-color: var(--han-pink);
    animation: iv-spin 0.9s linear infinite;
}

@keyframes iv-spin {
    to { transform: rotate(360deg); }
}

/* Fallback state */
.iv-fallback {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    text-align: center;
    padding: 32px;
    box-sizing: border-box;
    background: var(--card-bg);
    color: var(--text-color);
    font-family: 'Inter', system-ui, sans-serif;
}

.iframe-viewer[data-state="fallback"] .iv-fallback {
    display: flex;
}

.iv-fallback-icon {
    font-size: 42px;
    line-height: 1;
}

.iv-fallback-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-color);
}

.iv-fallback-msg {
    font-size: 0.95rem;
    line-height: 1.6;
    opacity: 0.8;
    margin: 0;
    max-width: 460px;
}

.iv-qr {
    background: #fff;
    padding: 14px;
    border-radius: var(--radius-md);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    line-height: 0;
    min-width: 180px;
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.iv-qr img,
.iv-qr canvas {
    display: block;
}

.iv-fallback-url {
    font-size: 0.8rem;
    opacity: 0.55;
    word-break: break-all;
    max-width: 460px;
    margin: 0;
}

/* QR popover (toolbar "QR" button — available for any open demo) */
.iv-qr-pop {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 5;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.4);
    padding: 16px;
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    animation: iv-pop 0.2s ease-out;
}

.iframe-viewer.iv-show-qr .iv-qr-pop {
    display: flex;
}

.iv-qr-pop p {
    margin: 0;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 12px;
    color: var(--text-color);
    opacity: 0.7;
    max-width: 200px;
    text-align: center;
}

/* ── Responsive / touch ── */
@media screen and (max-width: 767px) {
    .iframe-viewer {
        padding: 0;
    }
    .iv-shell {
        width: 100vw;
        height: 100vh;
        max-width: none;
        border-radius: 0;
        border: 0;
    }
    .iv-btn {
        padding: 0 12px;
        font-size: 13px;
    }
    .iv-open-extern {
        display: none;        /* keep the bar compact on small screens */
    }
}
