/* HSV to CMYK Converter - mobile-first, sleek */

:root {
    --h2c-bg: var(--bs-body-bg, #fff);
    --h2c-surface: var(--bs-secondary-bg, #f8f9fc);
    --h2c-border: var(--bs-border-color, #e8eaef);
    --h2c-text: var(--bs-body-color, #1a1d24);
    --h2c-muted: var(--text-muted, #64748b);
    --h2c-accent: #6366f1;
    --h2c-accent-hover: #4f46e5;
    --h2c-radius: 16px;
    --h2c-radius-sm: 12px;
    --h2c-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    --h2c-shadow-md: 0 8px 24px rgba(0, 0, 0, 0.06);
    --h2c-focus: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

/* --- Tool interface --- */
.h2c-tool {
    margin-bottom: 2.5rem;
}

.h2c-card {
    background: var(--h2c-bg);
    border: 1px solid var(--h2c-border);
    border-radius: var(--h2c-radius);
    box-shadow: var(--h2c-shadow-md);
    overflow: hidden;
}

/* Swatch: full-width on mobile, prominent */
.h2c-swatch-wrap {
    padding: 1.25rem 1.25rem 0.75rem;
    background: var(--h2c-surface);
    border-bottom: 1px solid var(--h2c-border);
}

.h2c-swatch {
    width: 100%;
    aspect-ratio: 2.2 / 1;
    max-height: 180px;
    border-radius: var(--h2c-radius-sm);
    box-shadow: var(--h2c-shadow);
    transition: background-color 0.15s ease;
}

.h2c-swatch-label {
    display: block;
    text-align: center;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--h2c-muted);
    margin-top: 0.5rem;
    letter-spacing: 0.04em;
}

/* Input block: HSV sliders */
.h2c-input-block {
    padding: 1.25rem 1.25rem 0.5rem;
    border-bottom: 1px solid var(--h2c-border);
}

.h2c-block-title {
    font-size: 0.8125rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--h2c-muted);
    margin: 0 0 1rem 0;
}

.h2c-channel {
    margin-bottom: 1.25rem;
}

.h2c-channel:last-of-type {
    margin-bottom: 0;
}

.h2c-channel-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.375rem;
}

.h2c-label {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--h2c-text);
}

.h2c-value {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--h2c-accent);
    font-variant-numeric: tabular-nums;
}

.h2c-range {
    width: 100%;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--h2c-border);
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.h2c-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--h2c-accent);
    cursor: pointer;
    box-shadow: var(--h2c-shadow);
    transition: transform 0.15s ease, background 0.15s ease;
}

.h2c-range::-webkit-slider-thumb:hover {
    transform: scale(1.08);
    background: var(--h2c-accent-hover);
}

.h2c-range::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: none;
    background: var(--h2c-accent);
    cursor: pointer;
    box-shadow: var(--h2c-shadow);
}

.h2c-range:focus-visible {
    outline: none;
}

.h2c-range:focus-visible::-webkit-slider-thumb {
    box-shadow: var(--h2c-focus);
}

.h2c-range:focus-visible::-moz-range-thumb {
    box-shadow: var(--h2c-focus);
}

.h2c-num {
    width: 100%;
    max-width: 88px;
    padding: 0.5rem 0.625rem;
    font-size: 0.875rem;
    font-weight: 600;
    border: 1px solid var(--h2c-border);
    border-radius: 8px;
    background: var(--h2c-bg);
    color: var(--h2c-text);
}

.h2c-num:focus {
    outline: none;
    border-color: var(--h2c-accent);
    box-shadow: var(--h2c-focus);
}

/* Output: CMYK bars */
.h2c-output-block {
    padding: 1.25rem;
    border-bottom: 1px solid var(--h2c-border);
}

.h2c-cmyk-grid {
    display: grid;
    gap: 1rem;
}

.h2c-cmyk-item {
    display: grid;
    grid-template-columns: 72px 1fr 44px;
    align-items: center;
    gap: 0.75rem;
}

.h2c-cmyk-name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--h2c-muted);
}

.h2c-cmyk-bar-wrap {
    height: 10px;
    background: var(--h2c-surface);
    border-radius: 5px;
    overflow: hidden;
}

.h2c-cmyk-bar {
    height: 100%;
    width: calc(var(--pct, 0) * 1%);
    border-radius: 5px;
    transition: width 0.2s ease;
}

