/* BloomScroll - Minimalist Design */

:root {
    --color-bg: #000000;
    --color-text: #f4f1e8;
    --color-text-muted: #9e9b89;
    --color-border: rgba(244, 241, 232, 0.08);
    --color-accent: #f4f1e8;

    /* iOS PWA Safe Areas */
    --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);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Berkeley Mono', 'Monaco', 'Menlo', monospace;
    background: var(--color-bg);
    color: var(--color-text);
    overflow: hidden;
    font-size: 11px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Canvas */
#p5js-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* When panel is open, bloom fits in top 50% */
body.panel-open #p5js-container {
    height: 50vh;
    align-items: center;
}

#p5js-container canvas {
    cursor: grab;
}

#p5js-container canvas:active {
    cursor: grabbing;
}

/* No more diamond toggle - integrated handle instead */

/* Control Panel - Bottom Sheet Design */
.control-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    transform: translateY(calc(100% - 40px - env(safe-area-inset-bottom, 0px)));
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

/* Panel Handle - Always Visible */
.panel-handle {
    position: relative;
    height: 60px;
    background: rgba(0, 0, 0, 0.98);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid rgba(244, 241, 232, 0.1);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.3);
}

.panel-handle:hover {
    background: rgba(18, 18, 18, 0.95);
}

.panel-handle:active {
    background: rgba(20, 20, 20, 0.95);
}

/* Handle Indicator - Pill Shape */
.handle-indicator {
    width: 36px;
    height: 4px;
    background: rgba(244, 241, 232, 0.3);
    border-radius: 2px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

/* Handle text removed - cleaner design */

/* Panel Content */
.panel-content {
    background: rgba(10, 10, 10, 0.98);
    backdrop-filter: blur(32px);
    -webkit-backdrop-filter: blur(32px);
    height: calc(50vh - 60px);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    padding-bottom: calc(40px + env(safe-area-inset-bottom, 0px));
    -webkit-overflow-scrolling: touch;
    border-top: 1px solid rgba(244, 241, 232, 0.05);
    scrollbar-width: thin;
    scrollbar-color: rgba(244, 241, 232, 0.2) transparent;
}

/* Custom Scrollbar */
.panel-content::-webkit-scrollbar {
    width: 6px;
}

.panel-content::-webkit-scrollbar-track {
    background: transparent;
}

.panel-content::-webkit-scrollbar-thumb {
    background: rgba(244, 241, 232, 0.2);
    border-radius: 3px;
}

.panel-content::-webkit-scrollbar-thumb:hover {
    background: rgba(244, 241, 232, 0.3);
}

/* Sliders */
.sliders {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.slider {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.slider label {
    font-size: 9px;
    color: var(--color-text-muted);
    letter-spacing: 1px;
}

.slider input[type="range"] {
    width: 100%;
    height: 2px;
    background: var(--color-border);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--color-text);
    cursor: pointer;
    transition: transform 0.15s ease;
}

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

.slider input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: var(--color-text);
    cursor: pointer;
    border: none;
    border-radius: 0;
    transition: transform 0.15s ease;
}

.slider input[type="range"]::-moz-range-thumb:active {
    transform: scale(1.2);
}

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

/* Color Controls */
.color-controls {
    margin-bottom: 20px;
}

.color-controls label {
    display: block;
    font-size: 9px;
    color: var(--color-text-muted);
    letter-spacing: 1px;
    margin-bottom: 10px;
}

/* Rainbow Hue Slider */
.hue-slider {
    width: 100%;
    height: 32px;
    background: linear-gradient(to right,
        hsl(0, 100%, 50%),
        hsl(30, 100%, 50%),
        hsl(60, 100%, 50%),
        hsl(90, 100%, 50%),
        hsl(120, 100%, 50%),
        hsl(150, 100%, 50%),
        hsl(180, 100%, 50%),
        hsl(210, 100%, 50%),
        hsl(240, 100%, 50%),
        hsl(270, 100%, 50%),
        hsl(300, 100%, 50%),
        hsl(330, 100%, 50%),
        hsl(360, 100%, 50%)
    );
    border: 1px solid var(--color-border);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: grab;
    margin-bottom: 14px;
    transition: border-color 0.2s ease;
}

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

.hue-slider:hover {
    border-color: rgba(244, 241, 232, 0.2);
}

.hue-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 24px;
    height: 36px;
    background: var(--color-text);
    cursor: grab;
    border: 2px solid var(--color-bg);
    box-shadow: 0 0 0 1px var(--color-border), 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.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);
}

