/*
 * OTTO Platform - Shared Styles
 * Used by index.html and api.html
 */

/* IBM Plex Mono for CRT/terminal blocks - classic IBM terminal font */
@font-face {
    font-family: 'IBM Plex Mono';
    src: url('fonts/IBMPlexMono-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

/* ============================================================================
 * CSS Variables
 * ============================================================================ */

:root {
    --bg: #0a0a0a;
    --bg-secondary: #141414;
    --bg-tertiary: #1a1a1a;
    --text: #e5e5e5;
    --text-muted: #9ca3af;
    --accent: #3b82f6;
    --accent-dim: #1e40af;
    --border: #2a2a2a;
    --success: #22c55e;
    --warning: #eab308;
    --error: #ef4444;
}

/* ============================================================================
 * Reset & Base
 * ============================================================================ */

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: ui-monospace, 'SF Mono', 'Cascadia Code', 'Segoe UI Mono', Menlo, Monaco, Consolas, monospace;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 15px;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ============================================================================
 * Layout
 * ============================================================================ */

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ============================================================================
 * Header
 * ============================================================================ */

header {
    padding: 48px 0 32px;
    border-bottom: 1px solid var(--border);
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 16px;
}

.logo {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: 4px;
    color: var(--text);
    animation: logo-electric 4s infinite;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
}

.logo span {
    color: var(--accent);
}

@keyframes logo-electric {
    0%, 100% {
        text-shadow:
            0 0 10px rgba(255, 255, 255, 0.15),
            0 0 20px rgba(255, 255, 255, 0.05);
        transform: translate(0, 0);
        filter: brightness(1);
    }
    5% {
        text-shadow:
            -1px 0 rgba(255, 100, 100, 0.5),
            1px 0 rgba(100, 180, 255, 0.5),
            0 0 10px rgba(255, 255, 255, 0.2);
        transform: translate(0.5px, 0);
    }
    10% {
        text-shadow:
            0 0 10px rgba(255, 255, 255, 0.15);
        transform: translate(0, 0);
    }
    30% {
        text-shadow:
            -2px 0 rgba(255, 60, 60, 0.6),
            2px 0 rgba(60, 180, 255, 0.6),
            0 0 20px rgba(255, 255, 255, 0.3);
        transform: translate(1px, 0) skewX(0.5deg);
        filter: brightness(1.15);
    }
    31% {
        text-shadow:
            2px 0 rgba(255, 60, 60, 0.5),
            -2px 0 rgba(60, 180, 255, 0.5),
            0 0 15px rgba(255, 255, 255, 0.2);
        transform: translate(-0.5px, 0.3px) skewX(-0.3deg);
    }
    33% {
        text-shadow:
            0 0 10px rgba(255, 255, 255, 0.15);
        transform: translate(0, 0);
        filter: brightness(1);
    }
    55% {
        text-shadow:
            0.5px 0 rgba(255, 150, 150, 0.3),
            -0.5px 0 rgba(150, 200, 255, 0.3),
            0 0 10px rgba(255, 255, 255, 0.15);
    }
    60% {
        text-shadow:
            0 0 10px rgba(255, 255, 255, 0.15),
            0 0 20px rgba(255, 255, 255, 0.05);
    }
    75% {
        text-shadow:
            -1.5px 0 rgba(255, 80, 80, 0.5),
            1.5px 0 rgba(80, 180, 255, 0.5),
            0 0 15px rgba(255, 255, 255, 0.25);
        transform: translate(0.6px, -0.2px);
        filter: brightness(1.1);
    }
    77% {
        text-shadow:
            0 0 10px rgba(255, 255, 255, 0.15);
        transform: translate(0, 0);
        filter: brightness(1);
    }
    92% { filter: brightness(0.95); }
    93% { filter: brightness(1.08); }
    94% { filter: brightness(1); }
}

.tagline {
    margin-top: 8px;
    color: var(--text-muted);
    font-size: 14px;
}

.expand {
    margin-top: 4px;
    font-size: 13px;
    color: var(--text-muted);
}

.header-nav {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.nav-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.nav-separator {
    color: var(--border);
    font-weight: 300;
    align-self: center;
}

.header-nav a {
    padding: 6px 12px;
    font-size: 13px;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 4px;
    text-decoration: none;
}

.header-nav a:hover {
    color: var(--text);
    border-color: var(--accent-dim);
    text-decoration: none;
}

/* ============================================================================
 * Hero
 * ============================================================================ */

.hero {
    padding: 48px 0;
    border-bottom: 1px solid var(--border);
}

.hero h1 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 16px;
}

.hero p {
    color: var(--text-muted);
    max-width: 700px;
}

/* ============================================================================
 * Badges
 * ============================================================================ */

.badges {
    margin-top: 24px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
    color: var(--text-muted);
}

.badge.green { border-color: var(--success); color: var(--success); }
.badge.blue { border-color: var(--accent); color: var(--accent); }
.badge.yellow { border-color: var(--warning); color: var(--warning); }

/* ============================================================================
 * Code Block - Terminal CRT Style
 * ============================================================================ */

.code-block {
    background: linear-gradient(135deg, #0a0a0a 0%, #141414 100%);
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    overflow-x: auto;
    position: relative;
    overflow: hidden;
}

.code-block::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.15) 0px,
        rgba(0, 0, 0, 0.15) 1px,
        transparent 1px,
        transparent 3px
    );
    pointer-events: none;
    z-index: 2;
    animation: crt-scanline-roll 8s linear infinite;
}

