/* ============================================================
   HISTORYGRAPHER.NET - RETRO-FUTURISTIC OBSERVATORY
   Complete Design System with CSS Grid, Animations, and Effects
   ============================================================ */

/* ============================================================
   1. CUSTOM PROPERTIES - Color Palette & Theme Variables
   ============================================================ */

:root {
    /* Background Colors */
    --bg-primary: #0E0B07;
    --bg-secondary: #1C1410;
    --bg-tertiary: #2A1F14;

    /* Borders and Structure */
    --bezel: #3D2B1F;
    --bezel-light: #4A3D2E;

    /* Text Colors */
    --text-primary: #E8D5C4;
    --text-secondary: #A0826D;

    /* Accent Colors - Orange Neon */
    --accent-primary: #FF6B35;
    --accent-glow: #FF8C42;
    --accent-hot: #D4740E;
    --accent-light: #FFB574;

    /* Alert and Contrast */
    --alert: #E85D26;
    --contrast-cool: #4A6B5A;

    /* Shadows for Neon Glow */
    --glow-shadow: 0 0 8px rgba(255, 107, 53, 0.35), 0 0 24px rgba(255, 140, 66, 0.15);
    --glow-shadow-medium: 0 0 12px rgba(255, 107, 53, 0.4);
}

/* ============================================================
   2. FONT IMPORTS & TYPOGRAPHY SYSTEM
   ============================================================ */

@supports (font-variation-settings: normal) {
    /* Fraunces - Variable display serif with SOFT axis */
    :root {
        --font-display: 'Fraunces', serif;
        --font-label: 'Space Grotesk', sans-serif;
        --font-body: 'Instrument Serif', serif;
        --font-mono: 'Share Tech Mono', monospace;
    }
}

/* Fallbacks for non-variable font support */
@supports not (font-variation-settings: normal) {
    :root {
        --font-display: 'Fraunces', serif;
        --font-label: 'Space Grotesk', sans-serif;
        --font-body: 'Instrument Serif', serif;
        --font-mono: 'Share Tech Mono', monospace;
    }
}

/* ============================================================
   3. RESET & BASE STYLES
   ============================================================ */

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 17px;
    line-height: 1.72;
    overflow-x: hidden;
    position: relative;
}

/* Global CRT Scan-line Overlay */
.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 2px,
        rgba(0, 0, 0, 0.03) 2px,
        rgba(0, 0, 0, 0.03) 4px
    );
}

/* ============================================================
   4. PARTICLE CANVAS
   ============================================================ */

#particleCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    background-color: var(--bg-primary);
}

/* ============================================================
   5. NAVIGATION / INSTRUMENT BAR
   ============================================================ */

.instrument-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 80px;
    background: linear-gradient(180deg, #1A1208 0%, #2A1F14 100%);
    border-top: 1px solid var(--accent-hot);
    z-index: 100;
    display: flex;
    align-items: center;
    padding: 0 32px;
    gap: 24px;
    box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.5);
}

.toggle-group {
    display: flex;
    gap: 24px;
    align-items: center;
    width: 100%;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    position: relative;
}

.toggle-label input[type="checkbox"] {
    display: none;
}

.toggle-switch {
    width: 40px;
    height: 20px;
    background: rgba(51, 37, 25, 0.8);
    border: 2px inset var(--bezel);
    border-radius: 10px;
    position: relative;
    transition: background-color 0.3s ease;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background-color: rgba(160, 130, 109, 0.5);
    top: 2px;
    left: 2px;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.3s ease;
}

.toggle-label input[type="checkbox"]:checked + .toggle-switch {
    background-color: rgba(255, 107, 53, 0.15);
}

.toggle-label input[type="checkbox"]:checked + .toggle-switch::after {
    transform: translateX(20px);
    background-color: var(--accent-primary);
    box-shadow: var(--glow-shadow);
}

