/* ============================================
   MMIDDL.com - Anti-Design Split-Screen
   Near-monochrome + #D4503A accent
   ============================================ */

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

html {
    scroll-behavior: auto;
    overflow-x: hidden;
}

body {
    background: #0A0A0A;
    color: #F0F0F0;
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-size: 1.125rem;
    line-height: 1.85;
    overflow-x: hidden;
}

::selection {
    background: #D4503A;
    color: #F0F0F0;
}

/* --- Debug Overlay Bar --- */
#debug-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 24px;
    background: transparent;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 0 1rem;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #808080;
    border-bottom: 1px solid #808080;
    pointer-events: none;
}

/* --- Split Container --- */
#split-container {
    display: grid;
    grid-template-columns: 38.2fr 0fr 61.8fr;
    min-height: 100vh;
    position: relative;
    transition: grid-template-columns 1.2s cubic-bezier(0.25, 0.1, 0.25, 1.0);
}

#split-container.scene-3-active {
    grid-template-columns: 61.8fr 0fr 38.2fr;
}

#split-container.scene-4-active {
    grid-template-columns: 1fr 0fr 0fr;
}

/* --- Left Column (The Anchor) --- */
#left-column {
    background: #0A0A0A;
    position: relative;
    z-index: 2;
    padding-top: 24px;
}

.scene {
    position: relative;
}

#scene-1 {
    height: 100vh;
    display: flex;
    align-items: center;
}

#scene-2 {
    min-height: 150vh;
}

#scene-3 {
    min-height: 120vh;
}

#scene-4 {
    min-height: 100vh;
}

#scene-5 {
    min-height: 80vh;
}

.scene-content {
    padding: 4rem 3rem 4rem 15vw;
}

#scene-1 .scene-content {
    padding-top: 0;
}

/* --- Scene Labels --- */
.scene-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #808080;
    margin-bottom: 2rem;
}

/* --- Typography --- */
.hero-word {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: clamp(4rem, 12vw, 14rem);
    letter-spacing: -0.03em;
    color: #F0F0F0;
    line-height: 0.9;
    margin-bottom: 1.5rem;
}

.hero-aside {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #808080;
}

.section-heading {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: clamp(2rem, 4vw, 4.5rem);
    letter-spacing: -0.03em;
    color: #F0F0F0;
    line-height: 1.1;
    margin-bottom: 2rem;
}

.body-text {
    color: #C8C8C8;
    margin-bottom: 1.5rem;
    max-width: 42ch;
}

.body-text.aside {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.8rem;
    letter-spacing: 0.04em;
    color: #808080;
    font-style: italic;
}

.body-text.meta-contact {
    margin-top: 3rem;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #808080;
    line-height: 2;
}

.accent-word {
    color: #D4503A;
    animation: accent-pulse 3s ease-in-out infinite;
    transition: color 0.3s cubic-bezier(0.25, 0.1, 0.25, 1.0);
}

.accent-word:hover {
    color: #E8715E;
}

@keyframes accent-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* --- Text Reveal Animation --- */
.scene-content .section-heading,
.scene-content .body-text {
    clip-path: inset(0 100% 0 0);
    transition: clip-path 0.8s cubic-bezier(0.25, 0.1, 0.25, 1.0);
}

.scene-content .section-heading.revealed,
.scene-content .body-text.revealed {
    clip-path: inset(0 0% 0 0);
}

.scene-content .scene-label {
    clip-path: inset(0 100% 0 0);
    transition: clip-path 0.5s cubic-bezier(0.25, 0.1, 0.25, 1.0);
}

.scene-content .scene-label.revealed {
    clip-path: inset(0 0% 0 0);
}

/* --- The Divide --- */
#the-divide {
    position: relative;
    width: 6px;
    z-index: 10;
    overflow: visible;
}

#divide-svg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

#divide-line-main {
    stroke: #0A0A0A;
    stroke-width: 2;
    animation: divide-pulse 4s ease-in-out infinite;
}

@keyframes divide-pulse {
    0%, 100% { stroke: #0A0A0A; }
    50% { stroke: #E8E8E8; }
}

.divide-fracture {
    stroke: #808080;
    stroke-width: 1;
    opacity: 0;
    transition: opacity 0.8s cubic-bezier(0.25, 0.1, 0.25, 1.0);
}

.divide-fracture.active {
    opacity: 0.4;
}

/* Scene 5: dissolve the line into dots */
#the-divide.dissolving #divide-line-main {
    stroke-dasharray: 3, 8;
    animation: divide-dissolve 3s forwards;
}

@keyframes divide-dissolve {
    to {
        stroke-dasharray: 1, 30;
        opacity: 0.2;
    }
}

/* --- Right Column (The Stage) --- */
#right-column {
    background: #F0F0F0;
    position: relative;
    overflow: hidden;
}

