/* ==========================================================================
   concurrengine.com — Styles
   Marble-as-computation, broken-grid, translucent-frost palette
   ========================================================================== */

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

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

body {
    background: #1C1917;
    color: #D4CFC8;
    font-family: 'Space Mono', monospace;
    font-size: clamp(0.9rem, 1.4vw, 1.1rem);
    line-height: 1.85;
    letter-spacing: 0.02em;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Leather Substrate Background --- */
.substrate {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    background-color: #1C1917;
    background-image:
        radial-gradient(circle at 20% 30%, rgba(139, 125, 107, 0.03) 1px, transparent 1px),
        radial-gradient(circle at 80% 70%, rgba(139, 125, 107, 0.03) 1px, transparent 1px),
        radial-gradient(ellipse 60px 60px at 50% 50%, rgba(139, 125, 107, 0.02), transparent),
        linear-gradient(175deg, rgba(139, 125, 107, 0.01), transparent);
    background-size: 3px 3px, 5px 5px, 60px 60px, 100% 100%;
}

/* --- Token Navigation (Right Sidebar) --- */
.token-nav {
    position: fixed;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 60px;
    padding: 16px 0;
}

.token {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.token svg {
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: box-shadow 0.4s ease, transform 0.4s ease;
}

.token:hover svg,
.token.active svg {
    box-shadow: 0 0 20px rgba(186, 210, 235, 0.4);
}

.token.active svg {
    transform: scale(1.1);
}

.token-label {
    font-family: 'Cutive Mono', monospace;
    font-size: 0.65rem;
    color: #D4CFC8;
    letter-spacing: 0.08em;
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

.token:hover .token-label,
.token.active .token-label {
    opacity: 1;
    color: #BAD2EB;
}

/* --- Main Broken Grid --- */
.broken-grid {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(16, 1fr);
    gap: 0;
    max-width: 100vw;
    padding-right: 70px;
}

/* --- Slab Base Styles --- */
.slab {
    position: relative;
    overflow: hidden;
}

.slab--marble-light {
    background: #E8E2D9;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(200, 210, 225, 0.15);
}

.slab--marble-dark {
    background: #1C1917;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(200, 210, 225, 0.1);
}

.slab--leather {
    background: #2C2520;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(139, 125, 107, 0.15);
}

.slab-content {
    position: relative;
    z-index: 5;
    padding: 60px 50px;
}

/* --- Marble Veins --- */
.marble-veins {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

.vein {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 2s ease-in-out;
}

.slab.in-view .vein,
.slab-group.in-view .vein,
.slab--fork.in-view .vein {
    stroke-dashoffset: 0;
}

/* --- Construction Lines --- */
.construction-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}

.construction-line {
    opacity: 0;
    transition: opacity 0.6s ease;
}

.slab.in-view .construction-line,
.slab-group.in-view .construction-line {
    opacity: 0.15;
    animation: constructionPulse 4s ease-in-out infinite;
}

@keyframes constructionPulse {
    0%, 100% { opacity: 0.12; }
    50% { opacity: 0.18; }
}

/* --- Typography --- */
.heading-primary {
    font-family: 'Cutive Mono', monospace;
    font-size: clamp(2rem, 5vw, 4rem);
    font-weight: 400;
    letter-spacing: 0.08em;
    color: #BAD2EB;
    line-height: 1.2;
    margin-bottom: 16px;
}

.heading-primary--dark {
    color: #1C1917;
}

.heading-sub {
    font-family: 'Architects Daughter', cursive;
    font-size: clamp(1rem, 2.5vw, 1.6rem);
    font-weight: 400;
    letter-spacing: 0.04em;
    color: #8B7D6B;
    line-height: 1.4;
    margin-bottom: 12px;
}

.heading-sub--dark {
    color: #8B7D6B;
}

.annotation {
    font-family: 'Architects Daughter', cursive;
    font-size: clamp(0.8rem, 1.5vw, 1rem);
    letter-spacing: 0.04em;
    color: #8B7D6B;
    margin-bottom: 24px;
    opacity: 0.7;
    background: #3D4F5E;
    display: inline-block;
    padding: 4px 12px;
    border-radius: 3px;
}

.annotation--dark {
    color: #8B7D6B;
}

.body-text {
    font-family: 'Space Mono', monospace;
    font-size: clamp(0.9rem, 1.4vw, 1.1rem);
    line-height: 1.85;
    letter-spacing: 0.02em;
    margin-bottom: 20px;
    max-width: 65ch;
}

.body-text--light {
    color: #D4CFC8;
}

.body-text--dark {
    color: #2C2520;
}

/* --- Section 1: Thread Zero (Hero) --- */
.slab--hero {
    grid-column: 1 / 15;
    grid-row: 1;
    min-height: 100vh;
    display: flex;
    align-items: center;
    z-index: 6;
    /* Initial zoom-focus state */
    transform: scale(0.97);
    opacity: 0.7;
    filter: blur(1px);
    transition: transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                opacity 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                filter 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.slab--hero.in-view {
    transform: scale(1.0);
    opacity: 1;
    filter: blur(0);
}

.hero-content {
    padding: 80px 80px 80px 100px;
}

.hero-title-svg {
    width: 100%;
    max-width: 800px;
    height: auto;
    margin-bottom: 30px;
}

.hero-title-text {
    font-family: 'Cutive Mono', monospace;
}

.hero-subtitle {
    font-family: 'Architects Daughter', cursive;
    font-size: clamp(1.1rem, 2.5vw, 1.6rem);
    color: #8B7D6B;
    letter-spacing: 0.04em;
    margin-bottom: 16px;
}

.hero-annotation {
    font-family: 'Cutive Mono', monospace;
    font-size: clamp(0.75rem, 1.2vw, 0.95rem);
    color: #6B8A9E;
    letter-spacing: 0.06em;
    opacity: 0.6;
}

/* --- Thread Flow Lines (between sections) --- */
.thread-flow {
    grid-column: 3 / 14;
    height: 80px;
    position: relative;
    z-index: 3;
    overflow: visible;
}

.thread-flow svg {
    width: 100%;
    height: 100%;
}

.thread-flow--1 { grid-row: 2; }
.thread-flow--2 { grid-row: 4; }
.thread-flow--3 { grid-row: 6; }
.thread-flow--4 { grid-row: 8; }

/* Flow line animations */
.flow-line {
    stroke-dasharray: 20 10;
}

.flow-down {
    animation: flowDown 6s linear infinite;
}

.flow-up {
    animation: flowUp 6s linear infinite;
}

@keyframes flowDown {
    from { stroke-dashoffset: 0; }
    to { stroke-dashoffset: -60; }
}

@keyframes flowUp {
    from { stroke-dashoffset: 0; }
    to { stroke-dashoffset: 60; }
}

/* --- Section 2: Synchronization Point --- */
.slab-group {
    grid-column: 1 / 17;
    display: grid;
    grid-template-columns: repeat(16, 1fr);
    position: relative;
    z-index: 4;
    min-height: 500px;
    /* Zoom-focus */
    transform: scale(0.97);
    opacity: 0.7;
    filter: blur(1px);
    transition: transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                opacity 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                filter 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.slab-group.in-view {
    transform: scale(1.0);
    opacity: 1;
    filter: blur(0);
}

#sync-point {
    grid-row: 3;
}

.slab--sync-left {
    grid-column: 1 / 10;
    grid-row: 1;
    z-index: 4;
    min-height: 500px;
}

.slab--sync-right {
    grid-column: 8 / 17;
    grid-row: 1;
    z-index: 2;
    min-height: 500px;
}

.sync-seam {
    grid-column: 8 / 10;
    grid-row: 1;
    z-index: 6;
    mix-blend-mode: multiply;
    pointer-events: none;
}

.sync-seam svg {
    width: 100%;
    height: 100%;
}

/* --- Section 3: Parallel Channels --- */
.slab-group--parallel {
    grid-column: 2 / 16;
    grid-row: 5;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    min-height: 600px;
}

.slab--channel {
    min-height: 600px;
    position: relative;
}

.slab--channel-1 {
    z-index: 4;
    margin-right: -20px;
}

.slab--channel-2 {
    z-index: 3;
    margin-left: -20px;
    margin-right: -20px;
}

.slab--channel-3 {
    z-index: 4;
    margin-left: -20px;
}

/* --- Section 4: The Fork --- */
.slab--fork {
    grid-column: 2 / 16;
    grid-row: 7;
    min-height: 500px;
    z-index: 4;
    /* Zoom-focus */
    transform: scale(0.97);
    opacity: 0.7;
    filter: blur(1px);
    transition: transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                opacity 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                filter 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.slab--fork.in-view {
    transform: scale(1.0);
    opacity: 1;
    filter: blur(0);
}

.fork-container {
    position: relative;
    z-index: 5;
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 500px;
}

.fork-left {
    clip-path: polygon(0 0, 100% 0, 92% 100%, 0 100%);
    padding: 0;
    background: #1C1917;
}

.fork-right {
    clip-path: polygon(8% 0, 100% 0, 100% 100%, 0 100%);
    margin-left: -40px;
    padding: 0;
    background: #E8E2D9;
}

.fork-left .slab-content,
.fork-right .slab-content {
    padding: 60px 50px;
}

.fork-split-line {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

/* --- Section 5: Commit Log --- */
.slab--commit {
    grid-column: 1 / 17;
    grid-row: 9;
    min-height: 600px;
    z-index: 4;
    background-image:
        radial-gradient(circle, rgba(139, 125, 107, 0.04) 1px, transparent 1px),
        radial-gradient(ellipse 60px 60px, rgba(139, 125, 107, 0.03), transparent);
    background-size: 4px 4px, 60px 60px;
    /* Zoom-focus */
    transform: scale(0.97);
    opacity: 0.7;
    filter: blur(1px);
    transition: transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                opacity 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                filter 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.slab--commit.in-view {
    transform: scale(1.0);
    opacity: 1;
    filter: blur(0);
}

.journal-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

.commit-content {
    display: grid;
    grid-template-columns: 1fr 200px;
    gap: 40px;
    padding: 80px 100px;
}

.commit-main {
    position: relative;
}

.commit-entry {
    margin-bottom: 32px;
    padding-left: 20px;
    border-left: 2px solid rgba(186, 210, 235, 0.2);
}

.commit-hash {
    font-family: 'Cutive Mono', monospace;
    font-size: 0.8rem;
    color: #BAD2EB;
    letter-spacing: 0.1em;
    display: block;
    margin-bottom: 8px;
    opacity: 0.7;
}

.commit-marginalia {
    position: relative;
    padding-top: 40px;
}

.marginalia-note {
    font-family: 'Architects Daughter', cursive;
    font-size: clamp(0.75rem, 1.2vw, 0.9rem);
    color: #8B7D6B;
    margin-bottom: 20px;
    opacity: 0.7;
    transform: rotate(-2deg);
    line-height: 1.5;
}

.marginalia-note:nth-child(2) {
    transform: rotate(1deg);
}

.marginalia-note:nth-child(3) {
    transform: rotate(-1.5deg);
}

.volute-decoration {
    display: block;
    margin-top: 30px;
    opacity: 0.5;
}

.commit-closing {
    grid-column: 1 / -1;
    text-align: center;
    padding-top: 40px;
}

.closing-text {
    font-family: 'Cutive Mono', monospace;
    font-size: clamp(1.2rem, 3vw, 2rem);
    color: #BAD2EB;
    letter-spacing: 0.08em;
    margin-bottom: 30px;
}

.greek-key {
    width: 100%;
    max-width: 600px;
    height: 12px;
    margin: 0 auto;
    display: block;
}

/* --- Frosted Glass Panels --- */
.token-nav {
    background: rgba(28, 25, 23, 0.6);
    backdrop-filter: blur(12px) saturate(1.2);
    -webkit-backdrop-filter: blur(12px) saturate(1.2);
    border-radius: 30px;
    border: 1px solid rgba(200, 210, 225, 0.08);
}

@supports not (backdrop-filter: blur(12px)) {
    .token-nav {
        background: rgba(28, 25, 23, 0.85);
    }
}

/* --- Zoom Focus States (applied via JS IntersectionObserver) --- */
.slab--channel {
    transform: scale(0.97);
    opacity: 0.7;
    filter: blur(1px);
    transition: transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                opacity 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                filter 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.slab--channel.in-view {
    transform: scale(1.0);
    opacity: 1;
    filter: blur(0);
}

/* --- Spacing between major grid rows --- */
.broken-grid {
    row-gap: 0;
}

/* The thread-flow elements provide the 80px breathing room */

/* --- Responsive Adjustments --- */
@media (max-width: 1024px) {
    .token-nav {
        right: 5px;
        width: 50px;
        gap: 14px;
    }

    .token svg {
        width: 32px;
        height: 32px;
    }

    .broken-grid {
        padding-right: 55px;
    }

    .hero-content {
        padding: 60px 40px 60px 50px;
    }

    .slab-content {
        padding: 40px 30px;
    }

    .commit-content {
        grid-template-columns: 1fr;
        padding: 60px 40px;
    }

    .commit-marginalia {
        display: flex;
        gap: 20px;
        flex-wrap: wrap;
    }
}

@media (max-width: 768px) {
    .broken-grid {
        display: flex;
        flex-direction: column;
        padding-right: 55px;
    }

    .slab-group {
        display: flex;
        flex-direction: column;
    }

    .slab-group--parallel {
        display: flex;
        flex-direction: column;
    }

    .slab--sync-left,
    .slab--sync-right {
        min-height: auto;
    }

    .sync-seam {
        display: none;
    }

    .slab--channel {
        margin: 0;
        min-height: auto;
    }

    .fork-container {
        grid-template-columns: 1fr;
    }

    .fork-left {
        clip-path: none;
    }

    .fork-right {
        clip-path: none;
        margin-left: 0;
    }

    .fork-split-line {
        display: none;
    }

    .slab--hero {
        min-height: 80vh;
    }

    .hero-content {
        padding: 40px 20px;
    }

    .slab-content {
        padding: 30px 20px;
    }

    .commit-content {
        padding: 40px 20px;
    }
}

/* --- Selection Color --- */
::selection {
    background: rgba(186, 210, 235, 0.3);
    color: #E8E2D9;
}
