/* ====================================================================
   ALL SKY (/allsky) — dedicated full-page view of the two all-sky
   sources. Both stacked and stream are captured server-side at all
   times; the view toggle only decides which panels are shown, so
   switching never interrupts capture.

   Only base.css tokens/reset and the sidebar shell are shared with the
   rest of the app.
   ==================================================================== */

.as-page {
    max-width: 1760px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ==================== TOPBAR ==================== */
.as-topbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding-bottom: 6px;
}

.as-title-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}

.as-eyebrow {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--secondary-purple);
}

.as-topbar h1 {
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1;
}

.as-global-state {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.as-global-state.is-down {
    color: var(--error-color);
}

/* ==================== VIEW TOGGLE ==================== */
.as-view-toggle {
    display: flex;
    gap: 4px;
}

.as-view-btn {
    padding: 5px 12px;
    border-radius: 999px;
    border: 1px solid var(--border-hairline);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.as-view-btn:hover {
    color: var(--text-secondary);
    border-color: var(--border-accent);
}

.as-view-btn.active {
    background: var(--surface-2);
    color: var(--text-primary);
    border-color: var(--border-accent);
}

/* ==================== GRID ====================
   "both" shows the two panels side by side (stacking below 900px, where
   there's no room for two); the single-source views hide the other panel
   and let the remaining one take the full width. */
.as-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

@media (min-width: 900px) {
    .as-grid[data-view="both"] {
        grid-template-columns: 1fr 1fr;
    }
}

.as-grid[data-view="stacked"] #as-panel-stream,
.as-grid[data-view="stream"] #as-panel-stacked {
    display: none;
}

/* ==================== PANEL ==================== */
.as-panel {
    display: flex;
    flex-direction: column;
    aspect-ratio: 4 / 3;
    border-radius: 10px;
    overflow: hidden;
    background: var(--surface-sunken);
    border: 1px solid var(--border-hairline);
    transition: border-color 0.15s ease;
}

.as-panel:hover {
    border-color: var(--border-accent);
}

.as-panel-head {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 13px;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 1.2px;
    color: var(--text-primary);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border-hairline);
}

.as-panel-title {
    flex-shrink: 0;
}

.as-panel-meta {
    margin-left: auto;
    font-weight: 400;
    letter-spacing: 0.3px;
    color: var(--text-faint);
    font-size: 0.64rem;
    text-align: right;
}

.as-panel-media {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
}

.as-panel-media img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    cursor: zoom-in;
}

/* Live dot: green when a fresh frame arrived within the expected window,
   red once the source goes stale or errors. */
.as-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-faint);
    flex-shrink: 0;
}

.as-dot.is-up {
    background: var(--accent-green);
    box-shadow: 0 0 6px var(--accent-green);
    animation: as-pulse 2s ease-in-out infinite;
}

.as-dot.is-down {
    background: var(--error-color);
    box-shadow: 0 0 6px var(--error-color);
}

@keyframes as-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

/* Unavailable: drop the (stale) image and collapse to a slim line, but
   keep the header visible so the source stays identifiable and the view
   toggle above remains usable. */
.as-panel-down {
    display: none;
}

.as-panel.is-down {
    aspect-ratio: auto;
}

.as-panel.is-down .as-panel-media {
    display: none;
}

.as-panel.is-down .as-panel-down {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 900px) {
    .as-topbar {
        padding-left: 46px;
    }
}
