/* RGB to HSV Converter – mobile-first */

:root {
    --rgb-hsv-bg: #f5f5f7;
    --rgb-hsv-surface: #fff;
    --rgb-hsv-border: #e5e5ea;
    --rgb-hsv-text: #1d1d1f;
    --rgb-hsv-muted: #6e6e73;
    --rgb-hsv-accent: #0a84ff;
    --rgb-hsv-accent-hover: #0066cc;
    --rgb-hsv-radius: 12px;
    --rgb-hsv-radius-sm: 8px;
    --rgb-hsv-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    --rgb-hsv-shadow-focus: 0 0 0 3px rgba(10, 132, 255, 0.25);
}

/* Tool interface */
.rgb-hsv-tool {
    background: var(--rgb-hsv-surface);
    border-radius: var(--rgb-hsv-radius);
    border: 1px solid var(--rgb-hsv-border);
    box-shadow: var(--rgb-hsv-shadow);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Picker + swatch row */
.picker-swatch-row {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.picker-swatch-row .picker-area {
    flex: 1;
    min-width: 0;
}

.picker-swatch-row .color-swatch {
    flex: 0 0 auto;
    min-height: 140px;
}

/* Color picker area */
.picker-area {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.picker-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--rgb-hsv-muted);
    margin: 0;
}

.picker-row {
    display: flex;
    gap: 0.75rem;
    align-items: stretch;
}

.sv-plane {
    flex: 1;
    min-height: 160px;
    border-radius: var(--rgb-hsv-radius-sm);
    border: 1px solid var(--rgb-hsv-border);
    position: relative;
    cursor: crosshair;
    overflow: hidden;
    touch-action: none;
    background: linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent);
}

.sv-plane:focus {
    outline: none;
    box-shadow: var(--rgb-hsv-shadow-focus);
}

.sv-marker {
    position: absolute;
    width: 18px;
    height: 18px;
    margin: -9px 0 0 -9px;
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
    pointer-events: none;
}

.hue-strip {
    width: 24px;
    min-width: 24px;
    border-radius: var(--rgb-hsv-radius-sm);
    border: 1px solid var(--rgb-hsv-border);
    position: relative;
    cursor: pointer;
    overflow: hidden;
    touch-action: none;
    background: linear-gradient(to bottom, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);
}

.hue-strip:focus {
    outline: none;
    box-shadow: var(--rgb-hsv-shadow-focus);
}

.hue-marker {
    position: absolute;
    left: 2px;
    right: 2px;
    height: 4px;
    margin-top: -2px;
    border: 2px solid #fff;
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
    pointer-events: none;
}

.picker-fallback {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.native-picker-label {
    font-size: 0.8125rem;
    color: var(--rgb-hsv-muted);
    margin: 0;
    cursor: pointer;
}

.native-color {
    width: 44px;
    height: 36px;
    padding: 2px;
    border: 1px solid var(--rgb-hsv-border);
    border-radius: var(--rgb-hsv-radius-sm);
    cursor: pointer;
    background: var(--rgb-hsv-surface);
}

.native-color::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.native-color::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}

.native-color::-moz-color-swatch {
    border: none;
    border-radius: 4px;
}

.color-swatch {
    aspect-ratio: 2 / 1;
    min-height: 120px;
    border-radius: var(--rgb-hsv-radius);
    border: 1px solid var(--rgb-hsv-border);
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    padding: 0.75rem 1rem;
    transition: box-shadow 0.2s ease;
}

.color-swatch:focus-within {
    box-shadow: var(--rgb-hsv-shadow-focus);
}

.swatch-hex {
    font-size: clamp(0.875rem, 2.5vw, 1rem);
    font-weight: 600;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.color-swatch.swatch-light .swatch-hex {
    color: #1d1d1f;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
}

.hsv-readout {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.readout-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--rgb-hsv-muted);
}

.readout-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--rgb-hsv-text);
}

.copy-readout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--rgb-hsv-border);
    border-radius: var(--rgb-hsv-radius-sm);
    background: var(--rgb-hsv-surface);
    color: var(--rgb-hsv-muted);
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.copy-readout:hover {
    color: var(--rgb-hsv-accent);
    border-color: var(--rgb-hsv-accent);
    background: rgba(10, 132, 255, 0.06);
}

.copy-readout:focus {
    outline: none;
    box-shadow: var(--rgb-hsv-shadow-focus);
}

