/* miris.dev — Grainy-Textured Immersive Scroll */

/* ===========================
   Design Palette & Variables
   =========================== */
:root {
    --volcanic-char: #1E1B18;
    --sandstone: #D4A574;
    --terracotta: #C4704B;
    --sage-moss: #6B8F71;
    --parchment: #E8DCC8;
    --umber: #2A2420;
    --warm-amber: #D4A06B;
    --dust: #8B7D6B;
    --ease-settle: cubic-bezier(0.23, 1, 0.32, 1);
}

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

html {
    font-size: 16px;
}

body {
    font-family: 'Libre Baskerville', serif;
    background-color: var(--volcanic-char);
    color: var(--parchment);
    overflow-x: hidden;
    cursor: none;
}

@media (pointer: coarse) {
    body {
        cursor: auto;
    }
}

/* ===========================
   Grain Overlay System
   =========================== */
.grain-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.06;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 200px 200px;
    animation: grainShift 0.3s steps(1) infinite;
}

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

/* ===========================
   Scroll Progress Indicator
   =========================== */
.scroll-indicator {
    position: fixed;
    right: 0;
    top: 0;
    width: 2px;
    height: 0%;
    background-color: var(--terracotta);
    z-index: 100;
    transition: height 100ms linear;
}

/* ===========================
   Cursor Follow
   =========================== */
.cursor-follow {
    position: fixed;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--terracotta) 0%, transparent 70%);
    pointer-events: none;
    z-index: 9998;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 300ms ease;
    will-change: left, top;
}

.cursor-follow::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='cn'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23cn)'/%3E%3C/svg%3E");
    mix-blend-mode: overlay;
    opacity: 0.3;
}

.cursor-follow.active {
    opacity: 0.8;
}

@media (pointer: coarse) {
    .cursor-follow {
        display: none;
    }
}

/* ===========================
   Typography
   =========================== */
.display-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: clamp(5rem, 15vw, 12rem);
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--parchment);
    line-height: 0.9;
}

.display-heading {
    font-family: 'Bebas Neue', sans-serif;
    font-size: clamp(3.5rem, 12vw, 10rem);
    font-weight: 400;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--parchment);
    line-height: 0.9;
    margin-bottom: 2rem;
}

.body-text {
    font-family: 'Libre Baskerville', serif;
    font-size: clamp(1rem, 1.8vw, 1.25rem);
    font-weight: 400;
    line-height: 1.75;
    letter-spacing: 0.01em;
    max-width: 680px;
    margin-bottom: 1.5rem;
}

.body-text:last-child {
    margin-bottom: 0;
}

.serif-italic {
    font-family: 'Libre Baskerville', serif;
    font-style: italic;
    opacity: 0;
    animation: fadeInSlow 1.5s var(--ease-settle) 1.5s forwards;
}

@keyframes fadeInSlow {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.caption-label {
    font-family: 'Bebas Neue', sans-serif;
    font-size: clamp(0.7rem, 1.2vw, 0.85rem);
    font-weight: 400;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--dust);
    display: block;
    margin-bottom: 3rem;
}

/* ===========================
   Section Base
   =========================== */
.section {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.section-content {
    position: relative;
    z-index: 2;
    padding: 5vh 8vw;
    max-width: 960px;
    width: 100%;
}

/* ===========================
   Section 1: Aurora Threshold
   =========================== */
.aurora-threshold {
    background-color: var(--volcanic-char);
}

.aurora-band {
    position: absolute;
    left: 0;
    width: 100%;
    filter: blur(30px);
    pointer-events: none;
    z-index: 1;
}

.aurora-band-1 {
    top: 20%;
    height: 100px;
    background: linear-gradient(90deg, transparent 5%, var(--sage-moss) 30%, var(--terracotta) 60%, transparent 95%);
    opacity: 0.5;
    animation: auroraDrift1 10s ease-in-out infinite, auroraBreathe1 7s ease-in-out infinite;
}

.aurora-band-2 {
    top: 35%;
    height: 80px;
    background: linear-gradient(90deg, transparent 10%, var(--terracotta) 40%, var(--warm-amber) 70%, transparent 90%);
    opacity: 0.4;
    animation: auroraDrift2 12s ease-in-out infinite, auroraBreathe2 9s ease-in-out infinite;
}

.aurora-band-3 {
    top: 50%;
    height: 60px;
    background: linear-gradient(90deg, transparent 15%, var(--warm-amber) 50%, var(--sage-moss) 80%, transparent 95%);
    opacity: 0.4;
    animation: auroraDrift3 8s ease-in-out infinite, auroraBreathe3 6s ease-in-out infinite;
}

@keyframes auroraDrift1 {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-25px); }
}

