/**
 * preview.css — Screen 5: Campaign Preview
 * Card CONTENT = welcome vCard (.vcard, .thumb, .gen-anim, etc)
 * Card SIZE + SELECTION = format/style pattern
 * Layout = space-evenly like format/style
 * Architecture: ZERO inline CSS. SSR. External only.
 */

/* ═══ LAYOUT CONTAINER ═══ */
.preview-layout {
    display: flex;
    align-items: center;
    justify-content: space-evenly;
    gap: 0;
    width: 100%;
    height: 100%;
    flex: 1;
    align-self: stretch;
    padding: 53px 2.5rem 5px;
}

/* ═══ OPTION WRAPPER ═══ */
.preview-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    position: relative;
    transition: transform 0.2s ease;
}

/* ═══ SELECT ROW (check + label) — always horizontal [○ A] ═══ */
.preview-select-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
}

/* ═══ SINGLE CARD MODE — hide check + label ═══ */
.preview-layout:not(.multi-card) .preview-select-row {
    display: none;
}

/* ═══ CARD SIZE OVERRIDES ═══ */
/* D = (100vh - 224px) * 9/16 — same as format/style */
.preview-option .vcard.card-P .thumb {
    width: calc((100vh - 224px) * 9 / 16);
    height: auto;
    border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.preview-option .vcard.card-L .thumb {
    height: calc((100vh - 224px) * 9 / 16);
    width: auto;
    border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

/* ═══ SELECTION STATES ═══ */
/* Selected: bright border */
.preview-option.selected .vcard .thumb {
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.05);
}

/* Dim non-selected when has-selection */
.preview-layout.has-selection .preview-option:not(.selected) .vcard .thumb {
    opacity: 0.5;
}

.preview-layout.has-selection .preview-option:not(.selected) .vcard .thumb img {
    opacity: 0.6;
}

/* Hover */
.preview-option:hover .vcard .thumb {
    border-color: rgba(255, 255, 255, 0.3);
}

/* ═══ SELECT BUTTON (checkmark) ═══ */
.preview-check {
    width: 19px;
    height: 19px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.preview-option:hover .preview-check {
    border-color: rgba(255, 255, 255, 0.4);
}

.preview-option.selected .preview-check {
    background: #fff;
    border-color: #fff;
}

.preview-check svg {
    width: 11px;
    height: 11px;
    color: transparent;
    transition: color 0.3s;
}

.preview-option.selected .preview-check svg {
    color: #000;
}

/* ═══ CARD LABEL (A / B) — styled as tag badge ═══ */
.preview-card-label {
    font-family: 'Inter', sans-serif;
    font-size: 9px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    text-align: center;
    padding: 3px 10px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.08);
}

.preview-option.selected .preview-card-label {
    color: rgba(255, 255, 255, 0.8);
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.08);
}

/* ═══ ACTION FRAMES ═══ */
.preview-frames {
    display: flex;
    flex-direction: column;
    gap: 64px;
    width: 100%;
    max-width: 340px;
    flex-shrink: 0;
}

.preview-frame {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 16px 20px 24px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 1.5rem;
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    transition: border-color 0.3s ease, background 0.3s ease;
}

.preview-frame:hover,
.preview-frame:active {
    border-color: rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.05);
}

.preview-frame-text {
    font-family: 'Inter', sans-serif;
    font-size: 9px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.55);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    text-align: center;
}

/* ═══ BUTTONS ═══ */
.preview-btn-adjust {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 48px;
    padding: 0 1.5rem;
    border-radius: 14px;
    border: none;
    font-family: 'Inter', sans-serif;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.5);
    background: transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

/* Animated gradient border via pseudo-element */
.preview-btn-adjust::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 14px;
    padding: 1px;
    background: linear-gradient(110deg, rgba(130, 190, 255, 0.7) 30%, rgba(255, 150, 190, 0.7) 70%);
    background-size: 200% 200%;
    animation: directorPastel 4s ease-in-out infinite;
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

.preview-btn-adjust:hover {
    filter: brightness(1.3);
}

