/* ==========================================================================
   monopole.systems
   Aesthetic: street-style + zen-contemplative
   Layout:    F-pattern (visible architectural element)
   Typography: serif-revival (Playfair Display, Cormorant Garamond, Lora, Cormorant)
   Palette:   deep-burgundy core with marble neutrals
   ========================================================================== */

:root {
    /* Palette */
    --oxblood:        #4A1528;
    --burgundy:       #6B1D3A;
    --mauve:          #8C3A5E;
    --gold:           #B8934A;
    --carrara:        #F5EDE3;
    --warm-stone:     #D4C5BA;
    --walnut:         #3D2B33;
    --vein-blue:      #7A8B91;
    --taupe:          #8C7B6E;

    /* Driven by JS scroll observer (0.0 .. 1.0) */
    --room-progress: 0;

    /* Layered material colors derived from progress */
    --stone-bg:    color-mix(in oklab, var(--carrara) calc((1 - var(--room-progress)) * 100%), var(--walnut));
    --stone-text:  color-mix(in oklab, var(--walnut)  calc((1 - var(--room-progress)) * 100%), var(--carrara));
    --vein-tint:   color-mix(in oklab, var(--oxblood) calc((1 - var(--room-progress)) * 100%), var(--gold));

    /* Type rhythm */
    --baseline: 32px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--carrara);
    color: var(--walnut);
    font-family: "Lora", Georgia, serif;
    font-weight: 400;
    font-size: 18px;
    line-height: 1.72;
    overflow-x: hidden;
}

body {
    min-height: 100vh;
    background-color: var(--stone-bg);
    transition: background-color 1200ms ease;
}

/* --- Marble Layer Stack ------------------------------------------------- */

.marble-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    will-change: transform, opacity;
}

/* Base stone: layered radial / linear marble veining drawn in CSS */
.marble-base {
    background-color: var(--carrara);
    background-image:
        radial-gradient(ellipse 60% 28% at 18% 22%, rgba(122, 139, 145, 0.10), transparent 60%),
        radial-gradient(ellipse 40% 22% at 78% 38%, rgba(122, 139, 145, 0.08), transparent 60%),
        radial-gradient(ellipse 55% 25% at 32% 72%, rgba(140, 123, 110, 0.10), transparent 60%),
        radial-gradient(ellipse 35% 18% at 88% 84%, rgba(122, 139, 145, 0.07), transparent 60%),
        linear-gradient(115deg, transparent 0%, rgba(122, 139, 145, 0.04) 22%, transparent 45%, rgba(140, 123, 110, 0.05) 70%, transparent 92%);
    opacity: 0.85;
    transition: filter 900ms ease, background-color 900ms ease;
    filter: hue-rotate(0deg) saturate(1) brightness(1);
}

/* As we descend, stone darkens toward black */
body.deep .marble-base {
    background-color: #1d1418;
    filter: brightness(0.6) saturate(0.9);
}

/* Vein overlay: burgundy veining painted as SVG-like CSS gradients */
.marble-vein {
    background-image:
        radial-gradient(ellipse 80% 6% at 22% 30%, rgba(74, 21, 40, 0.18), transparent 70%),
        radial-gradient(ellipse 70% 4% at 60% 55%, rgba(74, 21, 40, 0.14), transparent 70%),
        radial-gradient(ellipse 90% 3% at 40% 78%, rgba(74, 21, 40, 0.12), transparent 70%),
        linear-gradient(78deg, transparent 0%, rgba(74, 21, 40, 0.06) 24%, transparent 26%, transparent 60%, rgba(74, 21, 40, 0.08) 62%, transparent 64%);
    mix-blend-mode: multiply;
    opacity: 0.75;
    transform: translateY(0);
    transition: opacity 900ms ease, filter 900ms ease;
}

