/* ================================================
   GEMDISTRICT AR — style.css
   ================================================ */

:root {
    --gold:       #D4AF37;
    --gold-light: #F4E8C1;
    --gold-dark:  #B8941F;
    --black:      #0a0a0a;
    --black-light:#1a1a1a;
    --white:      #ffffff;
    --gray:       #888888;
    --success:    #00C853;
    --error:      #FF1744;
}

*, *::before, *::after {
    margin: 0; padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--black);
    color: var(--white);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    position: fixed;
}

/* ── Loading Screen ──────────────────────────── */
#loader {
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at center, #1a1a1a 0%, #000 100%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity .6s ease, visibility .6s ease;
}
#loader.hidden { opacity: 0; visibility: hidden; }

.loader-content { text-align: center; padding: 2rem; }

.loader-logo {
    font-family: 'Playfair Display', serif;
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 50%, var(--gold) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: .2em;
    margin-bottom: 1rem;
}

.loader-subtitle {
    color: var(--gray);
    font-size: .9rem;
    letter-spacing: .3em;
    text-transform: uppercase;
    margin-bottom: 3rem;
}

.progress-container {
    width: 280px; height: 2px;
    background: rgba(212,175,55,.2);
    border-radius: 2px;
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--gold), var(--gold-light));
    width: 0%;
    transition: width .3s ease;
    box-shadow: 0 0 20px rgba(212,175,55,.5);
}
.loader-status { margin-top: 1.5rem; font-size: .85rem; color: var(--gray); font-weight: 300; }

.spinner {
    width: 60px; height: 60px;
    border: 2px solid rgba(212,175,55,.1);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 2rem;
    position: relative;
}
.spinner::after {
    content: '';
    position: absolute;
    inset: -5px;
    border: 2px solid transparent;
    border-top-color: rgba(212,175,55,.3);
    border-radius: 50%;
    animation: spin 2s linear infinite reverse;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── App ─────────────────────────────────────── */
#app {
    position: relative;
    width: 100%; height: 100%;
    opacity: 0;
    transition: opacity .6s ease;
}
#app.active { opacity: 1; }

/* ── Video & Canvas ──────────────────────────── */
#video {
    position: absolute;
    inset: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
    z-index: 1;
}
#canvas-container {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
}

/* ─────────────────────────────────────────────────────────────────────────────
   HAMBURGER — top-LEFT corner, always clear of everything else
   ───────────────────────────────────────────────────────────────────────── */
.hamburger-btn {
    position: absolute;
    top: 1.2rem;
    left: 1.2rem;
    z-index: 30;
    background: rgba(0,0,0,.65);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(212,175,55,.35);
    border-radius: 50%;
    width: 44px; height: 44px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
    transition: all .3s ease;
    pointer-events: auto;
}
.hamburger-btn:hover,
.hamburger-btn:active { border-color: var(--gold); background: rgba(212,175,55,.18); }

.hamburger-btn span {
    display: block;
    width: 18px; height: 2px;
    background: var(--gold);
    border-radius: 2px;
    transition: all .3s ease;
}
.hamburger-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger-btn.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── CAMERA SWITCH — bottom-right, floating above the controls panel ─────── */
.camera-switch-btn {
    position: absolute;
    bottom: 230px;
    right: 1rem;
    z-index: 30;
    background: rgba(0,0,0,.65);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(212,175,55,.35);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    cursor: pointer;
    color: var(--gold);
    transition: all .3s ease;
    pointer-events: auto;
    -webkit-user-select: none;
    user-select: none;
}
.camera-switch-btn:hover,
.camera-switch-btn:active {
    border-color: var(--gold);
    background: rgba(212,175,55,.18);
}
.camera-switch-btn svg { display: block; }
.camera-switch-btn .cam-label {
    font-size: 7px;
    letter-spacing: .03em;
    text-transform: uppercase;
    color: rgba(212,175,55,.85);
    font-weight: 600;
    line-height: 1;
}
@media (max-width: 480px) {
    .camera-switch-btn { bottom: 280px; }
}

/* ── UI Layer ────────────────────────────────── */
.ui-layer {
    position: absolute;
    z-index: 10;
    pointer-events: none;
    width: 100%; height: 100%;
    inset: 0;
    transition: opacity .4s ease;
}
.ui-layer.hidden { opacity: 0; pointer-events: none !important; }
.ui-layer.hidden * { pointer-events: none !important; }

