/* ═══════════════════════════════════════════════════════════════════
   HTML Colour Picker — Frontend Styles
   Compatible with Divi Builder 4 & 5 + Shortcode
   ═══════════════════════════════════════════════════════════════════ */

/* ── Custom Properties ────────────────────────────────────────────── */
:root {
    --hcp-bg:            #1a1a2e;
    --hcp-surface:       #16213e;
    --hcp-surface-2:     #0f3460;
    --hcp-border:        rgba(255,255,255,0.10);
    --hcp-text:          #e2e8f0;
    --hcp-text-muted:    #94a3b8;
    --hcp-accent:        #3B82F6;
    --hcp-accent-glow:   rgba(59,130,246,0.35);
    --hcp-radius:        14px;
    --hcp-radius-sm:     8px;
    --hcp-radius-xs:     4px;
    --hcp-swatch-size:   28px;
    --hcp-shadow:        0 20px 60px rgba(0,0,0,0.5), 0 4px 16px rgba(0,0,0,0.3);
    --hcp-transition:    0.18s cubic-bezier(0.4,0,0.2,1);
    --hcp-font:          'DM Sans', 'Segoe UI', system-ui, sans-serif;
    --hcp-font-mono:     'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
}

/* ── Accessibility ─────────────────────────────────────────────────── */
.hcp-sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* ── Wrapper ────────────────────────────────────────────────────────── */
.hcp-module-wrapper {
    display: flex;
    justify-content: center;
    padding: 20px 12px;
    font-family: var(--hcp-font);
}

/* ── Main Card ─────────────────────────────────────────────────────── */
.hcp-picker {
    width: 100%;
    background: var(--hcp-bg);
    border-radius: var(--hcp-radius);
    padding: 20px;
    box-shadow: var(--hcp-shadow);
    border: 1px solid var(--hcp-border);
    display: flex;
    flex-direction: column;
    gap: 16px;
    color: var(--hcp-text);
    position: relative;
    overflow: hidden;
}

/* Subtle animated gradient top-border */
.hcp-picker::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, #3B82F6, #8B5CF6, #EC4899, #F59E0B, #10B981, #3B82F6);
    background-size: 300% 100%;
    animation: hcp-gradient-shift 6s linear infinite;
}

@keyframes hcp-gradient-shift {
    0%   { background-position: 0% 50%; }
    100% { background-position: 300% 50%; }
}

/* ── Header ────────────────────────────────────────────────────────── */
.hcp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.hcp-label {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--hcp-text-muted);
}

.hcp-copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--hcp-surface);
    border: 1px solid var(--hcp-border);
    border-radius: var(--hcp-radius-xs);
    color: var(--hcp-text-muted);
    font-size: 12px;
    font-family: var(--hcp-font);
    padding: 5px 10px;
    cursor: pointer;
    transition: var(--hcp-transition);
    transition-property: color, background, border-color, box-shadow;
}
.hcp-copy-btn:hover {
    color: var(--hcp-text);
    border-color: var(--hcp-accent);
    box-shadow: 0 0 0 2px var(--hcp-accent-glow);
}
.hcp-copy-btn.hcp-copied {
    color: #10B981;
    border-color: #10B981;
}

/* ── Spectrum ──────────────────────────────────────────────────────── */
.hcp-spectrum-wrap {
    position: relative;
    width: 100%;
    height: 200px;
    border-radius: var(--hcp-radius-sm);
    overflow: hidden;
    cursor: crosshair;
    touch-action: none;
}

.hcp-spectrum {
    width: 100%;
    height: 100%;
    display: block;
}

.hcp-spectrum-cursor {
    position: absolute;
    width: 16px; height: 16px;
    border-radius: 50%;
    border: 3px solid #fff;
    box-shadow: 0 0 0 2px rgba(0,0,0,0.5), 0 2px 8px rgba(0,0,0,0.4);
    transform: translate(-50%, -50%);
    pointer-events: none;
    top: 20%; left: 80%;
    transition: box-shadow var(--hcp-transition);
    will-change: top, left;
}

/* ── Slider Row ────────────────────────────────────────────────────── */
.hcp-sliders {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.hcp-slider-row {
    display: flex;
    align-items: center;
    gap: 14px;
}

.hcp-preview-swatch {
    flex-shrink: 0;
    width: 44px; height: 44px;
    border-radius: var(--hcp-radius-sm);
    border: 2px solid var(--hcp-border);
    background: var(--hcp-accent);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    transition: background var(--hcp-transition), box-shadow var(--hcp-transition);
    background-image:
        linear-gradient(45deg, #888 25%, transparent 25%),
        linear-gradient(-45deg, #888 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #888 75%),
        linear-gradient(-45deg, transparent 75%, #888 75%);
    background-size: 10px 10px;
    background-position: 0 0, 0 5px, 5px -5px, -5px 0px;
    position: relative;
    overflow: hidden;
}
.hcp-preview-swatch::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--hcp-preview-color, var(--hcp-accent));
}

.hcp-slider-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ── Range Sliders ─────────────────────────────────────────────────── */
input[type="range"].hcp-hue-slider,
input[type="range"].hcp-alpha-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 12px;
    border-radius: 6px;
    outline: none;
    cursor: pointer;
    border: none;
}

input[type="range"].hcp-hue-slider {
    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%)
    );
}

