/* ============================================
   concurrent.day - Styles
   Retro-futuristic control room aesthetic
   Gold-on-black, split-screen, card-flip
   ============================================ */

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

:root {
    --obsidian-black: #0A0A0A;
    --deep-onyx: #1A1A1A;
    --burnished-gold: #C8A951;
    --champagne-mist: #E8D5A3;
    --antique-brass: #8B7335;
    --cathode-green: #2A6B4A;
    --warm-charcoal: #2D2D2D;
    --ivory-flash: #F5F0E0;
    --font-weight: 300;
}

html {
    font-size: 16px;
    scroll-behavior: auto;
    overflow-x: hidden;
}

body {
    background: var(--obsidian-black);
    color: var(--champagne-mist);
    font-family: 'EB Garamond', Georgia, serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.4vw, 1.25rem);
    line-height: 1.72;
    letter-spacing: 0.01em;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Background Grid Overlay --- */
#grid-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    background-image:
        linear-gradient(to right, var(--warm-charcoal) 0.5px, transparent 0.5px),
        linear-gradient(to bottom, var(--warm-charcoal) 0.5px, transparent 0.5px);
    background-size: 40px 40px;
    opacity: 0.3;
}

/* --- Thread Indicator UI --- */
#thread-indicator {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-direction: row;
}

#thread-alpha-bar,
#thread-beta-bar {
    width: 4px;
    height: 60px;
    background: var(--warm-charcoal);
    position: relative;
    border-radius: 1px;
    overflow: hidden;
}

#thread-alpha-fill,
#thread-beta-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: var(--burnished-gold);
    transition: height 0.1s linear;
    border-radius: 1px;
}

#thread-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.6rem;
    color: var(--antique-brass);
    letter-spacing: 0.15em;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    margin-left: 4px;
}

/* --- Split Container --- */
#split-container {
    display: grid;
    grid-template-columns: 1fr 2px 1fr;
    width: 100%;
    min-height: 600vh;
    position: relative;
    z-index: 2;
}

/* --- Panes --- */
.pane {
    position: relative;
    overflow: hidden;
}

.pane-inner {
    position: relative;
    will-change: transform;
}

#pane-alpha {
    background: var(--obsidian-black);
}

#pane-beta {
    background: var(--obsidian-black);
}

/* --- Gold Divider --- */
#divider {
    position: relative;
    background: var(--burnished-gold);
    z-index: 10;
}

#divider-line {
    position: sticky;
    top: 0;
    width: 100%;
    height: 100vh;
    background: var(--burnished-gold);
    animation: divider-pulse 3s ease-in-out infinite;
}

@keyframes divider-pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* --- Typography --- */
.hero-title {
    font-family: 'Cormorant Garamond', 'Georgia', serif;
    font-weight: 700;
    font-size: clamp(3rem, 8vw, 7rem);
    letter-spacing: 0.08em;
    line-height: 1.05;
    text-transform: uppercase;
    color: var(--burnished-gold);
    position: relative;
    z-index: 5;
}

.hero-left {
    text-align: right;
    padding-right: 0;
}

.hero-right {
    text-align: left;
    padding-left: 0;
}

.hero-subtitle {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85em;
    color: var(--burnished-gold);
    letter-spacing: 0.12em;
    margin-top: 1rem;
    opacity: 0.7;
}

.section-heading {
    font-family: 'Cormorant Garamond', 'Georgia', serif;
    font-weight: var(--font-weight);
    font-size: clamp(2rem, 5vw, 4rem);
    letter-spacing: 0.08em;
    line-height: 1.1;
    color: var(--burnished-gold);
    margin-bottom: 2rem;
    transition: font-weight 0.6s ease-out;
}

.section-heading.in-view {
    --font-weight: 700;
    font-weight: 700;
}

.body-text {
    font-family: 'EB Garamond', Georgia, serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.4vw, 1.25rem);
    line-height: 1.72;
    letter-spacing: 0.01em;
    color: var(--champagne-mist);
    margin-bottom: 2rem;
    max-width: 90%;
}

.finale-process-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85em;
    color: var(--burnished-gold);
    letter-spacing: 0.1em;
    margin-top: 1.5rem;
}

