/* ===== SCALABILITY & TOKENS ===== */
:root {
    /* Design Tokens */
    --color-bg: #FFFFFF;
    --color-bg-subtle: #F9F9F9;
    --color-text: #111111;
    --color-text-muted: #666666;
    --color-border: #E5E5E5;
    
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-serif: 'Playfair Display', serif;
    
    --navbar-height: 64px;
}

/* ===== DARK MODE ===== */
[data-theme="dark"] {
    --color-bg: #111111;
    --color-bg-subtle: #1a1a1a;
    --color-text: #f5f5f5;
    --color-text-muted: #999999;
    --color-border: #333333;
}

[data-theme="dark"] .navbar {
    background: rgba(17, 17, 17, 0.9);
}

[data-theme="dark"] .logo-img {
    filter: invert(1);
}

[data-theme="dark"] .site-footer {
    background: #0a0a0a;
}

[data-theme="dark"] #lang-btn {
    color: #f5f5f5;
}

/* Reset & Base */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background-color: var(--color-bg);
    color: var(--color-text);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    animation: page-fade-in 0.4s ease-in-out;
}

/* ===== NAVIGATION (Sticky) ===== */
.navbar {
    position: sticky;
    top: 0;
    height: var(--navbar-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--color-border);
    z-index: 1000;
}

.nav-right {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    position: relative;
}

