/*
 * StarshipOS — Spectator Broadcast CSS (CC_100 P3)
 * LCARS-inspired sci-fi aesthetic. Full-screen 1080p+ landscape layout.
 * CSS-only view cycling via animation. No JavaScript frameworks.
 */

/* ── Base ───────────────────────────────────────────────────────────────── */

.spectator-body {
    margin: 0;
    padding: 0;
    background: #000;
    color: #00ff41;
    font-family: 'Courier New', Courier, monospace;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    user-select: none;
}

/* ── Alert flash overlay ────────────────────────────────────────────────── */

.alert-flash {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.2s;
}

.alert-flash.flashing {
    animation: flash-pulse 1.5s ease-out forwards;
}

.flash-red    { background: rgba(255, 0, 0, 0.35); }
.flash-yellow { background: rgba(255, 200, 0, 0.30); }
.flash-green  { background: rgba(0, 255, 65, 0.20); }
.flash-blue   { background: rgba(0, 120, 255, 0.30); }

@keyframes flash-pulse {
    0%   { opacity: 0; }
    20%  { opacity: 1; }
    60%  { opacity: 0.6; }
    100% { opacity: 0; }
}

/* ── Alert body states ──────────────────────────────────────────────────── */

body[data-alert="RED"] .spectator-header {
    border-bottom-color: #ff2222;
    animation: pulse-red 2s ease-in-out infinite;
}

body[data-alert="YELLOW"] .spectator-header {
    border-bottom-color: #ffcc00;
    animation: pulse-yellow 3s ease-in-out infinite;
}

@keyframes pulse-red {
    0%, 100% { box-shadow: 0 0 10px rgba(255, 34, 34, 0.4); }
    50%       { box-shadow: 0 0 30px rgba(255, 34, 34, 0.9); }
}

@keyframes pulse-yellow {
    0%, 100% { box-shadow: 0 0 10px rgba(255, 204, 0, 0.3); }
    50%       { box-shadow: 0 0 25px rgba(255, 204, 0, 0.7); }
}

/* ── Custom GM message ──────────────────────────────────────────────────── */

.custom-message {
    position: fixed;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 200, 0, 0.15);
    border: 2px solid #ffcc00;
    color: #ffcc00;
    font-size: clamp(1rem, 2.5vw, 1.6rem);
    font-weight: bold;
    letter-spacing: 0.08em;
    padding: 0.6em 2em;
    text-transform: uppercase;
    z-index: 500;
    animation: gm-msg-blink 1.5s step-end infinite;
}

@keyframes gm-msg-blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.6; }
}

/* ── Header ─────────────────────────────────────────────────────────────── */

.spectator-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5em 2em;
    background: #0a0a0a;
    border-bottom: 2px solid #00ff41;
    height: 56px;
    flex-shrink: 0;
    transition: box-shadow 0.5s;
}