body.deep .marble-vein {
    background-image:
        radial-gradient(ellipse 80% 6% at 22% 30%, rgba(184, 147, 74, 0.30), transparent 70%),
        radial-gradient(ellipse 70% 4% at 60% 55%, rgba(184, 147, 74, 0.22), transparent 70%),
        radial-gradient(ellipse 90% 3% at 40% 78%, rgba(184, 147, 74, 0.18), transparent 70%),
        linear-gradient(78deg, transparent 0%, rgba(184, 147, 74, 0.10) 24%, transparent 26%, transparent 60%, rgba(184, 147, 74, 0.12) 62%, transparent 64%);
    mix-blend-mode: screen;
    opacity: 0.85;
}

/* Grain: noise tile rendered via CSS conic-gradient + tiny pattern */
.marble-grain {
    background-image:
        repeating-radial-gradient(circle at 13% 17%, rgba(61, 43, 51, 0.18) 0 0.5px, transparent 0.5px 2px),
        repeating-radial-gradient(circle at 71% 63%, rgba(61, 43, 51, 0.16) 0 0.5px, transparent 0.5px 2.4px),
        repeating-radial-gradient(circle at 38% 88%, rgba(61, 43, 51, 0.14) 0 0.5px, transparent 0.5px 2.8px);
    background-size: 64px 64px, 56px 56px, 72px 72px;
    mix-blend-mode: overlay;
    opacity: 0.03;
    transition: opacity 700ms ease;
}

body.aged .marble-grain { opacity: 0.08; }
body.deep .marble-grain { opacity: 0.10; }

/* Vignette: subtle radial darkening at viewport edges */
.vignette {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    background: radial-gradient(ellipse 80% 80% at center, transparent 55%, rgba(74, 21, 40, 0.25) 100%);
    transition: opacity 900ms ease;
}

/* Light leak: thin amber band drifting slowly */
.light-leak {
    position: fixed;
    left: -10%;
    right: -10%;
    top: 35%;
    height: 80px;
    pointer-events: none;
    z-index: 1;
    background: linear-gradient(180deg, transparent 0%, rgba(184, 147, 74, 0.10) 35%, rgba(184, 147, 74, 0.08) 50%, rgba(184, 147, 74, 0.04) 65%, transparent 100%);
    mix-blend-mode: screen;
    filter: blur(8px);
    animation: lightLeakDrift 20s linear infinite;
}

@keyframes lightLeakDrift {
    0%   { transform: translateY(-30vh) rotate(-2deg); opacity: 0; }
    20%  { opacity: 0.7; }
    50%  { transform: translateY(20vh) rotate(0deg); opacity: 0.9; }
    80%  { opacity: 0.6; }
    100% { transform: translateY(70vh) rotate(2deg); opacity: 0; }
}

/* --- Persistent left rule (the breathing F-stem) ------------------------ */

.rule {
    position: fixed;
    top: 0;
    bottom: 0;
    left: clamp(36px, 7vw, 86px);
    width: 3px;
    background: var(--burgundy);
    opacity: 0.5;
    z-index: 5;
    pointer-events: none;
    transform-origin: top;
    animation: ruleBreath 6s ease-in-out infinite;
}

body.urgent .rule { animation-duration: 2s; }

@keyframes ruleBreath {
    0%, 100% { opacity: 0.3; }
    50%      { opacity: 0.7; }
}

.rule .notch {
    position: absolute;
    left: -6px;
    width: 15px;
    height: 1px;
    background: var(--gold);
    opacity: 0.65;
}
.rule .notch[data-section="1"] { top: 15%; }
.rule .notch[data-section="2"] { top: 30%; }
.rule .notch[data-section="3"] { top: 45%; }
.rule .notch[data-section="4"] { top: 60%; }
.rule .notch[data-section="5"] { top: 75%; }
.rule .notch[data-section="6"] { top: 90%; }

/* Initial entrance rule that draws downward on page load */
.entrance-rule {
    position: absolute;
    left: clamp(36px, 7vw, 86px);
    top: 38%;
    width: 3px;
    height: 0;
    background: var(--burgundy);
    z-index: 4;
    transition: height 800ms cubic-bezier(0.65, 0, 0.35, 1);
}