.cart-count-bubble {
    position: absolute;
    top: -4px;
    right: -4px;
    background-color: var(--color-text);
    color: var(--color-bg);
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* ===== MOBILE MENU OVERLAY ===== */
.mobile-menu-overlay {
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    width: 100%;
    height: calc(100dvh - var(--navbar-height));
    background: var(--color-bg);
    transform: translateX(100%);
    transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
    z-index: 999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.mobile-menu-overlay.active {
    transform: translateX(0);
}

.mobile-nav {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.mobile-link {
    font-size: 2rem;
    text-decoration: none;
    color: var(--color-text);
    margin: 1rem 0;
    font-weight: 500;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.mobile-menu-overlay.active .mobile-link {
    opacity: 1;
    transform: translateY(0);
}

.mobile-menu-overlay.active .mobile-link:nth-child(1) { transition-delay: 0.1s; }
.mobile-menu-overlay.active .mobile-link:nth-child(2) { transition-delay: 0.15s; }
.mobile-menu-overlay.active .mobile-link:nth-child(3) { transition-delay: 0.2s; }
.mobile-menu-overlay.active .mobile-link:nth-child(4) { transition-delay: 0.25s; }

/* ===== PRODUCT LAYOUT (Mobile First) ===== */
.product-layout {
    display: flex;
    flex-direction: column;
    min-height: calc(100dvh - var(--navbar-height));
}

.viewer-column {
    height: 62.5svh;
    width: 100%;
    background: var(--color-bg-subtle);
    position: relative;
    overflow: hidden;
}

model-viewer {
    width: 100%;
    height: 100%;
    cursor: grab;
    --poster-color: transparent;
    transition: transform 0.4s ease, opacity 0.4s ease;
}

model-viewer:active {
    cursor: grabbing;
}

/* Carousel Controls */
.carousel-controls {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    transform: translateY(-50%);
    display: flex;
    justify-content: space-between;
    padding: 0 1rem;
    pointer-events: none; /* Allows clicks to pass through to the 3D model */
    z-index: 10;
}

.carousel-btn {
    pointer-events: auto; /* Re-enables clicks for the buttons */
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid var(--color-border);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all 0.2s ease; color: var(--color-text);
}
.carousel-btn:hover { transform: scale(1.1); background: #FFFFFF; box-shadow: 0 4px 12px rgba(0,0,0,0.1); }

.details-column {
    flex: 1;
    padding: 2rem 1.5rem 6rem;
    background: var(--color-bg);
    border-top: 1px solid var(--color-border);
}

.details-content {
    transition: opacity 0.3s ease, transform 0.3s ease;
    opacity: 1;
    transform: translateY(0);
}

.details-content.fade-out {
    opacity: 0;
    transform: translateY(10px);
}

/* ===== MODEL LOADER ===== */
.model-loader {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.model-spinner {
    width: 32px;
    height: 32px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-text);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== VIEWER ANIMATIONS ===== */
.viewer-exit-left {
    transform: translateX(-100px);
    opacity: 0;
}

.viewer-exit-right {
    transform: translateX(100px);
    opacity: 0;
}

.viewer-enter-right {
    transform: translateX(100px);
    opacity: 0;
    transition: none !important;
}

.viewer-enter-left {
    transform: translateX(-100px);
    opacity: 0;
    transition: none !important;
}

/* Typography & Components */
.product-category { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.1em; color: #888; margin-bottom: 0.5rem; display: block; }
.product-title { font-family: var(--font-serif); font-size: 2rem; margin-bottom: 0.5rem; line-height: 1.1; }
.product-author { font-size: 1.1rem; color: var(--color-text-muted); margin-bottom: 1rem; font-style: italic; }
.product-price-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--color-border); }
.price { font-size: 1.5rem; font-weight: 500; }
.stock-status { font-size: 0.75rem; color: #2E7D32; background: #E8F5E9; padding: 4px 8px; border-radius: 4px; text-transform: uppercase; letter-spacing: 0.05em; }
.stock-status.out-of-stock { color: #C62828; background: #FFEBEE; }
.product-description { font-size: 1rem; line-height: 1.6; color: var(--color-text-muted); margin-bottom: 2rem; }

.specs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 2rem; }
.spec-label { font-size: 0.75rem; text-transform: uppercase; color: #888; margin-bottom: 0.25rem; }
.spec-value { font-weight: 500; }

.action-area {
    /* Changed to a floating container for the FAB */
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 900;
}
.btn-primary { 
    width: 100%; 
    padding: 1rem; 
    background: var(--color-text); 
    color: var(--color-bg); 
    border: none; 
    font-size: 0.875rem; 
    text-transform: uppercase; 
    letter-spacing: 0.05em; 
    cursor: pointer; 
    transition: all 0.2s; /* Changed to all for transform */
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-primary:hover { opacity: 0.9; }
.full-width { width: 100%; }

/* FAB styles for Add to Cart on mobile */
.btn-add-to-cart {
    width: 60px;
    height: 60px;
    padding: 0;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.btn-add-to-cart .btn-text { display: none; }
.btn-add-to-cart .btn-icon { display: inline-flex; }
.btn-icon { display: none; }

/* Product page photo / video — mobile base styles */
#product-photo-wrap,
#product-video-wrap {
    width: 100%;
    margin-top: 1.5rem;
}

#product-photo {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    display: block;
}

#product-video {
    width: 100%;
    aspect-ratio: 4 / 3;
    display: block;
    object-fit: cover;
    filter: grayscale(100%);
}

/* ===== DESKTOP SCALING (Min-Width) ===== */
@media (min-width: 1024px) {
    .navbar { padding: 0 3rem; }
    .product-layout { 
        display: grid; 
        grid-template-columns: 1.5fr 1fr; 
        height: calc(100dvh - var(--navbar-height)); 
        min-height: auto;
    }
    .viewer-column { height: 100%; }
    .details-column { border-top: none; border-left: 1px solid var(--color-border); padding: 4rem; overflow-y: auto; display: flex; flex-direction: column; justify-content: flex-start; }
    .details-content { max-width: 480px; margin: 0 auto; width: 100%; }
    #product-photo-wrap { flex: 1; min-height: 0; margin-top: 0; margin-left: -4rem; margin-right: -4rem; margin-bottom: -4rem; }
    #product-photo { width: 100%; height: 100%; object-fit: cover; display: block; }
    #product-video-wrap { flex: 1; min-height: 0; margin-top: 0; margin-left: -4rem; margin-right: -4rem; margin-bottom: -4rem; }
    #product-video { width: 100%; height: 100%; display: block; object-fit: cover; filter: grayscale(100%); }
    
    /* Reset action area and button for desktop */
    .action-area {
        position: static;
        padding: 0;
        border-top: none;
        width: 100%;
        max-width: 480px;
        margin: 1.5rem auto;
        bottom: auto;
        right: auto;
    }
    .btn-add-to-cart {
        width: 100%; height: auto; padding: 1rem; border-radius: 0; box-shadow: none;
    }
    .btn-add-to-cart .btn-text { display: inline; }
    .btn-add-to-cart .btn-icon { display: none; }

    .product-title { font-size: 3rem; }
}

/* ===== HOME STAGE (video grid layout) ===== */

/* Mobile: stack center elements, hide side panels */
.home-stage {
    display: flex;
    flex-direction: column;
    min-height: calc(100dvh - var(--navbar-height));
}

#home-video-1,
#home-video-2 {
    display: none;
}

.home-video-panel {
    overflow: hidden;
    background: #111;
    display: flex;
    flex-direction: column;
}

/* Photo panels follow the page theme */
#home-video-1,
#home-video-2 {
    background: var(--color-bg);
}

/* Invert photos in dark mode */
[data-theme="dark"] #home-video-1 img,
[data-theme="dark"] #home-video-2 img {
    filter: grayscale(100%) invert(1);
}

.home-video-panel video,
.home-video-panel img {
    flex: 1;
    min-height: 0;
    width: 100%;
    object-fit: cover;
    filter: grayscale(100%);
    transition: opacity 0.3s ease;
}

/* Hide native browser play button overlay on mobile */
.home-video-panel video::-webkit-media-controls,
.text-panel-bg-video::-webkit-media-controls {
    display: none !important;
}
.home-video-panel video::-webkit-media-controls-start-playback-button,
.text-panel-bg-video::-webkit-media-controls-start-playback-button {
    display: none !important;
}


.home-text-panel {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2.5rem 1.5rem;
    background: var(--color-bg);
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
}

/*
 * Two-layer overlay system:
 * ::before = solid cover (theme bg colour) — visible during loading, fades out when video plays
 * ::after  = dark tint — invisible during loading, fades in when video plays
 * The video itself is always visible so Chrome does not treat it as hidden and block autoplay.
 */
.home-text-panel::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--color-bg);
    z-index: 1;
    opacity: 1;
    transition: opacity 0.5s ease;
    pointer-events: none;
}

.home-text-panel::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1;
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
}

