/* ========================================
   iPhone Photos Viewer Clone Styles
   ======================================== */

/* Viewer screen container */
#viewer-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 100;
    display: none;
    flex-direction: column;
}

#viewer-screen.active {
    display: flex;
}

/* Viewer top bar */
.viewer-top-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 110;
    padding: env(safe-area-inset-top, 44px) 0 0 0;
    padding-top: calc(env(safe-area-inset-top, 44px) + 0px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: calc(env(safe-area-inset-top, 44px) + 44px);
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.viewer-top-bar.bars-hidden {
    opacity: 0;
    transform: translateY(-100%);
    pointer-events: none;
}

.viewer-back-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    font-size: 17px;
    font-weight: 400;
    color: #0a84ff;
}

.viewer-back-btn svg {
    width: 12px;
    height: 20px;
    fill: none;
    stroke: #0a84ff;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.viewer-edit-btn {
    padding: 8px 16px;
    font-size: 17px;
    font-weight: 400;
    color: #0a84ff;
}

/* Viewer bottom bar */
.viewer-bottom-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 110;
    padding: 10px 24px;
    padding-bottom: calc(env(safe-area-inset-bottom, 20px) + 10px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.viewer-bottom-bar.bars-hidden {
    opacity: 0;
    transform: translateY(100%);
    pointer-events: none;
}

.viewer-bottom-bar .bar-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.viewer-bottom-bar .bar-btn svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: #fff;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.viewer-bottom-bar .bar-btn.share-btn svg {
    width: 20px;
    height: 20px;
}

.viewer-bottom-bar .bar-btn.delete-btn svg {
    width: 20px;
    height: 22px;
}

/* Image container — handles zoom/pan */
.viewer-image-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    touch-action: none;
}

/* The zoomable wrapper */
.viewer-zoom-wrapper {
    position: relative;
    transform-origin: 0 0;
    will-change: transform;
}

/* Captured photo */
.viewer-photo {
    display: block;
    max-width: 100vw;
    max-height: 100vh;
    width: auto;
    height: auto;
    object-fit: contain;
}

/* ========================================
   Card Reveal Overlay — "Photographed detail" style
   
   The "2♣" is TINY and never fully sharp. Even at
   max zoom it retains some blur — the spectator has
   to lean in and squint to make it out. It should
   feel like a barely-legible mark in the background.
   
   Position, color, blend mode, and perspective are
   set dynamically by imageAnalysis.js via viewer.js.
   ======================================== */
.card-overlay {
    position: absolute;
    /* Default position — overridden by image analysis */
    top: 46%;
    left: 51%;
    transform: translate(-50%, -50%);
    
    pointer-events: none;
    
    /* Constant soft-focus — mimics a tiny photographed detail.
       No dynamic changes on zoom; zoom just makes it bigger. */
    filter: blur(0.4px) brightness(0.93) contrast(0.92);
    opacity: 0.9;
    
    /* Default blend — overridden by analysis */
    mix-blend-mode: multiply;
    
    /* Grain opacity variable from analysis */
    --grain-opacity: 0.03;
    
    transition: none;
}

.card-text {
    display: block;
    font-family: 'Georgia', 'Times New Roman', serif;
    /* Lapel pin size — visible as a smudge at 1x, readable when zoomed */
    font-size: 12px;
    font-weight: 700;
    /* Default color — overridden by analysis color matching */
    color: #1a1a1a;
    letter-spacing: -0.2px;
    line-height: 1;
    white-space: nowrap;
    /* Default transform — overridden by analysis perspective */
    transform: rotate(-2deg);
}

/* Grain overlay — intensity controlled by --grain-opacity from analysis */
.card-overlay::after {
    content: '';
    position: absolute;
    top: -200%;
    left: -200%;
    right: -200%;
    bottom: -200%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.15'/%3E%3C/svg%3E");
    background-size: 50px 50px;
    opacity: var(--grain-opacity, 0.03);
    mix-blend-mode: overlay;
    pointer-events: none;
}

/* Souvenir save button */
.souvenir-bar {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 120;
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
}

.souvenir-bar.visible {
    opacity: 1;
    pointer-events: auto;
}

.souvenir-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 24px;
    background: rgba(255,255,255,0.18);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    font-size: 15px;
    font-weight: 500;
    color: #fff;
    border: 1px solid rgba(255,255,255,0.25);
}

.souvenir-btn svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: #fff;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Offscreen compositing canvas */
#souvenir-canvas {
    display: none;
}

/* Transition from camera to viewer */
.viewer-enter {
    animation: viewerSlideIn 0.35s cubic-bezier(0.25, 0.1, 0.25, 1) forwards;
}

@keyframes viewerSlideIn {
    from {
        opacity: 0;
        transform: scale(0.3);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.viewer-exit {
    animation: viewerSlideOut 0.3s cubic-bezier(0.25, 0.1, 0.25, 1) forwards;
}

@keyframes viewerSlideOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.3);
    }
}