.toggle-text {
    font-family: var(--font-label);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

.toggle-label input[type="checkbox"]:checked + .toggle-switch + .toggle-text {
    color: var(--accent-primary);
    text-shadow: var(--glow-shadow-medium);
}

/* ============================================================
   6. MAIN OBSERVATION GRID LAYOUT
   ============================================================ */

main.observation-grid {
    position: relative;
    z-index: 10;
    width: 100%;
    padding: 32px;
    padding-bottom: 120px;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-gap: 16px;
    grid-auto-rows: auto;
    grid-auto-flow: dense;
    min-height: 100vh;
}

/* Hero Panel - Spans 5 columns, 2 rows */
.hero-panel {
    grid-column: 1 / span 5;
    grid-row: 1 / span 2;
    order: -1;
}

/* Data Readout Panels - Span 3 columns, 1 row */
.readout-panel {
    grid-column: span 3;
    grid-row: span 1;
}

/* Thumbnail Pods - Span 2 columns, 1 row */
.thumbnail-pod {
    grid-column: span 2;
    grid-row: span 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Narrative Strips - Span all columns */
.narrative-strip {
    grid-column: 1 / -1;
    grid-row: span 1;
}

/* ============================================================
   7. OBSERVATION PANEL BASE STYLES
   ============================================================ */

.observation-panel {
    background-color: var(--bg-secondary);
    border: 8px solid var(--bezel);
    padding: 24px;
    position: relative;
    transition: all 0.3s ease;
    animation: panel-reveal 0.4s ease-out backwards;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.5);
}

/* Staggered reveal animation for panels */
.hero-panel { animation-delay: 0ms; }
.readout-panel:nth-of-type(2) { animation-delay: 120ms; }
.readout-panel:nth-of-type(3) { animation-delay: 240ms; }
.readout-panel:nth-of-type(4) { animation-delay: 360ms; }
.readout-panel:nth-of-type(5) { animation-delay: 480ms; }
.thumbnail-pod:nth-of-type(3) { animation-delay: 600ms; }
.thumbnail-pod:nth-of-type(4) { animation-delay: 720ms; }
.thumbnail-pod:nth-of-type(5) { animation-delay: 840ms; }
.narrative-strip:first-of-type { animation-delay: 960ms; }
.narrative-strip:last-of-type { animation-delay: 1080ms; }

@keyframes panel-reveal {
    from {
        clip-path: inset(50% 0 50% 0);
        opacity: 0.8;
    }
    to {
        clip-path: inset(0 0 0 0);
        opacity: 1;
    }
}

/* Panel Hover State */
.observation-panel:hover {
    border-color: var(--accent-hot);
    transform: scale(1.008);
    transform-origin: center;
}

.observation-panel:hover::before {
    opacity: 0.06;
}

/* CRT Scan-line intensity increase on hover */
.observation-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 2px,
        rgba(0, 0, 0, 0.03) 2px,
        rgba(0, 0, 0, 0.03) 4px
    );
    opacity: 0.03;
    transition: opacity 0.3s ease;
}

/* ============================================================
   8. PANEL COMPONENTS
   ============================================================ */

.panel-header {
    background-color: var(--bg-tertiary);
    padding: 12px 16px;
    margin: -24px -24px 16px -24px;
    border-bottom: 1px solid var(--bezel);
}

.panel-designation {
    font-family: var(--font-label);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--accent-glow);
    text-shadow: var(--glow-shadow-medium);
}

.panel-content {
    position: relative;
    z-index: 2;
}

.panel-title {
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: 700;
    color: var(--accent-glow);
    margin-bottom: 20px;
    text-shadow: var(--glow-shadow-medium);
}

.panel-text {
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.68;
}

/* ============================================================
   9. HERO PANEL SPECIFIC STYLES
   ============================================================ */

.hero-panel {
    padding: 32px;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, rgba(28, 20, 16, 0.95) 100%);
}

.hero-title {
    font-family: var(--font-display);
    font-size: 72px;
    font-weight: 700;
    color: var(--accent-glow);
    margin-bottom: 16px;
    text-shadow: var(--glow-shadow-medium);
    font-variation-settings: 'opsz' 72;
    letter-spacing: -0.02em;
}

.hero-subtitle {
    font-family: var(--font-label);
    font-size: 18px;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent-primary);
    margin-bottom: 24px;
    text-shadow: var(--glow-shadow-medium);
}

.hero-text {
    color: var(--text-primary);
    font-size: 17px;
    line-height: 1.75;
    max-width: 90%;
}

/* ============================================================
   10. COUNTER ANIMATION SYSTEM
   ============================================================ */

.counter-block {
    margin: 20px 0;
    padding: 12px;
    border: 1px solid var(--bezel);
    background-color: rgba(14, 11, 7, 0.6);
    border-radius: 4px;
}