.ship-name {
    font-size: clamp(1rem, 2vw, 1.4rem);
    font-weight: bold;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.alert-badge {
    font-size: clamp(0.9rem, 1.8vw, 1.3rem);
    font-weight: bold;
    letter-spacing: 0.2em;
    padding: 0.2em 1.2em;
    border: 2px solid currentColor;
    text-transform: uppercase;
}

.alert-green  { color: #00ff41; border-color: #00ff41; }
.alert-yellow { color: #ffcc00; border-color: #ffcc00; }
.alert-red    { color: #ff2222; border-color: #ff2222; animation: badge-pulse 1s ease-in-out infinite; }
.alert-blue   { color: #4488ff; border-color: #4488ff; }

@keyframes badge-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.5; }
}

.crew-count,
.timestamp {
    font-size: clamp(0.75rem, 1.4vw, 1rem);
    letter-spacing: 0.1em;
    color: #88cc88;
    margin-left: 1.5em;
}

.header-right {
    display: flex;
    align-items: center;
}

/* ── View cycling container ─────────────────────────────────────────────── */

.view-cycle-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.spectator-view {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    padding: 1.5em 2em;
    opacity: 0;
    transform: translateX(100%);
    transition: opacity 0.6s ease, transform 0.6s ease;
    pointer-events: none;
}

.spectator-view.active {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.view-label {
    font-size: clamp(0.7rem, 1.3vw, 0.95rem);
    letter-spacing: 0.3em;
    color: #44aa44;
    text-transform: uppercase;
    margin-bottom: 1.2em;
    border-bottom: 1px solid #1a3a1a;
    padding-bottom: 0.4em;
}

/* ── View 1: OVERVIEW ───────────────────────────────────────────────────── */

.overview-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2em;
    flex: 1;
    align-content: start;
}

.vitals-panel {
    display: flex;
    flex-direction: column;
    gap: 1.4em;
}

.vital-item {
    display: grid;
    grid-template-columns: 220px 1fr 60px;
    align-items: center;
    gap: 1em;
}

.vital-label {
    font-size: clamp(0.7rem, 1.2vw, 0.9rem);
    letter-spacing: 0.1em;
    color: #88cc88;
    text-transform: uppercase;
}

.gauge-bar {
    height: 24px;
    background: #0d1a0d;
    border: 1px solid #1a3a1a;
    position: relative;
    overflow: hidden;
}

.gauge-fill {
    height: 100%;
    transition: width 1s ease;
    position: relative;
}

.hull-fill    { background: linear-gradient(90deg, #00cc33, #00ff41); }
.shield-fill  { background: linear-gradient(90deg, #0044bb, #4488ff); }
.reactor-fill { background: linear-gradient(90deg, #aa5500, #ff8800); }
.power-fill   { background: linear-gradient(90deg, #887700, #ffcc00); }

.gauge-fill.warning  { background: linear-gradient(90deg, #cc8800, #ffcc00) !important; }
.gauge-fill.critical { background: linear-gradient(90deg, #cc0000, #ff3333) !important; }

.vital-value {
    font-size: clamp(0.75rem, 1.3vw, 0.95rem);
    text-align: right;
    color: #aaffaa;
}

.overview-info {
    display: flex;
    flex-direction: column;
    gap: 1.2em;
    justify-content: center;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 0.2em;
}

.info-label {
    font-size: clamp(0.6rem, 1vw, 0.75rem);
    color: #44aa44;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.info-value {
    font-size: clamp(0.9rem, 1.6vw, 1.2rem);
    color: #00ff41;
    font-weight: bold;
}

/* ── View 2: SYSTEMS ────────────────────────────────────────────────────── */

.systems-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.8em;
    align-content: start;
}

.system-item {
    display: flex;
    flex-direction: column;
    gap: 0.3em;
    padding: 0.6em;
    background: #050f05;
    border: 1px solid #1a3a1a;
}

.system-item.system-critical {
    border-color: #ff2222;
    background: #1a0000;
    animation: pulse-critical 1.5s ease-in-out infinite;
}

.system-item.system-offline {
    border-color: #444;
    background: #0a0a0a;
    opacity: 0.6;
}

@keyframes pulse-critical {
    0%, 100% { box-shadow: none; }
    50%       { box-shadow: 0 0 8px rgba(255, 34, 34, 0.6); }
}

.system-name {
    font-size: clamp(0.6rem, 1vw, 0.75rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #88cc88;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.system-bar {
    height: 10px;
    background: #0d1a0d;
    border: 1px solid #1a3a1a;
    overflow: hidden;
}

.system-bar-fill {
    height: 100%;
    transition: width 1s ease;
}

.system-state {
    font-size: clamp(0.55rem, 0.9vw, 0.7rem);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-weight: bold;
}

/* ── View 3: EVENTS ─────────────────────────────────────────────────────── */

.events-feed {
    display: flex;
    flex-direction: column;
    gap: 0.5em;
    overflow: hidden;
    max-height: calc(100% - 80px);
}

.event-entry {
    display: grid;
    grid-template-columns: 120px 1fr 80px;
    align-items: center;
    gap: 1em;
    padding: 0.5em 0.8em;
    background: #050f05;
    border-left: 3px solid #1a3a1a;
}

.event-entry.event-critical { border-left-color: #ff2222; background: #1a0505; }
.event-entry.event-warning  { border-left-color: #ffcc00; background: #1a1500; }
.event-entry.event-info     { border-left-color: #00ff41; }

.event-type {
    font-size: clamp(0.6rem, 1vw, 0.75rem);
    letter-spacing: 0.1em;
    color: #44aa44;
    text-transform: uppercase;
}

.event-message {
    font-size: clamp(0.7rem, 1.2vw, 0.9rem);
    color: #ccffcc;
}

.event-time {
    font-size: clamp(0.6rem, 0.9vw, 0.7rem);
    color: #556655;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ── View 4: MISSION ────────────────────────────────────────────────────── */

.mission-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5em;
    align-items: flex-start;
    justify-content: center;
    flex: 1;
    max-width: 900px;
}

.mission-name {
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    font-weight: bold;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: #00ff41;
}

.mission-objective {
    font-size: clamp(0.85rem, 1.5vw, 1.1rem);
    color: #aaffaa;
    line-height: 1.6;
    max-width: 800px;
}

.mission-progress-container {
    width: 100%;
    display: grid;
    grid-template-columns: 120px 1fr 80px;
    align-items: center;
    gap: 1em;
}

.mission-progress-label {
    font-size: clamp(0.65rem, 1.1vw, 0.8rem);
    letter-spacing: 0.15em;
    color: #44aa44;
    text-transform: uppercase;
}

.mission-progress-bar {
    height: 28px;
    background: #0d1a0d;
    border: 1px solid #1a3a1a;
    overflow: hidden;
}

.mission-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #005522, #00ff41);
    transition: width 1.5s ease;
}

.mission-progress-value {
    font-size: clamp(0.8rem, 1.3vw, 1rem);
    color: #aaffaa;
    text-align: right;
}

.mission-status {
    font-size: clamp(0.75rem, 1.3vw, 1rem);
    font-weight: bold;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    padding: 0.3em 1em;
    border: 1px solid currentColor;
}

.status-active    { color: #00ff41; border-color: #00ff41; }
.status-completed { color: #4488ff; border-color: #4488ff; }
.status-failed    { color: #ff2222; border-color: #ff2222; }

/* ── No data ─────────────────────────────────────────────────────────────── */

.no-data {
    font-size: clamp(0.75rem, 1.3vw, 1rem);
    color: #335533;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    text-align: center;
    margin-top: 3em;
}

/* ── Footer ─────────────────────────────────────────────────────────────── */

.spectator-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4em 2em;
    background: #0a0a0a;
    border-top: 1px solid #1a3a1a;
    height: 36px;
    flex-shrink: 0;
}

.footer-left,
.footer-right {
    font-size: clamp(0.5rem, 0.9vw, 0.7rem);
    letter-spacing: 0.2em;
    color: #335533;
    text-transform: uppercase;
}

.footer-right {
    color: #00ff41;
    animation: blink-live 2s step-end infinite;
}

@keyframes blink-live {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.2; }
}

.view-indicators {
    display: flex;
    gap: 0.5em;
    align-items: center;
}

.view-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #1a3a1a;
    border: 1px solid #335533;
    display: inline-block;
    transition: background 0.3s, box-shadow 0.3s;
}

.view-dot.active {
    background: #00ff41;
    box-shadow: 0 0 6px #00ff41;
}

/* ── Offline page ────────────────────────────────────────────────────────── */

.spectator-offline {
    justify-content: center;
    align-items: center;
}

.offline-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1em;
    text-align: center;
}

.offline-icon {
    font-size: 4rem;
    color: #335533;
    animation: spin-offline 4s linear infinite;
}

@keyframes spin-offline {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.offline-title {
    font-size: clamp(1.5rem, 3vw, 2rem);
    letter-spacing: 0.4em;
    color: #335533;
    text-transform: uppercase;
}

.offline-subtitle {
    font-size: clamp(0.75rem, 1.3vw, 1rem);
    color: #223322;
}

.offline-retry {
    font-size: clamp(0.6rem, 1vw, 0.75rem);
    color: #1a2a1a;
    letter-spacing: 0.1em;
}
