/* ===================================
   BLOOMSCROLL MAIN CSS
   Consolidated Production Styles
   =================================== */

/* ===================================
   1. CSS VARIABLES & RESET
   =================================== */
:root {
    /* Colors */
    --color-bg: #000000;
    --color-text: #f4f1e8;
    --color-text-muted: #9e9b89;
    --color-accent: #ff5722;
    --color-border: rgba(244, 241, 232, 0.1);
    --color-border-hover: rgba(244, 241, 232, 0.2);

    /* Safe areas for mobile devices */
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-left: env(safe-area-inset-left, 0px);
    --safe-area-right: env(safe-area-inset-right, 0px);
}

/* PWA Standalone Mode Specific */
@media (display-mode: standalone) {
    :root {
        --safe-area-bottom: max(env(safe-area-inset-bottom, 0px), 20px);
    }
}

/* ===================================
   2. BASE STYLES
   =================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Berkeley Mono', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, monospace;
    background: var(--color-bg);
    color: var(--color-text);
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
    touch-action: none;
}

/* PWA Standalone Mode */
body.pwa-standalone {
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* ===================================
   3. CANVAS CONTAINER
   =================================== */
#p5js-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center; /* Always center */
    z-index: 1;
}

#p5js-container canvas {
    /* Let p5.js control canvas dimensions */
    display: block;
    /* Smooth vertical movement transition */
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center center;
}

/* ===================================
   4. CONTROL PANEL - MOBILE FIRST
   =================================== */
.control-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    height: 40vh; /* Optimal height - golden ratio inspired */
    max-height: none;
    transform: translateY(calc(100% - 72px)); /* Collapsed shows just handle */
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding-bottom: env(safe-area-inset-bottom, 0);
    background: #000000;
    overflow: hidden;
    will-change: transform;
}

.control-panel.expanded {
    transform: translateY(0);
}

/* PWA Standalone Mode Adjustments */
body.pwa-standalone .control-panel {
    bottom: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* ===================================
   5. PANEL HANDLE
   =================================== */
.panel-handle {
    position: relative;
    height: 72px; /* Increased for better touch target */
    background: #000000;
    border-top: 1px solid rgba(244, 241, 232, 0.15); /* More visible border */
    border-radius: 24px 24px 0 0;
    cursor: pointer;
    user-select: none;
    display: flex;
    flex-direction: column; /* Stack handle and text */
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s ease;
    touch-action: manipulation; /* Better for tap handling */
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent; /* Remove iOS tap highlight */
}

.panel-handle:hover {
    border-top-color: rgba(244, 241, 232, 0.15);
}

.panel-handle:active {
    border-top-color: rgba(244, 241, 232, 0.2);
    background: rgba(244, 241, 232, 0.02); /* Visual feedback on touch */
    cursor: grabbing;
}

.handle-indicator {
    width: 36px;
    height: 4px;
    background: rgba(244, 241, 232, 0.4); /* More visible */
    border-radius: 2px;
    transition: all 0.3s ease;
}

/* Handle text hint */
.panel-handle::after {
    content: 'Controls';
    font-size: 11px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: rgba(244, 241, 232, 0.5);
    transition: opacity 0.3s ease;
}

.control-panel.expanded .panel-handle::after {
    content: 'Close';
}

.panel-handle:hover .handle-indicator,
.control-panel.expanded .handle-indicator {
    width: 48px;
    background: rgba(244, 241, 232, 0.7);
}

/* ===================================
   6. PANEL CONTENT
   =================================== */
.panel-content {
    padding: 16px 20px 24px;
    height: calc(100% - 60px);
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    max-width: 100%;
    box-sizing: border-box;
}

/* ===================================
   7. SLIDERS - TOUCH OPTIMIZED
   =================================== */
.sliders {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.slider {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

.slider label {
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    width: 50px;
}

/* Slider value display */
.slider .value-display {
    position: absolute;
    right: 0;
    font-size: 10px;
    color: rgba(244, 241, 232, 0.6);
    min-width: 28px;
    text-align: right;
    font-family: 'Berkeley Mono', monospace;
}

.slider input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 2px;
    background: rgba(244, 241, 232, 0.1);
    border-radius: 1px;
    outline: none;
}

/* Touch-optimized thumb - 44px touch target */
.slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 44px;
    height: 44px;
    background: rgba(244, 241, 232, 0.85);
    cursor: pointer;
    border-radius: 22px;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: all 0.15s ease;
}

.slider input[type="range"]::-webkit-slider-thumb:hover {
    background: rgba(244, 241, 232, 1);
    transform: scale(1.05);
}

.slider input[type="range"]::-webkit-slider-thumb:active {
    background: rgba(244, 241, 232, 1);
    transform: scale(1.2);
}

/* Firefox */
.slider input[type="range"]::-moz-range-thumb {
    width: 44px;
    height: 44px;
    background: rgba(244, 241, 232, 0.85);
    cursor: pointer;
    border: none;
    border-radius: 22px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: all 0.15s ease;
}

.slider input[type="range"]::-moz-range-thumb:hover {
    background: rgba(244, 241, 232, 1);
    transform: scale(1.05);
}

.slider input[type="range"]::-moz-range-thumb:active {
    background: rgba(244, 241, 232, 1);
    transform: scale(1.2);
}

/* ===================================
   8. COLOR CONTROLS
   =================================== */
.color-controls {
    margin-bottom: 16px;
}

.color-controls label {
    display: block;
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-bottom: 8px;
}

/* ===================================
   8b. HUE SLIDER (SPECIAL)
   =================================== */
.hue-slider {
    -webkit-appearance: none !important;
    appearance: none !important;
    height: 44px !important;
    width: 100% !important;
    background: linear-gradient(to right,
        hsl(0, 70%, 50%),
        hsl(60, 70%, 50%),
        hsl(120, 70%, 50%),
        hsl(180, 70%, 50%),
        hsl(240, 70%, 50%),
        hsl(300, 70%, 50%),
        hsl(360, 70%, 50%)
    ) !important; /* Fixed rainbow gradient */
    border-radius: 16px !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    margin: 8px 0 !important;
}

.hue-slider::-webkit-slider-thumb {
    width: 36px !important;
    height: 36px !important;
    border: 2px solid var(--color-text) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4), inset 0 0 0 2px var(--color-bg) !important;
}