/* Channel strip + HSV readout row */
.channel-readout-row {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.channel-readout-row .channel-strip {
    flex: 1;
    min-width: 0;
}

.channel-readout-row .hsv-readout {
    flex-shrink: 0;
}

.channel-strip {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.channel-row {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.channel-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8125rem;
    color: var(--rgb-hsv-muted);
    cursor: default;
}

.channel-name {
    font-weight: 600;
}

.channel-num {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--rgb-hsv-text);
}

.rgb-slider {
    width: 100%;
    height: 10px;
    border-radius: 5px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--rgb-hsv-border);
    outline: none;
}

.rgb-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--rgb-hsv-surface);
    border: 2px solid var(--rgb-hsv-accent);
    cursor: pointer;
    box-shadow: var(--rgb-hsv-shadow);
}

.rgb-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--rgb-hsv-surface);
    border: 2px solid var(--rgb-hsv-accent);
    cursor: pointer;
    box-shadow: var(--rgb-hsv-shadow);
}

.hex-entry {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.hex-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--rgb-hsv-muted);
}

.hex-wrap {
    display: flex;
    align-items: center;
    border: 1px solid var(--rgb-hsv-border);
    border-radius: var(--rgb-hsv-radius-sm);
    background: var(--rgb-hsv-surface);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.hex-wrap:focus-within {
    border-color: var(--rgb-hsv-accent);
    box-shadow: var(--rgb-hsv-shadow-focus);
}

.hex-prefix {
    padding: 0.65rem 0.5rem 0.65rem 0.75rem;
    font-size: 0.9375rem;
    color: var(--rgb-hsv-muted);
}

.hex-input {
    flex: 1;
    padding: 0.65rem 0.75rem;
    border: none;
    background: transparent;
    font-size: 0.9375rem;
    color: var(--rgb-hsv-text);
    min-width: 0;
}

.hex-input::placeholder {
    color: var(--rgb-hsv-muted);
    opacity: 0.8;
}

.hex-input:focus {
    outline: none;
}

.format-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.65rem;
    border-radius: var(--rgb-hsv-radius-sm);
    background: var(--rgb-hsv-bg);
    border: 1px solid var(--rgb-hsv-border);
    font-size: 0.95rem;
}

.chip-label {
    font-weight: 600;
    color: var(--rgb-hsv-muted);
}

.chip-value {
    font-variant-numeric: tabular-nums;
    color: var(--rgb-hsv-text);
}

.chip-code {
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.chip-code:hover {
    border-color: var(--rgb-hsv-accent);
    background: rgba(10, 132, 255, 0.06);
}

.chip-code .chip-value {
    font-size: 0.85rem;
}

.preset-strip {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.preset-heading {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--rgb-hsv-muted);
}

.preset-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.preset-dot {
    width: 36px;
    height: 36px;
    padding: 0;
    border: 2px solid var(--rgb-hsv-border);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s, box-shadow 0.15s;
}

.preset-dot:hover {
    transform: scale(1.08);
    border-color: var(--rgb-hsv-text);
    box-shadow: var(--rgb-hsv-shadow);
}

.preset-dot:focus {
    outline: none;
    box-shadow: var(--rgb-hsv-shadow-focus);
}

.content-section {
    max-width: 720px;
}

.content-section h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.content-section p {
    color: var(--rgb-hsv-muted, #6e6e73);
    font-size: 0.9375rem;
    line-height: 1.5;
    margin-bottom: 1rem;
}

.content-grid {
    display: grid;
    gap: 1rem;
    margin-bottom: 1rem;
}

@media (min-width: 480px) {
    .content-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.content-block h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.content-block p {
    margin-bottom: 0;
}

/* Tablet and up */
@media (min-width: 640px) {
    .rgb-hsv-tool {
        padding: 1.5rem;
        gap: 1.5rem;
    }

    .picker-swatch-row {
        flex-direction: row;
        align-items: stretch;
    }

    .picker-swatch-row .picker-area {
        flex: 0 1 52%;
        max-width: 420px;
    }

    .picker-swatch-row .color-swatch {
        flex: 1;
        min-height: 160px;
        aspect-ratio: auto;
    }

    .sv-plane {
        min-height: 200px;
    }

    .channel-readout-row {
        flex-direction: row;
        align-items: flex-start;
        gap: 1.5rem;
    }

    .channel-readout-row .channel-strip {
        flex: 1;
        max-width: 420px;
    }

    .channel-readout-row .hsv-readout {
        flex-shrink: 0;
        flex-direction: column;
        align-items: flex-start;
        justify-content: center;
    }

    .readout-value {
        font-size: 1.125rem;
    }
}

@media (min-width: 768px) {
    .rgb-hsv-tool {
        padding: 2rem;
    }

    .picker-swatch-row .picker-area {
        max-width: 512px;
    }

    .channel-readout-row .channel-strip {
        max-width: 512px;
    }
}
