@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,500;0,600;1,400&family=Lato:wght@300;400;700&display=swap');

/* Luxury Palette Definitions */
:root {
    --bg-alabaster: #FDFBF7;
    --bg-warm-grey: #F5F2EB;
    --text-charcoal: #292524; /* Stone 800 */
    --text-muted: #78716C;    /* Stone 500 */
    --accent-gold: #B8956A;   /* Rich gold accent */
    --accent-gold-muted: #A89F91;   /* Muted metallic tone */
    --border-subtle: #E7E5E4; /* Stone 200 */

    /* Design tokens */
    --radius-sm: 0.5rem;      /* 8px */
    --radius-md: 0.75rem;     /* 12px */
    --radius-lg: 1rem;        /* 16px */
    --radius-xl: 1.5rem;      /* 24px */
}

body {
    font-family: 'Lato', sans-serif;
    overflow: hidden;
    background-color: var(--bg-alabaster);
    color: var(--text-charcoal);
}

.serif {
    font-family: 'Playfair Display', serif;
}

/* Brand Gradient for Luxury Feel */
.brand-gradient {
    background: linear-gradient(135deg, #292524 0%, #57534E 50%, #292524 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-size: 200% 200%;
    animation: shimmer 8s ease-in-out infinite;
}

@keyframes shimmer {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* Refined Scrollbar (Vertical) */
.custom-scroll::-webkit-scrollbar {
    width: 3px;
}

.custom-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.custom-scroll::-webkit-scrollbar-thumb {
    background: #D6D3D1;
    border-radius: 4px;
}

.custom-scroll::-webkit-scrollbar-thumb:hover {
    background: #A8A29E;
}

/* Elegant Horizontal Scrollbar (Palette) - Matches vertical scrollbar */
.palette-scroll {
    overflow-y: hidden;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding: 6px 0;
}

.palette-scroll::-webkit-scrollbar {
    height: 3px;
}

.palette-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.palette-scroll::-webkit-scrollbar-thumb {
    background: #D6D3D1;
    border-radius: 4px;
}

.palette-scroll::-webkit-scrollbar-thumb:hover {
    background: #A8A29E;
}

#canvas-container {
    width: 100%;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile browsers */
    background: radial-gradient(circle at center, #FDFBF7 0%, #F0EFE9 100%);
    position: relative;
}

/* Vignette effect overlay */
#canvas-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(
        circle at center,
        transparent 0%,
        transparent 50%,
        rgba(0, 0, 0, 0.02) 70%,
        rgba(0, 0, 0, 0.06) 100%
    );
    pointer-events: none;
    z-index: 1;
}

/* Noise/grain texture overlay */
#canvas-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.03'/%3E%3C/svg%3E");
    pointer-events: none;
    opacity: 0.4;
    z-index: 1;
    mix-blend-mode: overlay;
}

/* --- Luxury Selector Buttons --- */
.option-btn {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background-color: transparent;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    opacity: 0.7;
    position: relative;
}

.option-btn:hover {
    color: var(--text-charcoal);
    opacity: 1;
    background: linear-gradient(to bottom, rgba(248, 247, 244, 0.5), rgba(245, 242, 235, 0.8));
    transform: translateY(-1px);
}

.option-btn.active {
    color: var(--text-charcoal);
    background: linear-gradient(to bottom, rgba(248, 247, 244, 0.8), rgba(245, 242, 235, 1));
    border-bottom-color: var(--accent-gold);
    opacity: 1;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.option-btn:active {
    transform: scale(0.98);
}

.option-btn svg {
    stroke: currentColor;
    transition: stroke 0.3s;
}

/* --- Material List Buttons --- */
.bead-btn {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: left;
    background: linear-gradient(to right, rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0.6));
    border: 1px solid rgba(231, 229, 228, 0.5);
    border-radius: var(--radius-md);
}

.bead-btn:hover {
    transform: translateY(-2px);
    background: linear-gradient(to right, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.95));
    box-shadow: 0 8px 16px -4px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(184, 149, 106, 0.1);
    border-color: rgba(184, 149, 106, 0.3);
}

.bead-btn:active {
    transform: translateY(-1px) scale(0.99);
}

/* Palette Items */
.palette-btn {
    transition: all 0.3s ease;
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.palette-btn:hover {
    transform: translateY(-3px);
}

@keyframes popIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Floating Actions - Glassmorphism */
.float-btn {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: all 0.3s ease;
}

.float-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

/* Fine Line Icons */
.icon-fine {
    stroke-width: 1px;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

/* Luxury Range Slider */
input[type=range], .luxury-slider {
    -webkit-appearance: none;
    background: transparent;
    height: 24px;
}

input[type=range]::-webkit-slider-thumb, .luxury-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: linear-gradient(135deg, #57534E 0%, #44403C 100%);
    cursor: pointer;
    margin-top: -7px;
    box-shadow: 0 0 0 3px #FDFBF7, 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

input[type=range]::-webkit-slider-thumb:hover, .luxury-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 0 0 3px #FDFBF7, 0 0 0 5px rgba(184, 149, 106, 0.2), 0 4px 12px rgba(0, 0, 0, 0.2);
}

input[type=range]::-webkit-slider-thumb:active, .luxury-slider::-webkit-slider-thumb:active {
    transform: scale(1.05);
}

input[type=range]::-webkit-slider-runnable-track, .luxury-slider::-webkit-slider-runnable-track {
    width: 100%;
    height: 3px;
    cursor: pointer;
    background: linear-gradient(to right, #D6D3D1 0%, #B8956A 50%, #D6D3D1 100%);
    border-radius: 2px;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Vertical Text for Design Summary Tab */
.writing-mode-vertical {
    writing-mode: vertical-rl;
    text-orientation: mixed;
}

/* Design Summary Panel States */
/* Desktop: Slide from right */
@media (min-width: 768px) {
    #design-summary-container.panel-open #design-summary-panel {
        transform: translateX(0) translateY(-50%);
    }

    #design-summary-container.panel-open #toggle-arrow {
        transform: rotate(180deg);
    }

    /* Hide the toggle tab when panel is open */
    #design-summary-container.panel-open #summary-toggle {
        opacity: 0;
        pointer-events: none;
    }
}

/* Mobile: Slide from bottom with backdrop */
@media (max-width: 767px) {
    #design-summary-container.panel-open #design-summary-panel {
        transform: translateY(0);
    }

    #design-summary-container.panel-open #summary-backdrop {
        opacity: 1;
        pointer-events: auto;
    }
}

/* Increase scrollbar size on mobile */
@media (max-width: 767px) {
    .custom-scroll::-webkit-scrollbar {
        width: 8px;
    }

    .palette-scroll::-webkit-scrollbar {
        height: 8px;
    }
}

/* Mobile Material Drawer States */
@media (max-width: 767px) {
    /* Open state: slide drawer up from bottom */
    body.drawer-open #material-drawer {
        transform: translateY(0);
    }

    /* Show backdrop when drawer is open */
    body.drawer-open #mobile-menu-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    /* Ensure canvas doesn't overflow with fixed palette */
    #canvas-container {
        height: calc(100vh - 7rem); /* Subtract palette height (28 = 7rem) */
        height: calc(100dvh - 7rem); /* Dynamic viewport height for mobile */
    }
}