.hue-slider::-webkit-slider-thumb:hover {
    transform: scaleY(1.05);
    box-shadow: 0 0 0 1px var(--color-text), 0 4px 12px rgba(0, 0, 0, 0.4);
}

.hue-slider::-webkit-slider-thumb:active {
    cursor: grabbing;
    transform: scaleY(1.08);
}

/* Firefox */
.hue-slider::-moz-range-thumb {
    width: 36px !important;
    height: 36px !important;
    border: 2px solid var(--color-text) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4), inset 0 0 0 2px var(--color-bg) !important;
}

/* ===================================
   9. DIVIDERS
   =================================== */
.divider {
    height: 1px;
    background: var(--color-border);
    margin: 16px 0;
}

/* ===================================
   10. BUTTONS & CONTROLS
   =================================== */
/* Harmony Modes */
.harmony-modes {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-top: 12px;
}

.harmony-btn {
    padding: 8px 12px;
    font-size: 10px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 4px;
    font-family: inherit;
}

.harmony-btn:hover {
    background: rgba(244, 241, 232, 0.05);
    border-color: var(--color-border-hover);
    color: var(--color-text);
}

.harmony-btn.active {
    background: rgba(244, 241, 232, 0.08);
    border-color: rgba(244, 241, 232, 0.3);
    color: var(--color-text);
}

/* Styles Section */
.styles-section {
    display: flex;
    gap: 8px;
    justify-content: space-between;
    margin-top: 16px;
}

.style-group {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.style-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
}

.style-btn:hover {
    background: rgba(244, 241, 232, 0.05);
    border-color: var(--color-border-hover);
    color: var(--color-text);
}

.style-btn.active {
    background: rgba(244, 241, 232, 0.08);
    border-color: rgba(244, 241, 232, 0.3);
    color: var(--color-text);
}

/* Mode Buttons */
.mode-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    width: 100%;
}

.mode-btn {
    padding: 10px 4px;
    font-size: 9px;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 3px;
    font-family: inherit;
    white-space: nowrap;
}

.mode-btn:hover {
    background: rgba(244, 241, 232, 0.04);
    border-color: rgba(244, 241, 232, 0.15);
}

.mode-btn.active {
    background: rgba(244, 241, 232, 0.06);
    border-color: rgba(244, 241, 232, 0.25);
    color: var(--color-text);
}

