/* ═══════════════════════════════════════
   Aether Shell — index.html container
   Transmission console (player bar) +
   iframe layout. Tokens come from base.css
   (linked first by index.html).
   ═══════════════════════════════════════ */

body {
    --tabbar-h: 54px; /* mobile dock: tab bar height (excl. safe area) */
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-ui);
    overflow: hidden;
    /* iOS Safari: 100vh is taller than the visible area (URL/tool bars), so the
       iframe bottom hid behind the toolbar. dvh tracks the *dynamic* viewport;
       the vh line stays as fallback for older engines. */
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    /* mobile: the iframe ends above the tab bar (pages only pad for the player bar) */
    padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
    /* standalone PWA with black-translucent status bar: keep the iframe below the notch */
    padding-top: env(safe-area-inset-top, 0px);
}

/* Class rules below set display on elements the JS toggles with the `hidden`
   attribute (install buttons, sheet volume/log) — the attribute must always win. */
[hidden] {
    display: none !important;
}

#content-frame {
    flex-grow: 1;
    width: 100%;
    border: none;
}

/* ── Transmission console (player bar) ── */
.player-bar {
    position: fixed;
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px)); /* docks on the tab bar; 0 from 768px */
    left: 0;
    right: 0;
    background: var(--bg-overlay);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--line-signal);
    z-index: 100;
    transform: translateY(100%);
    transition: transform 0.3s var(--ease);
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.45);
}

.player-bar.active {
    transform: translateY(0);
}

/* Mobile-first: compact single row. On phones the tab bar below carries the
   home-indicator safe area; from 768px the bar sits at the bottom itself and the
   safe area moves into its padding shorthand (a separate padding-bottom
   declaration gets overridden by the shorthand — keep it inside). */
.player-bar {
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.now-playing {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.np-img {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    background: var(--bg-inset);
    border: 1px solid var(--line);
    flex-shrink: 0;
}

.np-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.np-name {
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.np-detail {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 0.6875rem;
    color: var(--signal);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}

/* mobile: the now-playing block is a tap target that opens the sheet */
.np-expand {
    flex-shrink: 0;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 0 0.25rem;
}

.now-playing[role="button"] {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.player-controls {
    flex-shrink: 0;
}

.btn-pp {
    background: var(--signal);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    color: var(--bg-base);
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: box-shadow var(--t-med) var(--ease), transform var(--t-fast) var(--ease);
    padding-left: 3px;
    touch-action: manipulation;
    box-shadow: var(--glow-signal);
}

.btn-pp:hover {
    transform: scale(1.05);
}

.btn-pp.is-playing {
    padding-left: 0;
    font-size: 1.2rem;
}

/* Telemetry + volume — hidden on mobile */
.player-right {
    display: none;
}

#viz-mini {
    display: none;
    flex-shrink: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--bg-inset);
    padding: 2px;
}

@media (min-width: 1200px) {
    #viz-mini {
        display: block;
    }
}

.tx-telemetry {
    display: flex;
    align-items: center;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: var(--fs-micro);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    white-space: nowrap;
    min-width: 0;
    overflow: hidden;
    flex-shrink: 1;
}

.tx-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

/* separators live on the items so hidden items take their divider with them */
.tx-item + .tx-item {
    border-left: 1px solid var(--line-strong);
    margin-left: 0.9rem;
    padding-left: 0.9rem;
}

/* progressive disclosure: codec from 1100px, SIG/BUF from 1300px */
#tx-codec,
#tx-sig,
#tx-buf {
    display: none;
}

.vol-label {
    margin-left: 0.25rem;
    flex-shrink: 0;
}


/* Console micro-buttons (sleep timer, share) — shown from 900px */
.btn-console {
    display: none;
    flex-shrink: 0;
    background: var(--bg-inset);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: var(--fs-micro);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.35rem 0.55rem;
    min-height: 32px;
    cursor: pointer;
    transition: border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
    white-space: nowrap;
}

.btn-console:hover {
    border-color: var(--line-strong);
    color: var(--text-primary);
}

.btn-console.active {
    border-color: var(--line-signal);
    color: var(--signal);
    background: var(--signal-bg);
}

