/* ============================================================
   archetype.works — five halls, full-bleed temple frieze
   Travertine cream + saffron gold + corinthian terracotta
   bright-optimistic glitch art on Mediterranean noon palette
   ============================================================ */

:root {
    --travertine: #F6EED4;
    --parchment:  #E8D9A8;
    --sun-gold:   #E8A04A;
    --terracotta: #D96E3A;
    --sienna:     #B24A2C;
    --umbra:      #3A2E1E;
    --iris:       #4F6D8C;

    --glitch-intensity: 0;

    --font-display: "Bebas Neue", Impact, "Arial Narrow", sans-serif;
    --font-sub:     "Oswald", "Arial Narrow", sans-serif;
    --font-body:    "Cormorant Garamond", "EB Garamond", Garamond, serif;
    --font-mono:    "JetBrains Mono", ui-monospace, "Courier New", monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    width: 100%;
    overflow-x: hidden;
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--travertine);
    color: var(--umbra);
    font-family: var(--font-body);
    font-size: 1.125rem;
    line-height: 1.55;
    cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 18 18'><line x1='9' y1='2' x2='9' y2='16' stroke='%23E8A04A' stroke-width='2'/><line x1='2' y1='9' x2='16' y2='9' stroke='%23E8A04A' stroke-width='2'/></svg>") 9 9, crosshair;
    position: relative;
    min-height: 100vh;
}

.svg-defs { position: absolute; width: 0; height: 0; }

/* ------------------------------------------------------------
   Grain scrim — the heartbeat of the aesthetic
   ------------------------------------------------------------ */
.grain-scrim {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 5;
    opacity: 0.22;
    mix-blend-mode: multiply;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='256' height='256'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.227   0 0 0 0 0.180   0 0 0 0 0.117   0 0 0 0.6 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
    background-size: 256px 256px;
    background-repeat: repeat;
}

.breath-layer {
    position: fixed;
    inset: -10%;
    pointer-events: none;
    z-index: 3;
    opacity: 0.08;
    filter: blur(120px);
    background: conic-gradient(
        from 0deg,
        var(--sun-gold) 0deg,
        var(--terracotta) 120deg,
        var(--sun-gold) 240deg,
        var(--terracotta) 360deg
    );
    animation: breathRotate 720s linear infinite;
}

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

/* ------------------------------------------------------------
   Architrave — fixed hairline rules at 8.5% / 91.5%
   ------------------------------------------------------------ */
.architrave {
    position: fixed;
    left: 0;
    width: 100vw;
    height: 1px;
    background: var(--umbra);
    opacity: 0.35;
    pointer-events: none;
    z-index: 50;
}
.architrave--top    { top: 8.5vh; }
.architrave--bottom { top: 91.5vh; }

/* ------------------------------------------------------------
   Vertical spine of Roman numerals
   ------------------------------------------------------------ */
.spine {
    position: fixed;
    top: 50%;
    left: 2vw;
    transform: translateY(-50%);
    z-index: 60;
    display: flex;
    flex-direction: column;
    gap: 1.4rem;
    align-items: center;
}

.spine-numeral {
    font-family: var(--font-mono);
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--umbra);
    opacity: 0.06;
    text-decoration: none;
    letter-spacing: 0.08em;
    transition: opacity 0.4s ease, color 0.4s ease, transform 0.4s ease;
    padding: 4px 6px;
    line-height: 1;
}

.spine-numeral.active {
    color: var(--sun-gold);
    opacity: 1;
    transform: scale(1.35);
    text-shadow:
        2px 0 0 var(--terracotta),
        -2px 0 0 var(--iris);
}

.spine-numeral:hover {
    opacity: 0.85;
    color: var(--terracotta);
}

/* ------------------------------------------------------------
   Speaker
   ------------------------------------------------------------ */
.speaker {
    position: fixed;
    bottom: 32px;
    right: 28px;
    z-index: 60;
    width: 34px;
    height: 34px;
    border: 1px solid var(--umbra);
    background: transparent;
    color: var(--umbra);
    cursor: inherit;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}
.speaker:hover {
    background: var(--sun-gold);
    color: var(--umbra);
    border-color: var(--sun-gold);
}
.speaker .wave { opacity: 0.5; }
.speaker.on { background: var(--sun-gold); border-color: var(--sun-gold); }
.speaker.on .wave { opacity: 1; }

