/* ============================================
   RRIPPL.com - Maximalist Cultural Design
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --kiln-clay: #3B2F2F;
    --dried-earth: #8B7355;
    --saffron-thread: #C4843C;
    --oxidized-copper: #5B7C65;
    --terracotta-blush: #C1666B;
    --bleached-linen: #F5EDE3;
    --sandstone-wash: #E8DFD0;
    --indigo-dye: #2C3E6B;

    --ease-entrance: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --ease-svg-draw: cubic-bezier(0.65, 0, 0.35, 1);
    --ease-hover: cubic-bezier(0.34, 1.56, 0.64, 1);

    --font-headline: 'Fraunces', serif;
    --font-body: 'Source Serif 4', serif;
    --font-accent: 'Anybody', sans-serif;
    --font-numeral: 'Cormorant Garamond', serif;
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1.05rem, 1vw + 0.7rem, 1.35rem);
    line-height: 1.8;
    color: var(--kiln-clay);
    background-color: var(--bleached-linen);
    overflow-x: hidden;
    position: relative;
}

/* --- Zellige Background Pattern --- */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.02;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Cpath d='M20 0L40 20L20 40L0 20Z' fill='none' stroke='%238B7355' stroke-width='0.5'/%3E%3C/svg%3E");
    background-repeat: repeat;
}

/* --- Ornamental Sidebar Rail --- */
#sidebar-rail {
    position: fixed;
    top: 0;
    left: 0;
    width: 120px;
    height: 100vh;
    z-index: 100;
    pointer-events: none;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 0;
}

#rail-svg {
    width: 80px;
    height: 100%;
}

#rail-path {
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* --- Typography --- */
.headline-fraunces {
    font-family: var(--font-headline);
    font-weight: 800;
    font-variation-settings: 'SOFT' 100, 'WONK' 1;
    font-size: clamp(2.5rem, 5vw + 1rem, 7rem);
    line-height: 1.1;
    color: var(--kiln-clay);
    margin-bottom: 1.5rem;
}

.body-serif {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1.05rem, 1vw + 0.7rem, 1.35rem);
    line-height: 1.8;
    color: var(--kiln-clay);
    margin-bottom: 1.5rem;
}

.body-serif em,
.body-serif strong {
    font-weight: 600;
}

.accent-anybody {
    font-family: var(--font-accent);
    font-weight: 500;
    font-variation-settings: 'wdth' 75;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-size: clamp(0.75rem, 0.8vw, 0.9rem);
    color: var(--dried-earth);
}

/* --- Zone Number (Ghost Watermarks) --- */
.zone-number {
    position: absolute;
    top: 10%;
    right: 5%;
    z-index: 1;
    pointer-events: none;
    overflow: hidden;
}

.zone-number span {
    font-family: var(--font-numeral);
    font-weight: 300;
    font-style: italic;
    font-size: clamp(8rem, 12vw, 15rem);
    color: var(--terracotta-blush);
    opacity: 0.08;
    line-height: 1;
    display: block;
}

/* --- Narrative Zones --- */
.narrative-zone {
    position: relative;
    min-height: 100vh;
    padding: 120px 60px 120px 160px;
    overflow: hidden;
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 500ms var(--ease-entrance), transform 500ms var(--ease-entrance);
    z-index: 1;
}

.narrative-zone.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.narrative-zone:nth-child(odd) {
    background-color: var(--bleached-linen);
}

.zone-alt {
    background-color: var(--sandstone-wash);
}

/* Kente pattern overlay on alt sections */
.zone-alt::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.03;
    background-image: repeating-linear-gradient(
        90deg,
        var(--dried-earth) 0px,
        var(--dried-earth) 2px,
        transparent 2px,
        transparent 6px,
        var(--dried-earth) 6px,
        var(--dried-earth) 8px,
        transparent 8px,
        transparent 16px
    );
    z-index: 0;
}

