/* Sized in rem throughout (root font = --font-size-base, values are
   px-at-12 ÷ 12), so the Display panel's TEXT SIZE scales the whole
   surface, not just its type. Hairlines stay px. */

.audio {
    display: contents;
}

/* Slot metrics come from the shared .bar-icon-button /
   .bar-status-button classes in bar.css. */

/* ---- Audio panel --------------------------------------------------- */

.audio-panel {
    position: fixed;
    z-index: 150;
    width: 31.6667rem;
    max-width: calc(var(--viewport-w) - 16px);
    max-height: calc(var(--viewport-h) - var(--bar-height) - 10px);
    overflow-y: auto;
    padding: 1.6667rem 2rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.1667rem;
    background: var(--color-background);
    border: var(--border-width) solid var(--color-accent);
    border-radius: var(--radius);
    color: var(--color-foreground);
    font-family: var(--font-mono);
}

.audio-panel > * {
    flex: none;
}

html[data-bar-position="left"] .audio-panel,
html[data-bar-position="right"] .audio-panel {
    max-height: calc(var(--viewport-h) - 10px);
}

html[data-bar-position="top"] .audio-panel {
    top: calc(var(--bar-height) + 5px);
    right: 5px;
}

html[data-bar-position="bottom"] .audio-panel {
    bottom: calc(var(--bar-height) + 5px);
    right: 5px;
}

html[data-bar-position="left"] .audio-panel {
    left: calc(var(--bar-size-vertical) + 5px);
    bottom: 5px;
}

html[data-bar-position="right"] .audio-panel {
    right: calc(var(--bar-size-vertical) + 5px);
    bottom: 5px;
}

/* ---- Hero: glyph · Audio/mood · master switch ---------------------- */

.audio-hero {
    display: flex;
    align-items: center;
    gap: 1.1667rem;
}

.audio-hero-glyph {
    font-size: 2.1667rem;
    line-height: 1;
}

.audio-hero-labels {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.1667rem;
}

.audio-hero-title {
    font-size: 1.25rem;
    font-weight: 700;
}

.audio-hero-status {
    font-size: 0.8333rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: color-mix(in srgb, var(--color-foreground) 65%, transparent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Master switch: a small themed toggle, upstream's ToggleSwitch. */
.audio-switch {
    flex: none;
    width: 2.8333rem;
    height: 1.5rem;
    padding: 0.1667rem;
    display: flex;
    align-items: center;
    border: 1px solid color-mix(in srgb, var(--color-foreground) 25%, transparent);
    border-radius: 1rem;
    background: color-mix(in srgb, var(--color-foreground) 8%, transparent);
    cursor: pointer;
}

.audio-switch-knob {
    width: 1.0833rem;
    height: 1.0833rem;
    border-radius: 50%;
    background: color-mix(in srgb, var(--color-foreground) 55%, transparent);
    transition: transform 160ms ease-out, background 160ms ease-out;
}

.audio-switch-on {
    border-color: color-mix(in srgb, var(--color-accent) 60%, transparent);
}

.audio-switch-on .audio-switch-knob {
    transform: translateX(1.3333rem);
    background: var(--color-accent);
}

.audio-separator {
    height: 1px;
    background: color-mix(in srgb, var(--color-foreground) 10%, transparent);
}

/* ---- Sections ------------------------------------------------------ */

.audio-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.audio-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.audio-section-title {
    font-size: 0.8333rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: color-mix(in srgb, var(--color-foreground) 65%, transparent);
}

.audio-section-value {
    font-size: 0.8333rem;
    font-weight: 700;
    color: color-mix(in srgb, var(--color-foreground) 65%, transparent);
}

/* ---- Sliders (continuous, filled) ---------------------------------- */

.audio-slider-row {
    padding: 0.3333rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.4167rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
}

.audio-slider {
    height: 1.1667rem;
    display: flex;
    align-items: center;
    cursor: pointer;
    touch-action: none;
}

.audio-slider-track {
    width: 100%;
    height: 0.4167rem;
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--color-foreground) 15%, transparent);
    overflow: hidden;
}

.audio-slider-fill {
    height: 100%;
    background: var(--color-foreground);
}

/* Input peak meter: live level under the slider. */
.audio-peak {
    height: 0.4167rem;
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--color-foreground) 18%, transparent);
    overflow: hidden;
}

.audio-peak-fill {
    height: 100%;
    width: 0;
    background: var(--color-foreground);
    transition: width 70ms linear;
}

/* ---- Device rows --------------------------------------------------- */

.audio-devices {
    display: flex;
    flex-direction: column;
    gap: 0.1667rem;
}

.audio-row {
    display: flex;
    align-items: center;
    gap: 0.6667rem;
    padding: 0.5833rem 0.5rem;
    border: 1px solid transparent;
    background: none;
    border-radius: var(--radius);
    font-family: var(--font-mono);
    text-align: left;
    color: var(--color-foreground);
    cursor: pointer;
}

.audio-row:hover {
    background: color-mix(in srgb, var(--color-foreground) 6%, transparent);
}

.audio-row-current {
    background: color-mix(in srgb, var(--color-foreground) 8%, transparent);
}

.audio-row-current .audio-row-label {
    font-weight: 700;
}

.audio-row-icon {
    flex: none;
    width: 1.8333rem;
    text-align: center;
    font-size: 1.25rem;
    line-height: 1;
}

.audio-row-label {
    flex: 1;
    min-width: 0;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---- Streams (the page's media elements) --------------------------- */

.audio-streams {
    display: flex;
    flex-direction: column;
    gap: 0.8333rem;
}

.audio-stream {
    display: flex;
    flex-direction: column;
    gap: 0.1667rem;
    padding: 0.3333rem 0.5rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
}

.audio-stream-top {
    display: flex;
    align-items: center;
    gap: 0.6667rem;
}

.audio-stream-mute {
    padding: 0;
    border: none;
    background: none;
    font-family: var(--font-mono);
    color: var(--color-foreground);
    cursor: pointer;
}

/* ---- Shared state -------------------------------------------------- */

.audio-dimmed {
    opacity: 0.5;
}

/* Keyboard cursor — the shared highlight hover and j/k/h/l both move. */
.audio-cursor {
    border-color: var(--color-accent);
}

/* The header cursor target is the switch itself. */
.audio-switch.audio-cursor {
    border-color: var(--color-accent);
}