.btn-fav-player {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.3rem;
    cursor: pointer;
    transition: color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
    padding: 0.2rem;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    min-height: 44px;
    min-width: 44px;
    justify-content: center;
    touch-action: manipulation;
}

.btn-fav-player:hover {
    color: var(--err);
    transform: scale(1.1);
}

.btn-fav-player.active {
    color: var(--err);
}

/* Volume fader */
.vol-slider {
    width: 100px;
    flex-shrink: 0;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    cursor: pointer;
}

.vol-slider::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    background: var(--bg-inset);
    border: 1px solid var(--line);
    border-radius: 1px;
}

.vol-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    height: 18px;
    width: 8px;
    border-radius: 1px;
    background: var(--signal);
    margin-top: -8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s;
}

.vol-slider::-moz-range-track {
    height: 4px;
    background: var(--bg-inset);
    border: 1px solid var(--line);
    border-radius: 1px;
}

.vol-slider::-moz-range-thumb {
    height: 18px;
    width: 8px;
    border: none;
    border-radius: 1px;
    background: var(--signal);
}

.vol-slider::-webkit-slider-thumb:hover,
.vol-slider:active::-webkit-slider-thumb {
    transform: scaleY(1.15);
}

/* ── 480px+: show detail text ── */
@media (min-width: 480px) {
    .np-img {
        width: 44px;
        height: 44px;
    }

    .np-name {
        font-size: 0.9rem;
    }

    .np-detail {
        font-size: 0.75rem;
    }
}

/* ── 768px+: full desktop layout ──
   Play button sits at the far left (first in the markup), the
   now-playing text takes all remaining space, and the right-hand
   telemetry/controls only claim the width they need. Telemetry items
   reveal progressively as the window grows. */
@media (min-width: 768px) {
    body {
        padding-bottom: 0;
    }

    .player-bar {
        bottom: 0;
        padding: 0.8rem 1.5rem calc(0.8rem + env(safe-area-inset-bottom, 0px));
        justify-content: flex-start;
        gap: 0.9rem;
    }

    .now-playing {
        flex: 1 1 auto;
        min-width: 0;
        gap: 1rem;
    }

    .np-img {
        width: 48px;
        height: 48px;
    }

    .np-name {
        font-size: 1rem;
    }

    .np-detail {
        font-size: 0.8rem;
        margin-top: 2px;
    }

    .player-controls {
        display: flex;
        align-items: center;
        flex: 0 0 auto;
    }

    .btn-pp {
        width: 48px;
        height: 48px;
    }

    .player-right {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: 0.9rem;
        flex: 0 1 auto;
        margin-left: auto;
        min-width: 0;
    }

    .player-right .btn-console {
        display: inline-flex;
        align-items: center;
    }
}

@media (min-width: 1000px) {
    #tx-codec {
        display: inline-flex;
    }
}

@media (min-width: 1200px) {
    #tx-sig,
    #tx-buf {
        display: inline-flex;
    }
}


/* ═══ Mobile dock: bottom tab bar (<768px; hidden from 768px above) ═══ */
.tab-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 110; /* above the player bar, which slides down behind it when inactive */
    display: flex;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--bg-base);
    border-top: 1px solid var(--line-strong);
}

.tab {
    position: relative;
    flex: 1;
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.625rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: color var(--t-fast) var(--ease);
}

.tab svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.tab.active {
    color: var(--signal);
}

.tab.active::after {
    content: '';
    position: absolute;
    top: -1px;
    left: 28%;
    right: 28%;
    height: 2px;
    background: var(--signal);
    box-shadow: var(--glow-signal);
}

.tab:active {
    color: var(--text-primary);
}

/* ═══ Mobile: full-screen now-playing sheet ═══ */
.np-sheet {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.9rem;
    padding: calc(0.25rem + env(safe-area-inset-top, 0px)) 1.25rem calc(1.25rem + env(safe-area-inset-bottom, 0px));
    background: var(--bg-base);
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: translateY(100%);
    visibility: hidden;
    transition: transform 0.3s var(--ease), visibility 0s linear 0.3s;
}

.np-sheet.open {
    transform: none;
    visibility: visible;
    transition: transform 0.3s var(--ease), visibility 0s;
}