/* ── Header — brand (left, offset past hamburger) + status (right) ─────── */
.header {
    position: absolute;
    top: 0; left: 0; right: 0;
    /* left padding ensures brand never overlaps hamburger btn */
    padding: 1rem 1rem 1rem 4.6rem;
    background: linear-gradient(to bottom, rgba(0,0,0,.8) 0%, transparent 100%);
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: auto;
}

.brand {
    font-family: 'Playfair Display', serif;
    font-size: 1.4rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: .1em;
}

/* Status pill — camera switch is gone from here */
.status-pill {
    background: rgba(0,0,0,.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(212,175,55,.3);
    border-radius: 20px;
    padding: .45rem .9rem;
    display: flex;
    align-items: center;
    gap: .45rem;
    font-size: .72rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .05em;
}
.status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--gray);
    transition: all .3s ease;
    flex-shrink: 0;
}
.status-dot.active    { background: var(--success); box-shadow: 0 0 10px var(--success); }
.status-dot.detecting {
    background: var(--gold);
    box-shadow: 0 0 10px var(--gold);
    animation: pulse 1.5s infinite;
}
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:.4; } }

/* ── Guide Overlay ───────────────────────────── */
.guide-overlay {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%,-50%);
    width: 280px; height: 280px;
    border: 2px dashed rgba(212,175,55,.3);
    border-radius: 50%;
    pointer-events: none;
    opacity: 0;
    transition: opacity .3s ease;
}
.guide-overlay.visible { opacity: 1; }
.guide-overlay::before {
    content: '';
    position: absolute;
    inset: 20px;
    border: 1px solid rgba(212,175,55,.2);
    border-radius: 50%;
}
.guide-text {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%,-50%);
    text-align: center;
    font-size: .85rem;
    color: rgba(255,255,255,.8);
    font-weight: 300;
    letter-spacing: .1em;
    text-transform: uppercase;
    white-space: nowrap;
}

/* ── Instructions Toast ──────────────────────── */
.instruction-toast {
    position: absolute;
    top: 80px; left: 50%;
    transform: translateX(-50%) translateY(-14px);
    background: rgba(0,0,0,.82);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(212,175,55,.3);
    border-radius: 30px;
    padding: .85rem 1.8rem;
    font-size: .88rem;
    color: var(--white);
    opacity: 0;
    transition: all .3s ease;
    pointer-events: none;
    white-space: nowrap;
    z-index: 20;
    max-width: 75vw;
    text-align: center;
}
.instruction-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── Gallery Preview ─────────────────────────── */
/* Sits top-right but shifted left enough to never overlap the camera btn */
.gallery-corner {
    position: absolute;
    top: 72px;
    right: 4.6rem;           /* clears the 52px camera-switch-btn + margin */
    width: 68px; height: 68px;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid rgba(212,175,55,.35);
    opacity: 0;
    transform: scale(.8);
    transition: all .3s ease;
    cursor: pointer;
    pointer-events: auto;
    background: rgba(0,0,0,.5);
}
.gallery-corner.visible { opacity: 1; transform: scale(1); }
.gallery-corner img { width: 100%; height: 100%; object-fit: cover; }

/* ── Controls Panel ──────────────────────────── */
.controls {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: linear-gradient(to top, rgba(0,0,0,.96) 0%, rgba(0,0,0,.72) 60%, transparent 100%);
    padding: 1.5rem 1.2rem 2.2rem;
    pointer-events: auto;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

/* ── Category Tabs ───────────────────────────── */
.category-tabs {
    display: flex;
    gap: .75rem;
    margin-bottom: 1.2rem;
    justify-content: center;
}
.tab {
    background: rgba(255,255,255,.05);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 30px;
    padding: .65rem 1.2rem;
    color: var(--gray);
    font-size: .82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .3s ease;
    display: flex;
    align-items: center;
    gap: .45rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    white-space: nowrap;
}
.tab:hover { background: rgba(212,175,55,.1); border-color: rgba(212,175,55,.3); color: var(--white); }
.tab.active { background: rgba(212,175,55,.2); border-color: var(--gold); color: var(--gold); box-shadow: 0 0 20px rgba(212,175,55,.2); }
.tab-icon { font-size: 1.1rem; }

/* ── Jewelry Grid ────────────────────────────── */
.jewelry-section { display: none; }
.jewelry-section.active { display: block; }

.jewelry-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: .85rem;
    margin-bottom: 1.2rem;
    max-width: 560px;
    margin-left: auto;
    margin-right: auto;
}
.jewelry-item {
    aspect-ratio: 1;
    background: rgba(255,255,255,.03);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    cursor: pointer;
    transition: all .3s ease;
    position: relative;
    overflow: hidden;
}
.jewelry-item::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, rgba(212,175,55,.1) 0%, transparent 70%);
    opacity: 0;
    transition: opacity .3s ease;
}
.jewelry-item:hover  { transform: translateY(-2px); border-color: rgba(212,175,55,.3); }
.jewelry-item.active { background: rgba(212,175,55,.1); border-color: var(--gold); box-shadow: 0 0 28px rgba(212,175,55,.15); }
.jewelry-item.active::before { opacity: 1; }

