/* =============================================
   PhotoStrip v2 — Style System
   Mobile-First  •  State-Machine Driven
   ============================================= */

:root {
    --bg:          #19192e;
    --bg-deep:     #0e0e1e;
    --bg-card:     rgba(255, 255, 255, 0.06);
    --border-card: rgba(255, 255, 255, 0.10);
    --gold:        #FFD700;
    --gold-dim:    #c9a800;
    --gold-glow:   rgba(255, 215, 0, 0.35);
    --text:        #ffffff;
    --text-dim:    rgba(255, 255, 255, 0.55);
    --success:     #4CAF50;
    --radius:      20px;
    --radius-sm:   12px;
    --safe-b:      env(safe-area-inset-bottom, 0px);
}

/* ── Reset ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg-deep);
    color: var(--text);
    overflow: hidden;
    height: 100%; width: 100%;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

/* ── App Container ─────────────────────────── */
#app {
    position: relative;
    width: 100%; height: 100%;
    max-width: 480px;
    margin: 0 auto;
    background: var(--bg);
    overflow: hidden;
}

/* ── Panels (state-driven visibility) ──────── */
.panel {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.45s ease, visibility 0.45s ease;
    z-index: 1;
}
.panel.center-panel { justify-content: center; align-items: center; padding: 32px; }

/* ── STATE VISIBILITY RULES ────────────────── */
/* Camera panel */
#app[data-state="idle"]         #panel-camera,
#app[data-state="countdown"]    #panel-camera,
#app[data-state="flash"]        #panel-camera,
#app[data-state="preview-shot"] #panel-camera { opacity:1; visibility:visible; pointer-events:auto; z-index:10; }

/* Camera overlays */
.cam-overlay {
    position: absolute; inset: 0; z-index: 3;
    display: flex; flex-direction: column;
    justify-content: space-between;
    padding: 40px 24px calc(32px + var(--safe-b));
    opacity: 0; visibility: hidden; pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
#app[data-state="idle"]         #overlay-idle,
#app[data-state="countdown"]    #overlay-countdown,
#app[data-state="flash"]        #overlay-flash,
#app[data-state="preview-shot"] #overlay-preview { opacity:1; visibility:visible; pointer-events:auto; }

/* Other panels */
#app[data-state="processing"] #panel-processing { opacity:1; visibility:visible; pointer-events:auto; z-index:10; }
#app[data-state="result"]     #panel-result     { opacity:1; visibility:visible; pointer-events:auto; z-index:10; }
#app[data-state="editor"]     #panel-editor     { opacity:1; visibility:visible; pointer-events:auto; z-index:10; }

/* ── Glass Card ────────────────────────────── */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-card);
    border-radius: var(--radius);
    padding: 20px;
}

/* ── Buttons ───────────────────────────────── */
.btn {
    font-family: 'Outfit', sans-serif;
    font-weight: 600; font-size: 17px;
    padding: 15px 28px;
    border: none; border-radius: 100px;
    cursor: pointer;
    display: inline-flex; justify-content: center; align-items: center; gap: 8px;
    width: 100%;
    transition: transform 0.15s, box-shadow 0.2s, background 0.2s;
}
.btn:active { transform: scale(0.96); }

.btn.gold {
    background: var(--gold);
    color: #1a1a2e;
    box-shadow: 0 4px 24px var(--gold-glow);
}
.btn.gold:active { background: var(--gold-dim); }

.btn.outline {
    background: transparent;
    color: var(--text);
    border: 1.5px solid var(--border-card);
}
.btn.small { font-size: 13px; padding: 10px 14px; }

/* ── Typography ────────────────────────────── */
h2 { font-size: 22px; font-weight: 700; }
p  { font-size: 14px; color: var(--text-dim); }
.brand { font-size: 18px; font-weight: 700; letter-spacing: 0.5px; }
.brand span { color: var(--gold); }

/* =============================================
   PANEL: CAMERA
   ============================================= */
#camera-feed {
    position: absolute; inset: 0; z-index: 1;
    width: 100%; height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
    background: #000;
}
.camera-vignette {
    position: absolute; inset: 0; z-index: 2;
    background: radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,0.55) 100%);
    pointer-events: none;
}

/* Overlay shared layout */
.ov-top    { text-align: center; }
.ov-center { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; }
.ov-bottom { text-align: center; }