.code-block::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(255, 255, 255, 0.03) 0px,
        rgba(255, 255, 255, 0.03) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
}

.code-block pre {
    margin: 0;
    padding: 20px;
    font-size: 13px;
    font-family: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, Monaco, Consolas, monospace;
    position: relative;
    z-index: 3;
    animation: crt-flicker-gray 4s infinite;
    /* Base CRT phosphor glow for all text */
    color: #b0b0b0;
    text-shadow:
        0 0 2px rgba(180, 180, 180, 0.8),
        0 0 5px rgba(180, 180, 180, 0.4),
        0 0 10px rgba(180, 180, 180, 0.2);
    /* Force consistent character width for box-drawing */
    letter-spacing: 0;
    word-spacing: 0;
    font-variant-ligatures: none;
    font-feature-settings: "calt" 0;
}

.code-block .comment {
    color: #707070;
    text-shadow:
        0 0 2px rgba(150, 150, 150, 0.6),
        0 0 5px rgba(150, 150, 150, 0.3);
}

.code-block .command {
    color: #50c878;
    text-shadow:
        0 0 2px rgba(80, 200, 120, 0.8),
        0 0 5px rgba(80, 200, 120, 0.5),
        0 0 10px rgba(80, 200, 120, 0.3),
        0 0 20px rgba(80, 200, 120, 0.1);
}

/* JSON syntax highlighting */
.code-block .key {
    color: #90caf9;
    text-shadow:
        0 0 2px rgba(144, 202, 249, 0.8),
        0 0 5px rgba(144, 202, 249, 0.5),
        0 0 10px rgba(144, 202, 249, 0.3);
}

.code-block .string {
    color: #a5d6a7;
    text-shadow:
        0 0 2px rgba(165, 214, 167, 0.8),
        0 0 5px rgba(165, 214, 167, 0.5),
        0 0 10px rgba(165, 214, 167, 0.3);
}

.code-block .number {
    color: #ffcc80;
    text-shadow:
        0 0 2px rgba(255, 204, 128, 0.8),
        0 0 5px rgba(255, 204, 128, 0.5),
        0 0 10px rgba(255, 204, 128, 0.3);
}

.code-block .url {
    color: #ce93d8;
    text-shadow:
        0 0 2px rgba(206, 147, 216, 0.8),
        0 0 5px rgba(206, 147, 216, 0.5),
        0 0 10px rgba(206, 147, 216, 0.3);
}

/* CRT flicker animation - subtle brightness variation */
@keyframes crt-flicker-gray {
    0%, 100% { opacity: 1; filter: brightness(1); }
    10% { opacity: 1; filter: brightness(1.01); }
    20% { opacity: 0.99; filter: brightness(0.99); }
    30% { opacity: 1; filter: brightness(1); }
    40% { opacity: 0.98; filter: brightness(1.02); }
    50% { opacity: 1; filter: brightness(1); }
    60% { opacity: 0.99; filter: brightness(0.98); }
    70% { opacity: 1; filter: brightness(1.01); }
    80% { opacity: 0.98; filter: brightness(1); }
    90% { opacity: 1; filter: brightness(0.99); }
    94% { opacity: 1; filter: brightness(1); }
    95% { opacity: 0.95; filter: brightness(0.97); }
    96% { opacity: 1; filter: brightness(1); }
}

