/* ============================================================
   reasoner.dev - Bauhaus-inspired design system
   Navy-metallic palette, tech-mono typography, geometric rigor
   ============================================================ */

:root {
    /* Palette */
    --bg-primary: #0D1B2A;       /* Midnight Navy */
    --bg-secondary: #1B2838;     /* Prussian Dark */
    --border-grid: #3D4F5F;      /* Weathered Steel */
    --text-tertiary: #7B8794;    /* Brushed Steel */
    --text-secondary: #C5CDD5;   /* Soft Silver */
    --text-primary: #E8ECF1;     /* Polished Aluminum */
    --accent-warm: #D4885A;      /* Copper Filament */
    --accent-cool: #4FC3F7;      /* Signal Cyan */

    /* Typography */
    --font-display: 'Space Mono', monospace;
    --font-body: 'IBM Plex Mono', monospace;

    /* Layout */
    --max-width: 1440px;
    --gutter: 32px;
    --nav-height: 48px;
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    background-color: var(--bg-primary);
    background-image: radial-gradient(ellipse at 30% 20%, #1B2838 0%, #0D1B2A 70%);
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.95rem, 1.1vw, 1.1rem);
    line-height: 1.75;
    letter-spacing: 0.01em;
    overflow-x: hidden;
    min-height: 100vh;
}

/* ---- Background Grid ---- */
#grid-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    background-image:
        linear-gradient(to right, rgba(123,135,148,0.12) 0.5px, transparent 0.5px),
        linear-gradient(to bottom, rgba(123,135,148,0.12) 0.5px, transparent 0.5px),
        radial-gradient(circle 1px at center, rgba(123,135,148,0.08) 1px, transparent 1px);
    background-size:
        120px 120px,
        120px 120px,
        120px 120px;
    background-position: center center;
    transition: opacity 0.3s ease;
}

/* ---- Navigation ---- */
#navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--gutter);
    max-width: var(--max-width);
    margin: 0 auto;
    border-bottom: 1px solid var(--text-tertiary);
    background-color: rgba(13, 27, 42, 0.95);
    z-index: 1000;
}

.nav-domain {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.02em;
    color: var(--text-primary);
}

.nav-links {
    display: flex;
    gap: 32px;
}

.nav-link {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 11px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.nav-link:hover {
    color: var(--accent-warm);
}

/* ---- Main Layout ---- */
main {
    position: relative;
    z-index: 1;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--gutter);
}

/* ---- Section Numbers ---- */
.section-number {
    position: absolute;
    left: -40px;
    top: 80px;
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 9px;
    color: var(--text-tertiary);
    opacity: 0.5;
    letter-spacing: 0.05em;
}

/* ---- Section: Hero ---- */
.section-hero {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 100vh;
    padding-top: var(--nav-height);
}

.hero-content {
    width: 66.666%;
    padding-left: calc(100% / 12);
}

.hero-headline {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2.8rem, 6vw, 5.2rem);
    letter-spacing: -0.03em;
    line-height: 1.15;
    color: var(--text-primary);
    position: relative;
}

.typewriter-line {
    display: block;
    overflow: hidden;
    white-space: nowrap;
}

.typewriter-line[data-line="0"] {
    max-width: 0;
    animation: revealLine 1.8s steps(24, end) 0.5s forwards;
}

.typewriter-line[data-line="1"] {
    max-width: 0;
    animation: revealLine 1.4s steps(18, end) 2.8s forwards;
}

@keyframes revealLine {
    from { max-width: 0; }
    to   { max-width: 100%; }
}

/* Typewriter cursor */
#typewriter-cursor {
    display: inline-block;
    width: 2px;
    height: 1.1em;
    background-color: var(--accent-warm);
    vertical-align: text-bottom;
    margin-left: 4px;
    animation: cursorBlink 1.06s step-end infinite;
    opacity: 1;
}

#typewriter-cursor.cursor-fade {
    animation: cursorFadeOut 0.8s ease forwards;
}

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

@keyframes cursorFadeOut {
    from { opacity: 1; }
    to   { opacity: 0; }
}

.hero-rule {
    width: 100%;
    height: 1px;
    background-color: #4A5568;
    margin: 32px 0;
}

.hero-subtitle {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    line-height: 1.8;
    max-width: 600px;
}