/* Alpha: set dynamically via JS */
input[type="range"].hcp-alpha-slider {
    background: var(--hcp-alpha-bg, linear-gradient(to right, transparent, #fff));
    background-image:
        linear-gradient(45deg, #aaa 25%, transparent 25%),
        linear-gradient(-45deg, #aaa 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #aaa 75%),
        linear-gradient(-45deg, transparent 75%, #aaa 75%),
        var(--hcp-alpha-gradient, linear-gradient(to right, transparent, white));
    background-size: 8px 8px, 8px 8px, 8px 8px, 8px 8px, 100% 100%;
    background-position: 0 0, 0 4px, 4px -4px, -4px 0px, 0 0;
}

/* Thumb styles */
input[type="range"].hcp-hue-slider::-webkit-slider-thumb,
input[type="range"].hcp-alpha-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid rgba(0,0,0,0.2);
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    cursor: pointer;
    transition: box-shadow var(--hcp-transition);
}
input[type="range"].hcp-hue-slider::-webkit-slider-thumb:hover,
input[type="range"].hcp-alpha-slider::-webkit-slider-thumb:hover {
    box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}

input[type="range"].hcp-hue-slider::-moz-range-thumb,
input[type="range"].hcp-alpha-slider::-moz-range-thumb {
    width: 20px; height: 20px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid rgba(0,0,0,0.2);
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    cursor: pointer;
}

/* ── Inputs ────────────────────────────────────────────────────────── */
.hcp-inputs {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.hcp-input-group {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--hcp-surface);
    border: 1px solid var(--hcp-border);
    border-radius: var(--hcp-radius-sm);
    padding: 8px 10px;
    transition: border-color var(--hcp-transition), box-shadow var(--hcp-transition);
}
.hcp-input-group:focus-within {
    border-color: var(--hcp-accent);
    box-shadow: 0 0 0 3px var(--hcp-accent-glow);
}

.hcp-input-group input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--hcp-text);
    font-family: var(--hcp-font-mono);
    font-size: 13px;
    min-width: 0;
    text-align: center;
    -moz-appearance: textfield;
}
.hcp-input-group input::-webkit-outer-spin-button,
.hcp-input-group input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.hcp-input-group input::placeholder { color: var(--hcp-text-muted); }

.hcp-hex-input { text-transform: uppercase; }

.hcp-input-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--hcp-text-muted);
    text-transform: uppercase;
    flex-shrink: 0;
    min-width: 28px;
    text-align: right;
}

/* ── Palette & History ─────────────────────────────────────────────── */
.hcp-palette,
.hcp-history {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hcp-section-title {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--hcp-text-muted);
}

.hcp-swatches,
.hcp-history-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.hcp-swatch {
    width: var(--hcp-swatch-size);
    height: var(--hcp-swatch-size);
    border-radius: var(--hcp-radius-xs);
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform var(--hcp-transition), border-color var(--hcp-transition), box-shadow var(--hcp-transition);
    padding: 0;
}
.hcp-swatch:hover {
    transform: scale(1.18);
    border-color: rgba(255,255,255,0.6);
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.hcp-swatch.hcp-swatch--active {
    border-color: #fff;
    box-shadow: 0 0 0 2px var(--hcp-accent);
    transform: scale(1.08);
}

.hcp-history-swatches .hcp-swatch {
    width: 24px; height: 24px;
}
.hcp-history-swatches:empty::before {
    content: attr(data-empty);
    font-size: 11px;
    color: var(--hcp-text-muted);
    font-style: italic;
}

/* ── Divider ───────────────────────────────────────────────────────── */
.hcp-palette,
.hcp-history {
    padding-top: 14px;
    border-top: 1px solid var(--hcp-border);
}

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 400px) {
    .hcp-picker { padding: 14px; }
    .hcp-spectrum-wrap { height: 160px; }
}

/* ── Light mode (users who force light) ────────────────────────────── */
@media (prefers-color-scheme: light) {
    .hcp-picker {
        --hcp-bg:          #ffffff;
        --hcp-surface:     #f1f5f9;
        --hcp-border:      rgba(0,0,0,0.08);
        --hcp-text:        #1e293b;
        --hcp-text-muted:  #64748b;
        --hcp-shadow:      0 20px 60px rgba(0,0,0,0.12), 0 4px 16px rgba(0,0,0,0.08);
    }
}

/* ── Divi Builder editor overrides ─────────────────────────────────── */
.et-db .hcp-module-wrapper { padding: 10px; }
