/* =========================================================
   RADIUS BUILDER
   assets/css/pages/radius-builder/radius-builder.css
   =========================================================
   Controls rail (#rd-sidebar) for the Radius Builder, plus
   workspace-level preview reflow. Reuses the website design
   system tokens (variables.css) — no new theme. Mirrors the
   visual language of spacing-builder.css for consistency.

   Preview-surface styling lives in preview/*.css.
   ========================================================= */


/* =========================================================
   CONTROLS PANEL — header
   ========================================================= */

.rd-controls-panel {
    background: var(--surface-primary);
    border: 1px solid var(--border-primary);
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

/* Panel header — unified in components/tool-shell.css (icon + heading). */


/* =========================================================
   1. CORNER STYLE — preset cards (2×2)
   ========================================================= */

.rd-preset-grid {
    display: grid;
    gap: var(--space-2);
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.rd-preset-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--space-1);
    width: 100%;
    min-width: 0;
    padding: var(--space-2);
    background: var(--surface-primary);
    border: 1.5px solid var(--border-primary);
    border-radius: 0.85rem;
    cursor: pointer;
    text-align: left;
    font-family: var(--font-primary);
    box-shadow: var(--shadow-sm);
    box-sizing: border-box;
    transition: border-color var(--transition-fast), background var(--transition-fast),
        box-shadow var(--transition-fast), transform var(--transition-fast);
}

.rd-preset-card:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.rd-preset-card--active {
    border-color: var(--color-primary);
    background: var(--color-primary-soft);
    box-shadow: var(--shadow-md), 0 0 0 1px var(--color-primary);
    transform: none;
}

.rd-preset-card__viz {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 35px;
    height: 35px;
}

.rd-preset-swatch {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary));
    /* border-radius set inline per preset (sharp → pill) */
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25), var(--shadow-sm);
}

.rd-preset-card__body {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.rd-preset-card__label {
    font-size: var(--text-sm);
    font-weight: var(--font-semi-bold);
    color: var(--text-primary);
}

.rd-preset-card--active .rd-preset-card__label {
    color: var(--color-primary);
}

.rd-preset-card__desc {
    font-size: 0.72rem;
    line-height: 1.3;
    color: var(--text-muted);
}


/* =========================================================
   SEGMENTED PILLS — component levels + unit
   ========================================================= */

.rd-seg {
    display: flex;
    width: 100%;
    gap: 0.25rem;
    background: var(--surface-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 0.65rem;
    padding: 0.15rem;
    box-sizing: border-box;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.05);
}

.rd-seg-btn {
    flex: 1;
    padding: 0.4rem 0.45rem;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 0.5rem;
    font-family: var(--font-primary);
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition-fast);
}

.rd-seg-btn:hover {
    color: var(--text-primary);
    background: var(--surface-hover);
}

.rd-seg-btn--active,
.rd-seg-btn--active:hover {
    background: var(--surface-primary);
    border-color: var(--color-primary);
    color: var(--color-primary);
    font-weight: var(--font-semi-bold);
    box-shadow: var(--shadow-sm), 0 0 0 1px var(--color-primary-soft);
}


/* =========================================================
   2. COMPONENTS — per-component level rows
   ========================================================= */

.rd-comp-row {
    margin-bottom: var(--space-2);
}

.rd-comp-row:last-of-type {
    margin-bottom: 0;
}

.rd-comp-row-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.45rem;
}

.rd-comp-row-label {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-primary);
    text-transform: capitalize;
}

.rd-comp-reset {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    border-radius: 0.45rem;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.rd-comp-reset:hover {
    background: var(--surface-hover);
    color: var(--color-primary);
}

.rd-locked-note {
    margin: var(--space-3) 0 0;
    font-size: 0.68rem;
    color: var(--text-muted);
    text-transform: capitalize;
}


/* =========================================================
   3. ADVANCED — collapsible
   ========================================================= */

.rd-advanced-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: var(--space-2) var(--space-3);
    margin: calc(var(--space-2) * -1) calc(var(--space-3) * -1) 0;
    border: none;
    border-radius: 0.5rem;
    background: transparent;
    cursor: pointer;
    font-family: var(--font-primary);
    transition: background var(--transition-fast);
}

.rd-advanced-header:hover {
    background: var(--surface-hover);
}