body.entrance-drawn .entrance-rule { height: 56vh; }

/* Hide global rule until entrance has been drawn */
.rule { opacity: 0; transition: opacity 600ms ease 100ms; }
body.entrance-drawn .rule { opacity: 0.5; }

/* --- Scroll lock overlay ------------------------------------------------ */

.scroll-lock {
    position: fixed;
    inset: 0;
    z-index: 10;
    pointer-events: auto;
    background: transparent;
}
body.unlocked .scroll-lock { display: none; }

body:not(.unlocked) {
    overflow: hidden;
    height: 100vh;
}

/* --- Main rooms layout -------------------------------------------------- */

main#rooms {
    position: relative;
    z-index: 2;
}

.room {
    position: relative;
    min-height: 100vh;
    width: 100%;
    padding: 0 clamp(36px, 8vw, 120px) 0 clamp(72px, 12vw, 168px);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    overflow: hidden;
}

/* --- Room 1: Entrance Vestibule ----------------------------------------- */

.room-1 {
    justify-content: center;
    align-items: flex-start;
    padding-top: 0;
}

.room-1-inner {
    width: 100%;
    max-width: 1200px;
    position: relative;
}

.entrance-title {
    font-family: "Playfair Display", Georgia, serif;
    font-weight: 900;
    font-size: clamp(48px, 9vw, 120px);
    color: var(--burgundy);
    letter-spacing: -0.04em;
    line-height: 1;
    margin: 0 0 24px;
    text-shadow: 1px 1px 0 rgba(245, 237, 227, 0.55), -1px -1px 0 rgba(74, 21, 40, 0.18);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 1500ms ease-out 1200ms, transform 1500ms ease-out 1200ms;
}
body.entrance-drawn .entrance-title { opacity: 1; transform: translateY(0); }

.entrance-sub {
    font-family: "Cormorant", Georgia, serif;
    font-weight: 300;
    font-size: 14px;
    letter-spacing: 0.18em;
    color: var(--taupe);
    text-transform: uppercase;
    margin: 0;
    display: flex;
    gap: 14px;
    align-items: center;
    opacity: 0;
    transition: opacity 1200ms ease 2200ms;
}
body.entrance-drawn .entrance-sub { opacity: 1; }

.caption-mark { color: var(--gold); }

/* --- F-Pattern bars ----------------------------------------------------- */

.f-bar {
    position: relative;
    width: 100%;
}

.f-bar-top {
    height: 15vh;
    min-height: 120px;
    display: flex;
    align-items: center;
    gap: clamp(24px, 4vw, 60px);
    padding: 24px 0;
    border-top: 1px solid rgba(74, 21, 40, 0.30);
    border-bottom: 1px solid rgba(74, 21, 40, 0.18);
}

.bar-marble {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(95deg,
            rgba(245, 237, 227, 0.65) 0%,
            rgba(212, 197, 186, 0.45) 30%,
            rgba(245, 237, 227, 0.55) 55%,
            rgba(212, 197, 186, 0.40) 80%,
            rgba(245, 237, 227, 0.55) 100%),
        radial-gradient(ellipse 60% 100% at 18% 50%, rgba(122, 139, 145, 0.10), transparent 70%);
    z-index: -1;
    border-bottom: 1px solid rgba(74, 21, 40, 0.10);
}

body.deep .bar-marble {
    background:
        linear-gradient(95deg,
            rgba(29, 20, 24, 0.85) 0%,
            rgba(45, 30, 36, 0.70) 30%,
            rgba(29, 20, 24, 0.85) 55%,
            rgba(184, 147, 74, 0.18) 80%,
            rgba(29, 20, 24, 0.85) 100%);
}

.room-title {
    font-family: "Playfair Display", Georgia, serif;
    font-weight: 900;
    font-size: clamp(40px, 6.5vw, 88px);
    letter-spacing: -0.04em;
    color: var(--burgundy);
    line-height: 1;
    margin: 0;
    text-shadow: 1px 1px 0 rgba(245, 237, 227, 0.55), -1px -1px 0 rgba(74, 21, 40, 0.20);
    flex: 0 1 auto;
}