.hue-slider::-moz-range-thumb {
    width: 24px;
    height: 36px;
    background: var(--color-text);
    cursor: grab;
    border: 2px solid var(--color-bg);
    border-radius: 0;
    box-shadow: 0 0 0 1px var(--color-border), 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.hue-slider::-moz-range-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::-moz-range-thumb:active {
    cursor: grabbing;
    transform: scaleY(1.08);
}

/* Harmony Modes */
.harmony-modes {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 7px;
}

.harmony-btn {
    padding: 12px 8px;
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-family: inherit;
    font-size: 9px;
    letter-spacing: 0.8px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.harmony-btn:hover {
    border-color: rgba(244, 241, 232, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.harmony-btn:active {
    transform: translateY(0) scale(0.98);
    transition-duration: 0.1s;
}

.harmony-btn.active {
    border-color: var(--color-text);
    color: var(--color-text);
    background: rgba(244, 241, 232, 0.1);
    transform: translateY(0);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

.harmony-btn.active:hover {
    transform: translateY(0);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Bottom Section: Styles + Randomize side by side */
.bottom-section {
    display: flex;
    gap: 12px;
    align-items: stretch;
}

/* Styles */
.styles {
    display: flex;
    gap: 10px;
    flex: 1;
}

.style-group {
    display: flex;
    gap: 6px;
    flex: 1;
}

.style-btn {
    flex: 1;
    min-height: 44px;
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    padding: 0;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.style-btn:hover {
    border-color: rgba(244, 241, 232, 0.3);
    transform: scale(1.02);
}

.style-btn:active {
    transform: scale(0.97);
    transition-duration: 0.1s;
}

.style-btn.active {
    border-color: var(--color-text);
    color: var(--color-text);
    background: rgba(244, 241, 232, 0.1);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

.style-btn.active:hover {
    transform: scale(1);
}

/* Randomize */
.randomize {
    min-width: 140px;
    padding: 14px 20px;
    background: rgba(244, 241, 232, 0.1);
    color: rgba(244, 241, 232, 0.7);
    border: 1px solid rgba(244, 241, 232, 0.15);
    font-family: inherit;
    font-size: 11px;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    white-space: nowrap;
}

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

.randomize:active {
    transform: translateY(0) scale(0.98);
    background: rgba(244, 241, 232, 0.08);
    transition-duration: 0.1s;
}

/* Advanced Controls */
.advanced-controls {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 0;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.group-header {
    font-size: 9px;
    letter-spacing: 2px;
    color: var(--color-text-dim);
    opacity: 0.5;
    padding: 0 4px;
}

.control-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 28px;
    padding: 0 4px;
}

.slider-row {
    position: relative;
}

.slider-row label {
    min-width: 45px;
    font-size: 9px;
    letter-spacing: 1.5px;
    color: var(--color-text-dim);
    opacity: 0.7;
}

.slider-row input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    cursor: pointer;
    height: 28px;
}

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

.slider-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    background: var(--color-text);
    border: none;
    height: 10px;
    width: 10px;
    border-radius: 0;
    cursor: pointer;
    transition: all 0.15s ease;
}

.slider-row input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    background: var(--color-accent);
}

/* Firefox support */
.slider-row input[type="range"]::-moz-range-track {
    background: rgba(244, 241, 232, 0.05);
    height: 1px;
}

.slider-row input[type="range"]::-moz-range-thumb {
    background: var(--color-text);
    border: none;
    height: 10px;
    width: 10px;
    border-radius: 0;
    cursor: pointer;
    transition: all 0.15s ease;
}

.slider-row input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.2);
    background: var(--color-accent);
}

.value-display {
    min-width: 30px;
    text-align: right;
    font-size: 9px;
    letter-spacing: 0.5px;
    color: var(--color-text-dim);
    opacity: 0.7;
}

/* Mode Buttons */
.mode-buttons {
    display: flex;
    gap: 2px;
}

.mode-buttons.full {
    width: 100%;
}

.mode-btn {
    flex: 1;
    padding: 6px 8px;
    background: transparent;
    border: 1px solid rgba(244, 241, 232, 0.08);
    color: var(--color-text-dim);
    font-family: inherit;
    font-size: 9px;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 26px;
    opacity: 0.6;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.mode-btn:hover {
    border-color: rgba(244, 241, 232, 0.2);
    color: var(--color-text);
    opacity: 1;
    transform: translateY(-1px);
}

.mode-btn.active {
    background: rgba(244, 241, 232, 0.1);
    color: var(--color-text);
    border-color: rgba(244, 241, 232, 0.2);
    opacity: 1;
}

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

/* Mobile */
@media (max-width: 640px) {
    .panel-content {
        padding: 16px;
        padding-bottom: calc(40px + env(safe-area-inset-bottom, 0px));
    }

    .panel-handle {
        height: 56px;
    }

    .sliders {
        gap: 12px;
    }

    .slider input[type="range"] {
        height: 3px;
    }

    .slider input[type="range"]::-webkit-slider-thumb {
        width: 18px;
        height: 18px;
    }

    .slider input[type="range"]::-moz-range-thumb {
        width: 18px;
        height: 18px;
    }

    .hue-slider {
        height: 36px;
    }

    .hue-slider::-webkit-slider-thumb {
        width: 28px;
        height: 40px;
    }

    .hue-slider::-moz-range-thumb {
        width: 28px;
        height: 40px;
    }

    .harmony-btn {
        padding: 13px 6px;
        font-size: 9px;
        letter-spacing: 0.5px;
    }

    .style-btn {
        font-size: 18px;
        min-height: 46px;
    }

    .randomize {
        padding: 16px 18px;
        font-size: 11px;
        min-width: 130px;
    }

    .bottom-section {
        flex-direction: column;
        gap: 12px;
    }

    .randomize {
        width: 100%;
    }

    /* Advanced Controls Mobile */
    .advanced-controls {
        gap: 16px;
    }

    .control-group {
        gap: 10px;
    }

    .group-header {
        font-size: 8px;
        letter-spacing: 1.5px;
        padding: 0 2px;
    }

    .control-row {
        min-height: 36px;
        padding: 0 2px;
    }

    .mode-btn {
        padding: 8px 4px;
        font-size: 8px;
        letter-spacing: 0.5px;
        height: 32px;
        min-width: auto;
    }

    .mode-buttons {
        gap: 1px;
    }

    .slider-row label {
        min-width: 40px;
        font-size: 8px;
    }

    .slider-row input[type="range"] {
        height: 36px;
    }

    .slider-row input[type="range"]::-webkit-slider-thumb {
        height: 14px;
        width: 14px;
    }

    .slider-row input[type="range"]::-webkit-slider-thumb:active {
        transform: scale(1.4);
    }

    .slider-row input[type="range"]::-moz-range-thumb {
        height: 14px;
        width: 14px;
    }

    /* Improve touch targets on mobile */
    @media (pointer: coarse) {
        .mode-btn {
            min-height: 36px;
        }

        .slider-row input[type="range"]::-webkit-slider-thumb {
            height: 18px;
            width: 18px;
        }

        .slider-row input[type="range"]::-moz-range-thumb {
            height: 18px;
            width: 18px;
        }
    }

    .value-display {
        font-size: 8px;
        min-width: 25px;
    }
}