/* --- Hero Zone --- */
.zone-hero {
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at 30% 40%, var(--sandstone-wash) 0%, var(--kiln-clay) 100%);
    background-size: 200% 200%;
    animation: gradientDrift 20s linear infinite;
    opacity: 1;
    transform: none;
}

@keyframes gradientDrift {
    0% { background-position: 30% 40%; }
    50% { background-position: 70% 60%; }
    100% { background-position: 30% 40%; }
}

.hero-content {
    text-align: center;
    max-width: 900px;
    padding: 2rem;
    z-index: 2;
}

.zone-hero .headline-fraunces {
    color: var(--bleached-linen);
    font-size: clamp(3rem, 6vw + 1rem, 7rem);
    margin-bottom: 2rem;
}

.zone-hero .headline-fraunces .letter {
    display: inline-block;
    opacity: 0;
    animation: letterFadeIn 400ms var(--ease-entrance) forwards;
}

@keyframes letterFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hero-subtitle .body-serif {
    color: var(--sandstone-wash);
    font-size: clamp(1.1rem, 1.2vw + 0.5rem, 1.5rem);
    opacity: 0;
    animation: fadeInUp 800ms var(--ease-entrance) 1.5s forwards;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hero-arabesque {
    width: 100%;
    max-width: 800px;
    height: 60px;
    margin: 2rem auto 0;
    opacity: 0;
    animation: fadeIn 500ms ease 2s forwards;
}

@keyframes fadeIn {
    to { opacity: 1; }
}

.zone-hero .zone-number span {
    color: var(--sandstone-wash);
    opacity: 0.05;
}

/* --- Content Splits (Golden Section 2:3) --- */
.content-split {
    display: flex;
    align-items: flex-start;
    gap: 4rem;
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    z-index: 2;
}

.content-right {
    flex-direction: row-reverse;
}

.panel-wide {
    flex: 3;
    min-width: 0;
}

.panel-narrow {
    flex: 2;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.content-centered {
    max-width: 800px;
    margin: 0 auto;
    text-align: center;
    position: relative;
    z-index: 2;
}

/* --- Arabesque SVG Borders --- */
.section-arabesque {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.3;
}

.closing-arabesque {
    position: relative;
    width: 100%;
    height: 120px;
    margin-bottom: 2rem;
    opacity: 0.5;
}

.arabesque-path {
    stroke-linecap: round;
    stroke-linejoin: round;
}

.arabesque-path:hover {
    filter: drop-shadow(0 0 6px var(--saffron-thread));
}

/* --- Divider Ornaments --- */
.divider-ornament {
    display: block;
    margin: 1.5rem auto;
}

/* --- Cultural Objects (3D Parallax) --- */
.cultural-object {
    position: relative;
    width: 280px;
    height: 340px;
    perspective: 800px;
    margin: 2rem auto;
}

.obj-shadow {
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 180px;
    height: 30px;
    background: radial-gradient(ellipse, rgba(59,47,47,0.3) 0%, transparent 70%);
    filter: blur(8px);
    border-radius: 50%;
}

.obj-main {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: objectRotate 8s linear infinite;
    transition: transform 400ms var(--ease-hover);
}

.cultural-object:hover .obj-main {
    animation-play-state: paused;
    transform: translate(-50%, -50%) scale(1.05);
}

@keyframes objectRotate {
    0% { transform: translate(-50%, -50%) rotateY(0deg); }
    100% { transform: translate(-50%, -50%) rotateY(360deg); }
}

.obj-highlight {
    position: absolute;
    top: 20%;
    left: 30%;
    width: 60%;
    height: 40%;
    background: radial-gradient(ellipse at 30% 30%, rgba(244,232,214,0.3) 0%, transparent 70%);
    pointer-events: none;
    border-radius: 50%;
}

/* Vessel Shape */
.vessel-shape {
    width: 160px;
    height: 200px;
    background: linear-gradient(135deg, var(--saffron-thread) 0%, var(--terracotta-blush) 60%, var(--dried-earth) 100%);
    border-radius: 50% 50% 45% 45% / 60% 60% 40% 40%;
    box-shadow:
        inset -20px -10px 30px rgba(59,47,47,0.3),
        inset 10px 5px 20px rgba(244,232,214,0.2),
        0 10px 40px rgba(59,47,47,0.2);
    position: relative;
}

.vessel-shape::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 15%;
    width: 70%;
    height: 20px;
    background: linear-gradient(to bottom, var(--dried-earth), var(--saffron-thread));
    border-radius: 50% 50% 0 0;
}

.vessel-shape::after {
    content: '';
    position: absolute;
    top: 30%;
    left: 10%;
    width: 80%;
    height: 3px;
    background: repeating-linear-gradient(90deg, var(--kiln-clay) 0px, var(--kiln-clay) 8px, transparent 8px, transparent 12px);
    opacity: 0.3;
    border-radius: 2px;
}

/* Textile Shape */
.textile-shape {
    width: 200px;
    height: 160px;
    background:
        repeating-linear-gradient(
            0deg,
            var(--saffron-thread) 0px,
            var(--saffron-thread) 4px,
            var(--terracotta-blush) 4px,
            var(--terracotta-blush) 8px,
            var(--oxidized-copper) 8px,
            var(--oxidized-copper) 12px,
            var(--indigo-dye) 12px,
            var(--indigo-dye) 16px
        ),
        repeating-linear-gradient(
            90deg,
            rgba(59,47,47,0.2) 0px,
            rgba(59,47,47,0.2) 4px,
            transparent 4px,
            transparent 8px
        );
    border-radius: 4px;
    box-shadow:
        5px 10px 30px rgba(59,47,47,0.25),
        inset 0 0 20px rgba(59,47,47,0.1);
    transform-style: preserve-3d;
}

.textile-shape::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, transparent 30%, rgba(244,232,214,0.15) 50%, transparent 70%);
    border-radius: 4px;
}

