/* DEON Lens — full-screen live photo coach overlay.
   Mobile-first; also usable on mobile-browser desktop widths.
   v1.1 — single continuous gradient ring, bigger tips, no top chrome. */

.lens-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: #000;
    display: none;
    flex-direction: column;
    align-items: stretch;
    justify-content: stretch;
    color: #fff;
    font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    overscroll-behavior: contain;
    touch-action: none;
}

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

.lens-stage {
    position: relative;
    flex: 1 1 auto;
    width: 100%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
}

.lens-video {
    width: 100%;
    height: 100%;
    object-fit: cover;            /* fills any phone, adapts to aspect */
    background: #000;
    transform: scale(1);
    transform-origin: center center;
    transition: transform 0.05s linear;
    -webkit-user-select: none;
    user-select: none;
}

/* Register --c1 / --c2 as actual <color> custom properties so the
   browser natively interpolates between hex values when they change.
   Without @property, custom properties are treated as raw strings and
   the gradient would jump-cut between colours. */
@property --c1 {
    syntax: '<color>';
    inherits: false;
    initial-value: #3AAFD4;
}
@property --c2 {
    syntax: '<color>';
    inherits: false;
    initial-value: #5BC8E8;
}
/* --ring-glow is registered as a <color> too so the rgba glow can be
   smoothly interpolated alongside --c1/--c2. inherits:true lets the
   value set on body propagate down to .lens-shutter, which sits
   outside the .lens-frame subtree. */
@property --ring-glow {
    syntax: '<color>';
    inherits: true;
    initial-value: rgba(58, 175, 212, 0.55);
}

/* v3 ring: three brand buckets only — blue (warm-up), orange (NO),
   green (YES locked). Yellow is used only as a 200ms transition "via"
   stop on big jumps so the eye sees a clean amber pass instead of
   muddy brown lerp. */
.lens-frame {
    --c1: #3AAFD4;
    --c2: #5BC8E8;
    --ring-glow: rgba(58, 175, 212, 0.55);
    position: absolute;
    inset: calc(env(safe-area-inset-top, 8px) + 60px) 22px 120px 22px;
    border-radius: 28px;
    pointer-events: none;
    padding: 3px;
    background: linear-gradient(135deg, var(--c1) 0%, var(--c2) 100%);
    -webkit-mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
            mask-composite: exclude;
    transition: --c1 0.55s ease, --c2 0.55s ease, --ring-glow 0.55s ease, filter 0.45s ease;
    filter: drop-shadow(0 0 16px var(--ring-glow));
    will-change: filter;
}

/* Single ~600ms "lock" breath when the AI confirms YES three frames
   in a row. Subtle scale + soft cyan inner glow. */
.lens-frame.lens-lock-pulse {
    animation: lens-lock-breath 0.6s ease-out 1;
}
@keyframes lens-lock-breath {
    0%   { transform: scale(1.00); filter: drop-shadow(0 0 16px var(--ring-glow)); }
    45%  { transform: scale(1.04); filter: drop-shadow(0 0 28px rgba(58, 175, 212, 0.85)); }
    100% { transform: scale(1.00); filter: drop-shadow(0 0 16px var(--ring-glow)); }
}

/* v3.1 tip: ~1.2× larger (17→21px), colour tracks the ring via --c1,
   and cross-fades between updates via opacity transition. */
.lens-tip {
    position: absolute;
    left: 36px;
    right: 36px;
    bottom: 138px;
    text-align: center;
    font-size: 21px;
    font-weight: 800;
    line-height: 1.3;
    letter-spacing: 0.2px;
    color: #fff;
    text-shadow:
        0 1px 2px rgba(0, 0, 0, 0.95),
        0 2px 14px rgba(0, 0, 0, 0.7);
    padding: 0 8px;
    pointer-events: none;
    z-index: 3;
    transition: opacity 0.15s ease, color 0.45s ease;
}

/* Quota pill — sits inside the topbar, no longer absolutely placed.
   Unlimited / Enterprise / Admin get the brand cyan→violet gradient
   that matches .workspace-tier-badge[data-tier="unlimited"]. */
.lens-quota {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.85);
    background: rgba(0, 0, 0, 0.45);
    padding: 6px 12px;
    border-radius: 999px;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    pointer-events: none;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    transition: background 0.3s ease, box-shadow 0.3s ease, color 0.3s ease;
}