.h2c-cmyk-item:nth-child(1) .h2c-cmyk-bar { background: #06b6d4; }
.h2c-cmyk-item:nth-child(2) .h2c-cmyk-bar { background: #ec4899; }
.h2c-cmyk-item:nth-child(3) .h2c-cmyk-bar { background: #eab308; }
.h2c-cmyk-item:nth-child(4) .h2c-cmyk-bar { background: #374151; }

.h2c-cmyk-pct {
    font-size: 0.875rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--h2c-text);
    text-align: right;
}

/* Copy chips */
.h2c-formats {
    padding: 1.25rem;
    border-bottom: 1px solid var(--h2c-border);
}

.h2c-formats-heading,
.h2c-samples-heading {
    display: block;
    font-size: 0.8125rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--h2c-muted);
    margin-bottom: 0.75rem;
}

.h2c-chip-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.h2c-chip {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 0.5rem 0.75rem;
    background: var(--h2c-surface);
    border: 1px solid var(--h2c-border);
    border-radius: var(--h2c-radius-sm);
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
    text-align: left;
    min-width: 0;
}

.h2c-chip:hover {
    border-color: var(--h2c-accent);
    background: var(--h2c-bg);
}

.h2c-chip:active {
    transform: scale(0.98);
}

.h2c-chip:focus-visible {
    outline: none;
    box-shadow: var(--h2c-focus);
}

.h2c-chip-label {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--h2c-muted);
    margin-bottom: 0.125rem;
}

.h2c-chip-value {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--h2c-text);
    font-variant-numeric: tabular-nums;
    word-break: break-all;
}

.h2c-chip[data-copied="true"] .h2c-chip-value {
    color: #059669;
}

/* Samples */
.h2c-samples {
    padding: 1.25rem;
}

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

.h2c-sample {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    border: 2px solid var(--h2c-border);
    background: hsl(var(--sample-h, 0), calc(var(--sample-s, 100) * 1%), calc(var(--sample-v, 100) * 1%));
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    padding: 0;
    overflow: hidden;
}

.h2c-sample:hover {
    transform: scale(1.06);
    border-color: var(--h2c-accent);
    box-shadow: var(--h2c-shadow-md);
}

.h2c-sample:focus-visible {
    outline: none;
    box-shadow: var(--h2c-focus);
}

.h2c-sample-name {
    display: block;
    font-size: 0.625rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    padding: 0.25rem;
    line-height: 1.1;
}

/* Educational */
.h2c-edu {
    margin-bottom: 2rem;
    padding: 1.5rem 0 0;
}

.h2c-edu-title {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--h2c-text);
    margin: 0 0 1rem 0;
}

.h2c-edu-grid {
    display: grid;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

.h2c-edu-block {
    padding: 1.25rem;
    background: var(--h2c-surface);
    border: 1px solid var(--h2c-border);
    border-radius: var(--h2c-radius-sm);
}

.h2c-edu-heading {
    font-size: 1rem;
    font-weight: 700;
    color: var(--h2c-text);
    margin: 0 0 0.5rem 0;
}

.h2c-edu-block p {
    font-size: 0.9375rem;
    color: var(--h2c-text);
    margin: 0 0 0.5rem 0;
    line-height: 1.5;
}

.h2c-edu-list {
    margin: 0;
    padding-left: 1.25rem;
    font-size: 0.875rem;
    color: var(--h2c-muted);
    line-height: 1.6;
}

.h2c-edu-full {
    grid-column: 1 / -1;
}

/* Desktop: two-column layout for swatch + input */
@media (min-width: 768px) {
    .h2c-swatch-wrap {
        padding: 1.5rem;
    }

    .h2c-swatch {
        max-height: 200px;
        aspect-ratio: 2 / 1;
    }

    .h2c-card {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto 1fr auto auto;
    }

    .h2c-swatch-wrap {
        grid-column: 1;
        grid-row: 1 / 4;
        border-bottom: none;
        border-right: 1px solid var(--h2c-border);
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .h2c-swatch {
        max-height: 240px;
        aspect-ratio: 1;
    }

    .h2c-input-block {
        grid-column: 2;
        grid-row: 1;
        padding: 1.5rem 1.5rem 0.5rem;
        border-bottom: 1px solid var(--h2c-border);
    }

    .h2c-output-block {
        grid-column: 2;
        grid-row: 2;
        padding: 1.5rem;
    }

    .h2c-formats {
        grid-column: 1 / -1;
        padding: 1.25rem 1.5rem;
    }

    .h2c-samples {
        grid-column: 1 / -1;
        padding: 1.25rem 1.5rem;
    }

    .h2c-edu-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (min-width: 992px) {
    .h2c-cmyk-item {
        grid-template-columns: 80px 1fr 48px;
    }
}