.home-text-panel.video-playing::before { opacity: 0; }
.home-text-panel.video-playing::after  { opacity: 1; }

/* Background video for mobile text panel */
.text-panel-bg-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: grayscale(100%);
    z-index: 0;
}

/* Text content floats above overlays */
.home-text-panel h1,
.home-text-panel p,
.home-text-panel .slider-container {
    position: relative;
    z-index: 2;
}

.home-text-panel h1 {
    font-family: var(--font-serif);
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    margin-bottom: 1rem;
    color: var(--color-text);
    transition: color 0.4s ease;
}

.home-text-panel p {
    margin-bottom: 1.5rem;
    line-height: 1.6;
    color: var(--color-text-muted);
    max-width: 480px;
    transition: color 0.4s ease;
}

/* Switch to white text once the dark tint is showing */
@media (max-width: 1023px) {
    .home-text-panel.video-playing h1 { color: #ffffff; }
    .home-text-panel.video-playing p  { color: rgba(255, 255, 255, 0.8); }
}

/*
 * Desktop: single flat CSS grid — photos left and right, text in centre.
 *
 *   col 1    | col 2    | col 3
 *   video-1  | text     | video-2   row 1 (1fr)
 */
@media (min-width: 1024px) {
    .home-stage {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
        grid-template-rows: 1fr;
        height: calc(100dvh - var(--navbar-height));
        min-height: auto;
    }

    #home-video-1 {
        display: flex;
        grid-column: 1;
        grid-row: 1;
    }

    #home-video-1 video {
        object-position: 30% 50%;
        transform: scale(1.15);
        transform-origin: center center;
    }

    .home-text-panel {
        grid-column: 2;
        grid-row: 1;
        flex: unset;
        padding: 2.5rem 2rem;
        border: none;
    }

    /* On desktop: hide the bg video and both overlays */
    .text-panel-bg-video { display: none; }
    .home-text-panel::before { display: none; }
    .home-text-panel::after  { display: none; }

    #home-video-2 {
        display: flex;
        grid-column: 3;
        grid-row: 1;
    }

}