body.deep .room-title { color: var(--carrara); text-shadow: 1px 1px 0 rgba(29, 20, 24, 0.7), -1px -1px 0 rgba(184, 147, 74, 0.35); }

.bar-meta {
    font-family: "Cormorant", Georgia, serif;
    font-weight: 300;
    font-size: 13px;
    letter-spacing: 0.14em;
    color: var(--taupe);
    text-transform: uppercase;
    margin-left: auto;
    margin-right: 8px;
    flex: 0 0 auto;
    text-align: right;
    max-width: 32%;
}

body.deep .bar-meta { color: var(--warm-stone); }

/* Wax seal at bar terminus */
.wax-seal {
    position: relative;
    display: inline-flex;
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    cursor: pointer;
    border-radius: 50%;
    transition: box-shadow 600ms ease, transform 400ms ease;
    outline: none;
}
.wax-seal svg { width: 48px; height: 48px; display: block; }
.wax-seal:hover, .wax-seal:focus { box-shadow: 0 0 12px 2px rgba(184, 147, 74, 0.30); }
.wax-seal.broken svg .seal-circle { display: none; }
.wax-seal.broken svg .seal-mark   { display: none; }

.seal-secret {
    position: absolute;
    top: 56px;
    right: 0;
    font-family: "Cormorant Garamond", Georgia, serif;
    font-style: italic;
    font-size: 14px;
    color: var(--burgundy);
    letter-spacing: 0.04em;
    width: 280px;
    text-align: right;
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 500ms ease, transform 500ms ease;
    pointer-events: none;
    line-height: 1.4;
}
.wax-seal.broken .seal-secret { opacity: 1; transform: translateY(0); }
body.deep .seal-secret { color: var(--gold); }

/* Fragments shown when seal breaks (rendered by JS) */
.seal-fragment {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    pointer-events: none;
    transition: transform 400ms cubic-bezier(0.22, 0.8, 0.36, 1), opacity 600ms ease 200ms;
    opacity: 1;
}
.seal-fragment.gone { opacity: 0; }

/* F-pattern middle bar (content block) */
.f-bar-mid {
    margin-top: clamp(36px, 8vh, 96px);
    display: flex;
    gap: 0;
    align-items: stretch;
    width: 100%;
}

.content-block {
    flex: 0 0 65%;
    max-width: 65%;
    padding-right: clamp(24px, 4vw, 60px);
    padding-top: 8px;
    padding-bottom: 8px;
}

.breathing-margin {
    flex: 0 0 23%;
    max-width: 23%;
    margin-left: auto;
    background:
        radial-gradient(ellipse 85% 4% at 30% 25%, rgba(74, 21, 40, 0.04), transparent 70%),
        radial-gradient(ellipse 90% 3% at 60% 70%, rgba(74, 21, 40, 0.03), transparent 70%),
        linear-gradient(94deg, transparent 0%, rgba(74, 21, 40, 0.02) 50%, transparent 100%);
    border-left: 1px solid rgba(74, 21, 40, 0.10);
    margin-top: 16px;
}

/* Section sub-heading (Cormorant Garamond) */
.room-sub {
    font-family: "Cormorant Garamond", Georgia, serif;
    font-weight: 600;
    font-size: clamp(24px, 3vw, 40px);
    color: var(--mauve);
    letter-spacing: 0.02em;
    line-height: 1.18;
    margin: 0 0 24px;
}
body.deep .room-sub { color: var(--gold); }

/* Body text */
.room-body {
    font-family: "Lora", Georgia, serif;
    font-weight: 400;
    font-size: 18px;
    line-height: 1.72;
    color: var(--walnut);
    margin: 0 0 24px;
    max-width: 62ch;
}
body.deep .room-body { color: var(--warm-stone); }