.stage-scene {
    position: sticky;
    top: 0;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 1s cubic-bezier(0.25, 0.1, 0.25, 1.0);
    pointer-events: none;
}

.stage-scene.active {
    opacity: 1;
    pointer-events: auto;
}

/* First scene visible by default */
#stage-1 {
    opacity: 1;
    pointer-events: auto;
}

/* --- Coordinate Labels --- */
.coord-label {
    position: absolute;
    bottom: 15%;
    right: 10%;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.05em;
    color: #808080;
    white-space: nowrap;
}

/* --- Grid Overlay --- */
.grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    background-image:
        linear-gradient(to right, #E8E8E8 1px, transparent 1px),
        linear-gradient(to bottom, #E8E8E8 1px, transparent 1px);
    background-size: 60px 60px;
    opacity: 0.25;
}

/* --- 3D Torus (Scene 1) --- */
#torus-container {
    perspective: 800px;
    width: 300px;
    height: 300px;
    position: relative;
}

.torus {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    animation: torus-rotate 40s linear infinite;
}

@keyframes torus-rotate {
    from { transform: rotateX(0deg) rotateY(0deg); }
    to { transform: rotateX(360deg) rotateY(200deg); }
}

.torus-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200px;
    height: 200px;
    margin-top: -100px;
    margin-left: -100px;
    border: 2px solid #3A3A3A;
    border-radius: 50%;
    transform-style: preserve-3d;
}

.torus-ring-1 { transform: rotateY(0deg) translateZ(50px); }
.torus-ring-2 { transform: rotateY(22.5deg) translateZ(50px); }
.torus-ring-3 { transform: rotateY(45deg) translateZ(50px); }
.torus-ring-4 { transform: rotateY(67.5deg) translateZ(50px); }
.torus-ring-5 { transform: rotateY(90deg) translateZ(50px); }
.torus-ring-6 { transform: rotateY(112.5deg) translateZ(50px); }
.torus-ring-7 { transform: rotateY(135deg) translateZ(50px); }
.torus-ring-8 { transform: rotateY(157.5deg) translateZ(50px); border-color: #D4503A; box-shadow: 0 0 15px rgba(212, 80, 58, 0.3); }

/* --- Geometric Assemblage (Scene 2) --- */
#assemblage-container {
    perspective: 1000px;
    width: 350px;
    height: 350px;
    position: relative;
}

.assemblage {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
}

.geo-shape {
    position: absolute;
    transform-style: preserve-3d;
    border: 1px solid #808080;
}

.geo-cube {
    width: 80px;
    height: 80px;
    top: 50%;
    left: 50%;
    margin-top: -40px;
    margin-left: -40px;
    animation: cube-drift 35s linear infinite;
}

@keyframes cube-drift {
    from { transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg); }
    to { transform: rotateX(360deg) rotateY(240deg) rotateZ(120deg); }
}

.geo-sphere {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    top: 25%;
    left: 60%;
    animation: sphere-drift 45s linear infinite;
}

@keyframes sphere-drift {
    from { transform: rotateZ(0deg) translateX(30px); }
    to { transform: rotateZ(360deg) translateX(30px); }
}

.geo-cone {
    width: 0;
    height: 0;
    border-left: 30px solid transparent;
    border-right: 30px solid transparent;
    border-bottom: 70px solid transparent;
    border-bottom-color: #808080;
    position: absolute;
    top: 65%;
    left: 30%;
    animation: cone-drift 55s linear infinite;
    opacity: 0.7;
}

@keyframes cone-drift {
    from { transform: rotateY(0deg) translateY(-20px); }
    to { transform: rotateY(360deg) translateY(-20px); }
}

.geo-octahedron {
    width: 50px;
    height: 50px;
    top: 35%;
    left: 25%;
    transform: rotate(45deg);
    animation: octa-drift 50s linear infinite;
}

@keyframes octa-drift {
    from { transform: rotate(45deg) rotateX(0deg) rotateY(0deg); }
    to { transform: rotate(45deg) rotateX(360deg) rotateY(360deg); }
}

.geo-small-cube {
    width: 35px;
    height: 35px;
    top: 70%;
    left: 65%;
    animation: small-cube-drift 30s linear infinite;
}

@keyframes small-cube-drift {
    from { transform: rotateX(0deg) rotateZ(0deg); }
    to { transform: rotateX(360deg) rotateZ(360deg); }
}

/* --- Fractured Plane (Scene 3) --- */
#fracture-container {
    width: 350px;
    height: 350px;
    position: relative;
}

.fractured-plane {
    width: 100%;
    height: 100%;
}

.frag {
    fill: none;
    stroke: #3A3A3A;
    stroke-width: 1.5;
    transition: transform 1s cubic-bezier(0.25, 0.1, 0.25, 1.0);
    transform-origin: center;
}