.rd-advanced-label {
    font-size: 0.75rem;
    font-weight: var(--font-bold);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.rd-advanced-chevron {
    font-size: 1.1rem;
    line-height: 1;
    color: var(--text-muted);
    transition: transform var(--transition-fast);
}

.rd-advanced--open .rd-advanced-chevron {
    transform: rotate(90deg);
    color: var(--color-primary);
}

.rd-advanced-body {
    display: none;
    flex-direction: column;
    gap: var(--space-4);
    margin-top: var(--space-5);
}

.rd-advanced--open .rd-advanced-body {
    display: flex;
}

.rd-adv-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
}

.rd-adv-row--col {
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
}

.rd-adv-row--end {
    justify-content: flex-end;
}

.rd-adv-row-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
}

.rd-adv-row-label {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-primary);
}

.rd-adv-row-value {
    font-size: var(--text-xs);
    font-weight: var(--font-semi-bold);
    color: var(--color-primary);
    font-variant-numeric: tabular-nums;
    background: var(--color-primary-soft);
    padding: 0.15rem 0.5rem;
    border-radius: 9999px;
}


/* Range slider — primary control, styled beyond the native accent-color look. */
.rd-range {
    width: 100%;
    height: 1.25rem;
    margin: 0;
    background: transparent;
    accent-color: var(--color-primary);
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.rd-range::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 9999px;
    background: var(--surface-secondary);
    border: 1px solid var(--border-primary);
}

.rd-range::-moz-range-track {
    height: 6px;
    border-radius: 9999px;
    background: var(--surface-secondary);
    border: 1px solid var(--border-primary);
}

.rd-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    margin-top: -7px;
    border-radius: 50%;
    background: var(--color-primary);
    border: 3px solid var(--surface-primary);
    box-shadow: 0 0 0 1px var(--color-primary), var(--shadow-sm);
    cursor: pointer;
    transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}

.rd-range::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--color-primary);
    border: 3px solid var(--surface-primary);
    box-shadow: 0 0 0 1px var(--color-primary), var(--shadow-sm);
    cursor: pointer;
    transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}

.rd-range:hover::-webkit-slider-thumb,
.rd-range:focus-visible::-webkit-slider-thumb {
    box-shadow: 0 0 0 5px var(--color-primary-soft), var(--shadow-sm);
}

.rd-range:hover::-moz-range-thumb,
.rd-range:focus-visible::-moz-range-thumb {
    box-shadow: 0 0 0 5px var(--color-primary-soft), var(--shadow-sm);
}

.rd-range:active::-webkit-slider-thumb {
    transform: scale(1.1);
}

.rd-range:active::-moz-range-thumb {
    transform: scale(1.1);
}

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


/* Semantic step editors */
.rd-semantic-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
}

.rd-sem-cell {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.rd-sem-cell-label {
    width: 2.2rem;
    flex-shrink: 0;
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    color: var(--text-secondary);
}

.rd-sem-cell--locked {
    grid-column: 1 / -1;
    gap: 0.5rem;
    padding-top: 0.2rem;
}

.rd-sem-cell-pill {
    font-size: var(--text-xs);
    font-weight: var(--font-semi-bold);
    color: var(--text-muted);
    background: var(--surface-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 9999px;
    padding: 0.2rem 0.6rem;
}

.rd-num-input-wrap {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.rd-num-input {
    width: 100%;
    min-width: 0;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border-primary);
    border-radius: 0.5rem;
    background: var(--surface-primary);
    font: inherit;
    font-size: var(--text-sm);
    color: var(--text-primary);
    box-sizing: border-box;
}

.rd-num-input:focus {
    outline: none;
    border-color: var(--color-primary);
}

.rd-num-input-unit {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

/* Reset footer — unified in components/tool-shell.css (.tool-reset-row/-btn). */


/* =========================================================
   PREVIEW — mobile device reflow
   =========================================================
   The device toggle flips .rd-preview-root--mobile; each
   surface narrows to a phone-ish column. Per-surface grid
   rules live in preview/*.css.
   ========================================================= */

.rd-preview-root--mobile .tool-preview-panel--active {
    max-width: 420px;
    margin: 0 auto;
}


/* =========================================================
   MOBILE — controls drawer scroll fix
   =========================================================
   .rd-controls-panel has overflow:hidden (rounded corners); per the
   flexbox spec that gives it an automatic min-height of 0, so inside
   the flex-column drawer (#rd-sidebar) it gets shrunk to fit and
   clips the controls instead of letting the drawer scroll.
   flex-shrink:0 keeps it at full content height so the drawer scrolls
   (the shared shell already hides the drawer scrollbar).
   ========================================================= */

@media (max-width: 768px) {
    .rd-controls-panel {
        flex-shrink: 0;
    }

    /* Breathing room so the last control clears the bottom of the drawer. */
    #rd-sidebar {
        padding-bottom: var(--space-6);
    }
}