@keyframes auroraDrift2 {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(30px); }
}

@keyframes auroraDrift3 {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-20px); }
}

@keyframes auroraBreathe1 {
    0%, 100% { opacity: 0.5; }
    50%      { opacity: 0.8; }
}

@keyframes auroraBreathe2 {
    0%, 100% { opacity: 0.4; }
    50%      { opacity: 0.7; }
}

@keyframes auroraBreathe3 {
    0%, 100% { opacity: 0.4; }
    50%      { opacity: 0.7; }
}

.aurora-threshold .section-content {
    text-align: left;
    padding-left: 10vw;
}

.aurora-threshold .subtitle {
    font-size: clamp(1rem, 2vw, 1.4rem);
    margin-top: 2rem;
    max-width: 500px;
    color: var(--dust);
}

/* ===========================
   Section 2: Terrain Grid
   =========================== */
.terrain-grid {
    background-color: var(--volcanic-char);
    padding: 20vh 0;
}

.terrain-shapes {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 2rem;
    max-width: 800px;
    margin: 2rem auto;
}

.geo-shape {
    opacity: 0;
    transform: scale(0);
    transition: opacity 600ms var(--ease-settle),
                transform 600ms var(--ease-settle);
    transition-delay: calc(var(--shape-delay, 0) * 120ms);
}

.geo-shape.visible {
    opacity: 1;
    transform: scale(1);
}

.shape-circle {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 40%, var(--terracotta), var(--sage-moss));
    filter: blur(1px);
    justify-self: center;
}

.shape-pill {
    width: 240px;
    height: 100px;
    border-radius: 50px;
    background: linear-gradient(135deg, var(--warm-amber), var(--sandstone));
    justify-self: center;
    align-self: center;
}

.shape-polygon {
    width: 180px;
    height: 180px;
    clip-path: polygon(32% 2%, 72% 0%, 98% 28%, 100% 72%, 68% 98%, 28% 100%, 2% 68%, 0% 32%);
    background-color: var(--terracotta);
    justify-self: center;
}

.shape-rect {
    width: 160px;
    height: 220px;
    border-radius: 40%;
    background: linear-gradient(135deg, var(--sage-moss), var(--volcanic-char));
    justify-self: center;
}

.shape-circle-sm {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--warm-amber), transparent);
    justify-self: center;
}

.shape-lozenge {
    width: 260px;
    height: 80px;
    border-radius: 40px;
    background: linear-gradient(135deg, var(--sandstone), var(--terracotta));
    justify-self: center;
    align-self: center;
}

.line-cluster {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4rem;
    opacity: 0.5;
}

.line-cluster span {
    display: block;
    height: 1.5px;
    background-color: var(--parchment);
    opacity: 0.5;
}

.line-cluster span:nth-child(1) { width: 80%; }
.line-cluster span:nth-child(2) { width: 60%; }
.line-cluster span:nth-child(3) { width: 90%; }
.line-cluster span:nth-child(4) { width: 45%; }
.line-cluster span:nth-child(5) { width: 70%; }

/* ===========================
   Section 3: Canyon Narrative
   =========================== */
.canyon-narrative {
    background-color: var(--sandstone);
    color: var(--umber);
    min-height: 100vh;
}

.canyon-narrative .body-text {
    color: var(--umber);
}

.canyon-narrative .display-heading {
    color: var(--umber);
}

.canyon-narrative .caption-label {
    color: var(--terracotta);
}

.canyon-content {
    padding: 10vh 8vw;
}

.canyon-text {
    clip-path: inset(50% 50% 50% 50%);
    transition: clip-path 1s var(--ease-settle);
}

.canyon-text.revealed {
    clip-path: inset(0% 0% 0% 0%);
}

/* Grain intensity 8% for text sections */
.canyon-narrative::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 3;
    opacity: 0.08;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='cn'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23cn)'/%3E%3C/svg%3E");
    background-size: 200px 200px;
}

/* ===========================
   Section 4: Floating Geometry
   =========================== */
.floating-geometry {
    background-color: var(--volcanic-char);
    min-height: 100vh;
}

