/* ==========================================================================
   SPACE PROGRAM — Design System v3.0 (Minimal, Precision Space Dark)
   Aesthetic: HeroUI V3 subtle glass + Swiss precision + Monospace telemetry
   WCAG 2.1 AA compliant (contrast ratios >= 4.5:1, text-muted >= 5.2:1)
   ========================================================================== */

:root {
    color-scheme: dark;
    --bg-base: #06070a;
    --bg-surface: rgba(14, 17, 24, 0.72);
    --bg-elevated: #161b26;
    --bg-overlay: rgba(6, 7, 10, 0.85);

    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-medium: rgba(255, 255, 255, 0.16);
    --border-accent: rgba(34, 211, 238, 0.45);

    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8; /* Contrast >= 5.2:1 vs #06070a */

    --accent-cyan: #22d3ee;
    --accent-cyan-dim: rgba(34, 211, 238, 0.12);
    --accent-cyan-glow: rgba(34, 211, 238, 0.35);

    --accent-purple: #a855f7;
    --accent-purple-dim: rgba(168, 85, 247, 0.12);

    --status-success: #34d399;
    --status-success-dim: rgba(52, 211, 153, 0.14);
    --status-failure: #f87171;
    --status-failure-dim: rgba(248, 113, 113, 0.14);
    --status-warning: #fbbf24;
    --status-warning-dim: rgba(251, 191, 36, 0.14);

    --font-display: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;

    --transition: 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Subtle Starfield Canvas Background */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        radial-gradient(1px 1px at 25px 35px, rgba(255, 255, 255, 0.25), transparent),
        radial-gradient(1.5px 1.5px at 140px 90px, rgba(34, 211, 238, 0.3), transparent),
        radial-gradient(1px 1px at 240px 180px, rgba(255, 255, 255, 0.2), transparent),
        radial-gradient(1.2px 1.2px at 320px 40px, rgba(168, 85, 247, 0.25), transparent);
    background-repeat: repeat;
    background-size: 400px 400px;
    opacity: 0.7;
    z-index: -1;
}

::selection {
    background: var(--accent-cyan);
    color: var(--bg-base);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.sr-only:focus {
    position: fixed;
    top: 1rem;
    left: 1rem;
    width: auto;
    height: auto;
    padding: 0.75rem 1.25rem;
    background: var(--accent-cyan);
    color: var(--bg-base);
    font-weight: 600;
    border-radius: var(--radius-sm);
    z-index: 1000;
    outline: 2px solid white;
}

.container {
    width: 100%;
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Header & Glass Navigation */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 72px;
    z-index: 100;
    background: var(--bg-overlay);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-subtle);
}

.header .container {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.12em;
    color: var(--text-primary);
    text-decoration: none;
}

.logo-telemetry {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    padding: 0.15rem 0.45rem;
    border-radius: var(--radius-sm);
    background: var(--accent-cyan-dim);
    color: var(--accent-cyan);
    border: 1px solid rgba(34, 211, 238, 0.3);
    letter-spacing: 0.05em;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 0.25rem;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    padding: 0.25rem;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-subtle);
}

.nav-link {
    display: inline-block;
    padding: 0.45rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius-full);
    transition: all var(--transition);
}

.nav-link:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
    color: var(--text-primary);
    background: var(--accent-cyan-dim);
    border: 1px solid rgba(34, 211, 238, 0.35);
}

.menu-toggle {
    display: none;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 5px;
    background: transparent;
    border: 1px solid var(--border-subtle);
    padding: 0.55rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.menu-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-primary);
    transition: transform var(--transition);
}

/* Freshness Telemetry Banner */
.freshness-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.55rem 1rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.freshness-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--status-success);
    box-shadow: 0 0 10px var(--status-success);
    display: inline-block;
}

.pulse-dot.stale {
    background: var(--status-warning);
    box-shadow: 0 0 10px var(--status-warning);
}

.pulse-dot.offline {
    background: var(--status-warning);
    box-shadow: 0 0 10px var(--status-warning);
}

/* Sections */
.pt-header {
    padding-top: 108px;
    flex: 1;
}

.section {
    padding: 3rem 0;
}

.section-header {
    margin-bottom: 2.25rem;
}

.section-header h1, .section-header h2 {
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.15;
}

.section-header h1 {
    font-size: clamp(2.2rem, 4.5vw, 3.4rem);
    margin-bottom: 0.6rem;
}