.nps-grab {
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 0.6rem 0 0.2rem;
    touch-action: none; /* swipe-down-to-close */
    cursor: grab;
    flex-shrink: 0;
}

.nps-handle {
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: var(--line-strong);
}

.nps-head {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-shrink: 0;
}

.nps-close {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
}

.nps-status {
    font-family: var(--font-mono);
    font-size: var(--fs-micro);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
}

.nps-art {
    width: min(58vw, 240px);
    aspect-ratio: 1;
    margin-top: 0.5rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--bg-inset);
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: var(--shadow-panel);
}

.nps-art img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.nps-name {
    font-size: 1.25rem;
    font-weight: 800;
    line-height: 1.3;
    text-align: center;
    margin: 0.25rem 0 0;
    max-width: 100%;
}

.nps-detail {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: var(--fs-data);
    color: var(--signal);
    text-align: center;
    margin: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
}

.nps-telemetry {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: var(--fs-micro);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
}

.nps-telemetry .tx-item + .tx-item {
    border-left: 1px solid var(--line-strong);
    margin-left: 0.7rem;
    padding-left: 0.7rem;
}

.nps-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 0.5rem;
    flex-shrink: 0;
}

.nps-controls .btn-console {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    min-width: 64px;
    justify-content: center;
}

.btn-pp--lg {
    width: 72px;
    height: 72px;
    font-size: 1.6rem;
}

.btn-pp--lg.is-playing {
    font-size: 1.9rem;
}

.nps-row {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

.nps-row .btn-console {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
}

.nps-vol {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 0;
}

.nps-vol .vol-slider {
    flex: 1;
    width: auto;
    min-height: 32px;
}

.nps-log {
    width: 100%;
    border-top: 1px solid var(--line);
    padding-top: 0.75rem;
}

.nps-tracklog {
    list-style: none;
    margin: 0.5rem 0 0;
    padding: 0;
    font-family: var(--font-mono);
    font-size: var(--fs-data);
    color: var(--text-secondary);
}

.nps-tracklog li {
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 0.75rem;
    min-width: 0;
}

.nps-tracklog li:first-child {
    color: var(--text-primary);
}

.nps-tracklog .t {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nps-tracklog .ts {
    color: var(--text-muted);
    font-size: var(--fs-micro);
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

/* Desktop: no dock, no sheet (must follow the base rules above to win the cascade) */
@media (min-width: 768px) {
    .tab-bar,
    .np-sheet,
    .np-expand {
        display: none;
    }
}


/* ═══ Autoplay blocked (iOS: the tune gesture happened in the iframe) — make
   the one tap that fixes it obvious. Animation is killed globally under
   prefers-reduced-motion; the text change carries the state. ═══ */
.btn-pp.needs-tap {
    animation: pp-pulse 1.2s var(--ease) infinite;
}

@keyframes pp-pulse {
    0%, 100% { box-shadow: var(--glow-signal); }
    50% { box-shadow: 0 0 4px rgba(0, 229, 255, 0.9), 0 0 26px rgba(0, 229, 255, 0.5); }
}

/* ═══ Mobile: install hint — sits on the dock, lifts above the player bar when active ═══ */
.install-hint {
    position: fixed;
    left: 0.75rem;
    right: 0.75rem;
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 0.75rem);
    z-index: 105;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0.8rem;
    background: var(--bg-panel);
    border: 1px solid var(--line-signal);
    border-radius: var(--radius);
    box-shadow: var(--shadow-panel);
}

.install-hint[hidden] {
    display: none;
}

.player-bar.active ~ .install-hint {
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 65px + 0.75rem);
}

.install-body {
    flex: 1;
    min-width: 0;
}

.install-text {
    margin: 0.25rem 0 0;
    font-size: 0.8rem;
    line-height: 1.45;
    color: var(--text-secondary);
}

.install-actions {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    flex-shrink: 0;
}

.install-actions .btn-console {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    min-width: 36px;
}

.install-cta {
    border-color: var(--line-signal);
    color: var(--signal);
}

@media (min-width: 768px) {
    .install-hint {
        display: none;
    }
}