/* --- Acts / Sections --- */
.act {
    padding: 4rem 3rem;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.act-genesis {
    min-height: 100vh;
}

.act-divergence {
    min-height: 150vh;
}

.act-contention {
    min-height: 150vh;
}

.act-synchronization {
    min-height: 100vh;
}

.act-convergence {
    min-height: 100vh;
}

.genesis-content,
.divergence-content,
.contention-content,
.sync-content,
.convergence-content {
    position: relative;
    z-index: 5;
    width: 100%;
}

/* --- Concentric Rectangles Motif --- */
.concentric-rects {
    position: relative;
    width: 200px;
    height: 200px;
    margin: 2rem auto;
}

.concentric-rects .rect {
    position: absolute;
    border: 1px solid var(--burnished-gold);
    top: 50%;
    left: 50%;
}

.concentric-rects .r1 {
    width: 200px;
    height: 200px;
    transform: translate(-50%, -50%) rotate(2deg);
}

.concentric-rects .r2 {
    width: 160px;
    height: 160px;
    transform: translate(-50%, -50%) rotate(-3deg);
}

.concentric-rects .r3 {
    width: 120px;
    height: 120px;
    transform: translate(-50%, -50%) rotate(5deg);
}

.concentric-rects .r4 {
    width: 80px;
    height: 80px;
    transform: translate(-50%, -50%) rotate(-2deg);
}

.concentric-rects .r5 {
    width: 40px;
    height: 40px;
    transform: translate(-50%, -50%) rotate(4deg);
}

.genesis-bg-motif {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.2;
    width: 400px;
    height: 400px;
}

.genesis-bg-motif .r1 { width: 400px; height: 400px; }
.genesis-bg-motif .r2 { width: 320px; height: 320px; }
.genesis-bg-motif .r3 { width: 240px; height: 240px; }
.genesis-bg-motif .r4 { width: 160px; height: 160px; }
.genesis-bg-motif .r5 { width: 80px; height: 80px; }

.convergence-motif {
    opacity: 0.15;
    width: 300px;
    height: 300px;
    margin: 0 auto;
}

.convergence-motif .r1 { width: 300px; height: 300px; }
.convergence-motif .r2 { width: 200px; height: 200px; }
.convergence-motif .r3 { width: 100px; height: 100px; }

/* --- Parallel Lines --- */
.parallel-lines {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 2rem 0;
}

.parallel-lines span {
    display: block;
    height: 0.5px;
    background: var(--antique-brass);
    width: 100%;
    opacity: 0.5;
}

.fork-point {
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 10px solid var(--burnished-gold);
    margin: 4px auto;
}

/* --- Card Flip --- */
.card-flip-container {
    perspective: 1200px;
    margin: 3rem 0;
    width: 100%;
    max-width: 280px;
}

.card-flip {
    position: relative;
    width: 100%;
    aspect-ratio: 3/4;
    transform-style: preserve-3d;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: default;
}

.card-flip.flipped {
    transform: rotateY(180deg);
}

.card-front,
.card-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border: 1px solid var(--antique-brass);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.card-front {
    background: var(--obsidian-black);
}

.card-back {
    background: var(--deep-onyx);
    transform: rotateY(180deg);
    flex-direction: column;
    text-align: left;
    align-items: flex-start;
    gap: 0.75rem;
}

.card-back h3 {
    font-family: 'Cormorant Garamond', 'Georgia', serif;
    font-weight: 600;
    font-size: 1.3rem;
    color: var(--burnished-gold);
    letter-spacing: 0.05em;
}

.card-back p {
    font-family: 'EB Garamond', Georgia, serif;
    font-weight: 400;
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--champagne-mist);
}

.card-svg {
    width: 100%;
    height: 100%;
}

/* --- Flowchart Motif --- */
.flowchart-motif {
    margin: 3rem 0;
    width: 100%;
    max-width: 300px;
}

.flowchart-svg {
    width: 100%;
    height: auto;
}

/* --- Clock Faces --- */
.clock-container {
    position: relative;
    width: 250px;
    height: 250px;
    margin: 2rem auto 3rem;
}

.clock {
    position: absolute;
    width: 200px;
    height: 200px;
}

.clock-1 {
    top: 0;
    left: 0;
}

.clock-2 {
    top: 20px;
    left: 30px;
    opacity: 0.7;
}

.clock-3 {
    top: 40px;
    left: 15px;
    opacity: 0.5;
}