.parallax-bg {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}

.float-element {
    position: absolute;
    will-change: transform;
}

.float-circle-large {
    width: 350px;
    height: 350px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 40%, var(--terracotta), var(--sage-moss));
    top: 15%;
    right: 10%;
    opacity: 0.6;
    filter: blur(1px);
}

.float-lines {
    position: absolute;
    top: 50%;
    left: 5%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.float-lines span {
    display: block;
    height: 1.5px;
    background-color: var(--parchment);
    opacity: 0.4;
}

.float-lines span:nth-child(1) { width: 120px; }
.float-lines span:nth-child(2) { width: 200px; }
.float-lines span:nth-child(3) { width: 80px; }
.float-lines span:nth-child(4) { width: 160px; }
.float-lines span:nth-child(5) { width: 100px; }
.float-lines span:nth-child(6) { width: 220px; }
.float-lines span:nth-child(7) { width: 140px; }

.float-squares {
    position: absolute;
    bottom: 20%;
    right: 25%;
}

.float-squares span {
    position: absolute;
    width: 6px;
    height: 6px;
    background-color: var(--parchment);
    opacity: 0.2;
    border-radius: 50%;
}

.float-squares span:nth-child(1) { top: 0;    left: 0; }
.float-squares span:nth-child(2) { top: 0;    left: 30px; }
.float-squares span:nth-child(3) { top: 0;    left: 60px; }
.float-squares span:nth-child(4) { top: 30px; left: 15px; }
.float-squares span:nth-child(5) { top: 30px; left: 45px; }
.float-squares span:nth-child(6) { top: 60px; left: 0; }
.float-squares span:nth-child(7) { top: 60px; left: 30px; }
.float-squares span:nth-child(8) { top: 60px; left: 60px; }

.floating-geometry .section-content {
    padding-left: 10vw;
}

/* ===========================
   Section 5: Dissolution
   =========================== */
.dissolution {
    background-color: var(--volcanic-char);
    min-height: 100vh;
}

.dissolution .aurora-band-1 {
    opacity: 0.3;
}

.dissolution .aurora-band-2 {
    opacity: 0.25;
}

.dissolution-ember {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200px;
    height: 200px;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, var(--warm-amber) 0%, transparent 70%);
    opacity: 0;
    z-index: 1;
    pointer-events: none;
    transition: opacity 800ms var(--ease-settle);
}

.dissolution-ember.ember-glow {
    opacity: 0.4;
}

.dissolution .section-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.dissolution-text {
    max-width: 600px;
    text-align: center;
}

.dissolution .caption-label {
    text-align: center;
}

/* Dissolution fade effect: elements fade to charcoal as section scrolls */
.dissolution .section-content {
    transition: opacity 600ms var(--ease-settle);
}

/* ===========================
   Dot Field Pattern
   =========================== */
.dot-field {
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle, var(--dust) 1px, transparent 1px);
    background-size: 40px 40px;
    opacity: 0.15;
    pointer-events: none;
    z-index: 0;
}

/* ===========================
   Section-specific grain overlays
   =========================== */
.aurora-threshold::after,
.dissolution::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 3;
    opacity: 0.04;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='sg'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23sg)'/%3E%3C/svg%3E");
    background-size: 200px 200px;
}

.terrain-grid::after,
.floating-geometry::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 3;
    opacity: 0.06;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='gg'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23gg)'/%3E%3C/svg%3E");
    background-size: 200px 200px;
}

/* ===========================
   Responsive
   =========================== */
@media (max-width: 768px) {
    .aurora-threshold .section-content {
        padding-left: 6vw;
    }

    .terrain-shapes {
        grid-template-columns: repeat(2, 1fr);
    }

    .shape-circle    { width: 140px; height: 140px; }
    .shape-pill      { width: 180px; height: 80px; }
    .shape-polygon   { width: 130px; height: 130px; }
    .shape-rect      { width: 120px; height: 160px; }
    .shape-circle-sm { width: 90px;  height: 90px; }
    .shape-lozenge   { width: 180px; height: 60px; }

    .float-circle-large {
        width: 200px;
        height: 200px;
    }
}

@media (max-width: 480px) {
    .display-title {
        font-size: 4rem;
    }

    .display-heading {
        font-size: 2.5rem;
    }

    .terrain-shapes {
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
    }

    .section-content {
        padding: 5vh 5vw;
    }
}