/* Door Shape */
.door-shape {
    width: 140px;
    height: 220px;
    background: linear-gradient(180deg, var(--dried-earth) 0%, var(--kiln-clay) 100%);
    border-radius: 70px 70px 4px 4px;
    box-shadow:
        inset -15px 0 25px rgba(59,47,47,0.4),
        inset 10px 0 20px rgba(139,115,85,0.2),
        0 10px 40px rgba(59,47,47,0.3);
    position: relative;
    overflow: hidden;
}

.door-shape::before {
    content: '';
    position: absolute;
    top: 20px;
    left: 15px;
    right: 15px;
    bottom: 20px;
    border: 1.5px solid var(--saffron-thread);
    border-radius: 55px 55px 2px 2px;
    opacity: 0.5;
}

.door-shape::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 60px;
    height: 60px;
    transform: translate(-50%, -50%) rotate(45deg);
    border: 1px solid var(--saffron-thread);
    opacity: 0.4;
}

/* Astrolabe Shape */
.astrolabe-shape {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 35%, #d4a855 0%, var(--dried-earth) 40%, var(--kiln-clay) 100%);
    box-shadow:
        inset -8px -8px 20px rgba(59,47,47,0.4),
        inset 5px 5px 15px rgba(212,168,85,0.3),
        0 8px 30px rgba(59,47,47,0.3);
    position: relative;
}

.astrolabe-shape::before {
    content: '';
    position: absolute;
    top: 15%;
    left: 15%;
    width: 70%;
    height: 70%;
    border: 1px solid rgba(196,132,60,0.5);
    border-radius: 50%;
}

.astrolabe-shape::after {
    content: '';
    position: absolute;
    top: 30%;
    left: 30%;
    width: 40%;
    height: 40%;
    border: 1px solid rgba(196,132,60,0.4);
    border-radius: 50%;
    transform: rotate(45deg);
}