/* ---- Section: Panels ---- */
.section-panel {
    position: relative;
    padding: 120px 0;
    padding-left: calc(100% / 12);
}

.panel-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 48px;
    max-width: calc(100% * 8 / 12);
}

.panel {
    position: relative;
    grid-column: span 4;
    border: 1px solid var(--border-grid);
    padding: 40px 32px;
    background-color: var(--bg-secondary);
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.panel.visible {
    opacity: 1;
    transform: translateY(0);
}

.panel:last-child:nth-child(odd) {
    grid-column: 1 / span 4;
}

.panel-heading {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.2rem, 2vw, 1.6rem);
    letter-spacing: -0.02em;
    line-height: 1.2;
    color: var(--text-primary);
    margin-bottom: 20px;
}

.panel-text {
    color: var(--text-secondary);
    line-height: 1.75;
}

/* ---- Corner Marks ---- */
.corner-mark {
    position: absolute;
    width: 8px;
    height: 8px;
}

.corner-mark::before,
.corner-mark::after {
    content: '';
    position: absolute;
    background-color: var(--border-grid);
}

.corner-tl { top: -1px; left: -1px; }
.corner-tl::before { top: 0; left: 0; width: 8px; height: 1px; }
.corner-tl::after  { top: 0; left: 0; width: 1px; height: 8px; }

.corner-tr { top: -1px; right: -1px; }
.corner-tr::before { top: 0; right: 0; width: 8px; height: 1px; }
.corner-tr::after  { top: 0; right: 0; width: 1px; height: 8px; }

.corner-bl { bottom: -1px; left: -1px; }
.corner-bl::before { bottom: 0; left: 0; width: 8px; height: 1px; }
.corner-bl::after  { bottom: 0; left: 0; width: 1px; height: 8px; }

.corner-br { bottom: -1px; right: -1px; }
.corner-br::before { bottom: 0; right: 0; width: 8px; height: 1px; }
.corner-br::after  { bottom: 0; right: 0; width: 1px; height: 8px; }

/* ---- Section: Collage Strips ---- */
.collage-strip {
    position: relative;
    width: 100vw;
    margin-left: calc(-1 * var(--gutter));
    height: 40vh;
    overflow: hidden;
}

.collage-fragment {
    position: absolute;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.8s cubic-bezier(0.22, 1, 0.36, 1),
                transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.collage-fragment.assembled {
    opacity: 1;
    transform: translate(0, 0) !important;
}

/* Collage Characters */
.collage-char {
    font-family: var(--font-display);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: var(--text-primary);
    opacity: 0.6;
}

/* Collage Code Texture */
.collage-code {
    font-family: var(--font-body);
    font-size: 6px;
    line-height: 1.5;
    color: var(--text-tertiary);
    padding: 8px;
    white-space: nowrap;
    overflow: hidden;
}

.collage-code span {
    display: block;
}

/* Collage Patterns */
.collage-pattern {
    width: 100%;
    height: 100%;
}

.pattern-lines {
    background-image: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 4px,
        var(--border-grid) 4px,
        var(--border-grid) 5px
    );
    opacity: 0.5;
}

.pattern-dots {
    background-image: radial-gradient(circle 1.5px at center, var(--text-tertiary) 1.5px, transparent 1.5px);
    background-size: 12px 12px;
    opacity: 0.4;
}

.pattern-concentric {
    display: flex;
    align-items: center;
    justify-content: center;
}

.pattern-concentric::before {
    content: '';
    width: 80%;
    height: 80%;
    border: 1px solid var(--border-grid);
    box-shadow:
        inset 0 0 0 12px transparent,
        inset 0 0 0 13px var(--border-grid),
        inset 0 0 0 26px transparent,
        inset 0 0 0 27px var(--border-grid),
        inset 0 0 0 40px transparent,
        inset 0 0 0 41px var(--border-grid);
}

/* ---- Collage Strip 1 Fragment Positions ---- */
.frag-1 {
    top: 5%; left: 5%;
    width: 180px; height: 200px;
    background-color: var(--bg-secondary);
    font-size: clamp(80px, 12vw, 160px);
    transform: rotate(-2deg);
    mix-blend-mode: screen;
}

.frag-2 {
    top: 15%; left: 22%;
    width: 200px; height: 140px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-grid);
}

