/* ==========================================================================
   FINAL FANSTERY X: THE WHITE-IRON FIEND
   Spiran Machina & Pyrefly Telemetry Design System
   ========================================================================== */

:root {
    --bg-base: #04070e;
    --bg-surface: #080d19;
    --bg-card: rgba(11, 19, 36, 0.78);
    --bg-card-border: rgba(0, 240, 255, 0.18);
    --bg-card-border-gold: rgba(212, 154, 61, 0.25);
    
    --accent-cyan: #00f0ff;
    --accent-cyan-dim: rgba(0, 240, 255, 0.15);
    --accent-cyan-glow: rgba(0, 240, 255, 0.35);
    
    --accent-gold: #e5a842;
    --accent-brass: #b88228;
    --accent-gold-dim: rgba(229, 168, 66, 0.15);
    
    --accent-red: #ff3b4b;
    --accent-red-glow: rgba(255, 59, 75, 0.3);
    
    --text-primary: #e6edf8;
    --text-secondary: #94a3b8;
    --text-dim: #64748b;
    --text-gold: #f3c267;
    
    --font-prose: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-heading: 'Outfit', sans-serif;
    --font-title: 'Cinzel', serif;
    --font-mono: 'Space Mono', monospace;
    
    --transition-smooth: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    --reader-font-size: 1.05rem;
}

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

html, body {
    width: 100%;
    min-height: 100%;
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-prose);
    font-size: 16px;
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Background Atmospheric Overlays */
.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(
        rgba(18, 16, 16, 0) 50%, 
        rgba(0, 0, 0, 0.25) 50%
    );
    background-size: 100% 4px;
    z-index: 100;
    pointer-events: none;
    opacity: 0.6;
}

.glow-radial {
    position: fixed;
    top: -20vh;
    left: 50%;
    transform: translateX(-50%);
    width: 120vw;
    height: 90vh;
    background: radial-gradient(
        ellipse at top, 
        rgba(0, 240, 255, 0.07) 0%, 
        rgba(212, 154, 61, 0.04) 45%, 
        rgba(4, 7, 14, 0) 75%
    );
    z-index: 0;
    pointer-events: none;
}

.pyrefly-particles-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-image: 
        radial-gradient(circle 1.5px at 15% 25%, rgba(0, 240, 255, 0.4), transparent),
        radial-gradient(circle 2px at 85% 35%, rgba(229, 168, 66, 0.35), transparent),
        radial-gradient(circle 1px at 45% 75%, rgba(0, 240, 255, 0.3), transparent),
        radial-gradient(circle 2px at 70% 85%, rgba(0, 240, 255, 0.25), transparent);
    background-size: 100% 100%;
    z-index: 1;
    pointer-events: none;
    animation: pyreflyPulse 8s ease-in-out infinite alternate;
}

@keyframes pyreflyPulse {
    0% { opacity: 0.4; transform: translateY(0); }
    100% { opacity: 0.85; transform: translateY(-10px); }
}

/* App Container */
.app-container {
    position: relative;
    z-index: 10;
    max-width: 1540px;
    margin: 0 auto;
    padding: 1.5rem 2rem 2.5rem;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    gap: 1.25rem;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--bg-card-border);
    padding-bottom: 1.25rem;
    gap: 1.5rem;
}

.eyebrow {
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    color: var(--accent-gold);
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.glyph-icon {
    color: var(--accent-cyan);
}

.main-title {
    font-family: var(--font-title);
    font-size: 1.9rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #ffffff;
    text-shadow: 0 0 20px rgba(0, 240, 255, 0.3);
}

.accent-text {
    color: var(--accent-cyan);
    font-family: var(--font-heading);
    font-weight: 800;
    letter-spacing: 0.02em;
}

.system-status {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    background: rgba(0, 240, 255, 0.06);
    border: 1px solid var(--bg-card-border);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-cyan);
    box-shadow: 0 0 10px var(--accent-cyan);
    animation: statusBlink 2.5s infinite;
}

@keyframes statusBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Workspace Layout */
.workspace {
    display: grid;
    grid-template-columns: 460px 1fr;
    gap: 1.5rem;
    flex: 1;
    align-items: stretch;
}