.counter-label {
    display: block;
    font-family: var(--font-label);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.counter {
    font-family: var(--font-mono);
    font-size: 36px;
    font-weight: 400;
    color: var(--accent-primary);
    text-shadow: var(--glow-shadow-medium);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

/* ============================================================
   11. NEON-GLOW SVG ILLUSTRATIONS
   ============================================================ */

.neon-icon {
    width: 100%;
    height: 100%;
    max-width: 120px;
    max-height: 120px;
    color: var(--accent-glow);
    filter: drop-shadow(0 0 6px rgba(255, 140, 66, 0.5));
    animation: svg-draw 1.8s ease-in-out 0.4s forwards;
    opacity: 0;
}

@keyframes svg-draw {
    0% {
        stroke-dashoffset: 500;
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        stroke-dashoffset: 0;
        opacity: 1;
    }
}

.neon-icon line,
.neon-icon path,
.neon-icon circle,
.neon-icon rect,
.neon-icon polygon {
    stroke-dasharray: 500;
}

/* ============================================================
   12. NARRATIVE STRIP STYLES
   ============================================================ */

.narrative-strip {
    padding: 40px !important;
    background: linear-gradient(to right, var(--bg-secondary), rgba(28, 20, 16, 0.95));
    column-count: 2;
    column-gap: 32px;
}

.narrative-title {
    font-family: var(--font-display);
    font-size: 48px;
    font-weight: 700;
    color: var(--accent-glow);
    margin-bottom: 24px;
    text-shadow: var(--glow-shadow-medium);
    column-span: all;
}

.narrative-text {
    color: var(--text-primary);
    font-size: 16px;
    line-height: 1.8;
    text-align: justify;
}

/* ============================================================
   13. THUMBNAIL POD BORDER ANIMATION
   ============================================================ */

.thumbnail-pod {
    animation: pulse-border 3s ease-in-out infinite;
}

@keyframes pulse-border {
    0%, 100% {
        border-color: var(--bezel);
        box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.5), 0 0 0 0 rgba(255, 107, 53, 0);
    }
    50% {
        border-color: var(--accent-hot);
        box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.5), 0 0 12px 2px rgba(255, 107, 53, 0.2);
    }
}

/* ============================================================
   14. RESPONSIVE DESIGN - MEDIUM VIEWPORT (768px-1439px)
   ============================================================ */

@media (max-width: 1439px) {
    main.observation-grid {
        grid-template-columns: repeat(6, 1fr);
        grid-gap: 12px;
        padding: 24px;
        padding-bottom: 100px;
    }

    .hero-panel {
        grid-column: 1 / span 4;
        grid-row: 1 / span 2;
    }

    .readout-panel {
        grid-column: span 2;
    }

    .thumbnail-pod {
        grid-column: span 2;
    }

    .narrative-strip {
        grid-column: 1 / -1;
    }

    .hero-title {
        font-size: 56px;
    }

    .panel-title {
        font-size: 24px;
    }

    .narrative-title {
        font-size: 36px;
    }

    .narrative-strip {
        column-count: 1;
    }
}

/* ============================================================
   15. RESPONSIVE DESIGN - NARROW VIEWPORT (<768px)
   ============================================================ */

@media (max-width: 767px) {
    main.observation-grid {
        grid-template-columns: 1fr;
        grid-gap: 12px;
        padding: 16px;
        padding-bottom: 100px;
    }

    .hero-panel,
    .readout-panel,
    .thumbnail-pod,
    .narrative-strip {
        grid-column: 1 / -1;
        grid-row: auto;
    }

    .observation-panel {
        border-width: 6px;
        border-radius: 12px;
        box-shadow: inset 0 -4px 8px rgba(255, 107, 53, 0.1);
    }

    .hero-title {
        font-size: 40px;
    }

    .panel-title {
        font-size: 20px;
    }

    .narrative-title {
        font-size: 28px;
    }

    .counter {
        font-size: 28px;
    }

    .instrument-bar {
        height: 100px;
        padding: 12px 16px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .toggle-group {
        gap: 12px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .toggle-text {
        font-size: 12px;
    }
}

/* ============================================================
   16. MOBILE - EXTRA SMALL (<480px)
   ============================================================ */

@media (max-width: 479px) {
    body {
        font-size: 15px;
    }

    main.observation-grid {
        padding: 12px;
        padding-bottom: 90px;
    }

    .hero-title {
        font-size: 32px;
    }

    .hero-subtitle {
        font-size: 14px;
    }

    .panel-title {
        font-size: 18px;
    }

    .counter {
        font-size: 24px;
    }

    .toggle-group {
        gap: 8px;
    }

    .instrument-bar {
        height: auto;
        padding: 8px;
    }
}

/* ============================================================
   17. PRINT STYLES
   ============================================================ */

@media print {
    .instrument-bar,
    .scanlines,
    #particleCanvas {
        display: none;
    }

    .observation-panel {
        page-break-inside: avoid;
        box-shadow: none;
    }
}

/* ============================================================
   18. PREFERS REDUCED MOTION
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