.section-header p {
    color: var(--text-muted);
    font-size: 1.05rem;
    max-width: 68ch;
}

.text-gradient {
    background: linear-gradient(120deg, #ffffff 30%, var(--accent-cyan) 85%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Grids */
.grid {
    display: grid;
    gap: 1.25rem;
}

.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* HeroUI-Inspired Minimal Glass Card */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.6rem;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}

.card:hover {
    border-color: var(--border-medium);
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

/* Telemetry Stat Cards */
.stat-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1.4rem 1.6rem;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--border-medium), transparent);
}

.stat-card.cyan::before {
    background: linear-gradient(90deg, transparent, var(--accent-cyan), transparent);
}

.stat-card.purple::before {
    background: linear-gradient(90deg, transparent, var(--accent-purple), transparent);
}

.stat-card.pink::before {
    background: linear-gradient(90deg, transparent, #ec4899, transparent);
}

.stat-value {
    font-family: var(--font-display);
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
    margin-bottom: 0.35rem;
    font-variant-numeric: tabular-nums;
}

.stat-label {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

/* Launch Cards */
.launch-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 1.25rem;
}

.launch-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
}

.launch-header h3 {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text-primary);
}

.card-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.65rem;
    border-radius: var(--radius-full);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    white-space: nowrap;
}

.card-badge.success {
    background: var(--status-success-dim);
    color: var(--status-success);
    border-color: rgba(52, 211, 153, 0.3);
}

.card-badge.failure {
    background: var(--status-failure-dim);
    color: var(--status-failure);
    border-color: rgba(248, 113, 113, 0.3);
}

.card-badge.upcoming, .card-badge.go {
    background: var(--accent-cyan-dim);
    color: var(--accent-cyan);
    border-color: rgba(34, 211, 238, 0.3);
}

.card-badge.danger {
    background: var(--status-failure-dim);
    color: var(--status-failure);
    border-color: rgba(248, 113, 113, 0.3);
}

.card-badge.warning {
    background: var(--status-warning-dim);
    color: var(--status-warning);
    border-color: rgba(251, 191, 36, 0.3);
}

.launch-info {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.info-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.86rem;
    color: var(--text-secondary);
}

.info-row svg {
    color: var(--accent-cyan);
    flex-shrink: 0;
}

.launch-description {
    font-size: 0.82rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-subtle);
    padding-top: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Card pieces shared by JS-rendered launch/vehicle cards */
.card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.6rem;
    margin-bottom: 0.7rem;
}

.card-title {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 600;
    line-height: 1.35;
    margin-bottom: 0.35rem;
    color: var(--text-primary);
}

.text-muted {
    color: var(--text-muted);
}

/* Stale Data Warning Banner */
.stale-banner {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.9rem;
    background: var(--status-warning-dim);
    border: 1px solid rgba(251, 191, 36, 0.3);
    border-radius: var(--radius-sm);
    color: var(--status-warning);
    font-size: 0.78rem;
    font-family: var(--font-mono);
    margin-bottom: 0.8rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    gap: 0.5rem;
    padding: 0.65rem 1.4rem;
    font-family: var(--font-body);
    font-size: 0.86rem;
    font-weight: 600;
    text-decoration: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
    border: 1px solid transparent;
}

.btn-primary {
    background: var(--accent-cyan);
    color: var(--bg-base);
}

.btn-primary:hover {
    background: #67e8f9;
    box-shadow: 0 0 24px var(--accent-cyan-glow);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    border-color: var(--border-subtle);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--border-medium);
}

/* Filters */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.9rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    margin-bottom: 2rem;
}

.filter-input, .filter-select {
    flex: 1;
    min-width: 180px;
    padding: 0.65rem 0.9rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.86rem;
    transition: border-color var(--transition);
}

.filter-input:focus, .filter-select:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px var(--accent-cyan-dim);
}

select {
    min-height: 44px;
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 0.6rem 0.9rem;
    font-family: var(--font-body);
    font-size: 0.86rem;
}

.vehicle-compare-field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.vehicle-compare-field select {
    width: 100%;
}

