/* ===================================================
   mujun.cafe - Bauhaus Paradox Scholarship
   =================================================== */

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

:root {
    --warm-parchment: #faf5eb;
    --charcoal-umber: #2c2416;
    --bauhaus-vermillion: #c45e3a;
    --aged-ochre: #d4a245;
    --deep-indigo: #3a4a6e;
    --weathered-brass: #8a7a62;
    --toasted-linen: #f0e6d0;
    --inverted-teal: #2ec4b6;
    --perspective-depth: 1200px;
}

html {
    scroll-snap-type: y proximity;
    scroll-behavior: smooth;
}

body {
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    color: var(--charcoal-umber);
    background: var(--warm-parchment);
    overflow-x: hidden;
    perspective: var(--perspective-depth);
    -webkit-font-smoothing: antialiased;
}

/* --- Layer 0: The Substrate --- */
.layer-substrate {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    opacity: 0.4;
    pointer-events: none;
    background:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 59px,
            #e8dfc8 59px,
            #e8dfc8 60px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 59px,
            #e8dfc8 59px,
            #e8dfc8 60px
        );
    background-size: 60px 60px;
    animation: substrateRotate 180s linear infinite;
}

@keyframes substrateRotate {
    from { transform: rotate(0deg) scale(1.5); }
    to { transform: rotate(360deg) scale(1.5); }
}

/* --- Layer 1: The Framework --- */
.layer-framework {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
    pointer-events: none;
    transform: translateZ(40px);
}

.geo-shape {
    position: absolute;
    border: 2px solid var(--bauhaus-vermillion);
    opacity: 0.6;
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.4s ease;
}

.geo-shape:hover {
    transform: rotate(90deg);
}

.geo-circle {
    border-radius: 50%;
}

.geo-square {
    border-radius: 0;
}

.geo-triangle {
    border: none;
    width: 0 !important;
    height: 0 !important;
    border-left: 90px solid transparent;
    border-right: 90px solid transparent;
    border-bottom: 156px solid transparent;
    position: absolute;
}

.geo-triangle::after {
    content: '';
    position: absolute;
    top: 4px;
    left: -86px;
    border-left: 86px solid transparent;
    border-right: 86px solid transparent;
    border-bottom: 149px solid var(--warm-parchment);
}

.geo-triangle::before {
    content: '';
    position: absolute;
    top: 0;
    left: -90px;
    border-left: 90px solid transparent;
    border-right: 90px solid transparent;
    border-bottom: 156px solid var(--bauhaus-vermillion);
    z-index: -1;
}

/* --- Layer 3: The Glitch Membrane --- */
.layer-glitch {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 800;
    pointer-events: none;
}

.glitch-scanline {
    position: absolute;
    left: 0;
    width: 100vw;
    height: 3px;
    background: linear-gradient(
        transparent 0%,
        rgba(46, 196, 182, 0.15) 50%,
        transparent 100%
    );
    animation: scanlineSweep 0.8s linear forwards;
    pointer-events: none;
}

@keyframes scanlineSweep {
    from { transform: translateY(-100vh); }
    to { transform: translateY(100vh); }
}

.glitch-band {
    position: absolute;
    left: 0;
    width: 100vw;
    height: 4px;
    mix-blend-mode: difference;
    backdrop-filter: hue-rotate(180deg);
    -webkit-backdrop-filter: hue-rotate(180deg);
    background: rgba(46, 196, 182, 0.3);
    pointer-events: none;
    animation: glitchFlash 0.15s ease-out forwards;
}