/* Text + SVG above particles */
.adjust-label {
    position: relative;
    z-index: 2;
    background: linear-gradient(110deg, rgba(130, 190, 255, 0.9) 30%, rgba(255, 150, 190, 0.9) 70%);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: directorPastel 4s ease-in-out infinite;
}

.preview-btn-adjust svg {
    position: relative;
    z-index: 2;
}

/* ═══ PIXEL PARTICLES ═══ */
.adjust-pixels {
    position: absolute;
    inset: 0;
    overflow: hidden;
    border-radius: 14px;
    pointer-events: none;
}

.adjust-pixels .px {
    position: absolute;
    width: 3px;
    height: 3px;
    border-radius: 1px;
    background: linear-gradient(110deg, rgba(130, 190, 255, 0.9) 30%, rgba(255, 150, 190, 0.9) 70%);
    background-size: 200% 200%;
    left: 0;
    transform: translateX(-6px);
    animation: pxSlide 14s linear infinite, directorPastel 4s ease-in-out infinite;
    opacity: 0;
    will-change: transform, opacity;
}

/* 5 rows */
.px.r1 { top: 15%; } .px.r2 { top: 30%; } .px.r3 { top: 50%; } .px.r4 { top: 65%; } .px.r5 { top: 80%; }

/* Staggered — ~3-4 visible at once, matrix rain feel */
.px.r1:nth-child(1){animation-delay:0s,0s}.px.r1:nth-child(2){animation-delay:.8s,.3s}.px.r1:nth-child(3){animation-delay:1.6s,.7s}.px.r1:nth-child(4){animation-delay:2.4s,1s}.px.r1:nth-child(5){animation-delay:3.2s,1.5s}.px.r1:nth-child(6){animation-delay:4s,2s}.px.r1:nth-child(7){animation-delay:4.8s,.1s}.px.r1:nth-child(8){animation-delay:5.6s,.6s}.px.r1:nth-child(9){animation-delay:6.4s,1.2s}.px.r1:nth-child(10){animation-delay:7.2s,1.8s}
.px.r2:nth-child(11){animation-delay:.3s,.5s}.px.r2:nth-child(12){animation-delay:1.1s,1.1s}.px.r2:nth-child(13){animation-delay:1.9s,.2s}.px.r2:nth-child(14){animation-delay:2.7s,.8s}.px.r2:nth-child(15){animation-delay:3.5s,1.4s}.px.r2:nth-child(16){animation-delay:4.3s,2.1s}.px.r2:nth-child(17){animation-delay:5.1s,.4s}.px.r2:nth-child(18){animation-delay:5.9s,.9s}.px.r2:nth-child(19){animation-delay:6.7s,1.6s}.px.r2:nth-child(20){animation-delay:7.5s,2.2s}
.px.r3:nth-child(21){animation-delay:.5s,1s}.px.r3:nth-child(22){animation-delay:1.3s,.3s}.px.r3:nth-child(23){animation-delay:2.1s,.8s}.px.r3:nth-child(24){animation-delay:2.9s,1.5s}.px.r3:nth-child(25){animation-delay:3.7s,.1s}.px.r3:nth-child(26){animation-delay:4.5s,.6s}.px.r3:nth-child(27){animation-delay:5.3s,1.3s}.px.r3:nth-child(28){animation-delay:6.1s,2s}.px.r3:nth-child(29){animation-delay:6.9s,.4s}.px.r3:nth-child(30){animation-delay:7.7s,1.1s}
.px.r4:nth-child(31){animation-delay:.15s,.7s}.px.r4:nth-child(32){animation-delay:.95s,1.3s}.px.r4:nth-child(33){animation-delay:1.75s,.2s}.px.r4:nth-child(34){animation-delay:2.55s,.9s}.px.r4:nth-child(35){animation-delay:3.35s,1.6s}.px.r4:nth-child(36){animation-delay:4.15s,.1s}.px.r4:nth-child(37){animation-delay:4.95s,.5s}.px.r4:nth-child(38){animation-delay:5.75s,1.2s}.px.r4:nth-child(39){animation-delay:6.55s,1.9s}.px.r4:nth-child(40){animation-delay:7.35s,.3s}
.px.r5:nth-child(41){animation-delay:.45s,1.2s}.px.r5:nth-child(42){animation-delay:1.25s,.4s}.px.r5:nth-child(43){animation-delay:2.05s,1s}.px.r5:nth-child(44){animation-delay:2.85s,1.7s}.px.r5:nth-child(45){animation-delay:3.65s,.2s}.px.r5:nth-child(46){animation-delay:4.45s,.8s}.px.r5:nth-child(47){animation-delay:5.25s,1.5s}.px.r5:nth-child(48){animation-delay:6.05s,2.1s}.px.r5:nth-child(49){animation-delay:6.85s,.6s}.px.r5:nth-child(50){animation-delay:7.65s,1.4s}

