/* 3D Virtual Try-On: full-screen camera filter (js/tryon3d.js). */

.t3-root {
    position: fixed; inset: 0; z-index: 100;
    background: #000; color: #fff; overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}
.t3-root button { font-family: inherit; cursor: pointer; }

/* Camera and 3D glasses: identical size and crop, so the glasses line up with the face */
.t3-video, .t3-canvas {
    position: absolute; inset: 0; width: 100%; height: 100%;
    object-fit: cover; pointer-events: none;
}
.t3-mirror .t3-video, .t3-mirror .t3-canvas { transform: scaleX(-1); }
.t3-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.t3-flash.go { animation: t3-flash 0.45s ease-out; }
@keyframes t3-flash { from { opacity: 0.8; } to { opacity: 0; } }

/* Top bar */
.t3-top {
    position: absolute; left: 0; right: 0; top: 0;
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
    background: linear-gradient(rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0));
}
.t3-icon {
    width: 40px; height: 40px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    border: none; border-radius: 50%;
    background: rgba(20, 16, 40, 0.5); color: #fff;
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.t3-icon svg { width: 20px; height: 20px; }
.t3-icon.dark { background: var(--surface-alt, #F2F0FB); color: var(--ink, #1B1730); backdrop-filter: none; }
.t3-icon:active, .t3-chip:active { transform: scale(0.94); }
.t3-chip {
    min-width: 0; padding: 8px 12px; border: none; border-radius: 999px;
    background: rgba(20, 16, 40, 0.5); color: #fff;
    font-size: 12.5px; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.t3-chip.ready { background: linear-gradient(120deg, #3E7BFA, #8B3FF0); }

/* Centre message (and "Try again" when something failed) */
.t3-center {
    position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%);
    width: calc(100% - 48px); max-width: 420px;
    display: flex; flex-direction: column; align-items: center; gap: 12px;
    pointer-events: none;
}
.t3-status {
    margin: 0; padding: 12px 16px;
    border-radius: 16px; background: rgba(20, 16, 40, 0.6);
    font-size: 14px; font-weight: 600; text-align: center; line-height: 1.4;
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.t3-status[hidden], .t3-retry[hidden], .t3-product[hidden] { display: none; }
.t3-retry {
    pointer-events: auto;
    padding: 12px 24px; border: none; border-radius: 999px;
    background: #fff; color: #3B2A7A; font-size: 14px; font-weight: 700;
}
.t3-retry:active { transform: scale(0.96); }
.t3-failed .t3-bottom { display: none; }

/* Bottom controls */
.t3-bottom {
    position: absolute; left: 0; right: 0; bottom: 0;
    display: flex; flex-direction: column; gap: 8px;
    padding: 32px 0 12px; padding-bottom: max(12px, env(safe-area-inset-bottom));
    background: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.6) 40%);
}
.t3-bottom > * { width: 100%; max-width: 640px; margin: 0 auto; }

.t3-product {
    display: flex; align-items: center; gap: 12px;
    width: calc(100% - 32px); padding: 8px 8px 8px 16px;
    border-radius: 16px; background: rgba(20, 16, 40, 0.55);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.t3-product-text { flex: 1; min-width: 0; }
.t3-product-name { margin: 0; font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t3-product-sub { margin: 0; font-size: 12px; color: rgba(255, 255, 255, 0.75); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t3-book {
    flex-shrink: 0; padding: 8px 16px; border: none; border-radius: 999px;
    background: linear-gradient(120deg, #3E7BFA, #8B3FF0); color: #fff;
    font-size: 13px; font-weight: 700;
}
.t3-book:active { transform: scale(0.96); }

.t3-row, .t3-carousel {
    display: flex; gap: 8px; overflow-x: auto; padding: 0 16px;
    scrollbar-width: none;
}
.t3-row::-webkit-scrollbar, .t3-carousel::-webkit-scrollbar { display: none; }
.t3-swatch-btn {
    flex-shrink: 0; display: inline-flex; align-items: center; gap: 8px;
    padding: 4px 12px 4px 4px; border: 1.5px solid transparent; border-radius: 999px;
    background: rgba(20, 16, 40, 0.5); color: #fff;
    font-size: 12.5px; font-weight: 600;
}
.t3-swatch-btn.active { border-color: #fff; background: rgba(255, 255, 255, 0.2); }
.t3-swatch { width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid rgba(255, 255, 255, 0.7); }

.t3-carousel { padding-top: 4px; padding-bottom: 4px; }
.t3-style {
    position: relative; flex-shrink: 0; width: 88px;
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 8px 4px; border: 2px solid transparent; border-radius: 16px;
    background: rgba(20, 16, 40, 0.5); color: #fff;
    font-size: 12px; font-weight: 600;
}
.t3-style svg { width: 64px; height: 24px; }
.t3-style.active { border-color: #fff; background: rgba(255, 255, 255, 0.22); }
.t3-style em {
    position: absolute; top: -4px; right: -4px;
    padding: 2px 8px; border-radius: 999px;
    background: #1FAA59; color: #fff; font-style: normal; font-size: 10px; font-weight: 700;
}

.t3-controls { display: flex; align-items: center; justify-content: space-between; padding: 4px 24px 0; }
.t3-shutter {
    width: 72px; height: 72px; border-radius: 50%;
    border: 4px solid #fff; background: rgba(255, 255, 255, 0.25);
    box-shadow: inset 0 0 0 4px rgba(0, 0, 0, 0.25);
}
.t3-shutter::after { content: ''; display: block; width: 52px; height: 52px; margin: auto; border-radius: 50%; background: #fff; }
.t3-shutter:active { transform: scale(0.92); }
.t3-gallery, .t3-gallery-spacer { width: 48px; height: 48px; flex-shrink: 0; }
.t3-gallery {
    position: relative; padding: 0; overflow: visible;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid #fff; border-radius: 12px;
    background: rgba(20, 16, 40, 0.5); color: #fff;
}
.t3-gallery svg { width: 20px; height: 20px; }
.t3-gallery img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; }
.t3-count {
    position: absolute; top: -8px; right: -8px;
    min-width: 20px; height: 20px; padding: 0 4px; border-radius: 999px;
    background: #8B3FF0; font-size: 11px; font-weight: 700; line-height: 20px; text-align: center;
}

/* Sheets: compare photos, face-shape guide */
.t3-sheet-wrap {
    position: absolute; inset: 0; z-index: 2;
    display: flex; align-items: flex-end; justify-content: center;
    background: rgba(20, 16, 40, 0.5);
}
.t3-sheet-wrap[hidden] { display: none; }
.t3-sheet {
    width: 100%; max-width: 640px; max-height: 88%; overflow-y: auto;
    padding: 20px 16px; padding-bottom: max(20px, env(safe-area-inset-bottom));
    border-radius: 20px 20px 0 0; background: var(--surface, #fff); color: var(--ink, #1B1730);
}
.t3-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.t3-sheet h2 { margin: 0; font-size: 17px; font-weight: 700; }
.t3-note { margin: 0 0 12px; font-size: 12.5px; color: var(--ink-soft, #4B4768); line-height: 1.45; }
.t3-lead { margin: 0 0 4px; font-size: 16px; }
.t3-label { margin: 16px 0 8px; font-size: 12px; font-weight: 700; letter-spacing: 0.04em; color: var(--muted, #8985A3); text-transform: uppercase; }
.t3-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.t3-compare figure { margin: 0; border: 1px solid var(--border, #E7E4F5); border-radius: 12px; overflow: hidden; }
.t3-compare img { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: cover; background: var(--surface-alt, #F2F0FB); }
.t3-compare figcaption { padding: 8px; font-size: 12px; line-height: 1.4; }
.t3-fig-actions { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 8px 8px; }
.t3-fig-actions button, .t3-text-btn {
    padding: 4px 8px; border: 1.5px solid var(--border, #E7E4F5); border-radius: 8px;
    background: var(--surface, #fff); color: var(--ink, #1B1730); font-size: 12px; font-weight: 600;
}
.t3-text-btn { padding: 8px 12px; }
.t3-suggest { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.t3-suggest button {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    width: 88px; padding: 8px 4px; border: 1.5px solid var(--border, #E7E4F5); border-radius: 12px;
    background: var(--surface-alt, #F2F0FB); color: var(--ink, #1B1730); font-size: 12px; font-weight: 600;
}
.t3-suggest svg { width: 64px; height: 24px; }

/* Laptops: sheets open in the middle */
@media (min-width: 700px) {
    .t3-sheet-wrap { align-items: center; padding: 24px; }
    .t3-sheet { border-radius: 20px; }
    .t3-compare { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
    .t3-flash.go { animation: none; }
}