/* ===== CONTENT PAGES (About, Contact, Account) ===== */
.content-page {
    padding: 6rem 1.5rem 2rem; /* Top padding accounts for navbar */
    max-width: 600px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.content-page h1 {
    font-family: var(--font-serif);
    font-size: 2.5rem;
    margin-bottom: 2rem;
    text-align: center;
    color: var(--color-text);
}

.content-page p {
    margin-bottom: 1.5rem;
    line-height: 1.6;
    color: var(--color-text-muted);
}

.form-group {
    margin-bottom: 1.5rem;
    width: 100%;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #888;
}

.form-input {
    width: 100%;
    padding: 1rem;
    border: 1px solid var(--color-border);
    font-family: var(--font-sans);
    font-size: 1rem;
    background: var(--color-bg-subtle);
    outline: none;
    transition: border-color 0.2s;
}

.form-input:focus {
    border-color: var(--color-text);
}

textarea.form-input {
    resize: vertical;
    min-height: 120px;
}

/* ===== INTERACTIVE SLIDER ===== */
.slider-container {
    position: relative;
    width: 100%;
    max-width: 300px;
    height: 56px;
    background: var(--color-text);
    border-radius: 28px;
    margin: 2rem auto 0;
    cursor: pointer;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none; /* Prevents scroll while sliding */
}

.slider-text {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    padding-left: 3rem;
    color: var(--color-bg);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    pointer-events: none;
    transition: opacity 0.2s;
}

.slider-thumb {
    position: absolute;
    top: 4px; left: 4px;
    width: 48px; height: 48px;
    background: var(--color-bg);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: var(--color-text);
    cursor: grab;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    z-index: 2;
}

.slider-thumb:active {
    cursor: grabbing;
}

/* ===== CART PAGE ===== */
.cart-item {
    display: flex;
    align-items: flex-start;
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--color-border);
}
.cart-item-image {
    width: 80px;
    height: 80px;
    min-width: 80px;
    background-color: var(--color-bg-subtle);
    margin-right: 1rem;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cart-item-details {
    flex: 1;
}
.cart-item-title {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
    font-weight: 400;
}
.cart-item-price {
    color: var(--color-text);
    font-weight: 500;
    font-size: 0.9rem;
}
.cart-remove-btn {
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    cursor: pointer;
    padding: 0.5rem;
    margin-left: 0.5rem;
}
.cart-summary { margin-top: 2rem; padding-top: 1rem; }
.summary-row { display: flex; justify-content: space-between; margin-bottom: 1rem; font-size: 0.9rem; }
.summary-total { display: flex; justify-content: space-between; margin-top: 1rem; margin-bottom: 2rem; font-size: 1.25rem; font-weight: 500; border-top: 1px solid var(--color-border); padding-top: 1.5rem; }

/* Quantity Controls */
.cart-quantity-controls { display: flex; align-items: center; margin-top: 0.5rem; }
.qty-btn { width: 24px; height: 24px; border: 1px solid var(--color-border); background: none; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 1rem; color: var(--color-text); transition: background 0.2s; }
.qty-btn:hover { background: var(--color-bg-subtle); }
.qty-val { margin: 0 0.5rem; font-size: 0.9rem; min-width: 1.5rem; text-align: center; }

/* ===== FOOTER ===== */
.site-footer {
    background: var(--color-text);
    color: var(--color-bg);
    padding: 3rem 1.5rem 1.5rem;
    margin-top: auto;
}

.footer-content {
    max-width: 900px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2rem;
    text-align: left;
}

.footer-section h4 {
    font-family: var(--font-serif);
    font-size: 1rem;
    margin-bottom: 1rem;
    font-weight: 400;
}

.footer-section p {
    font-size: 0.875rem;
    line-height: 1.8;
    color: rgba(255, 255, 255, 0.7);
    margin: 0;
}

.footer-section a {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: color 0.2s;
}

.footer-section a:hover {
    color: var(--color-bg);
}

.footer-link {
    font-size: 0.875rem;
    display: block;
}

.footer-bottom {
    max-width: 900px;
    margin: 2rem auto 0;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}

.footer-bottom p {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    margin: 0;
}

/* ===== PAGE TRANSITIONS ===== */
@keyframes page-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

body.page-fade-out {
    opacity: 0;
    transition: opacity 0.4s ease-in-out;
}