.lens-quota.unlimited,
.lens-quota[data-tier="unlimited"],
.lens-quota[data-tier="enterprise"],
.lens-quota[data-tier="admin"] {
    background: linear-gradient(135deg, #3AAFD4 0%, #8B5CF6 100%);
    color: #ffffff;
    box-shadow: 0 1px 4px rgba(139, 92, 246, 0.32);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    letter-spacing: 0.04em;
}

/* Top bar: just the close X (left) + quota pill (right). */
.lens-topbar {
    position: absolute;
    top: 0; left: 0; right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(env(safe-area-inset-top, 8px) + 10px) 14px 8px;
    z-index: 4;
    pointer-events: none;
    gap: 12px;
}
.lens-topbar > * { pointer-events: auto; }

/* Perfect circle, never stretched by flex. */
.lens-close {
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

/* v3.1: controls overlay the viewfinder instead of sitting in a
   separate bottom bar. The camera feed is now truly full-screen. */
.lens-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 14px 16px calc(env(safe-area-inset-bottom, 12px) + 18px);
    background: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    z-index: 5;
    pointer-events: none;
}
.lens-controls > * { pointer-events: auto; }

.lens-shutter-row {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    position: relative;
}

/* v3.1 shutter: subtle depth (radial gradient + inner shadow) so it
   reads as a physical button, not a flat white disc. Glow follows the
   live ring colour via the body-level --ring-glow CSS var. */
.lens-shutter {
    width: 84px;
    height: 84px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 36%, #ffffff 0%, #e8e8e8 80%, #d4d4d4 100%);
    border: 5px solid rgba(255, 255, 255, 0.45);
    cursor: pointer;
    /* --ring-glow is a registered <color> custom prop (see @property
       above) so it interpolates in sync with the ring's --c1/--c2
       gradient instead of jump-cutting when the colour changes. */
    transition: transform 0.1s ease, box-shadow 0.3s ease, --ring-glow 0.55s ease;
    box-shadow:
        inset 0 2px 4px rgba(255, 255, 255, 0.9),
        inset 0 -2px 6px rgba(0, 0, 0, 0.12),
        0 0 0 7px rgba(255, 255, 255, 0.06),
        0 0 22px var(--ring-glow, rgba(58, 175, 212, 0.55)),
        0 4px 12px rgba(0, 0, 0, 0.35);
}
.lens-shutter:active { transform: scale(0.94); }

/* While the review screen is open, hide the live shutter row + topbar
   so the captured photo + filter chips own the screen. */
body.lens-review-open .lens-shutter-row,
body.lens-review-open .lens-topbar {
    display: none !important;
}

/* "Still shooting?" idle modal. */
.lens-idle {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.78);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 20;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.lens-idle.open { display: flex; }
.lens-idle-card {
    background: #1a1a1c;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 18px;
    padding: 22px 22px 18px;
    text-align: center;
    max-width: 320px;
    width: calc(100% - 48px);
}
.lens-idle-title { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.lens-idle-sub {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.65);
    margin-bottom: 16px;
    line-height: 1.4;
}
.lens-idle-row { display: flex; gap: 10px; }
.lens-idle-btn {
    flex: 1;
    padding: 12px 0;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    font-family: inherit;
}
.lens-idle-btn.yes {
    background: linear-gradient(135deg, #3AAFD4, #8B5CF6);
    color: #fff;
}
.lens-idle-btn.no {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

/* Quota-spent / signup-required upgrade modal. */
.lens-upgrade {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.78);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.lens-upgrade.open { display: flex; }
.lens-upgrade-card {
    background: #1a1a1c;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 18px;
    padding: 24px;
    max-width: 360px;
    width: calc(100% - 48px);
    color: #fff;
    text-align: center;
}
.lens-upgrade-title { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.lens-upgrade-body {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 18px;
    line-height: 1.45;
}
.lens-upgrade-cta {
    display: inline-block;
    background: linear-gradient(135deg, #3AAFD4, #8B5CF6);
    color: #fff;
    padding: 12px 22px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 14px;
    text-decoration: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
}
.lens-upgrade-dismiss {
    display: block;
    margin-top: 12px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.55);
    font-size: 13px;
    cursor: pointer;
    margin-left: auto;
    margin-right: auto;
    font-family: inherit;
}

/* Capture preview / review screen — filters live HERE, not in live view. */
.lens-review {
    position: absolute;
    inset: 0;
    background: #000;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 30;
    padding: 16px;
}
.lens-review.open { display: flex; }
.lens-review-img {
    max-width: 100%;
    max-height: 62vh;
    border-radius: 12px;
    object-fit: contain;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
}

/* v3 post-capture filter strip — small glass chips with a coloured
   swatch dot, visually distinct from the larger Retake / Save CTAs. */
.lens-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 18px;
}
.lens-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 30px;
    padding: 0 12px 0 10px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: rgba(255, 255, 255, 0.82);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.2px;
    font-family: inherit;
    cursor: pointer;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: background 0.15s ease, border-color 0.15s ease,
                color 0.15s ease, box-shadow 0.2s ease;
}
.lens-filter-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}
.lens-filter-btn.active {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.45);
    color: #fff;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08);
}

