/* ============================================
   lungi.dev — Glitch Museum of Classical Antiquity
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --alabaster-milk: #F5F0F7;
    --rose-quartz: #F0E4EC;
    --twilight-marble: #3D3149;
    --dusk-plum: #4A4258;
    --pastel-terracotta: #D4A08E;
    --lavender-stone: #8B7FA0;
    --blush-corruption: #E8B4C8;
    --mint-fragment: #A8D8C8;
    --veined-marble: #6B5B7B;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--alabaster-milk);
    color: var(--dusk-plum);
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.25rem);
    line-height: 1.72;
    letter-spacing: 0.01em;
    overflow-x: hidden;
    position: relative;
}

/* --- Ambient Canvas --- */
#ambient-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    pointer-events: none;
}

/* --- Tessellation Background --- */
#tessellation-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    pointer-events: none;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='52'%3E%3Cpolygon points='30,0 60,15 60,37 30,52 0,37 0,15' fill='none' stroke='%238B7FA0' stroke-width='1'/%3E%3C/svg%3E");
    background-size: 60px 52px;
}

/* --- Glitch Artifacts (persistent random bars) --- */
#glitch-artifacts {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
    overflow: hidden;
}

.glitch-bar {
    position: absolute;
    height: 2px;
    opacity: 0;
    animation-timing-function: step-end;
}

.glitch-bar-blush {
    background-color: var(--blush-corruption);
}

.glitch-bar-mint {
    background-color: var(--mint-fragment);
}

/* --- Grid Section Base --- */
.grid-section {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 32px;
    padding: 0 32px;
    position: relative;
    max-width: 1400px;
    margin: 0 auto;
}

/* --- Hero Section --- */
#hero {
    height: 100vh;
    align-items: center;
    overflow: hidden;
}

#hero-logotype {
    grid-column: 1 / 5;
    grid-row: 1;
    z-index: 2;
}

#lungi-title {
    font-family: 'Fraunces', serif;
    font-size: clamp(4rem, 12vw, 9rem);
    color: var(--twilight-marble);
    font-variation-settings: 'wght' 100, 'SOFT' 0, 'opsz' 144;
    transition: font-variation-settings 2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    line-height: 1;
    margin-bottom: 0.3em;
}

#lungi-title.settled {
    font-variation-settings: 'wght' 700, 'SOFT' 60, 'opsz' 144;
}

.hero-subtitle {
    font-family: 'Recursive', sans-serif;
    font-size: clamp(0.75rem, 1vw, 0.95rem);
    color: var(--lavender-stone);
    font-variation-settings: 'MONO' 0, 'CASL' 0.5;
    letter-spacing: 0.05em;
    text-transform: lowercase;
}

#hero-composition {
    grid-column: 5 / 13;
    grid-row: 1;
    position: relative;
    height: 70vh;
    z-index: 1;
}

/* --- Marble Slabs --- */
.marble-slab {
    position: absolute;
    overflow: hidden;
    border-radius: 2px;
    opacity: 0;
    transition: transform 1s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 0.8s ease;
}

.marble-slab.visible {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) !important;
}