.frag-1 { transform: translate(0, 0); }
.frag-2 { transform: translate(0, 0); }
.frag-3 { transform: translate(0, 0); }
.frag-4 { transform: translate(0, 0); }
.frag-5 { transform: translate(0, 0); }
.frag-6 { transform: translate(0, 0); }
.frag-7 { transform: translate(0, 0); }
.frag-8 { transform: translate(0, 0); }
.frag-9 { transform: translate(0, 0); }
.frag-10 { transform: translate(0, 0); }

.fractured-plane.scattered .frag-1 { transform: translate(-12px, -18px); }
.fractured-plane.scattered .frag-2 { transform: translate(15px, -10px); }
.fractured-plane.scattered .frag-3 { transform: translate(-5px, 8px); }
.fractured-plane.scattered .frag-4 { transform: translate(-20px, 14px); }
.fractured-plane.scattered .frag-5 { transform: translate(18px, 12px); }
.fractured-plane.scattered .frag-6 { transform: translate(-15px, -8px); }
.fractured-plane.scattered .frag-7 { transform: translate(-8px, -22px); }
.fractured-plane.scattered .frag-8 { transform: translate(22px, -15px); }
.fractured-plane.scattered .frag-9 { transform: translate(-25px, 18px); }
.fractured-plane.scattered .frag-10 { transform: translate(20px, 22px); }

/* --- Grid Canvas (Scene 4) --- */
#grid-canvas {
    width: 100%;
    height: 100%;
    max-width: 500px;
    max-height: 500px;
}

/* --- Dissolve Dots (Scene 5) --- */
#dissolve-container {
    width: 300px;
    height: 300px;
    position: relative;
}

.dissolve-dots {
    width: 100%;
    height: 100%;
    position: relative;
}

.dissolve-dot {
    position: absolute;
    width: 3px;
    height: 3px;
    background: #808080;
    border-radius: 50%;
    transition: transform 3s cubic-bezier(0.25, 0.1, 0.25, 1.0),
                opacity 3s cubic-bezier(0.25, 0.1, 0.25, 1.0);
}

.dissolve-dot.scattered {
    opacity: 0;
}

/* --- Border Animation Pattern --- */
.scene-content {
    border-left: 2px solid transparent;
    animation: border-flux 6s steps(3) infinite;
    padding-left: calc(15vw - 2px);
}

@keyframes border-flux {
    0% { border-left-style: solid; border-left-color: #141414; }
    33% { border-left-style: dashed; border-left-color: #1A1A1A; }
    66% { border-left-style: dotted; border-left-color: #3A3A3A; }
    100% { border-left-style: solid; border-left-color: #141414; }
}

#scene-1 .scene-content {
    border-left: none;
    padding-left: 15vw;
}

/* --- Scene 4: Full-width mode --- */
#split-container.scene-4-active #left-column {
    background: #0A0A0A;
}

#split-container.scene-4-active #right-column {
    display: none;
}

#split-container.scene-4-active #the-divide {
    display: none;
}

#split-container.scene-4-active .scene-content {
    max-width: 70ch;
    padding-left: 10vw;
}

#split-container.scene-4-active .section-heading {
    font-size: clamp(3rem, 6vw, 7rem);
}

/* --- Stage positioning: layer scenes absolutely for sticky behavior --- */
#right-column {
    display: flex;
    flex-direction: column;
    position: relative;
}

.stage-scene {
    position: fixed;
    top: 0;
    right: 0;
    width: 61.8%;
    height: 100vh;
}

#split-container.scene-3-active .stage-scene {
    width: 38.2%;
}

#split-container.scene-4-active .stage-scene {
    display: none;
}

/* --- Border animate on scene containers --- */
.stage-scene::after {
    content: '';
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    bottom: 20px;
    border: 1px solid transparent;
    pointer-events: none;
    animation: stage-border-anim 8s linear infinite;
}

@keyframes stage-border-anim {
    0% { border-color: transparent; }
    25% { border-color: #E8E8E8; border-style: solid; }
    50% { border-color: #C8C8C8; border-style: dashed; }
    75% { border-color: #E8E8E8; border-style: dotted; }
    100% { border-color: transparent; }
}

/* --- Viewport edge border animation --- */
body::before {
    content: '';
    position: fixed;
    top: 24px;
    left: 0;
    right: 0;
    bottom: 0;
    border: 1px solid transparent;
    pointer-events: none;
    z-index: 9998;
    animation: viewport-border 7s ease-in-out infinite;
}

@keyframes viewport-border {
    0%, 100% { border-color: transparent; }
    30% { border-color: #1A1A1A; border-style: solid; }
    60% { border-color: #3A3A3A; border-style: dashed; }
    80% { border-color: #1A1A1A; border-style: dotted; }
}