/* Glass Panels */
.glass-panel {
    background: var(--bg-card);
    border: 1px solid var(--bg-card-border);
    border-radius: 8px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Left Panel */
.panel-left {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(0, 0, 0, 0.2);
}

.panel-title {
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
}

.panel-header-dots {
    display: flex;
    gap: 5px;
}

.panel-header-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
}

.panel-header-dots span:nth-child(1) { background: var(--accent-cyan); }
.panel-header-dots span:nth-child(2) { background: var(--accent-gold); }

/* Canvas Visualizer Wrapper */
.canvas-wrapper {
    position: relative;
    width: 100%;
    height: 320px;
    background: radial-gradient(circle at center, rgba(8, 18, 36, 0.6) 0%, rgba(3, 6, 12, 0.95) 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

#canvas-telemetry {
    width: 100%;
    height: 100%;
    display: block;
}

.canvas-overlay-data {
    position: absolute;
    bottom: 0.6rem;
    left: 1rem;
    right: 1rem;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    color: var(--text-dim);
}

/* HUD Readouts */
.hud-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    padding: 1rem 1.25rem;
    gap: 0.75rem;
    background: rgba(4, 8, 16, 0.4);
}

.hud-stat-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.hud-label {
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    color: var(--text-dim);
}

.hud-value {
    font-size: 0.95rem;
    font-weight: 700;
}

/* Metrics Card */
.metrics-card {
    padding: 1.15rem 1.25rem;
    background: rgba(8, 13, 24, 0.7);
    border: 1px solid var(--bg-card-border-gold);
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.metric-box {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 0.5rem 0.65rem;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.metric-label {
    font-size: 0.6rem;
    letter-spacing: 0.06em;
    color: var(--text-dim);
}

.metric-status {
    font-size: 0.78rem;
    font-weight: 700;
}

.log-ticker {
    border-top: 1px dashed rgba(255, 255, 255, 0.08);
    padding-top: 0.75rem;
    font-style: italic;
    color: #8da1b9;
    min-height: 2.2rem;
}

/* Colors Utilities */
.text-accent-cyan { color: var(--accent-cyan); }
.text-accent-gold { color: var(--accent-gold); }
.text-accent-red { color: var(--accent-red); }
.text-ok { color: #34d399; }
.text-dim { color: var(--text-dim); }
.text-xs { font-size: 0.72rem; }
.font-mono { font-family: var(--font-mono); }

/* Right Panel: Story Reader */
.panel-right {
    display: flex;
    flex-direction: column;
    min-height: 700px;
}

/* Tab Navigation */
.tab-navigation {
    display: flex;
    background: rgba(4, 7, 14, 0.6);
    border-bottom: 1px solid var(--bg-card-border);
    overflow-x: auto;
    scrollbar-width: thin;
}

.tab-btn {
    flex: 1;
    min-width: 140px;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-secondary);
    padding: 0.9rem 0.8rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    border-right: 1px solid rgba(255, 255, 255, 0.04);
    position: relative;
    transition: var(--transition-smooth);
}

.tab-btn:hover {
    background: rgba(0, 240, 255, 0.04);
    color: var(--text-primary);
}

.tab-btn.active {
    background: rgba(0, 240, 255, 0.08);
    color: #ffffff;
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-gold), var(--accent-cyan));
    box-shadow: 0 0 10px var(--accent-cyan);
}

.tab-num {
    font-size: 0.65rem;
    color: var(--accent-gold);
    letter-spacing: 0.1em;
}

.tab-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Reader Viewport */
.reader-viewport {
    flex: 1;
    overflow-y: auto;
    padding: 2.25rem 3rem;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: var(--bg-card-border) transparent;
}

.reader-viewport::-webkit-scrollbar {
    width: 6px;
}

.reader-viewport::-webkit-scrollbar-thumb {
    background: var(--bg-card-border);
    border-radius: 3px;
}

/* Reader Content Typography */
.reader-content {
    max-width: 820px;
    margin: 0 auto;
    font-size: var(--reader-font-size);
    line-height: 1.85;
    color: #d1dced;
    transition: opacity 0.2s ease-in-out;
}