@keyframes pxSlide {
    0%   { transform: translateX(-6px); opacity: 0; }
    5%   { opacity: 0.9; }
    75%  { opacity: 0.25; }
    100% { transform: translateX(100vw); opacity: 0; }
}

/* Hide adjust button when Card B exists (already used) */
.preview-layout.multi-card .preview-btn-adjust {
    display: none;
}

.preview-btn-adjust svg {
    width: 14px;
    height: 14px;
    stroke: rgba(180, 170, 230, 0.9);
    fill: none;
    flex-shrink: 0;
}

.preview-btn-generate {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 48px;
    padding: 0 1.5rem;
    border-radius: 14px;
    border: none;
    font-family: 'Inter', sans-serif;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: #000;
    background: #fff;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
}

.preview-btn-generate::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg, transparent 10%, rgba(130, 190, 255, 0.7) 40%, rgba(255, 150, 190, 0.7) 60%, transparent 90%);
    background-size: 200% 200%;
    animation: previewPastelFlow 4s ease-in-out infinite;
    pointer-events: none;
}

.preview-btn-generate:hover {
    box-shadow: 0 4px 24px rgba(130, 190, 255, 0.3), 0 2px 8px rgba(0, 0, 0, 0.3);
}

.preview-btn-generate span,
.preview-btn-generate svg {
    position: relative;
    z-index: 2;
}

@keyframes previewPastelFlow {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* ═══ DESC ═══ */
.preview-desc {
    font-family: 'Inter', sans-serif;
    font-size: 9px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.55);
    line-height: 1.6;
    text-align: center;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

/* ═══ TABLET (768px) ═══ */
@media (max-width: 768px) {
    .preview-layout {
        gap: 1.5rem;
        padding: 53px 1.5rem 5px;
    }

    .preview-option .vcard.card-P .thumb {
        width: calc((100vh - 224px) * 9 / 16);
    }

    .preview-option .vcard.card-L .thumb {
        height: calc((100vh - 224px) * 9 / 16);
    }

    .preview-panel {
        width: 280px;
    }
}

/* ═══ MOBILE (480px) — stack vertical, no scroll ═══ */
@media (max-width: 480px) {
    .preview-layout {
        flex-direction: column;
        align-items: center;
        justify-content: space-evenly;
        gap: 0;
        padding: 53px 1.5rem 5px;
        overflow: hidden;
    }

    /* Smaller cards to fit viewport without scroll */
    .preview-option .vcard.card-P .thumb {
        width: clamp(80px, calc((100vh - 224px) * 9 / 16 * 0.32), 130px);
    }

    .preview-option .vcard.card-L .thumb {
        height: clamp(60px, calc((100vh - 224px) * 9 / 16 * 0.32), 100px);
    }

    .preview-option {
        gap: 4px;
    }

    .preview-frames {
        width: 100%;
        gap: 24px;
    }

    .preview-btn-generate {
        width: 100%;
    }
}

/* ═══ EXPAND BUTTON (on card thumb) ═══ */
.preview-expand-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: none;
    background: rgba(0, 0, 0, 0.5);
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.2s;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.preview-expand-btn:hover {
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    transform: scale(1.1);
}

/* ═══ LIGHTBOX OVERLAY ═══ */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    z-index: 950;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 2.5%;
}

.lightbox-overlay.open {
    display: flex;
}

.lightbox-overlay img {
    max-width: 95%;
    max-height: 95vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.lightbox-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.2s;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}