.slab-1 {
    width: 55%;
    height: 65%;
    top: 5%;
    left: 10%;
    background: linear-gradient(135deg, #F5F0F7 0%, #E8B4C8 35%, #F0E4EC 65%, #A8D8C8 100%);
    transform: translate(40px, 30px) rotate(3deg);
    clip-path: polygon(5% 0%, 100% 2%, 97% 95%, 0% 100%);
}

.slab-2 {
    width: 45%;
    height: 55%;
    top: 20%;
    left: 35%;
    background: linear-gradient(225deg, #A8D8C8 0%, #F0E4EC 40%, #E8B4C8 70%, #F5F0F7 100%);
    transform: translate(-30px, 50px) rotate(-2deg);
    clip-path: polygon(3% 5%, 98% 0%, 100% 92%, 2% 98%);
}

.slab-3 {
    width: 40%;
    height: 50%;
    top: 30%;
    left: 50%;
    background: linear-gradient(160deg, #E8B4C8 0%, #F5F0F7 50%, #A8D8C8 100%);
    transform: translate(60px, -20px) rotate(4deg);
    clip-path: polygon(0% 3%, 95% 0%, 100% 97%, 8% 100%);
}

.marble-veining {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* --- Column Fragments --- */
.column-fragment {
    background: linear-gradient(180deg, #F5F0F7 0%, #E8B4C8 50%, #F0E4EC 100%);
    border-radius: 50% 50% 0 0;
    position: absolute;
}

.col-frag-1 {
    width: 8%;
    height: 40%;
    bottom: 5%;
    left: 5%;
    opacity: 0.6;
}

.col-frag-2 {
    width: 6%;
    height: 30%;
    bottom: 5%;
    left: 16%;
    opacity: 0.5;
}

/* --- Hero Scanlines --- */
.hero-scanline {
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--blush-corruption);
    opacity: 0;
    pointer-events: none;
    z-index: 10;
}

/* --- Hero Glitch State --- */
#hero.glitch-tick #lungi-title {
    transform: translateX(3px);
}

#hero.glitch-tick .marble-slab {
    mix-blend-mode: exclusion;
}

#hero.glitch-tick .hero-scanline {
    opacity: 0.7;
}

/* --- Content Zones --- */
.content-zone {
    padding-top: 80px;
    padding-bottom: 80px;
    min-height: 50vh;
    align-items: start;
}

/* --- Zone Children (animate in) --- */
.zone-child {
    opacity: 0;
    transform: translateX(-20px) skewX(2deg);
    filter: hue-rotate(15deg) blur(1px);
    transition: opacity 800ms cubic-bezier(0.34, 1.56, 0.64, 1),
                transform 800ms cubic-bezier(0.34, 1.56, 0.64, 1),
                filter 800ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.zone-child.resolved {
    opacity: 1;
    transform: translateX(0) skewX(0);
    filter: hue-rotate(0deg) blur(0px);
}

/* --- Section Pediment --- */
.section-pediment {
    margin-bottom: 24px;
}

.pediment-svg {
    width: 200px;
    height: 30px;
}

.pediment-outline {
    stroke-dashoffset: 0;
    animation: pediment-flow 8s linear infinite;
}

@keyframes pediment-flow {
    to {
        stroke-dashoffset: -100;
    }
}

.section-pediment:hover .pediment-outline {
    animation-duration: 4s;
}

/* --- Headings --- */
.section-heading {
    font-family: 'Fraunces', serif;
    font-size: clamp(2rem, 5vw, 4rem);
    color: var(--twilight-marble);
    font-variation-settings: 'wght' 600, 'SOFT' 40, 'opsz' 48;
    line-height: 1.2;
    margin-bottom: 0.5em;
}

/* --- Manifesto --- */
#manifesto {
    align-items: center;
}

.manifesto-text {
    grid-column: 1 / 9;
}

.manifesto-text p {
    max-width: 38em;
    margin-bottom: 1em;
}

/* --- Entablature Divider --- */
.entablature-divider {
    grid-column: 1 / -1;
    height: 3px;
    width: 80%;
    margin: 40px auto;
    background: repeating-linear-gradient(
        90deg,
        var(--veined-marble) 0px,
        var(--veined-marble) 30px,
        transparent 30px,
        transparent 48px,
        var(--veined-marble) 48px,
        var(--veined-marble) 90px,
        transparent 90px,
        transparent 102px,
        var(--veined-marble) 102px,
        var(--veined-marble) 160px,
        transparent 160px,
        transparent 178px,
        var(--veined-marble) 178px,
        var(--veined-marble) 220px,
        transparent 220px,
        transparent 240px
    );
    opacity: 0.5;
}

/* --- Left Vignettes --- */
.left-vignette {
    grid-column: 1 / 5;
}

/* --- Right Vignettes (Disruption) --- */
.disruption .right-vignette {
    grid-column: 7 / 12;
}

.disruption .ghost-afterimage {
    grid-column: 1 / 5;
    opacity: 0;
}

.disruption .ghost-afterimage.resolved {
    opacity: 0.15;
}

.ghost-text {
    font-family: 'Fraunces', serif;
    font-size: clamp(2rem, 5vw, 4rem);
    color: var(--blush-corruption);
    font-variation-settings: 'wght' 600, 'SOFT' 40;
}

/* --- Marble Swatch --- */
.marble-swatch,
.marble-swatch-2 {
    width: 100%;
    height: 200px;
    position: relative;
    overflow: hidden;
    border-radius: 4px;
    background: linear-gradient(135deg, #F5F0F7 0%, #E8B4C8 35%, #F0E4EC 65%, #A8D8C8 100%);
    margin-bottom: 16px;
    cursor: pointer;
}

/* --- Code Block --- */
.code-block {
    background-color: var(--rose-quartz);
    border: 1px solid var(--veined-marble);
    border-radius: 4px;
    padding: 24px;
    margin-bottom: 16px;
    overflow-x: auto;
}

.code-block pre {
    margin: 0;
}

.code-block code {
    font-family: 'Recursive', monospace;
    font-size: clamp(0.75rem, 1vw, 0.95rem);
    color: var(--lavender-stone);
    font-variation-settings: 'MONO' 1, 'CASL' 0;
    line-height: 1.6;
}

.recursive-font {
    font-family: 'Recursive', monospace;
}

/* --- Vignette Labels --- */
.vignette-label {
    font-family: 'Recursive', sans-serif;
    font-size: clamp(0.75rem, 1vw, 0.95rem);
    color: var(--lavender-stone);
    font-variation-settings: 'MONO' 0.5, 'CASL' 0.3;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 8px;
}

.vignette-text {
    max-width: 38em;
    color: var(--dusk-plum);
}

.large-text {
    font-family: 'Fraunces', serif;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    font-variation-settings: 'wght' 400, 'SOFT' 60, 'opsz' 48;
    color: var(--twilight-marble);
    line-height: 1.4;
}

/* --- Column Group (inline columns) --- */
.column-group {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    margin-top: 24px;
    height: 160px;
}

.col-inline {
    position: relative;
    width: 28px;
}

.col-inline-1 {
    height: 140px;
    opacity: 0.7;
}

.col-inline-2 {
    height: 100px;
    opacity: 0.5;
}

.col-inline-3 {
    height: 120px;
    opacity: 0.6;
}

/* --- Geometric Composition --- */
.geometric-composition {
    position: relative;
    width: 100%;
    height: 200px;
    margin-bottom: 16px;
}

.geo-shape {
    position: absolute;
}

.geo-rect-1 {
    width: 60%;
    height: 60%;
    top: 10%;
    left: 5%;
    background: linear-gradient(135deg, var(--blush-corruption), var(--rose-quartz));
    transform: rotate(2deg);
    opacity: 0.7;
}

.geo-rect-2 {
    width: 50%;
    height: 50%;
    top: 25%;
    left: 30%;
    background: linear-gradient(225deg, var(--mint-fragment), var(--alabaster-milk));
    transform: rotate(-1deg);
    opacity: 0.6;
}

.geo-triangle {
    width: 0;
    height: 0;
    border-left: 60px solid transparent;
    border-right: 60px solid transparent;
    border-bottom: 100px solid var(--veined-marble);
    opacity: 0.2;
    top: 15%;
    right: 10%;
}

/* --- Color Swatches --- */
.color-swatches {
    display: flex;
    gap: 16px;
    margin-top: 24px;
}

.swatch {
    width: 120px;
    height: 80px;
    border-radius: 4px;
    display: flex;
    align-items: flex-end;
    padding: 8px;
}

.swatch span {
    font-family: 'Recursive', monospace;
    font-size: 0.75rem;
    font-variation-settings: 'MONO' 1;
    color: var(--twilight-marble);
    opacity: 0.8;
}

.swatch-blush {
    background-color: var(--blush-corruption);
}

.swatch-mint {
    background-color: var(--mint-fragment);
}

/* --- Glitch Word --- */
.glitch-word {
    position: relative;
    display: inline-block;
    color: var(--pastel-terracotta);
    cursor: default;
}

.glitch-word:hover::before,
.glitch-word:hover::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
}

.glitch-word:hover::before {
    color: var(--blush-corruption);
    transform: translate(-2px, -2px);
    opacity: 0.7;
}

.glitch-word:hover::after {
    color: var(--mint-fragment);
    transform: translate(2px, 2px);
    opacity: 0.7;
}

/* --- Links --- */
a {
    color: var(--pastel-terracotta);
    text-decoration: none;
    position: relative;
    display: inline-block;
}

a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 1px;
    background-color: var(--pastel-terracotta);
    transition: width 300ms ease;
}