/* Coloured swatch dot — one per filter mood. */
.lens-filter-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #f4f4f4;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3) inset;
    flex: 0 0 auto;
}
.lens-filter-btn[data-filter="natural"] .lens-filter-dot { background: #f5f5f5; }
.lens-filter-btn[data-filter="warm"]    .lens-filter-dot { background: #FFB458; }
.lens-filter-btn[data-filter="crisp"]   .lens-filter-dot { background: #5BC8E8; }
.lens-filter-btn[data-filter="moody"]   .lens-filter-dot { background: #6E5BD4; }

.lens-review-row {
    display: flex;
    gap: 12px;
    margin-top: 18px;
}
.lens-review-btn {
    padding: 13px 26px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.2px;
    cursor: pointer;
    border: none;
    font-family: inherit;
    transition: transform 0.1s ease, box-shadow 0.2s ease,
                background 0.2s ease, border-color 0.2s ease;
}
.lens-review-btn:active { transform: scale(0.97); }

/* Retake = ghost outline. Distinct from the gradient confirm. */
.lens-review-btn.retake {
    background: transparent;
    color: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.28);
}
.lens-review-btn.retake:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.45);
}

/* Confirm = brand cyan→violet pill with a soft outer glow that
   matches the workspace tier badge. */
.lens-review-btn.save {
    background: linear-gradient(135deg, #3AAFD4 0%, #8B5CF6 100%);
    color: #fff;
    box-shadow:
        0 4px 18px rgba(58, 175, 212, 0.35),
        0 2px 12px rgba(139, 92, 246, 0.35);
}
.lens-review-btn.save:hover {
    box-shadow:
        0 6px 22px rgba(58, 175, 212, 0.5),
        0 4px 16px rgba(139, 92, 246, 0.5);
}

.lens-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 13px;
    z-index: 10001;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.25s ease;
    pointer-events: none;
}
.lens-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (min-width: 720px) {
    .lens-frame { inset: 22px 18%; }
    /* Frame bottom inset is 22px here, so anchor the tip ~18px inside
       the frame's bottom edge (matches the visual "hug bottom" we
       have on mobile). Horizontal insets match the frame plus a small
       inner padding so the text doesn't kiss the orange border. */
    .lens-tip { left: calc(18% + 14px); right: calc(18% + 14px); bottom: 40px; }
}

/* ───────────────────────────────────────────────────────────────────
   Anonymous signup teaser — 5-second muted preview.
   ───────────────────────────────────────────────────────────────── */
.lens-teaser {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 10001;
    display: none;
    flex-direction: column;
    align-items: stretch;
    justify-content: space-between;
    padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
.lens-teaser.open { display: flex; }
.lens-teaser-close {
    position: absolute;
    top: calc(env(safe-area-inset-top) + 12px);
    right: 14px;
    width: 36px;
    height: 36px;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2;
    padding: 0;
}
.lens-teaser-stage {
    position: relative;
    flex: 1;
    overflow: hidden;
}
.lens-teaser-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
}
.lens-teaser-frame {
    position: absolute;
    /* Match the live frame: pull the gradient rectangle inward so it
       doesn't touch the top-right "Preview" label or the close X. */
    inset: calc(env(safe-area-inset-top, 8px) + 56px) 22px 96px 22px;
    border-radius: 28px;
    pointer-events: none;
    padding: 3px;
    background: linear-gradient(135deg, #22d3ee 0%, #8b5cf6 100%);
    -webkit-mask:
        linear-gradient(#000 0 0) content-box,
        linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
            mask-composite: exclude;
    transition: opacity 0.25s ease;
}
.lens-teaser-video {
    transition: filter 0.45s ease;
}
.lens-teaser.paywall .lens-teaser-video {
    filter: blur(18px) saturate(0.9) brightness(0.7);
}
.lens-teaser.paywall .lens-teaser-frame {
    opacity: 0;
}
.lens-teaser-paywall {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 6;
    padding: 28px;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    animation: lens-paywall-fade 0.35s ease both;
}
.lens-teaser.paywall .lens-teaser-paywall { display: flex; }
@keyframes lens-paywall-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.lens-teaser-paywall-card {
    position: relative;
    width: 100%;
    max-width: 360px;
    background: rgba(20, 20, 22, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    padding: 22px 22px 18px;
    text-align: center;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.55);
    color: #fff;
}
.lens-teaser-paywall-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    z-index: 2;
}
.lens-teaser-paywall-close:hover {
    background: rgba(255, 255, 255, 0.16);
}
.lens-teaser-paywall-title {
    font-size: 19px;
    font-weight: 700;
    margin-bottom: 8px;
}
.lens-teaser-paywall-sub {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.78);
    line-height: 1.45;
    margin-bottom: 18px;
}
.lens-teaser-secondary {
    margin-top: 10px;
    width: 100%;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #fff;
    padding: 12px 18px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.lens-teaser-label {
    position: absolute;
    top: calc(env(safe-area-inset-top) + 14px);
    left: 22px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #fff;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.18);
    padding: 5px 10px;
    border-radius: 999px;
}
.lens-teaser-cta-wrap {
    display: none;
}
.lens-teaser-tag { color: #fff; font-size: 14px; text-align: center; opacity: 0.92; }
.lens-teaser-cta {
    width: 100%;
    max-width: 360px;
    padding: 14px 18px;
    border: 0;
    border-radius: 14px;
    background: linear-gradient(135deg, #22d3ee 0%, #8b5cf6 100%);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 24px rgba(139, 92, 246, 0.35);
}

/* Hide the mobile bottom tab bar (Home / Chat / Workspace / Profile)
   while DEON Lens is open so the camera owns the whole screen. */
body.lens-active .mobile-bottom-tabs,
body.lens-active #mobileBottomTabs {
    display: none !important;
}
