/* Color Converter - inline app: mode bar, live preview, input/result panels.
   Width comes from the shared inline-app column in css/common.css, so the
   tool lines up with the page heading and the content below it. */

/* Mode bar: From / swap / To */
.cc-modes {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
}

.cc-mode {
    flex: 1 1 0;
    min-width: 0;
}

.cc-mode-label {
    display: block;
    font-size: 0.8rem;
    color: var(--gn-muted);
    margin-bottom: 0.25rem;
}

.cc-swap {
    flex: 0 0 auto;
    width: 42px;
    height: 38px;
    border: 1px solid var(--bs-border-color);
    border-radius: 0.375rem;
    background: none;
    color: var(--gn-muted);
}

.cc-swap:hover {
    border-color: var(--gn-accent);
    color: var(--gn-accent);
}

/* --- Hub mode: one detecting input, then every model at once --- */
.cc-hub-label {
    display: block;
    font-size: 0.8rem;
    color: var(--gn-muted);
    margin-bottom: 0.35rem;
}

.cc-hub-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.cc-input-wrap {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
}

/* Room for the clear button inside the field */
.cc-input-wrap .form-control {
    padding-right: 2.75rem;
}

/* Bootstrap draws its invalid state as a warning icon in the right edge -
   exactly where the clear button sits. Drop the icon: the red border and
   the message beside the field carry the meaning, and the button needs
   the space. */
.cc-input-wrap .form-control.is-invalid {
    background-image: none;
    padding-right: 2.75rem;
}

.cc-clear {
    position: absolute;
    top: 50%;
    right: 0.6rem;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: none;
    color: var(--gn-muted);
    font-size: 0.75rem;
}

.cc-clear:hover {
    background-color: var(--gn-sidebar-hover-bg);
    color: var(--gn-accent);
}

.cc-hub-picker {
    flex: 0 0 auto;
}

/* The detected notation, shown as a control so a value that could be read
   two ways can be corrected */
.cc-hub-detected {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0.6rem 0 0;
    font-size: 0.85rem;
    color: var(--gn-muted);
}

.cc-hub-model {
    width: auto;
    padding-top: 0.1rem;
    padding-bottom: 0.1rem;
}

.cc-hub-hint {
    color: var(--bs-danger);
}

/* Live preview band */
.cc-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 110px;
    margin-top: 1rem;
    padding: 0 1rem;
    border: 1px solid var(--gn-card-border);
    border-radius: 0.75rem;
    text-align: center;
}

.cc-preview-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
    overflow-wrap: anywhere;
}

/* Light colors need dark text to stay readable */
.cc-preview-light .cc-preview-label {
    color: #14161a;
    text-shadow: none;
}

/* Separates the source value from the converted one */
.cc-preview-arrow {
    margin: 0 0.6rem;
    opacity: 0.75;
    vertical-align: -1px;
}

/* Input and result panels, side by side on desktop */
.cc-panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1rem;
}

.cc-panel {
    padding: 1rem;
    border: 1px solid var(--gn-card-border);
    border-radius: 0.75rem;
    background-color: var(--gn-card-bg);
}

.cc-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    min-height: 31px;
}

.cc-panel-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0;
}

.cc-panel-role {
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--gn-muted);
}

.cc-panel-note {
    font-size: 0.78rem;
    color: var(--gn-muted);
    margin: 0.35rem 0 0.75rem;
}

/* Input rows: label, slider, number box, unit */
.cc-field {
    display: grid;
    grid-template-columns: 2rem 1fr 5.25rem 0.9rem;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.cc-field-text {
    grid-template-columns: 2rem 1fr;
}

.cc-field-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gn-muted);
    margin: 0;
}

.cc-field-range {
    min-width: 0;
    margin: 0;
}

.cc-field-unit {
    font-size: 0.8rem;
    color: var(--gn-muted);
}

/* Result rows: big read-only numbers */
.cc-fields-out {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.cc-out-field {
    flex: 1 1 4.5rem;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--gn-card-border);
    border-radius: 0.5rem;
    text-align: center;
}

.cc-out-label {
    display: block;
    font-size: 0.7rem;
    color: var(--gn-muted);
}

.cc-out-value {
    display: block;
    font-size: 1.1rem;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.cc-value-label {
    display: block;
    font-size: 0.8rem;
    color: var(--gn-muted);
    margin: 0.85rem 0 0.25rem;
}

.cc-value-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cc-picker-wrap {
    flex: 0 0 auto;
}

.cc-output-text {
    font-weight: 600;
}

.cc-copy {
    flex: 0 0 auto;
    white-space: nowrap;
}

.cc-invalid {
    font-size: 0.78rem;
    color: var(--bs-danger);
    margin: 0.4rem 0 0;
}

/* Every model at once, under the panels */
.cc-all {
    margin-top: 1.25rem;
}

/* Section headings inside the app need real air above them - the preview
   band and the value rows are both solid blocks of color */
.cc-all-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-top: 1.75rem;
    margin-bottom: 0.5rem;
}