.clock-1 .clock-hand-hour { animation: rotate-clock 60s linear infinite; transform-origin: 100px 100px; }
.clock-1 .clock-hand-minute { animation: rotate-clock 60s linear infinite; transform-origin: 100px 100px; }
.clock-2 .clock-hand-hour { animation: rotate-clock 23s linear infinite; transform-origin: 100px 100px; }
.clock-2 .clock-hand-minute { animation: rotate-clock 23s linear infinite; transform-origin: 100px 100px; }
.clock-3 .clock-hand-hour { animation: rotate-clock 7s linear infinite; transform-origin: 100px 100px; }
.clock-3 .clock-hand-minute { animation: rotate-clock 7s linear infinite; transform-origin: 100px 100px; }

/* Separate hour/minute hands with different speeds */
.clock-1 .clock-hand-hour { animation-duration: 720s; }
.clock-2 .clock-hand-hour { animation-duration: 276s; }
.clock-3 .clock-hand-hour { animation-duration: 84s; }

@keyframes rotate-clock {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* --- Scheduling Grid --- */
.scheduling-grid {
    margin: 2rem 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.grid-row {
    display: flex;
    gap: 2px;
}

.grid-cell {
    width: 40px;
    height: 20px;
    background: var(--warm-charcoal);
    display: block;
    transition: background 0.4s ease;
}

.grid-cell.active {
    background: var(--antique-brass);
}

.grid-cell.highlight {
    background: var(--burnished-gold);
}

/* --- Bleed Elements (Contention) --- */
.bleed-element {
    position: relative;
    margin: 3rem 0;
}

.bleed-right {
    margin-right: -3rem;
    padding-right: 3rem;
}

.bleed-left {
    margin-left: -3rem;
    padding-left: 3rem;
}

.bleed-element .concentric-rects {
    opacity: 0.4;
    transition: transform 0.8s ease-out;
}

/* --- Mirror Elements (Synchronization) --- */
.mirror-element {
    margin: 2rem 0;
    opacity: 0.6;
}

/* --- Skyline Silhouettes --- */
.skyline {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 120px;
    z-index: 3;
}

.skyline-alpha {
    background: var(--deep-onyx);
    clip-path: polygon(
        0% 100%,
        0% 60%,
        4% 60%,
        4% 40%,
        8% 40%,
        8% 55%,
        12% 55%,
        12% 30%,
        16% 30%,
        16% 50%,
        20% 50%,
        20% 65%,
        24% 65%,
        24% 35%,
        28% 35%,
        28% 25%,
        32% 25%,
        32% 45%,
        36% 45%,
        36% 55%,
        40% 55%,
        40% 20%,
        44% 20%,
        44% 40%,
        48% 40%,
        48% 60%,
        52% 60%,
        52% 30%,
        56% 30%,
        56% 50%,
        60% 50%,
        60% 70%,
        64% 70%,
        64% 45%,
        68% 45%,
        68% 25%,
        72% 25%,
        72% 55%,
        76% 55%,
        76% 40%,
        80% 40%,
        80% 60%,
        84% 60%,
        84% 35%,
        88% 35%,
        88% 50%,
        92% 50%,
        92% 65%,
        96% 65%,
        96% 45%,
        100% 45%,
        100% 100%
    );
}

.skyline-beta {
    background: var(--deep-onyx);
    clip-path: polygon(
        0% 100%,
        0% 50%,
        3% 50%,
        3% 35%,
        7% 35%,
        7% 55%,
        11% 55%,
        11% 20%,
        15% 20%,
        15% 45%,
        19% 45%,
        19% 60%,
        23% 60%,
        23% 30%,
        27% 30%,
        27% 50%,
        31% 50%,
        31% 40%,
        35% 40%,
        35% 15%,
        39% 15%,
        39% 35%,
        43% 35%,
        43% 55%,
        47% 55%,
        47% 25%,
        51% 25%,
        51% 45%,
        55% 45%,
        55% 60%,
        59% 60%,
        59% 35%,
        63% 35%,
        63% 50%,
        67% 50%,
        67% 30%,
        71% 30%,
        71% 55%,
        75% 55%,
        75% 40%,
        79% 40%,
        79% 20%,
        83% 20%,
        83% 45%,
        87% 45%,
        87% 60%,
        91% 60%,
        91% 35%,
        95% 35%,
        95% 50%,
        100% 50%,
        100% 100%
    );
}

/* Glowing windows in skyline */
.skyline-window {
    position: absolute;
    width: 3px;
    height: 4px;
    background: var(--burnished-gold);
    box-shadow: 0 0 20px rgba(200, 169, 81, 0.3);
    opacity: 0;
    transition: opacity 0.6s ease;
    z-index: 4;
}

.skyline-window.lit {
    opacity: 1;
}

/* --- Convergence Finale --- */
#convergence-finale {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--obsidian-black);
    z-index: 10;
    overflow: hidden;
}

#particle-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.finale-title {
    font-family: 'Cormorant Garamond', 'Georgia', serif;
    font-weight: 700;
    font-size: clamp(3rem, 8vw, 7rem);
    letter-spacing: 0.08em;
    line-height: 1.05;
    color: var(--ivory-flash);
    text-align: center;
    position: relative;
    z-index: 5;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 1.2s ease-out, transform 1.2s ease-out;
}