.reader-content.fade-out {
    opacity: 0;
}

.reader-content h1 {
    font-family: var(--font-title);
    font-size: 2.1rem;
    color: #ffffff;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--bg-card-border);
    padding-bottom: 0.75rem;
    letter-spacing: 0.03em;
    text-shadow: 0 0 16px rgba(0, 240, 255, 0.2);
}

.reader-content h2, 
.reader-content h3 {
    font-family: var(--font-heading);
    color: var(--accent-gold);
    margin-top: 2rem;
    margin-bottom: 0.9rem;
    letter-spacing: 0.03em;
}

.reader-content h2 {
    font-size: 1.45rem;
    border-left: 3px solid var(--accent-gold);
    padding-left: 0.75rem;
}

.reader-content h3 {
    font-size: 1.15rem;
}

.reader-content p {
    margin-bottom: 1.35rem;
}

.reader-content em {
    color: #fce7b2;
    font-style: italic;
}

.reader-content strong {
    color: #ffffff;
    font-weight: 600;
}

.reader-content hr {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--bg-card-border), transparent);
    margin: 2.5rem 0;
}

/* Code & Telemetry Blocks */
.reader-content code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: rgba(0, 240, 255, 0.08);
    color: var(--accent-cyan);
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    border: 1px solid rgba(0, 240, 255, 0.2);
}

.reader-content pre {
    background: rgba(4, 7, 14, 0.85);
    border: 1px solid var(--bg-card-border);
    border-left: 4px solid var(--accent-cyan);
    padding: 1rem 1.25rem;
    border-radius: 4px;
    margin: 1.5rem 0;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.6;
    color: #8be9fd;
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.6);
}

.reader-content pre code {
    background: transparent;
    padding: 0;
    border: none;
    color: inherit;
}

/* Blockquotes / Yevon Inquisition & Crusader Dispatches */
.reader-content blockquote {
    background: rgba(229, 168, 66, 0.05);
    border: 1px solid rgba(229, 168, 66, 0.25);
    border-left: 4px solid var(--accent-gold);
    padding: 1.25rem 1.5rem;
    margin: 1.75rem 0;
    border-radius: 0 6px 6px 0;
    font-style: normal;
    color: #e2e8f0;
}

.reader-content blockquote p {
    margin-bottom: 0.75rem;
}

.reader-content blockquote p:last-child {
    margin-bottom: 0;
}

/* Roman Numeral formatting */
.roman-num {
    color: var(--accent-gold);
    font-weight: 700;
    margin-right: 0.5rem;
}

/* Skeleton Loader */
.loader-skeleton {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(0, 240, 255, 0.1);
    border-top: 3px solid var(--accent-cyan);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Reader Footer Controls */
.reader-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 0.75rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(4, 8, 16, 0.4);
}

.reader-controls {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.ctrl-btn {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-secondary);
    padding: 0.35rem 0.75rem;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.ctrl-btn:hover {
    background: rgba(0, 240, 255, 0.1);
    border-color: var(--accent-cyan);
    color: #ffffff;
}

.text-resizer {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.font-size-indicator {
    min-width: 42px;
    text-align: center;
}

/* Focus Mode */
body.focus-mode .panel-left {
    display: none;
}

body.focus-mode .workspace {
    grid-template-columns: 1fr;
}

body.focus-mode .reader-content {
    max-width: 960px;
}

/* Site Footer */
.footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding-top: 1rem;
    color: var(--text-dim);
}

.footer-sep {
    margin: 0 0.5rem;
    opacity: 0.4;
}

/* Responsive Breakpoints */
@media (max-width: 1100px) {
    .workspace {
        grid-template-columns: 1fr;
    }
    
    .panel-left {
        max-width: 600px;
        margin: 0 auto;
        width: 100%;
    }
}

@media (max-width: 768px) {
    .app-container {
        padding: 1rem;
    }
    
    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .main-title {
        font-size: 1.4rem;
    }
    
    .reader-viewport {
        padding: 1.5rem 1.25rem;
    }
    
    .footer {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }
}