/* --- Woven Interstitials --- */
.woven-interstitial {
    position: relative;
    height: 140px;
    overflow: hidden;
    z-index: 2;
}

.ribbon {
    position: absolute;
    top: 0;
    left: -5%;
    width: 110%;
    height: 100%;
}

.ribbon-pattern {
    background-color: var(--ribbon-color, var(--terracotta-blush));
    clip-path: polygon(0 30%, 100% 0%, 100% 70%, 0 100%);
    opacity: 0.85;
}

.ribbon-text {
    display: flex;
    align-items: center;
    justify-content: center;
    clip-path: polygon(0 0%, 100% 30%, 100% 100%, 0 70%);
    background-color: var(--bleached-linen);
    z-index: 1;
}

.ribbon-text .accent-anybody {
    color: var(--kiln-clay);
    font-size: clamp(0.85rem, 1vw, 1.1rem);
    letter-spacing: 0.25em;
}

.interstitial-1 .ribbon-pattern { clip-path: polygon(0 20%, 100% 0%, 100% 80%, 0 100%); }
.interstitial-1 .ribbon-text { clip-path: polygon(0 0%, 100% 20%, 100% 100%, 0 80%); }

.interstitial-2 .ribbon-pattern { clip-path: polygon(0 0%, 100% 20%, 100% 100%, 0 80%); }
.interstitial-2 .ribbon-text { clip-path: polygon(0 20%, 100% 0%, 100% 80%, 0 100%); }

.interstitial-3 .ribbon-pattern { clip-path: polygon(0 25%, 100% 0%, 100% 75%, 0 100%); }
.interstitial-3 .ribbon-text { clip-path: polygon(0 0%, 100% 25%, 100% 100%, 0 75%); }

.interstitial-4 .ribbon-pattern { clip-path: polygon(0 0%, 100% 25%, 100% 100%, 0 75%); }
.interstitial-4 .ribbon-text { clip-path: polygon(0 25%, 100% 0%, 100% 75%, 0 100%); }

.interstitial-5 .ribbon-pattern { clip-path: polygon(0 15%, 100% 0%, 100% 85%, 0 100%); }
.interstitial-5 .ribbon-text { clip-path: polygon(0 0%, 100% 15%, 100% 100%, 0 85%); }

.interstitial-6 .ribbon-pattern { clip-path: polygon(0 0%, 100% 15%, 100% 100%, 0 85%); }
.interstitial-6 .ribbon-text { clip-path: polygon(0 15%, 100% 0%, 100% 85%, 0 100%); }

/* --- Constellation Dots Background --- */
#constellation-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.constellation-dot {
    fill: var(--saffron-thread);
    opacity: 0.12;
    animation: pulse 4s ease-in-out infinite;
}

.constellation-line {
    stroke: var(--saffron-thread);
    stroke-width: 0.5;
    opacity: 0.08;
    animation: pulse 4s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.08; }
    50% { opacity: 0.15; }
}

/* --- Links --- */
a {
    color: var(--saffron-thread);
    text-decoration: none;
    position: relative;
}

a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--saffron-thread);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 300ms var(--ease-hover);
}

a:hover::after {
    transform: scaleX(1);
}

/* --- Footer --- */
#site-footer {
    position: relative;
    background-color: var(--kiln-clay);
    padding: 60px 40px;
    text-align: center;
    z-index: 1;
}

#site-footer .accent-anybody {
    color: var(--sandstone-wash);
    letter-spacing: 0.3em;
    font-size: 0.8rem;
}

.footer-pattern {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Cpath d='M20 0L40 20L20 40L0 20Z' fill='none' stroke='%23E8DFD0' stroke-width='0.5'/%3E%3C/svg%3E");
    background-repeat: repeat;
    pointer-events: none;
}

/* --- Closing Zone --- */
.zone-closing {
    background-color: var(--kiln-clay);
    display: flex;
    align-items: center;
    justify-content: center;
}

.zone-closing .headline-fraunces {
    color: var(--bleached-linen);
}