/* ------------------------------------------------------------
   Reel (main scroll container)
   ------------------------------------------------------------ */
.reel {
    width: 100vw;
    margin-left: calc(50% - 50vw);
    scroll-snap-type: y proximity;
    position: relative;
    z-index: 10;
}

/* ------------------------------------------------------------
   HALL — full viewport temple frieze
   ------------------------------------------------------------ */
.hall {
    position: relative;
    width: 100vw;
    margin-left: calc(50% - 50vw);
    min-height: 100vh;
    padding: 12vh 4vw 10vh 8vw;
    scroll-snap-align: start;
    scroll-snap-stop: normal;
    display: grid;
    grid-template-rows: auto 1fr auto auto;
    overflow: hidden;
    background: var(--travertine);
}

.hall-i   { background: var(--travertine); }
.hall-ii  { background: linear-gradient(180deg, var(--travertine) 0%, #F8F0D8 100%); }
.hall-iii { background: var(--travertine); }
.hall-iv  { background: linear-gradient(180deg, #F8F1DC 0%, var(--travertine) 100%); }
.hall-v   { background: var(--travertine); }

/* ambient Greek watermark */
.ambient-greek {
    position: absolute;
    top: 50%;
    right: -2vw;
    transform: translateY(-50%);
    font-family: var(--font-display);
    font-size: clamp(8rem, 22vw, 22rem);
    color: var(--parchment);
    letter-spacing: 0.12em;
    line-height: 1;
    pointer-events: none;
    z-index: 1;
    opacity: 0.55;
    user-select: none;
    white-space: nowrap;
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.hall.glitching .ambient-greek {
    text-shadow:
        4px 0 0 var(--sun-gold),
        -4px 0 0 var(--iris),
        2px 0 0 var(--terracotta);
}

/* hall meta */
.hall-meta {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--umbra);
    z-index: 4;
    position: relative;
}
.numeral-mono {
    font-weight: 500;
    color: var(--sun-gold);
}
.archetype-label {
    font-family: var(--font-sub);
    font-weight: 500;
    font-size: 0.95rem;
    letter-spacing: 0.18em;
    color: var(--sienna);
}

/* hall title — Bebas Neue at clamp(4rem, 14vw, 13rem) */
.hall-title {
    font-family: var(--font-display);
    font-size: clamp(4rem, 14vw, 13rem);
    line-height: 0.85;
    letter-spacing: 0.04em;
    color: var(--umbra);
    margin-top: 0.25em;
    text-transform: uppercase;
    white-space: nowrap;
    position: relative;
    z-index: 4;
    /* deliberate clip beyond the viewport edge */
    width: 110vw;
    margin-left: -8vw;
    padding-left: 8vw;
    pointer-events: none;
}

.hall-title::before,
.hall-title::after {
    content: attr(data-text);
    position: absolute;
    inset: 0;
    padding-left: 8vw;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.hall-title::before {
    color: var(--sun-gold);
    transform: translate(3px, 1px);
    mix-blend-mode: multiply;
}
.hall-title::after {
    color: var(--iris);
    transform: translate(-2px, -1px);
    mix-blend-mode: multiply;
}
.hall.glitching .hall-title::before,
.hall.glitching .hall-title::after {
    opacity: 0.85;
}

/* frieze — the horizontal middle band */
.frieze {
    display: grid;
    grid-template-columns: minmax(280px, 38vw) 1fr;
    align-items: center;
    gap: clamp(2rem, 6vw, 8rem);
    margin-top: 2vh;
    padding: 4vh 0;
    position: relative;
    z-index: 4;
}

.marble-fragment {
    position: relative;
    width: 100%;
    max-width: 38vw;
    aspect-ratio: 4 / 5;
    transition:
        transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1.1),
        filter 0.28s ease;
    filter: drop-shadow(calc(var(--glitch-intensity) * 1px) 0 0 var(--sun-gold))
            drop-shadow(calc(var(--glitch-intensity) * -1px) calc(var(--glitch-intensity) * -0.5px) 0 var(--iris));
    will-change: transform, filter;
    cursor: inherit;
}

.marble-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.marble-fragment::before {
    content: "";
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='m'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.7   0 0 0 0 0.55   0 0 0 0 0.35   0 0 0 0.5 0'/></filter><rect width='100%25' height='100%25' filter='url(%23m)'/></svg>");
    mix-blend-mode: multiply;
    opacity: 0.18;
    pointer-events: none;
    z-index: 2;
}

.marble-fragment:hover {
    transform: scale(1.08);
    filter:
        drop-shadow(5px 1px 0 var(--sun-gold))
        drop-shadow(-3px -1px 0 var(--iris))
        drop-shadow(2px 0 0 var(--terracotta));
}

.marble-fragment.tearing {
    animation: tear 0.52s steps(6, end);
}

@keyframes tear {
    0%   { clip-path: inset(0 0 0 0); transform: scale(1.08) translateX(0); }
    18%  { clip-path: polygon(0 0,100% 0,100% 30%, 0 30%, 0 38%, 100% 38%, 100% 100%, 0 100%); transform: scale(1.08) translateX(20px); }
    36%  { clip-path: polygon(0 0,100% 0,100% 55%, 0 55%, 0 65%, 100% 65%, 100% 100%, 0 100%); transform: scale(1.08) translateX(-12px); }
    52%  { transform: scale(1.10) translateX(8px); }
    72%  { transform: scale(1.08) translateX(-4px); }
    100% { clip-path: inset(0 0 0 0); transform: scale(1.08) translateX(0); }
}

/* hall body copy */
.hall-body {
    font-family: var(--font-body);
    font-size: clamp(1.05rem, 1.35vw, 1.45rem);
    line-height: 1.55;
    color: var(--umbra);
    max-width: 70ch;
    font-weight: 400;
}
.hall-body em {
    font-style: italic;
    color: var(--sienna);
    font-weight: 500;
}

/* hall foot — caption + counter */
.hall-foot {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-family: var(--font-sub);
    font-size: 0.85rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--sienna);
    margin-top: 3vh;
    z-index: 4;
    position: relative;
    padding-right: 2vw;
}
.counter {
    font-family: var(--font-mono);
    color: var(--umbra);
    opacity: 0.65;
}

.doric-rule {
    color: var(--umbra);
    margin-top: 2vh;
    opacity: 0.55;
    width: 100%;
    z-index: 4;
    position: relative;
}

/* ------------------------------------------------------------
   Transition slabs (20vh)
   ------------------------------------------------------------ */
.slab {
    width: 100vw;
    margin-left: calc(50% - 50vw);
    height: 22vh;
    background: var(--parchment);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0 8vw;
    position: relative;
    z-index: 9;
    border-top: 1px solid rgba(58, 46, 30, 0.18);
    border-bottom: 1px solid rgba(58, 46, 30, 0.18);
    overflow: hidden;
}

.slab::before {
    content: "";
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='256' height='256'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.6   0 0 0 0 0.45   0 0 0 0 0.25   0 0 0 0.5 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
    mix-blend-mode: multiply;
    opacity: 0.18;
    pointer-events: none;
}

.slab-quote {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    position: relative;
    z-index: 2;
}
.slab-text {
    font-family: var(--font-display);
    font-size: clamp(1.6rem, 4vw, 4.5rem);
    line-height: 0.95;
    letter-spacing: 0.04em;
    color: var(--umbra);
    text-transform: uppercase;
}
.slab-cite {
    font-family: var(--font-sub);
    font-size: 0.95rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--sienna);
    font-style: normal;
}

/* ------------------------------------------------------------
   Dedication footer
   ------------------------------------------------------------ */
.dedication {
    width: 100vw;
    margin-left: calc(50% - 50vw);
    min-height: 60vh;
    background: var(--travertine);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2.4rem;
    padding: 8vh 8vw 12vh;
    position: relative;
    z-index: 9;
    text-align: center;
}

.dedication-line {
    font-family: var(--font-body);
    font-size: clamp(1.4rem, 2.6vw, 2.6rem);
    color: var(--umbra);
    max-width: 60ch;
    font-style: italic;
}

.begin-again {
    font-family: var(--font-sub);
    font-size: clamp(1rem, 1.5vw, 1.4rem);
    letter-spacing: 0.22em;
    text-transform: lowercase;
    color: var(--sienna);
    text-decoration: none;
    border-bottom: 1px solid var(--sienna);
    padding-bottom: 4px;
    transition: color 0.3s ease, border-color 0.3s ease, letter-spacing 0.3s ease;
}
.begin-again:hover {
    color: var(--sun-gold);
    border-color: var(--sun-gold);
    letter-spacing: 0.3em;
}

.chronology {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    letter-spacing: 0.18em;
    color: var(--umbra);
    opacity: 0.5;
    text-transform: lowercase;
    margin-top: 1rem;
}

/* ------------------------------------------------------------
   Bottom meander fret — fixed 12px full-bleed footing
   ------------------------------------------------------------ */
.meander {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100vw;
    height: 12px;
    z-index: 55;
    pointer-events: none;
    opacity: 0.85;
}
.meander svg { display: block; height: 12px; }

/* ------------------------------------------------------------
   Reveal animations (IntersectionObserver-driven)
   ------------------------------------------------------------ */
.hall-title .letter {
    display: inline-block;
    transform: translateY(60px);
    opacity: 0;
    transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1.05), opacity 0.6s ease;
    will-change: transform, opacity;
}
.hall-title .letter.space {
    width: 0.35em;
}
.hall.in-view .hall-title .letter {
    transform: translateY(0);
    opacity: 1;
}
.hall.in-view .hall-title .letter.jitter {
    animation: jitterSettle 1.2s cubic-bezier(0.2, 0.8, 0.2, 1.05);
}

@keyframes jitterSettle {
    0%   { transform: translate(0, 60px); }
    25%  { transform: translate(2px, 30px); }
    50%  { transform: translate(-2px, 12px); }
    70%  { transform: translate(1px, 4px); }
    90%  { transform: translate(-1px, 1px); }
    100% { transform: translate(0, 0); }
}

.marble-fragment {
    opacity: 0;
    transform: scale(1.04);
    transition:
        transform 0.9s cubic-bezier(0.2, 0.8, 0.2, 1),
        opacity 0.9s ease,
        filter 0.28s ease;
}
.hall.in-view .marble-fragment {
    opacity: 1;
    transform: scale(1);
}

.hall-body, .hall-meta, .hall-foot, .doric-rule {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.hall.in-view .hall-body,
.hall.in-view .hall-meta,
.hall.in-view .hall-foot,
.hall.in-view .doric-rule {
    opacity: 1;
    transform: translateY(0);
}
.hall.in-view .hall-body { transition-delay: 0.6s; }
.hall.in-view .hall-foot { transition-delay: 0.8s; }
.hall.in-view .doric-rule { transition-delay: 0.9s; }

/* ambient greek glyph drop */
.ambient-greek.dropping {
    animation: greekDrop 1.4s ease-in-out;
}
@keyframes greekDrop {
    0%, 100% { opacity: 0.55; filter: none; }
    20% { opacity: 0.55; }
    25% { opacity: 0; filter: blur(6px); }
    55% { opacity: 0; filter: blur(6px); }
    65% { opacity: 0.4; filter: blur(2px); text-shadow: 5px 0 0 var(--sun-gold), -5px 0 0 var(--iris); }
    100% { opacity: 0.55; filter: none; }
}

/* ------------------------------------------------------------
   Mobile degradation (<768px)
   ------------------------------------------------------------ */
@media (max-width: 768px) {
    .spine {
        top: auto;
        bottom: 26px;
        left: 50%;
        transform: translateX(-50%);
        flex-direction: row;
        gap: 1.4rem;
        background: rgba(246, 238, 212, 0.85);
        padding: 8px 14px;
        border-radius: 0;
        z-index: 60;
    }
    .architrave--top    { top: 6vh; }
    .architrave--bottom { top: 94vh; }

    .hall {
        padding: 10vh 6vw 14vh 6vw;
        grid-template-rows: auto auto auto auto auto;
    }

    .frieze {
        grid-template-columns: 1fr;
        gap: 2rem;
        margin-top: 1vh;
    }

    .marble-fragment {
        max-width: 85vw;
        margin: 0 auto;
        filter:
            drop-shadow(calc(var(--glitch-intensity) * 0.5px) 0 0 var(--sun-gold))
            drop-shadow(calc(var(--glitch-intensity) * -0.5px) 0 0 var(--iris));
    }
    .marble-fragment:hover {
        filter:
            drop-shadow(2px 0 0 var(--sun-gold))
            drop-shadow(-2px 0 0 var(--iris));
    }

    .hall-title {
        font-size: clamp(3rem, 13vw, 6rem);
        white-space: normal;
        width: 100vw;
        margin-left: -6vw;
        padding-left: 6vw;
    }

    .ambient-greek {
        font-size: clamp(6rem, 30vw, 14rem);
        opacity: 0.35;
    }

    .speaker { bottom: 80px; right: 18px; }
}
