/* Manody stylesheet, part 15 — color picker (core/js/color-picker.js).
   Loaded in order by core/templates/core/includes/stylesheets.html. */

/* ---------- The field itself: a clean swatch ---------- */

input[type="color"] {
    -webkit-appearance: none;
    appearance: none;
    min-width: 44px;
    min-height: 36px;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="color"]:hover:not(:disabled) { border-color: var(--border-strong); }
input[type="color"]:focus-visible,
input[type="color"][aria-expanded="true"] {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--focus);
}

input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch {
    border: 0;
    border-radius: calc(var(--radius-sm) - 3px);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}
input[type="color"]::-moz-color-swatch {
    border: 0;
    border-radius: calc(var(--radius-sm) - 3px);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

input[type="color"]:disabled { cursor: not-allowed; opacity: 0.45; }

/* ---------- Popover ---------- */

.cp {
    --cp-hue: #ff0000;
    --cp-color: #000000;
    position: fixed;
    z-index: 80;
    display: grid;
    gap: 12px;
    width: 256px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-lg);
    animation: cp-in 0.14s var(--ease);
}

.cp[hidden] { display: none; }

@keyframes cp-in {
    from { opacity: 0; transform: translateY(-4px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

.cp-area {
    position: relative;
    height: 150px;
    border-radius: var(--radius-sm);
    background:
        linear-gradient(to top, #000000, transparent),
        linear-gradient(to right, #ffffff, transparent),
        var(--cp-hue);
    cursor: crosshair;
    touch-action: none;
}

.cp-area:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus); }

.cp-thumb {
    position: absolute;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    background: var(--cp-color);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3), 0 2px 6px rgba(0, 0, 0, 0.3);
    pointer-events: none;
}

.cp-hue {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 12px;
    margin: 0;
    border-radius: 999px;
    background: linear-gradient(to right, #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000);
    cursor: pointer;
}

.cp-hue::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    background: var(--cp-hue);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3), 0 2px 6px rgba(0, 0, 0, 0.3);
}

.cp-hue::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    background: var(--cp-hue);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3), 0 2px 6px rgba(0, 0, 0, 0.3);
}

.cp-hue:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus); }

.cp-row { display: flex; align-items: center; gap: 8px; }

.cp-preview {
    flex: none;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--cp-color);
    box-shadow: inset 0 0 0 1px var(--border-strong);
}

.cp-hex {
    flex: 1;
    min-width: 0;
    height: 32px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font: 500 0.88rem ui-monospace, SFMono-Regular, Menlo, monospace;
    text-transform: lowercase;
}

.cp-hex:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.cp-hex.is-invalid { border-color: var(--danger); }

.cp-dropper {
    display: grid;
    place-items: center;
    flex: none;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
}

.cp-dropper:hover { background: var(--bg-soft); border-color: var(--border-strong); }
.cp-dropper svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.cp-swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.cp-swatches[hidden] { display: none; }

.cp-swatch {
    aspect-ratio: 1;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: var(--swatch);
    /* A visible edge for the colors close to the background (black in dark theme, white in light). */
    box-shadow: inset 0 0 0 1px var(--border-strong);
    cursor: pointer;
    transition: transform 0.12s var(--ease);
}

.cp-swatch:hover { transform: scale(1.08); }
.cp-swatch:focus-visible { outline: none; box-shadow: inset 0 0 0 1px var(--border-strong), 0 0 0 3px var(--focus); }
.cp-swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }

.cp-label { margin: 2px 0 -4px; font-size: 0.75rem; font-weight: 600; color: var(--text-muted); }
.cp-label[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
    .cp { animation: none; }
}