.zone-closing .body-serif {
    color: var(--sandstone-wash);
}

.zone-closing .zone-number span {
    color: var(--sandstone-wash);
    opacity: 0.04;
}

.closing-ornament {
    margin: 3rem auto;
}

/* --- Section Entry Animation Staggering --- */
.narrative-zone .section-arabesque .arabesque-path {
    transition: stroke-dashoffset 800ms var(--ease-svg-draw);
}

.narrative-zone.is-visible .zone-content {
    animation: contentSlideIn 500ms var(--ease-entrance) 600ms both;
}

@keyframes contentSlideIn {
    from {
        opacity: 0;
        transform: translateY(40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Responsive: Tablet --- */
@media (max-width: 1024px) {
    #sidebar-rail {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 60px;
        flex-direction: row;
    }

    #rail-svg {
        width: 100%;
        height: 60px;
        transform: rotate(90deg);
    }

    .narrative-zone {
        padding: 100px 40px 100px 40px;
    }

    .content-split {
        gap: 2rem;
    }

    .cultural-object {
        width: 220px;
        height: 280px;
    }
}

/* --- Responsive: Mobile --- */
@media (max-width: 768px) {
    #sidebar-rail {
        position: fixed;
        bottom: 0;
        top: auto;
        left: 0;
        width: 100%;
        height: 4px;
        background: linear-gradient(90deg, var(--oxidized-copper), var(--indigo-dye));
        z-index: 200;
    }

    #rail-svg {
        display: none;
    }

    .narrative-zone {
        padding: 80px 24px;
        min-height: auto;
    }

    .content-split {
        flex-direction: column;
        gap: 2rem;
    }

    .content-right {
        flex-direction: column;
    }

    .panel-wide,
    .panel-narrow {
        flex: none;
        width: 100%;
    }

    .zone-hero {
        padding: 60px 24px;
    }

    .zone-hero .headline-fraunces {
        font-size: clamp(2.2rem, 8vw, 4rem);
    }

    .headline-fraunces {
        font-size: clamp(2rem, 6vw, 3.5rem);
    }

    .zone-number span {
        font-size: clamp(5rem, 15vw, 8rem);
    }

    .cultural-object {
        width: 200px;
        height: 260px;
    }

    .woven-interstitial {
        height: 100px;
    }

    .ribbon-pattern {
        clip-path: polygon(0 0, 100% 4rem, 100% 100%, 0 calc(100% - 4rem));
    }

    .ribbon-text {
        clip-path: polygon(0 4rem, 100% 0, 100% calc(100% - 4rem), 0 100%);
    }

    /* Override individual interstitial clips for mobile */
    .interstitial-1 .ribbon-pattern,
    .interstitial-2 .ribbon-pattern,
    .interstitial-3 .ribbon-pattern,
    .interstitial-4 .ribbon-pattern,
    .interstitial-5 .ribbon-pattern,
    .interstitial-6 .ribbon-pattern {
        clip-path: polygon(0 0, 100% 4rem, 100% 100%, 0 calc(100% - 4rem));
    }

    .interstitial-1 .ribbon-text,
    .interstitial-2 .ribbon-text,
    .interstitial-3 .ribbon-text,
    .interstitial-4 .ribbon-text,
    .interstitial-5 .ribbon-text,
    .interstitial-6 .ribbon-text {
        clip-path: polygon(0 4rem, 100% 0, 100% calc(100% - 4rem), 0 100%);
    }

    .section-arabesque {
        opacity: 0.15;
    }
}

/* --- Scroll reveal initial state for zone-content --- */
.narrative-zone .zone-content {
    opacity: 0;
}

.narrative-zone.is-visible .zone-content,
.zone-hero .zone-content {
    opacity: 1;
}

/* Hero zone should always be visible */
.zone-hero {
    opacity: 1;
    transform: none;
}

.zone-hero .zone-content {
    opacity: 1;
}