.cc-all-list {
    list-style: none;
    padding: 0;
    margin: 0;
    border: 1px solid var(--gn-card-border);
    border-radius: 0.75rem;
    overflow: hidden;
}

.cc-all-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.45rem 0.75rem;
    border-top: 1px solid var(--gn-card-border);
}

.cc-all-item:first-child {
    border-top: 0;
}

/* Family heading inside the list (Web / Print / Perceptual) */
.cc-all-group {
    padding: 0.4rem 0.75rem 0.2rem;
    border-top: 1px solid var(--gn-card-border);
    background-color: var(--gn-sidebar-hover-bg);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gn-body-color);
}

.cc-all-group:first-child {
    border-top: 0;
}

/* The row after a heading already has the heading's rule above it */
.cc-all-group + .cc-all-item {
    border-top: 0;
}

.cc-all-model {
    flex: 0 0 3.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gn-muted);
}

.cc-all-value {
    flex: 1 1 auto;
    min-width: 0;
    color: var(--gn-body-color);
    overflow-wrap: anywhere;
}

.cc-all-copy {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 0.375rem;
    background: none;
    color: var(--gn-muted);
}

.cc-all-copy:hover {
    border-color: var(--gn-accent);
    color: var(--gn-accent);
}

/* Line under the heading explaining what a row can do */
.cc-all-hint {
    font-size: 0.8rem;
    color: var(--gn-muted);
    margin: -0.25rem 0 0.5rem;
}

/* Opens the dedicated page for that pair. The source row keeps an empty
   slot of the same width so the right edge stays straight. */
.cc-all-open {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid transparent;
    border-radius: 0.375rem;
    color: var(--gn-muted);
    text-decoration: none;
}

.cc-all-open:hover {
    border-color: var(--gn-accent);
    color: var(--gn-accent);
}

.cc-all-open-empty {
    pointer-events: none;
}

/* --- Page content below the app (hub index, conversion pages) --- */

/* Worked example on a conversion page */
.cc-example {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--gn-card-border);
    border-radius: 0.75rem;
    background-color: var(--gn-card-bg);
}

.cc-example-swatch {
    width: 46px;
    height: 46px;
    flex: 0 0 auto;
    border: 1px solid var(--gn-card-border);
    border-radius: 0.5rem;
}

.cc-example-values {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
}

.cc-example-arrow {
    color: var(--gn-muted);
}

/* Reference list of well-known colors in both models: two columns of
   clickable rows, divided rather than boxed, each loading its color into
   the converter */
.cc-values-intro {
    color: var(--gn-muted);
    font-size: 0.9rem;
}

.cc-values {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border: 1px solid var(--gn-card-border);
    border-radius: 0.75rem;
    overflow: hidden;
    background-color: var(--gn-card-bg);
}

.cc-value {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-width: 0;
    padding: 0.6rem 0.85rem;
    border: 0;
    border-top: 1px solid var(--gn-card-border);
    background: none;
    color: var(--gn-body-color);
    text-align: left;
}

/* Dividers between rows and between the two columns, but not around the
   outside - the container already has the border */
.cc-value:nth-child(-n+2) {
    border-top: 0;
}

.cc-value:nth-child(even) {
    border-left: 1px solid var(--gn-card-border);
}

.cc-value:hover {
    background-color: var(--gn-sidebar-hover-bg);
}

.cc-value-swatch {
    flex: 0 0 auto;
    width: 46px;
    height: 46px;
    border: 1px solid var(--gn-card-border);
    border-radius: 0.5rem;
}

.cc-value-name {
    flex: 0 0 4.75rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.cc-value-pair {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 1px;
}

.cc-value-pair code {
    font-size: 0.8rem;
    color: var(--gn-muted);
    overflow-wrap: anywhere;
}

/* The source value leads, the converted value follows in body color */
.cc-value-pair code:last-child {
    color: var(--gn-body-color);
}

/* Related converters at the foot of a conversion page */
.cc-related-intro {
    color: var(--gn-muted);
    font-size: 0.9rem;
}

.cc-related {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0;
    margin: 0;
    list-style: none;
}

.cc-related a {
    display: inline-block;
    padding: 0.3rem 0.7rem;
    border: 1px solid var(--gn-card-border);
    border-radius: 2rem;
    font-size: 0.85rem;
    text-decoration: none;
}

.cc-related a:hover {
    border-color: var(--gn-accent);
}

/* One column of reference colors on narrow screens */
@media (max-width: 639px) {
    .cc-values {
        grid-template-columns: 1fr;
    }

    .cc-value:nth-child(2) {
        border-top: 1px solid var(--gn-card-border);
    }

    .cc-value:nth-child(even) {
        border-left: 0;
    }
}

@media (max-width: 767px) {
    .cc-panels {
        grid-template-columns: 1fr;
    }

    /* Sliders are fiddly on a phone - the number boxes carry the editing */
    .cc-field {
        grid-template-columns: 2rem 1fr 0.9rem;
    }

    .cc-field-range {
        display: none;
    }
}