.finale-title.visible {
    opacity: 1;
    transform: translateY(0);
}

.finale-process-label {
    position: relative;
    z-index: 5;
    opacity: 0;
    transition: opacity 1.5s ease-out 0.5s;
}

.finale-process-label.visible {
    opacity: 1;
}

/* --- Mobile Responsive --- */
@media (max-width: 768px) {
    #split-container {
        display: flex;
        flex-direction: column;
        min-height: auto;
    }

    #divider {
        display: none;
    }

    .pane {
        width: 100%;
    }

    .act {
        padding: 3rem 1.5rem;
        min-height: auto;
    }

    .act-genesis { min-height: 80vh; }
    .act-divergence { min-height: auto; }
    .act-contention { min-height: auto; }
    .act-synchronization { min-height: auto; }
    .act-convergence { min-height: 50vh; }

    .hero-title {
        text-align: center;
        font-size: clamp(2.5rem, 10vw, 5rem);
    }

    .hero-left,
    .hero-right {
        text-align: center;
        padding: 0;
    }

    .body-text {
        max-width: 100%;
    }

    .card-flip-container {
        max-width: 220px;
    }

    #thread-indicator {
        top: 12px;
        right: 12px;
    }

    #thread-alpha-bar,
    #thread-beta-bar {
        height: 40px;
    }

    .pane::before {
        content: attr(data-thread-label);
        display: block;
        font-family: 'IBM Plex Mono', monospace;
        font-size: 0.75rem;
        color: var(--burnished-gold);
        letter-spacing: 0.15em;
        padding: 1rem 1.5rem 0;
        text-transform: uppercase;
    }

    #pane-alpha::before {
        content: "Thread Alpha";
    }

    #pane-beta::before {
        content: "Thread Beta";
    }

    .clock-container {
        width: 180px;
        height: 200px;
    }

    .clock {
        width: 150px;
        height: 150px;
    }

    .skyline {
        height: 80px;
    }

    .genesis-bg-motif {
        width: 250px;
        height: 250px;
    }

    .genesis-bg-motif .r1 { width: 250px; height: 250px; }
    .genesis-bg-motif .r2 { width: 200px; height: 200px; }
    .genesis-bg-motif .r3 { width: 150px; height: 150px; }
    .genesis-bg-motif .r4 { width: 100px; height: 100px; }
    .genesis-bg-motif .r5 { width: 50px; height: 50px; }
}

/* --- Scroll-driven concentric rect rotation --- */
.concentric-rects .rect {
    transition: transform 0.3s ease-out;
}

/* --- Selection color --- */
::selection {
    background: var(--antique-brass);
    color: var(--obsidian-black);
}

::-moz-selection {
    background: var(--antique-brass);
    color: var(--obsidian-black);
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: var(--obsidian-black);
}

::-webkit-scrollbar-thumb {
    background: var(--antique-brass);
    border-radius: 2px;
}

/* --- Grid cell illumination animation --- */
@keyframes grid-illuminate {
    0% { opacity: 0; }
    50% { opacity: 1; }
    100% { opacity: 0; }
}

.grid-overlay-cell {
    position: fixed;
    width: 40px;
    height: 40px;
    background: var(--antique-brass);
    opacity: 0;
    pointer-events: none;
    z-index: 0;
}

.grid-overlay-cell.illuminated {
    animation: grid-illuminate 2s ease-in-out forwards;
}