.jewelry-preview {
    width: 44px; height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    z-index: 1;
}
.jewelry-preview img {
    width: 100%; height: 100%;
    object-fit: cover;
    border-radius: 50%;
}
.jewelry-preview .emoji-placeholder { font-size: 1.4rem; }

.jewelry-name {
    font-size: .68rem;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: .05em;
    font-weight: 500;
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 0 .2rem;
}
.jewelry-item.active .jewelry-name { color: var(--gold); }

/* gem colour swatches */
.gem-emerald  { background: linear-gradient(135deg, #50C878, #228B22); }
.gem-ruby     { background: linear-gradient(135deg, #E0115F, #8B0000); }
.gem-sapphire { background: linear-gradient(135deg, #0F52BA, #00008B); }
.gem-diamond  { background: linear-gradient(135deg, #E0F7FA, #B2EBF2); }
.gem-amethyst { background: linear-gradient(135deg, #9966CC, #663399); }
.gem-topaz    { background: linear-gradient(135deg, #FFD700, #FFA500); }
.gem-gold     { background: linear-gradient(135deg, #FFD700, #B8860B); }
.gem-custom   { background: linear-gradient(135deg, #888, #333); }

/* ── Action Buttons ──────────────────────────── */
.action-bar {
    display: flex;
    gap: .85rem;
    max-width: 560px;
    margin: 0 auto;
}
.btn {
    flex: 1;
    padding: .9rem 1.2rem;
    border: none;
    border-radius: 12px;
    font-family: 'Inter', sans-serif;
    font-size: .88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .3s ease;
    text-transform: uppercase;
    letter-spacing: .05em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
}
.btn-primary {
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
    color: var(--black);
    box-shadow: 0 4px 18px rgba(212,175,55,.3);
}
.btn-primary:hover  { transform: translateY(-2px); box-shadow: 0 6px 28px rgba(212,175,55,.4); }
.btn-secondary {
    background: rgba(255,255,255,.1);
    color: var(--white);
    border: 1px solid rgba(255,255,255,.2);
}
.btn-secondary:hover { background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.3); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }

/* ── Flash ───────────────────────────────────── */
.flash {
    position: fixed;
    inset: 0;
    background: white;
    opacity: 0;
    pointer-events: none;
    z-index: 9998;
    transition: opacity .3s ease;
}
.flash.active { opacity: 1; transition: opacity .1s ease; }

/* ── Responsive ──────────────────────────────── */
@media (max-width: 480px) {
    .jewelry-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: .65rem;
    }
    .category-tabs { gap: .4rem; }
    .tab { padding: .55rem .85rem; font-size: .72rem; }
    .action-bar { flex-direction: column; }
    .loader-logo { font-size: 2rem; }
    .brand { font-size: 1.1rem; }

    /* keep camera btn right-center, tighter on small screens */
    .camera-switch-btn { right: .6rem; width: 48px; }
    .gallery-corner    { right: 4.2rem; }
}

@media (min-width: 768px) {
    .jewelry-grid { grid-template-columns: repeat(6, 1fr); }

    /* on wider screens, move camera btn to top-right header area */
    .camera-switch-btn {
        top: .8rem;
        right: 1rem;
        transform: none;
        border-radius: 50%;
        min-height: 44px;
        width: 44px;
        height: 44px;
    }
    .camera-switch-btn:hover,
    .camera-switch-btn:active { transform: scale(1.08); }
    .camera-switch-btn .cam-label { display: none; } /* hide label on desktop */

    .gallery-corner { right: 4rem; top: 76px; }
}

/* safe-area / notch support */
@supports (padding: max(0px)) {
    .controls {
        padding-bottom: max(2.2rem, env(safe-area-inset-bottom));
    }
    .hamburger-btn {
        top: max(1.2rem, env(safe-area-inset-top));
        left: max(1.2rem, env(safe-area-inset-left));
    }
}