/* Meta line */
.room-meta {
    font-family: "Cormorant", Georgia, serif;
    font-weight: 300;
    font-size: 13px;
    letter-spacing: 0.12em;
    color: var(--taupe);
    text-transform: uppercase;
    margin: 16px 0 0;
    display: flex;
    align-items: center;
    gap: 12px;
}
.room-meta em { font-style: italic; color: var(--mauve); letter-spacing: 0.04em; text-transform: none; }
.room-meta.dark { color: var(--warm-stone); }
.meta-rule { width: 36px; height: 1px; background: var(--burgundy); display: inline-block; }
.meta-rule.gold { background: var(--gold); }

.addr {
    font-family: "Cormorant Garamond", Georgia, serif;
    font-style: italic;
    color: var(--gold);
    letter-spacing: 0.06em;
    text-transform: none;
}

/* Lists */
.room-list {
    list-style: none;
    padding: 0;
    margin: 24px 0 0;
    border-top: 1px solid rgba(74, 21, 40, 0.20);
}
.room-list li {
    font-family: "Lora", Georgia, serif;
    font-size: 17px;
    color: var(--walnut);
    padding: 14px 0;
    border-bottom: 1px solid rgba(74, 21, 40, 0.10);
    display: flex;
    gap: 14px;
}
body.deep .room-list li { color: var(--warm-stone); border-bottom-color: rgba(184, 147, 74, 0.20); }
.list-dot { color: var(--gold); flex: 0 0 12px; }

/* Pull quote */
.pull-quote {
    font-family: "Cormorant Garamond", Georgia, serif;
    font-weight: 500;
    font-style: italic;
    font-size: clamp(22px, 2.4vw, 30px);
    color: var(--mauve);
    line-height: 1.4;
    margin: 28px 0 0;
    padding: 16px 0 16px 24px;
    border-left: 2px solid var(--gold);
    max-width: 56ch;
}
.pull-quote cite {
    display: block;
    margin-top: 12px;
    font-family: "Cormorant", Georgia, serif;
    font-style: normal;
    font-size: 13px;
    letter-spacing: 0.14em;
    color: var(--taupe);
    text-transform: uppercase;
}

/* Floor depth marker */
.room-floor {
    margin-top: auto;
    padding: 16px 0 24px;
    display: flex;
    justify-content: flex-end;
}
.depth-mark {
    font-family: "Cormorant", Georgia, serif;
    font-weight: 300;
    font-size: 12px;
    letter-spacing: 0.18em;
    color: var(--taupe);
    text-transform: uppercase;
}
.depth-mark.dark { color: var(--warm-stone); }

/* Section dividers */
.section-divider {
    position: relative;
    height: 80px;
    width: 100%;
    z-index: 2;
    pointer-events: none;
    overflow: visible;
}
.section-divider .fracture {
    position: absolute;
    left: clamp(72px, 12vw, 168px);
    top: 0;
    width: 60%;
    height: 80px;
}

/* --- Room 6: Exit Meditation ------------------------------------------- */

.room-6 {
    padding-left: 0 !important;
    padding-right: 0 !important;
    text-align: center;
    align-items: center;
    justify-content: center;
}

.exit-inner {
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    padding: 80px 32px;
    text-align: center;
    transform: translateX(0);
    transition: transform 800ms ease;
}

.exit-mark {
    display: inline-flex;
    width: 120px;
    height: 120px;
    cursor: pointer;
    margin: 0 auto 28px;
    transition: transform 800ms ease, filter 800ms ease;
    outline: none;
}
.exit-mark svg { width: 120px; height: 120px; display: block; }
.exit-mark:hover { filter: drop-shadow(0 0 12px rgba(184, 147, 74, 0.5)); }

.exit-stroke {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 1600ms ease;
}
.room-6.in-view .exit-stroke { stroke-dashoffset: 0; }