/* Idle */
.tagline {
    font-size: 24px; font-weight: 700; color: #fff;
    text-shadow: 0 3px 16px rgba(0,0,0,0.7);
    background: rgba(0,0,0,0.25);
    padding: 10px 24px; border-radius: 100px;
    backdrop-filter: blur(4px);
}
.hint { margin-top: 14px; font-size: 13px; color: rgba(255,255,255,0.6); }

/* Countdown */
#countdown-number {
    font-size: 140px; font-weight: 800; line-height: 1;
    color: var(--gold);
    text-shadow: 0 0 60px var(--gold-glow);
    animation: cd-pop 0.6s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes cd-pop {
    0%   { transform: scale(2.5); opacity: 0; filter: blur(8px); }
    60%  { transform: scale(0.95); opacity: 1; filter: blur(0); }
    100% { transform: scale(1); opacity: 1; }
}
.pose-label {
    font-size: 16px; font-weight: 600;
    background: rgba(0,0,0,0.35); backdrop-filter: blur(6px);
    display: inline-block; padding: 6px 20px; border-radius: 100px;
    color: var(--gold);
}

/* Pose dots */
.pose-dots { display: flex; gap: 10px; justify-content: center; }
.dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: rgba(255,255,255,0.3);
    transition: all 0.3s;
}
.dot.active { background: var(--gold); box-shadow: 0 0 8px var(--gold-glow); transform: scale(1.3); }
.dot.done   { background: var(--success); }

/* Flash */
.flash-white { background: #fff; z-index: 50; }

/* Preview shot */
.shot-ok   { font-size: 64px; animation: cd-pop 0.4s ease both; }
.shot-text { font-size: 28px; font-weight: 700; color: #fff; margin-top: 8px; text-shadow: 0 2px 12px rgba(0,0,0,0.6); }

/* =============================================
   PANEL: PROCESSING
   ============================================= */
#panel-processing { background: var(--bg); }
#panel-processing .glass-card { text-align: center; width: 100%; }

.spinner {
    width: 44px; height: 44px;
    border: 4px solid rgba(255,215,0,0.15);
    border-top-color: var(--gold);
    border-radius: 50%;
    margin: 0 auto 20px;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.progress-track {
    width: 100%; height: 5px;
    background: rgba(255,255,255,0.08);
    border-radius: 10px; margin-top: 20px; overflow: hidden;
}
.progress-fill {
    height: 100%; width: 0%;
    background: var(--gold);
    border-radius: 10px;
    transition: width 0.4s ease;
}

/* =============================================
   PANEL: RESULT
   ============================================= */
#panel-result { background: var(--bg); }
.result-header { padding: 20px 24px; text-align: center; }

.result-body {
    flex: 1; display: flex;
    justify-content: center; align-items: center;
    overflow: hidden; padding: 0 20px;
}
.strip-frame {
    max-height: 65vh; width: 100%;
    display: flex; justify-content: center; align-items: center;
}
#result-canvas {
    max-width: 100%; max-height: 100%;
    border-radius: var(--radius-sm);
    box-shadow: 0 12px 48px rgba(0,0,0,0.5);
    animation: result-in 0.6s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes result-in {
    0%   { transform: scale(0.8) translateY(40px); opacity: 0; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

.result-footer {
    margin: 16px 20px calc(20px + var(--safe-b));
    display: flex; flex-direction: column; gap: 10px;
}

/* =============================================
   PANEL: EDITOR
   ============================================= */
#panel-editor { background: var(--bg-deep); }
.editor-header { padding: 14px 20px; background: var(--bg); border-bottom: 1px solid var(--border-card); }

.editor-body {
    flex: 1; overflow: auto;
    display: flex; justify-content: center; align-items: flex-start;
    padding: 16px;
}
#fabric-wrapper {
    width: 100%;
    display: flex; justify-content: center;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #111;
}
#fabric-wrapper canvas { display: block; }

.editor-footer {
    border-radius: var(--radius) var(--radius) 0 0;
    padding-bottom: calc(20px + var(--safe-b));
}
.editor-row { display: flex; gap: 8px; margin-bottom: 8px; }
.editor-row .btn { flex: 1; }

#editor-msg {
    min-height: 20px; margin-top: 4px;
    font-size: 12px; text-align: center; color: var(--success);
}
.link-back {
    display: block; text-align: center; margin-top: 10px;
    font-size: 13px; color: var(--gold); text-decoration: none;
}