/* CRT scanline animation - subtle vertical movement */
@keyframes crt-scanline-roll {
    0% { background-position: 0 0; }
    100% { background-position: 0 60px; }
}

/* Typing animation cursor */
.code-block.typing pre::after {
    content: '\2588';
    color: #50c878;
    animation: cursor-blink 0.7s step-end infinite;
    text-shadow: 0 0 8px rgba(80, 200, 120, 0.6);
}

.code-block.typed pre::after {
    content: '\2588';
    color: #50c878;
    animation: cursor-blink 1s step-end infinite;
    text-shadow: 0 0 8px rgba(80, 200, 120, 0.6);
}

@keyframes cursor-blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* ============================================================================
 * ASCII Art Block - Gray CRT Style
 * ============================================================================ */

.ascii-art {
    background: linear-gradient(135deg, #1a1a1a 0%, #222 100%);
    border: 1px solid #333;
    border-radius: 6px;
    padding: 24px;
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.3;
    position: relative;
    overflow: hidden;
}

.ascii-art::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.12) 0px,
        rgba(0, 0, 0, 0.12) 1px,
        transparent 1px,
        transparent 3px
    );
    pointer-events: none;
    z-index: 2;
    animation: crt-scanline-roll 8s linear infinite;
}

.ascii-art::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(255, 255, 255, 0.04) 0px,
        rgba(255, 255, 255, 0.04) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
}

.ascii-art pre {
    margin: 0;
    font-family: ui-monospace, 'SF Mono', Menlo, Monaco, Consolas, monospace;
    color: #a0a0a0;
    text-shadow:
        0 0 2px rgba(200, 200, 200, 0.8),
        0 0 5px rgba(200, 200, 200, 0.5),
        0 0 10px rgba(200, 200, 200, 0.3),
        0 0 20px rgba(200, 200, 200, 0.1);
    position: relative;
    z-index: 3;
    animation: crt-flicker-gray 4s infinite;
    /* Force consistent character width for box-drawing */
    letter-spacing: 0;
    word-spacing: 0;
    font-variant-ligatures: none;
    font-feature-settings: "calt" 0;
    line-height: 1;
}

/* ============================================================================
 * Tables
 * ============================================================================ */

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th, td {
    text-align: left;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

th {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

td:last-child {
    color: var(--success);
    font-weight: 500;
}

/* ============================================================================
 * Cards & Grid
 * ============================================================================ */

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 20px;
}

.card:hover {
    border-color: var(--accent-dim);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.card-name {
    font-weight: 600;
    font-size: 16px;
}

.card-lang {
    font-size: 11px;
    padding: 2px 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    color: var(--text-muted);
}

.card-desc {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 12px;
}

.card-meta {
    font-size: 12px;
    color: var(--text-muted);
}

.card.planned {
    border-style: dashed;
    opacity: 0.7;
}

.card.planned:hover {
    opacity: 1;
}

.badge-planned {
    font-size: 10px;
    padding: 2px 6px;
    background: var(--bg-tertiary);
    border: 1px dashed var(--text-muted);
    border-radius: 3px;
    color: var(--text-muted);
    margin-left: auto;
}

/* ============================================================================
 * Sections
 * ============================================================================ */

.section-title {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-muted);
    margin-bottom: 24px;
}

.subsection {
    margin-bottom: 48px;
}

.subsection:last-child {
    margin-bottom: 0;
}

.subsection-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
}

/* ============================================================================
 * Footer
 * ============================================================================ */

footer {
    padding: 32px 0;
    color: var(--text-muted);
    font-size: 13px;
}

.footer-links {
    display: flex;
    gap: 24px;
    margin-bottom: 16px;
}

/* ============================================================================
 * Skip Link (Accessibility)
 * ============================================================================ */

.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--accent);
    color: white;
    padding: 8px 16px;
    z-index: 100;
    text-decoration: none;
}

.skip-link:focus {
    top: 0;
}

/* ============================================================================
 * Responsive
 * ============================================================================ */

@media (max-width: 600px) {
    .logo { font-size: 24px; }
    .hero h1 { font-size: 18px; }
    .ascii-art { font-size: 10px; padding: 16px; }
    .code-block pre { font-size: 11px; padding: 16px; }
    .footer-links { flex-direction: column; gap: 8px; }
    .header-top { flex-direction: column; }
    .header-nav { margin-top: 16px; }
}