/* Vehicle Selector Pills */
.vehicle-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.vehicle-btn {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 0.45rem 0.9rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.vehicle-btn:hover {
    border-color: var(--accent-cyan);
    color: var(--text-primary);
}

.vehicle-btn.selected {
    background: var(--accent-cyan);
    color: var(--bg-base);
    border-color: var(--accent-cyan);
    font-weight: 600;
    box-shadow: 0 0 16px var(--accent-cyan-glow);
}

/* Data Table */
.comparison-table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-lg);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.data-table th, .data-table td {
    padding: 0.85rem 1.1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
}

.data-table th {
    font-family: var(--font-mono);
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.02);
}

.data-table td.highlight {
    color: var(--accent-cyan);
    font-weight: 600;
}

/* News Cards */
.news-card {
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

.news-card .card-image {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-bottom: 1px solid var(--border-subtle);
}

.news-card .card-content {
    padding: 1.3rem;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.news-card .card-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.6rem;
    font-family: var(--font-mono);
}

.news-card h3 {
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 0.6rem;
}

.news-card p {
    font-size: 0.86rem;
    color: var(--text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 1rem;
}

.read-more {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-cyan);
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: auto;
}

.read-more:hover {
    color: #67e8f9;
}

/* Charts */
.chart-container {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.6rem;
}

.chart-container h3 {
    font-family: var(--font-display);
    font-size: 1.05rem;
    margin-bottom: 1.25rem;
}

.chart-wrapper {
    position: relative;
    height: 320px;
}

/* Footer */
.footer {
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-base);
    padding: 3.5rem 0 2rem;
    margin-top: 5rem;
}

.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 2.5rem;
    margin-bottom: 2.5rem;
}

.footer-brand p {
    color: var(--text-muted);
    font-size: 0.88rem;
    margin-top: 0.6rem;
    max-width: 38ch;
}

.footer h2, .footer h4 {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
    margin-bottom: 0.9rem;
}

.footer-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.footer-links a {
    display: inline-block;
    padding: 0.35rem 0;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.86rem;
    transition: color var(--transition);
}

.footer-links a:hover {
    color: var(--accent-cyan);
}

.footer-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-subtle);
    padding-top: 1.5rem;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.footer:not(:has(.footer-grid)) {
    padding-top: 1.75rem;
}

/* Launches : sections par provider (onglet Upcoming) */
.provider-section {
    margin-bottom: 2.5rem;
}

.provider-heading {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--text-primary);
    margin-bottom: 0.15rem;
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.provider-count {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: none;
    color: var(--text-muted);
}

/* Launches : onglet Completed groupe par lanceur (donnees statiques) */
.launcher-list {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    max-height: 420px;
    overflow-y: auto;
}

.launcher-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.85rem;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.86rem;
}

.launcher-row:last-child {
    border-bottom: 0;
}

.launcher-row time {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-muted);
    min-width: 84px;
}

.launcher-row .name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-secondary);
}

/* Reserve de hauteur des graphiques (Chart.js dimensionne apres coup -> CLS) */
#radar {
    aspect-ratio: 1 / 1;
    width: 100%;
    height: auto;
}

#year-chart, #provider-chart {
    aspect-ratio: 2 / 1;
    width: 100%;
    height: auto;
}

.sync-status {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin: 0.5rem 0 1rem;
}

.sync-status.stale {
    color: var(--status-warning);
}

.launcher-note {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-muted);
    text-align: right;
    margin-top: 0.5rem;
}

/* Squelettes de chargement (reservent la place -> pas de layout shift) */
.skeleton-card {
    min-height: 380px;
    background: linear-gradient(100deg, rgba(255,255,255,0.03) 30%, rgba(255,255,255,0.07) 50%, rgba(255,255,255,0.03) 70%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.4s ease-in-out infinite;
}

@keyframes skeleton-shimmer {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

/* Loading & Empty states */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 3rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 2px solid var(--border-subtle);
    border-top-color: var(--accent-cyan);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.hidden { display: none !important; }

/* Responsive */
@media (max-width: 900px) {
    .grid-4, .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
    .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
    .footer-grid { grid-template-columns: 1fr; }
    .menu-toggle { display: flex; }
    .nav-menu {
        display: none;
        position: absolute;
        top: 72px;
        left: 0;
        right: 0;
        background: var(--bg-base);
        flex-direction: column;
        padding: 1rem;
        border-radius: 0 0 var(--radius-lg) var(--radius-lg);
        border-bottom: 1px solid var(--border-subtle);
    }
    .nav-menu.active { display: flex; }
}

/* Accessibility: respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
