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

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


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

.sh-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. STYLE — preset cards (single row of 3, real shadow specimens)
   ========================================================= */

/* Single-row, 3 equal cards. */
.sh-preset-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.sh-preset-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-1);
    min-width: 0;
    min-height: 112px;
    padding: var(--space-3) var(--space-2) var(--space-2);
    background: var(--surface-primary);
    border: 1.5px solid var(--border-primary);
    border-radius: 0.85rem;
    cursor: pointer;
    text-align: center;
    font-family: var(--font-primary);
    box-sizing: border-box;
    transition: border-color var(--transition-fast), background var(--transition-fast),
        box-shadow var(--transition-fast), transform var(--transition-fast);
}

.sh-preset-card:hover {
    border-color: var(--color-primary);
    transform: translateY(-1px);
}

/* Selected — clear but restrained (accent border + soft tint + lift + scale). */
.sh-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: scale(1.02);
}

.sh-preset-card--active:hover {
    transform: scale(1.02);
}

/* Style name — top */
.sh-preset-card__label {
    font-size: var(--text-xs);
    font-weight: var(--font-semi-bold);
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

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

/* Specimen stage — centre. A subtly recessed canvas so the specimen reads as
   "floating above a surface" and even the soft, diffuse shadow stays legible
   (a white-on-white shadow would all but disappear). */
.sh-preset-card__viz {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 auto;
    width: 100%;
    min-height: 58px;
    background: var(--surface-secondary);
    border-radius: 0.6rem;
}

/* The floating specimen — a white surface carrying the style's shadow. */
.sh-preset-swatch {
    width: 40px;
    height: 28px;
    border-radius: 0.5rem;
    background: var(--surface-primary);
    border: 1px solid var(--border-primary);
    /* box-shadow set inline per style (soft / default / sharp) */
}

/* Descriptor — bottom */
.sh-preset-card__desc {
    font-size: 0.66rem;
    line-height: 1.2;
    font-weight: var(--font-medium);
    color: var(--text-muted);
}

/* Stack when the panel is too narrow for 3 across. */
@media (max-width: 360px) {
    .sh-preset-grid {
        grid-template-columns: 1fr;
    }
}


/* =========================================================
   2. INTENSITY — slider + readout
   ========================================================= */

.sh-row-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.sh-row-hint {
    font-size: 0.68rem;
    font-weight: var(--font-medium);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.sh-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. */
.sh-range {
    width: 100%;
    height: 1.25rem;
    margin: 0;
    background: transparent;
    accent-color: var(--color-primary);
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

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

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

.sh-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);
}

.sh-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);
}

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

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

.sh-range:active::-webkit-slider-thumb { transform: scale(1.1); }
.sh-range:active::-moz-range-thumb { transform: scale(1.1); }
.sh-range:focus-visible { outline: none; }


/* =========================================================
   SEGMENTED PILLS — surface + component elevation
   ========================================================= */

.sh-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);
}

.sh-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);
}

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

.sh-seg-btn--active,
.sh-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);
}


/* =========================================================
   4. COMPONENTS — collapsible
   ========================================================= */

.sh-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);
}

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

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

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

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

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

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

.sh-comp-row { margin-bottom: var(--space-1); }
.sh-comp-row:last-of-type { margin-bottom: 0; }

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

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

.sh-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);
}

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

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

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

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


/* =========================================================
   PREVIEW — mobile device reflow
   =========================================================
   The device toggle flips .sh-preview-area--mobile; the active
   surface narrows to a phone-ish column. Per-surface rules live
   in preview/*.css.
   ========================================================= */

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


/* =========================================================
   MOBILE — controls drawer scroll fix
   =========================================================
   #sh-sidebar (the slide-up drawer) already scrolls with a hidden
   scrollbar via the shared shell. But .sh-controls-panel has
   overflow:hidden (for its rounded corners), and per the flexbox
   spec a flex item with overflow ≠ visible gets an automatic
   min-height of 0 — so inside the flex-column drawer the panel is
   shrunk to fit and clips the controls instead of letting the
   drawer scroll. flex-shrink:0 keeps it at full content height
   (corners still clip) so the drawer scrolls.
   ========================================================= */

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

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