@keyframes glitchFlash {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

.displacement-rect {
    position: absolute;
    width: 60px;
    height: 20px;
    backdrop-filter: invert(1);
    -webkit-backdrop-filter: invert(1);
    pointer-events: none;
    z-index: 900;
    animation: displaceFade 0.3s ease-out forwards;
}

@keyframes displaceFade {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

/* --- Navigation --- */
.nav-bar {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 16px 0;
    z-index: 700;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    background: rgba(250, 245, 235, 0.85);
    border-right: 1px solid rgba(138, 122, 98, 0.2);
    border-radius: 0 8px 8px 0;
}

.nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    text-decoration: none;
    transition: transform 0.25s ease;
}

.nav-btn:hover {
    transform: scale(1.15);
}

.nav-icon {
    display: block;
    border: 2px solid var(--bauhaus-vermillion);
    transition: background 0.25s ease, border-color 0.25s ease;
}

.nav-icon-circle {
    width: 14px;
    height: 14px;
    border-radius: 50%;
}

.nav-icon-square {
    width: 12px;
    height: 12px;
}

.nav-icon-triangle {
    width: 0;
    height: 0;
    border: none;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-bottom: 12px solid transparent;
    position: relative;
}

.nav-icon-triangle::before {
    content: '';
    position: absolute;
    top: 1px;
    left: -7px;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-bottom: 12px solid var(--bauhaus-vermillion);
}

.nav-btn.active .nav-icon-circle {
    background: var(--bauhaus-vermillion);
}

.nav-btn.active .nav-icon-square {
    background: var(--bauhaus-vermillion);
}

.nav-btn.active .nav-icon-triangle::before {
    border-bottom-color: var(--bauhaus-vermillion);
}

/* --- Opening Sequence --- */
.opening-sequence {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 300;
    scroll-snap-align: start;
}

.opening-shapes {
    position: relative;
    width: 300px;
    height: 300px;
    margin-bottom: 24px;
}

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

.draw-shape {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
}

.shape-circle {
    animation: drawShape 0.7s ease-out 0.6s forwards;
}

.shape-square {
    animation: drawShape 0.5s ease-out 1.3s forwards;
}

.shape-triangle {
    animation: drawShape 0.4s ease-out 1.8s forwards;
}

@keyframes drawShape {
    to { stroke-dashoffset: 0; }
}

.opening-shapes svg {
    animation: shapesRecede 1s ease-out 3.8s forwards,
               shapesRotateA 120s linear 4.8s infinite;
}

@keyframes shapesRecede {
    to { opacity: 0.4; }
}

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

.opening-title {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 700;
    font-size: clamp(3rem, 8vw, 6rem);
    letter-spacing: 0.04em;
    line-height: 1.1;
    color: var(--charcoal-umber);
    overflow: hidden;
    min-height: 1.2em;
}

.title-mujun {
    display: inline;
}

.title-cafe {
    display: inline;
    color: var(--bauhaus-vermillion);
    font-size: 0.6em;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.title-cafe.visible {
    opacity: 1;
}

.opening-subtitle {
    font-family: 'Varela Round', sans-serif;
    font-size: clamp(0.75rem, 1.4vw, 0.9rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--weathered-brass);
    margin-top: 16px;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeUp 0.8s ease-out 4.2s forwards;
}

@keyframes fadeUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Channel Split Glitch on Text --- */
.channel-split {
    text-shadow:
        2px 0 var(--inverted-teal),
        -2px 0 var(--bauhaus-vermillion);
    animation: channelSplitFlash 0.15s ease-out forwards;
}

@keyframes channelSplitFlash {
    0% {
        text-shadow:
            2px 0 var(--inverted-teal),
            -2px 0 var(--bauhaus-vermillion);
    }
    100% {
        text-shadow: none;
    }
}

/* --- Main Content Container --- */
.content-container {
    position: relative;
    z-index: 300;
    padding-left: 48px;
}

/* --- Section Divider --- */
.section-divider {
    width: 0;
    height: 2px;
    background: var(--bauhaus-vermillion);
    margin: 0 auto 40px;
    transition: width 0.4s ease-out;
}

.section-divider.drawn {
    width: 100%;
}

/* --- Content Sections --- */
.content-section {
    min-height: 100vh;
    padding: 80px 40px 80px 20px;
    scroll-snap-align: start;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease-out, transform 0.6s ease-out;
}

.content-section.visible {
    opacity: 1;
    transform: translateY(0) translateZ(0);
}

/* --- Section Grid (6-column) --- */
.section-grid {
    display: grid;
    grid-template-columns: minmax(80px, 1fr) 5fr;
    gap: 24px;
    max-width: 1100px;
    margin: 0 auto;
}

/* Section 1: standard layout */
.content-section[data-index="0"] .section-grid {
    grid-template-columns: minmax(80px, 1fr) 5fr;
}

/* Section 2: slightly narrower marginalia */
.content-section[data-index="1"] .section-grid {
    grid-template-columns: minmax(60px, 0.8fr) 5fr;
}

/* Section 3: wider content */
.content-section[data-index="2"] .section-grid {
    grid-template-columns: minmax(80px, 1fr) 6fr;
}

/* Section 4: balanced */
.content-section[data-index="3"] .section-grid {
    grid-template-columns: minmax(80px, 1fr) 5fr;
}

/* Section 5: centered-feel */
.content-section[data-index="4"] .section-grid {
    grid-template-columns: minmax(80px, 1fr) 5fr;
}

/* --- Marginalia --- */
.section-marginalia {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding-top: 60px;
}

.annotation {
    position: relative;
    cursor: pointer;
    opacity: 0.7;
    transform: scale(0.97);
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

.annotation:hover {
    opacity: 1;
    transform: scale(1);
}

.annotation-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1.5px solid var(--weathered-brass);
    font-family: 'Varela Round', sans-serif;
    font-size: 11px;
    color: var(--weathered-brass);
    letter-spacing: 0;
}

.annotation::after {
    content: attr(data-note);
    display: block;
    max-height: 0;
    overflow: hidden;
    font-family: 'Varela Round', sans-serif;
    font-size: clamp(0.75rem, 1.4vw, 0.9rem);
    letter-spacing: 0.02em;
    color: var(--weathered-brass);
    line-height: 1.5;
    margin-top: 6px;
    transition: max-height 0.3s ease-out, opacity 0.3s ease-out;
    opacity: 0;
}

.annotation:hover::after {
    max-height: 200px;
    opacity: 1;
}

/* --- Section Headings --- */
.section-heading {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 700;
    font-size: clamp(1.5rem, 3vw, 2.4rem);
    letter-spacing: 0.06em;
    line-height: 1.25;
    color: var(--charcoal-umber);
    margin-bottom: 28px;
    display: flex;
    align-items: center;
    gap: 14px;
}

/* --- Heading Geometric Markers --- */
.heading-marker {
    display: inline-block;
    flex-shrink: 0;
    border: 2px solid var(--bauhaus-vermillion);
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.heading-marker.spin {
    transform: rotate(360deg);
}

.heading-marker-circle {
    width: 16px;
    height: 16px;
    border-radius: 50%;
}

.heading-marker-square {
    width: 14px;
    height: 14px;
}

.heading-marker-triangle {
    width: 0;
    height: 0;
    border: none;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 14px solid var(--bauhaus-vermillion);
}

/* --- Section Body --- */
.section-body {
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    line-height: 1.72;
    letter-spacing: 0.01em;
    max-width: 38em;
    color: var(--charcoal-umber);
    margin-bottom: 20px;
}

.section-body em {
    font-weight: 600;
    font-style: normal;
}

.section-body[data-mujun="true"] {
    position: relative;
}

/* --- SVG Diagrams --- */
.svg-diagram {
    margin: 40px 0 20px;
    padding: 24px;
    background: var(--toasted-linen);
    border-radius: 4px;
    display: inline-block;
}

.svg-diagram svg {
    display: block;
    max-width: 100%;
    height: auto;
}

.diagram-draw {
    stroke-dasharray: 800;
    stroke-dashoffset: 800;
    transition: stroke-dashoffset 1.2s ease-out;
}

.diagram-draw.drawn {
    stroke-dashoffset: 0;
}

/* --- Link Styles --- */
a {
    color: var(--bauhaus-vermillion);
    text-decoration: none;
    background-image: linear-gradient(var(--bauhaus-vermillion), var(--bauhaus-vermillion));
    background-size: 0% 2px;
    background-position: left bottom;
    background-repeat: no-repeat;
    transition: background-size 0.2s ease, color 0.25s ease;
    position: relative;
}

a:hover {
    background-size: 100% 2px;
    color: var(--aged-ochre);
}

a::before {
    content: '';
    position: absolute;
    left: 0;
    bottom: -1px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--bauhaus-vermillion);
    transform: scale(0);
    transition: transform 0.2s ease;
}

a:hover::before {
    transform: scale(1);
}

/* Nav links override */
.nav-btn {
    background-image: none;
}

.nav-btn::before {
    display: none;
}

/* --- Buttons --- */
button, .btn {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 700;
    font-size: clamp(0.85rem, 1.5vw, 1rem);
    letter-spacing: 0.04em;
    padding: 10px 24px;
    border: 2px solid var(--bauhaus-vermillion);
    border-radius: 2px;
    background: transparent;
    color: var(--bauhaus-vermillion);
    cursor: pointer;
    transition: border-color 0.25s ease, background 0.25s ease, border-radius 0.25s ease, color 0.25s ease;
}

button:hover, .btn:hover {
    border-color: var(--aged-ochre);
    background: rgba(212, 162, 69, 0.08);
    border-radius: 6px;
    color: var(--aged-ochre);
}

/* --- Focus Outlines (per design spec) --- */
/* Note: design specifies focus outlines with deep indigo */

/* --- Section Transition Intensification --- */
.content-section.transitioning .geo-shape {
    transform: scale(1.3);
    opacity: 0.4;
}

/* --- Parallax Layer Movement --- */
.layer-framework.parallax-shift {
    transition: transform 0.1s linear;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .nav-bar {
        display: none;
    }

    .content-container {
        padding-left: 0;
    }

    .section-grid {
        grid-template-columns: 1fr !important;
    }

    .section-marginalia {
        flex-direction: row;
        gap: 12px;
        padding-top: 0;
        margin-bottom: 20px;
    }

    .annotation::after {
        position: absolute;
        left: 0;
        top: 100%;
        width: 200px;
        z-index: 10;
        background: var(--toasted-linen);
        padding: 8px;
        border-radius: 4px;
    }

    .content-section {
        padding: 60px 20px;
    }

    .svg-diagram {
        padding: 16px;
    }

    .svg-diagram svg {
        width: 100%;
    }

    .opening-shapes {
        width: 200px;
        height: 200px;
    }
}

@media (max-width: 480px) {
    .section-heading {
        font-size: 1.3rem;
    }

    .section-body {
        font-size: 0.95rem;
    }
}

/* --- Utility: Hidden --- */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}