a:hover::after {
    width: 100%;
}

/* --- Marble Link (footer) --- */
.marble-link {
    color: var(--dusk-plum);
    font-family: 'Nunito', sans-serif;
    position: relative;
}

.marble-link:hover {
    animation: link-glitch 200ms step-end;
}

.marble-link::before,
.marble-link::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    pointer-events: none;
}

.marble-link:hover::before {
    color: var(--blush-corruption);
    transform: translate(-2px, -1px);
    opacity: 0.6;
    animation: none;
}

.marble-link:hover::after {
    color: var(--mint-fragment);
    transform: translate(2px, 1px);
    opacity: 0.6;
}

@keyframes link-glitch {
    0% { transform: translate(0); }
    25% { transform: translate(2px, 1px); }
    50% { transform: translate(-1px, -1px); }
    75% { transform: translate(1px, 0); }
    100% { transform: translate(0); }
}

/* --- Footer --- */
#footer {
    min-height: 30vh;
    align-items: center;
    justify-items: center;
    padding-bottom: 120px;
}

.footer-content {
    grid-column: 1 / -1;
    text-align: center;
}

.footer-text {
    margin-top: 40px;
    font-size: clamp(1rem, 1.2vw, 1.25rem);
}

/* --- Hover micro-glitch for interactive elements --- */
.marble-swatch:hover,
.swatch:hover {
    transform: translate(2px, 1px);
    transition: transform 150ms step-end;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .grid-section {
        gap: 16px;
        padding: 0 16px;
    }

    #hero-logotype {
        grid-column: 1 / 7;
    }

    #hero-composition {
        grid-column: 5 / 13;
        height: 50vh;
    }

    .manifesto-text {
        grid-column: 1 / -1;
    }

    .left-vignette {
        grid-column: 1 / 8;
    }

    .disruption .right-vignette {
        grid-column: 5 / -1;
    }

    .disruption .ghost-afterimage {
        grid-column: 1 / 5;
    }
}

@media (max-width: 480px) {
    #hero-logotype {
        grid-column: 1 / -1;
    }

    #hero-composition {
        grid-column: 1 / -1;
        height: 40vh;
    }

    .left-vignette,
    .disruption .right-vignette {
        grid-column: 1 / -1;
    }

    .disruption .ghost-afterimage {
        display: none;
    }
}