/* Randomize Button */
.randomize {
    flex: 1;
    min-height: 44px;
    padding: 0 16px;
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-size: 12px;
    line-height: 1;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.randomize:hover {
    background: rgba(244, 241, 232, 0.03);
    border-color: rgba(244, 241, 232, 0.15);
    color: rgba(244, 241, 232, 0.9);
    transform: translateY(-1px);
}

.randomize:active {
    transform: translateY(0);
    background: rgba(244, 241, 232, 0.06);
}

/* Export PFP Button */
.export-pfp {
    width: 48px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 8px;
}

.export-pfp:hover {
    background: rgba(244, 241, 232, 0.03);
    border-color: rgba(244, 241, 232, 0.15);
    color: rgba(244, 241, 232, 0.9);
}

.export-pfp svg {
    width: 18px;
    height: 18px;
}

/* ===================================
   11. ACTION BUTTONS
   =================================== */
.action-buttons {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

/* Purchase CTA Section */
.panel-cta {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid rgba(244, 241, 232, 0.1);
}

.buy-cta-btn {
    width: 100%;
    padding: 16px 20px;
    background: #fff; /* Will be updated dynamically to match bloom */
    color: #000;
    border: none;
    border-radius: 8px;
    font-family: 'Berkeley Mono', monospace;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.3s ease;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    overflow: hidden;
}

.buy-cta-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

.buy-cta-btn:active {
    transform: translateY(0);
}

.cta-text {
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.cta-price {
    font-size: 11px;
    opacity: 0.8;
    font-weight: 400;
}

/* ===================================
   12. ADVANCED CONTROLS
   =================================== */
.advanced-controls {
    margin: 12px 0;
}

.control-group {
    margin-bottom: 12px;
}

.group-header {
    font-size: 9px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-bottom: 8px;
    opacity: 0.6;
}

.control-row {
    display: flex;
    gap: 8px;
}

.control-row.full {
    width: 100%;
}

/* ===================================
   13. MOBILE OPTIMIZATIONS
   =================================== */
/* Prevent scroll bouncing */
@supports (-webkit-touch-callout: none) {
    .control-panel {
        position: fixed;
    }
}

/* Improve touch response */
@media (hover: none) and (pointer: coarse) {
    .slider input[type="range"] {
        height: 44px;
        background: transparent;
    }

    .slider input[type="range"]::-webkit-slider-runnable-track {
        height: 2px;
        background: rgba(244, 241, 232, 0.1);
    }

    .harmony-btn,
    .style-btn,
    .mode-btn,
    .randomize {
        -webkit-tap-highlight-color: transparent;
    }
}

/* ===================================
   14. SPLASH SCREEN
   =================================== */
.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.splash-content {
    text-align: center;
    padding: 40px;
}

.splash-title {
    font-family: 'Berkeley Mono', monospace;
    font-size: 24px;
    font-weight: 400;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.8);
    margin: 0 0 24px 0;
}

.splash-description {
    font-family: 'Berkeley Mono', monospace;
    font-size: 13px;
    line-height: 1.8;
    color: rgba(255, 255, 255, 0.4);
    margin: 0 0 40px 0;
    font-weight: 300;
}

.splash-description br {
    display: block;
    margin: 4px 0;
}

.splash-continue {
    position: static;
    font-family: 'Berkeley Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.25);
    animation: none;
    margin-top: 60px;
}

/* ===================================
   15. DESKTOP ADJUSTMENTS
   =================================== */
/* Mobile-first: no desktop overrides for panel positioning */

/* Removed desktop media queries - mobile-first approach */

/* ===================================
   16. INSTALL GUIDE MODAL
   =================================== */
.install-guide {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(10, 10, 10, 0.95);
    border: 1px solid rgba(244, 241, 232, 0.1);
    border-radius: 12px;
    padding: 16px 20px;
    max-width: 300px;
    width: calc(100% - 40px);
    z-index: 2000;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.install-guide-text {
    font-size: 12px;
    line-height: 1.6;
    color: rgba(244, 241, 232, 0.7);
    margin-bottom: 12px;
}

.install-guide-button {
    width: 100%;
    padding: 10px;
    background: rgba(244, 241, 232, 0.08);
    border: 1px solid rgba(244, 241, 232, 0.2);
    color: var(--color-text);
    font-size: 12px;
    font-family: inherit;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.install-guide-button:hover {
    background: rgba(244, 241, 232, 0.12);
    border-color: rgba(244, 241, 232, 0.3);
}

/* ===================================
   17. HIDE SCROLLBARS
   =================================== */
.panel-content::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.panel-content {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

/* ===================================
   18. Z-INDEX HIERARCHY
   =================================== */
/*
   1: Canvas
   1000: Control Panel
   2000: Install Guide
   10000: Splash Screen
   99999: Favorites Modal (in separate file)
*/