.frag-3 {
    top: 8%; left: 48%;
    width: 120px; height: 160px;
    background-color: var(--accent-warm);
    opacity: 0.15;
    transform: rotate(1deg);
}

.frag-4 {
    top: 40%; left: 40%;
    width: 140px; height: 150px;
    font-size: clamp(60px, 10vw, 120px);
    background-color: rgba(13, 27, 42, 0.8);
    transform: rotate(2deg);
    mix-blend-mode: screen;
}

.frag-5 {
    top: 20%; right: 25%;
    width: 160px; height: 100px;
    background-color: var(--accent-cool);
    opacity: 0.1;
    transform: rotate(-1deg);
}

.frag-6 {
    top: 50%; right: 15%;
    width: 180px; height: 120px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-grid);
    transform: rotate(-3deg);
}

.frag-7 {
    bottom: 10%; left: 12%;
    width: 100px; height: 80px;
    background-color: var(--border-grid);
    opacity: 0.3;
}

.frag-8 {
    bottom: 5%; right: 30%;
    width: 120px; height: 140px;
    font-size: clamp(60px, 8vw, 100px);
    background-color: rgba(27, 40, 56, 0.7);
    transform: rotate(1.5deg);
    mix-blend-mode: screen;
}

/* ---- Collage Strip 2 Fragment Positions ---- */
.frag-9 {
    top: 10%; left: 8%;
    width: 160px; height: 180px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-grid);
}

.frag-10 {
    top: 5%; left: 28%;
    width: 140px; height: 100px;
    background-color: var(--accent-warm);
    opacity: 0.12;
    transform: rotate(2deg);
}

.frag-11 {
    top: 25%; left: 38%;
    width: 130px; height: 150px;
    font-size: clamp(50px, 8vw, 90px);
    background-color: rgba(13, 27, 42, 0.9);
    transform: rotate(-1.5deg);
    mix-blend-mode: screen;
}

.frag-12 {
    top: 10%; right: 28%;
    width: 200px; height: 120px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-grid);
    transform: rotate(1deg);
}

.frag-13 {
    top: 55%; left: 20%;
    width: 100px; height: 90px;
    background-color: var(--accent-cool);
    opacity: 0.08;
}

.frag-14 {
    bottom: 10%; right: 12%;
    width: 150px; height: 150px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-grid);
    transform: rotate(-2deg);
}

.frag-15 {
    bottom: 15%; left: 45%;
    width: 120px; height: 70px;
    background-color: var(--border-grid);
    opacity: 0.25;
    transform: rotate(3deg);
}

/* ---- Section: Terminal ---- */
.section-terminal {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    padding: 120px 0;
    text-align: center;
}

.terminal-domain {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 8vw;
    color: var(--text-primary);
    opacity: 0.3;
    letter-spacing: -0.02em;
    line-height: 1;
    margin-bottom: 24px;
}

.terminal-tagline {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

/* ---- Reduced Motion ---- */
@media (prefers-reduced-motion: reduce) {
    .typewriter-line[data-line="0"],
    .typewriter-line[data-line="1"] {
        max-width: 100%;
        animation: none;
    }

    #typewriter-cursor {
        animation: none;
        opacity: 0;
    }

    .panel {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .collage-fragment {
        opacity: 1;
        transform: none !important;
        transition: none;
    }
}

/* ---- Responsive ---- */
@media (max-width: 1024px) {
    .panel-grid {
        grid-template-columns: 1fr;
        max-width: 100%;
    }

    .panel {
        grid-column: span 1;
    }

    .panel:last-child:nth-child(odd) {
        grid-column: span 1;
    }

    .section-panel {
        padding-left: 0;
    }

    .hero-content {
        width: 100%;
        padding-left: 0;
    }

    .section-number {
        position: relative;
        left: 0;
        top: 0;
        margin-bottom: 24px;
    }
}

@media (max-width: 768px) {
    :root {
        --gutter: 20px;
    }

    .nav-links {
        gap: 20px;
    }

    .collage-strip {
        height: 30vh;
    }

    .collage-fragment {
        transform: none !important;
    }

    .frag-1, .frag-2, .frag-3, .frag-4, .frag-5, .frag-6, .frag-7, .frag-8,
    .frag-9, .frag-10, .frag-11, .frag-12, .frag-13, .frag-14, .frag-15 {
        width: 100px;
        height: 100px;
    }
}