.exit-line {
    font-family: "Playfair Display", Georgia, serif;
    font-weight: 700;
    font-style: italic;
    font-size: clamp(22px, 3vw, 36px);
    color: var(--carrara);
    letter-spacing: 0.02em;
    margin: 0 0 24px;
    line-height: 1.4;
}

.exit-meta {
    font-family: "Cormorant", Georgia, serif;
    font-weight: 300;
    font-size: 12px;
    letter-spacing: 0.20em;
    color: var(--gold);
    text-transform: lowercase;
    margin: 0;
}

/* --- Reveal animations -------------------------------------------------- */

.reveal-text {
    display: inline-block;
    overflow: visible;
}
.reveal-text .letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(12px) rotate(8deg);
    transition: opacity 600ms ease, transform 600ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.reveal-text .letter.shown { opacity: 1; transform: translateY(0) rotate(0); }
.reveal-text .letter.space { width: 0.28em; }

/* Stagger reveal for content blocks */
.content-block .room-sub,
.content-block .room-body,
.content-block .room-meta,
.content-block .room-list,
.content-block .pull-quote {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 900ms ease, transform 900ms ease;
}
.room.in-view .content-block .room-sub  { transition-delay: 100ms; opacity: 1; transform: translateY(0); }
.room.in-view .content-block .room-body { transition-delay: 300ms; opacity: 1; transform: translateY(0); }
.room.in-view .content-block .room-list { transition-delay: 500ms; opacity: 1; transform: translateY(0); }
.room.in-view .content-block .pull-quote{ transition-delay: 500ms; opacity: 1; transform: translateY(0); }
.room.in-view .content-block .room-meta { transition-delay: 700ms; opacity: 1; transform: translateY(0); }

/* Bar-meta and seal slow reveal */
.f-bar-top .bar-meta,
.f-bar-top .wax-seal {
    opacity: 0;
    transform: translateX(8px);
    transition: opacity 800ms ease, transform 800ms ease;
}
.room.in-view .f-bar-top .bar-meta { transition-delay: 200ms; opacity: 1; transform: translateX(0); }
.room.in-view .f-bar-top .wax-seal { transition-delay: 400ms; opacity: 1; transform: translateX(0); }

/* --- Shake error -------------------------------------------------------- */

.shake {
    animation: shakeError 300ms cubic-bezier(0.36, 0.07, 0.19, 0.97);
}
@keyframes shakeError {
    0%, 100% { transform: translateX(0); }
    20%      { transform: translateX(-3px); }
    40%      { transform: translateX(3px); }
    60%      { transform: translateX(-2px); }
    80%      { transform: translateX(2px); }
}

.shake-flash {
    position: relative;
}
.shake-flash::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(184, 147, 74, 0.15);
    pointer-events: none;
    animation: flashGold 300ms ease;
}
@keyframes flashGold {
    0%   { opacity: 0; }
    50%  { opacity: 1; }
    100% { opacity: 0; }
}

/* --- Responsive --------------------------------------------------------- */

@media (max-width: 760px) {
    body { font-size: 16px; }
    .room { padding: 0 24px 0 60px; }
    .rule { left: 24px; }
    .entrance-rule { left: 24px; }
    .section-divider .fracture { left: 60px; }
    .f-bar-top { flex-wrap: wrap; height: auto; gap: 12px; padding: 18px 0; }
    .room-title { font-size: clamp(34px, 9vw, 56px); }
    .bar-meta { max-width: 100%; margin-left: 0; text-align: left; }
    .f-bar-mid { flex-direction: column; }
    .content-block { flex: 1 1 100%; max-width: 100%; padding-right: 0; }
    .breathing-margin { display: none; }
    .room-sub { font-size: clamp(20px, 5vw, 28px); }
    .room-body { font-size: 16px; max-width: 100%; }
    .pull-quote { font-size: 19px; }
    .exit-line { font-size: 22px; }
    .exit-mark, .exit-mark svg { width: 88px; height: 88px; }
}

/* Reduce motion: still readable, less drama */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
    .reveal-text .letter { opacity: 1; transform: none; }
    .light-leak { display: none; }
}
