/* miris.works — Anti-Design Aged Paper Aesthetic */

/* ============================================
   CSS Custom Properties (required by DESIGN.md)
   ============================================ */

:root {
    --bg-primary: #F2EBE0;
    --bg-secondary: #E8DFD0;
    --text-primary: #2B2520;
    --text-secondary: #9B8E7E;
    --accent-primary: #C4956A;
    --accent-secondary: #A67C52;
    --surface-divider: #D4C8B8;
    --crystal-highlight: #DDD8CE;
}

/* ============================================
   Reset
   ============================================ */

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

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

/* ============================================
   Body: Aged Paper Background + Texture Layers
   ============================================ */

body {
    font-family: 'Libre Baskerville', serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    overflow-x: hidden;
    line-height: 1.75;
    letter-spacing: 0.01em;
    position: relative;
    /* Layered radial gradients simulating uneven paper density */
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(196, 149, 106, 0.02), transparent 50%),
        radial-gradient(ellipse at 80% 30%, rgba(155, 142, 126, 0.03), transparent 40%),
        radial-gradient(circle at 15% 20%, rgba(196, 149, 106, 0.015) 0%, transparent 40%),
        radial-gradient(circle at 85% 70%, rgba(155, 142, 126, 0.02) 0%, transparent 35%),
        radial-gradient(circle at 50% 50%, rgba(232, 223, 208, 0.04), transparent 60%);
}

/* Fine-grain noise layer (SVG-based at 3-4% opacity) */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='grain'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' seed='5'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' fill='%23F2EBE0' filter='url(%23grain)'/%3E%3C/svg%3E");
    background-size: 200px 200px;
    opacity: 0.035;
    pointer-events: none;
    z-index: 9998;
}

/* Foxing spots: small radial gradients of #C4956A at 5% opacity */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        radial-gradient(circle at 22% 35%, rgba(196, 149, 106, 0.05) 0%, transparent 6%),
        radial-gradient(circle at 78% 62%, rgba(196, 149, 106, 0.05) 0%, transparent 5%),
        radial-gradient(circle at 5% 85%, rgba(155, 142, 126, 0.04) 0%, transparent 4%),
        radial-gradient(circle at 92% 15%, rgba(196, 149, 106, 0.04) 0%, transparent 5%),
        radial-gradient(circle at 45% 90%, rgba(155, 142, 126, 0.03) 0%, transparent 5%),
        radial-gradient(circle at 60% 10%, rgba(196, 149, 106, 0.03) 0%, transparent 4%),
        radial-gradient(circle at 35% 55%, rgba(196, 149, 106, 0.04) 0%, transparent 3%);
    pointer-events: none;
    z-index: 9997;
}

/* ============================================
   Typography System
   ============================================ */

/* Headlines / Display: Space Grotesk */
.primary-statement {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 300;
    font-size: clamp(2.4rem, 6vw, 4.8rem);
    letter-spacing: 0.04em;
    line-height: 1.15;
    color: var(--text-primary);
    word-spacing: 0.5em;
    animation: wordSpacingSettle 2000ms cubic-bezier(0.25, 0.1, 0.25, 1) forwards;
}

.entry-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: clamp(1.3rem, 2.5vw, 2rem);
    letter-spacing: 0.04em;
    line-height: 1.15;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

/* Body Text: Libre Baskerville */
.body-text {
    font-family: 'Libre Baskerville', serif;
    font-size: clamp(0.95rem, 1.2vw, 1.1rem);
    font-weight: 400;
    line-height: 1.75;
    letter-spacing: 0.01em;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

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

/* Wordmark: small grotesque like a colophon */
.wordmark {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 300;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
    transition: opacity 200ms ease;
    display: inline-block;
}

.wordmark:hover {
    opacity: 0.6;
}

/* Date / Edition marker: DM Mono */
.date-mark {
    font-family: 'DM Mono', monospace;
    font-size: clamp(0.7rem, 0.8vw, 0.8rem);
    font-weight: 400;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}

/* Monospace accent: DM Mono */
.mono-accent {
    font-family: 'DM Mono', monospace;
    font-size: clamp(0.7rem, 0.8vw, 0.8rem);
    font-weight: 400;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}

/* Captions / Metadata: Space Grotesk small uppercase */
.meta-label {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 400;
    font-size: clamp(0.7rem, 0.9vw, 0.8rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 0.75rem;
}

/* Breath text */
.breath-text {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 300;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    color: var(--text-primary);
    opacity: 0.7;
    max-width: 600px;
    position: relative;
    z-index: 1;
    letter-spacing: 0.03em;
    line-height: 1.4;
}

/* Closing statement */
.closing-statement {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 300;
    font-size: clamp(1.2rem, 2vw, 1.6rem);
    line-height: 1.5;
    color: var(--text-primary);
    max-width: 450px;
    letter-spacing: 0.02em;
}

/* Pull-quote text */
.quote-text {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 300;
    font-size: clamp(1.3rem, 2vw, 1.8rem);
    font-style: oblique 4deg;
    color: var(--accent-secondary);
    line-height: 1.4;
    letter-spacing: 0.03em;
}

/* ============================================
   Animations
   ============================================ */

@keyframes wordSpacingSettle {
    0% { word-spacing: 0.5em; }
    100% { word-spacing: 0.1em; }
}

@keyframes fadeReveal {
    0% {
        opacity: 0;
        transform: translateY(8px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes crystallineRotate {
    0% {
        opacity: 0;
        transform: rotate(-7.5deg);
    }
    100% {
        opacity: 0.15;
        transform: rotate(7.5deg);
    }
}

/* ============================================
   Section Layout: Plate container
   ============================================ */

.plate {
    position: relative;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 clamp(1rem, 2vw, 2.5rem);
    transition: opacity 400ms ease;
}

/* ============================================
   Hero Plate: 100vh z-pattern entry
   ============================================ */

.hero-plate {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.hero-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto 1fr;
    gap: clamp(2rem, 5vw, 4rem) clamp(1rem, 3vw, 3rem);
    width: 100%;
    min-height: 80vh;
    align-content: space-between;
    padding: 5vh 0;
}

.hero-tl {
    grid-column: 1;
    grid-row: 1;
    align-self: start;
    opacity: 0;
    animation: fadeReveal 800ms cubic-bezier(0.25, 0.1, 0.25, 1) 100ms forwards;
}

.hero-tr {
    grid-column: 2;
    grid-row: 1;
    align-self: start;
    justify-self: end;
    opacity: 0;
    animation: fadeReveal 800ms cubic-bezier(0.25, 0.1, 0.25, 1) 200ms forwards;
}

.hero-bl {
    grid-column: 1;
    grid-row: 2;
    align-self: end;
    max-width: 600px;
    opacity: 0;
    animation: fadeReveal 800ms cubic-bezier(0.25, 0.1, 0.25, 1) 300ms forwards;
}

.hero-br {
    grid-column: 2;
    grid-row: 2;
    align-self: end;
    justify-self: end;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================
   Crystalline Glyphs (SVG)
   ============================================ */

.crystal-path {
    fill: none;
    stroke: var(--surface-divider);
    stroke-width: 1;
}

.crystal-facet {
    fill: none;
    stroke: var(--surface-divider);
    stroke-width: 0.5;
    opacity: 0.3;
}

.crystal-glyph {
    color: var(--accent-primary);
    opacity: 0;
    animation: crystallineRotate 1500ms cubic-bezier(0.25, 0.1, 0.25, 1) 500ms forwards;
    transition: opacity 400ms ease;
}

.crystal-glyph .crystal-path {
    stroke: var(--accent-primary);
}

.crystal-glyph .crystal-facet {
    stroke: var(--accent-primary);
}

.crystal-glyph:hover {
    opacity: 0.6;
}

.crystal-glyph-hero {
    width: 200px;
    height: 200px;
}

/* ============================================
   Crystalline HR Divider (line + 3 nodes)
   ============================================ */

.crystalline-hr {
    max-width: 1200px;
    margin: 0 auto;
    padding: clamp(1rem, 3vw, 2rem) clamp(1rem, 2vw, 2.5rem);
    opacity: 0.5;
}

.crystalline-hr-sm {
    padding: clamp(0.5rem, 1.5vw, 1rem) clamp(1rem, 2vw, 2.5rem);
    opacity: 0.35;
}

.hr-line {
    width: 100%;
    height: 20px;
    display: block;
}

/* ============================================
   Works Stream
   ============================================ */

.works-stream {
    padding-top: clamp(3rem, 8vw, 6rem);
    padding-bottom: clamp(3rem, 8vw, 6rem);
}

.work-entry {
    margin-bottom: clamp(1rem, 2vw, 1.5rem);
    padding-bottom: clamp(1rem, 2vw, 1.5rem);
    position: relative;
}

.entry-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: clamp(1rem, 2vw, 1.5rem) clamp(1.5rem, 3vw, 2.5rem);
}

.entry-tl {
    grid-column: 1;
    grid-row: 1;
}

.entry-tr {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    align-self: start;
}

.entry-bl {
    grid-column: 1;
    grid-row: 2;
    max-width: 500px;
}

.entry-br {
    grid-column: 2;
    grid-row: 2;
    justify-self: end;
    display: flex;
    align-items: flex-start;
}

/* ============================================
   Thumbnails: CSS-only Abstract Compositions
   with torn-edge clip-paths
   ============================================ */

.thumbnail {
    width: clamp(140px, 20vw, 200px);
    height: clamp(90px, 12vw, 140px);
    background-color: var(--bg-secondary);
    position: relative;
    filter: sepia(0.25) contrast(0.95);
    transition: clip-path 600ms cubic-bezier(0.25, 0.1, 0.25, 1);
    overflow: hidden;
}

/* CSS-only visual layers inside thumbnails */
.thumb-layer {
    position: absolute;
    inset: 0;
}

.thumb-rect-a {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--surface-divider) 50%, var(--bg-secondary) 100%);
}

.thumb-rect-b {
    top: 20%;
    left: 15%;
    right: 40%;
    bottom: 30%;
    background-color: var(--accent-primary);
    opacity: 0.12;
    box-shadow: 2px 2px 4px rgba(43, 37, 32, 0.06);
}

.thumb-rect-c {
    background: linear-gradient(160deg, var(--surface-divider) 0%, var(--bg-secondary) 60%, var(--crystal-highlight) 100%);
}

.thumb-rect-d {
    top: 35%;
    left: 10%;
    right: 25%;
    bottom: 20%;
    background-color: var(--accent-secondary);
    opacity: 0.15;
    box-shadow: 1px 3px 4px rgba(43, 37, 32, 0.05);
}

.thumb-rect-e {
    background: linear-gradient(110deg, var(--bg-secondary) 0%, var(--crystal-highlight) 40%, var(--bg-secondary) 100%);
}

.thumb-rect-f {
    top: 10%;
    left: 30%;
    right: 15%;
    bottom: 40%;
    background-color: var(--accent-primary);
    opacity: 0.1;
    box-shadow: -1px 2px 3px rgba(43, 37, 32, 0.04);
}

.thumb-rect-g {
    background: linear-gradient(145deg, var(--crystal-highlight) 0%, var(--bg-secondary) 50%, var(--surface-divider) 100%);
}

.thumb-rect-h {
    top: 25%;
    left: 20%;
    right: 30%;
    bottom: 15%;
    background-color: var(--accent-secondary);
    opacity: 0.1;
    box-shadow: 2px 1px 4px rgba(43, 37, 32, 0.05);
}

/* Diagonal construction lines */
.thumb-diag {
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 12px,
        rgba(212, 200, 184, 0.15) 12px,
        rgba(212, 200, 184, 0.15) 13px
    );
}

.thumb-diag-alt {
    background: repeating-linear-gradient(
        -45deg,
        transparent,
        transparent 15px,
        rgba(196, 149, 106, 0.08) 15px,
        rgba(196, 149, 106, 0.08) 16px
    );
}

/* Torn-edge clip-paths (3-8px deviations from straight edges) */
.torn-1 {
    clip-path: polygon(1% 3%, 25% 0%, 50% 2%, 75% 1%, 99% 0%, 100% 25%, 100% 50%, 100% 75%, 100% 96%, 75% 100%, 50% 98%, 25% 100%, 4% 98%, 0% 75%, 2% 50%, 0% 25%);
}

.torn-2 {
    clip-path: polygon(0% 2%, 30% 0%, 60% 3%, 97% 1%, 100% 30%, 100% 60%, 100% 95%, 70% 100%, 40% 97%, 6% 100%, 0% 70%, 3% 40%);
}

.torn-3 {
    clip-path: polygon(3% 1%, 28% 0%, 55% 2%, 80% 0%, 100% 2%, 100% 30%, 98% 60%, 100% 99%, 72% 100%, 45% 97%, 20% 100%, 1% 100%, 0% 65%, 2% 35%);
}

.torn-4 {
    clip-path: polygon(0% 1%, 35% 0%, 65% 2%, 98% 0%, 100% 35%, 99% 65%, 100% 98%, 65% 100%, 35% 97%, 2% 99%, 0% 60%, 1% 30%);
}

/* Thumbnail hover: subtle clip-path shift (2-3px changes) */
.torn-1:hover {
    clip-path: polygon(2% 4%, 26% 1%, 51% 3%, 76% 2%, 100% 1%, 100% 26%, 99% 51%, 100% 76%, 99% 95%, 74% 99%, 49% 97%, 24% 99%, 5% 97%, 1% 74%, 3% 49%, 1% 24%);
}

.torn-2:hover {
    clip-path: polygon(1% 3%, 31% 1%, 61% 4%, 98% 2%, 100% 31%, 99% 61%, 99% 94%, 69% 99%, 39% 96%, 5% 99%, 1% 69%, 4% 39%);
}

.torn-3:hover {
    clip-path: polygon(4% 2%, 29% 1%, 56% 3%, 81% 1%, 100% 3%, 99% 31%, 97% 61%, 99% 98%, 71% 99%, 44% 96%, 19% 99%, 2% 99%, 1% 64%, 3% 34%);
}

.torn-4:hover {
    clip-path: polygon(1% 2%, 36% 1%, 66% 3%, 99% 1%, 100% 36%, 98% 66%, 99% 97%, 64% 99%, 34% 96%, 3% 98%, 1% 59%, 2% 29%);
}

/* ============================================
   Breath Plate: 50vh reflective pause
   ============================================ */

.breath-plate {
    min-height: 50vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    position: relative;
    padding-top: clamp(3rem, 8vw, 5rem);
    padding-bottom: clamp(3rem, 8vw, 5rem);
}

/* Crystalline pattern bg: small repeating shapes at 3-5% opacity */
.crystal-pattern-bg {
    position: absolute;
    inset: 0;
    background-image:
        repeating-linear-gradient(60deg, transparent, transparent 28px, rgba(212, 200, 184, 0.02) 28px, rgba(212, 200, 184, 0.02) 29px),
        repeating-linear-gradient(-60deg, transparent, transparent 35px, rgba(221, 216, 206, 0.015) 35px, rgba(221, 216, 206, 0.015) 36px),
        radial-gradient(circle at 30% 30%, rgba(221, 216, 206, 0.03), transparent 50%),
        radial-gradient(circle at 70% 70%, rgba(221, 216, 206, 0.02), transparent 50%);
    pointer-events: none;
}

/* ============================================
   Detail Plate: two-column dense composition
   ============================================ */

.detail-plate {
    padding-top: clamp(3rem, 8vw, 5rem);
    padding-bottom: clamp(3rem, 8vw, 5rem);
}

.detail-grid {
    display: grid;
    gap: clamp(2rem, 5vw, 4rem);
}

.detail-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(2rem, 4vw, 3.5rem);
}

.detail-col-left {
    grid-column: 1;
}

.detail-col-right {
    grid-column: 2;
}

/* Pull-quote in bleed zone (offset left) */
.pull-quote {
    grid-column: 1 / -1;
    padding: clamp(1.5rem, 3vw, 2rem) 0 clamp(1.5rem, 3vw, 2rem) clamp(1.5rem, 3vw, 2.5rem);
    border-left: 2px solid var(--accent-primary);
    max-width: 550px;
    margin-left: -1.5rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.crystal-bullet {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    margin-top: 0.35rem;
}

/* ============================================
   Crystalline Divider (medium glyph)
   ============================================ */

.crystalline-divider {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: clamp(2rem, 5vw, 4rem) 0;
    position: relative;
    z-index: 1;
}

.crystal-divider-glyph {
    opacity: 0.25;
    transition: opacity 400ms ease;
}

.crystal-divider-glyph .crystal-path {
    stroke: var(--surface-divider);
}

.crystal-divider-glyph .crystal-facet {
    stroke: var(--surface-divider);
}

.crystal-divider-glyph:hover {
    opacity: 0.6;
}

/* ============================================
   Closing Plate: 80vh inverted z-pattern
   ============================================ */

.closing-plate {
    min-height: 80vh;
    display: flex;
    align-items: center;
    padding-top: clamp(3rem, 8vw, 5rem);
    padding-bottom: clamp(3rem, 8vw, 5rem);
}

.closing-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: clamp(2rem, 5vw, 3rem);
    width: 100%;
    min-height: 60vh;
    align-content: space-between;
}

/* Inverted z: statement top-right, colophon bottom-left */
.closing-tr {
    grid-column: 2;
    grid-row: 1;
    align-self: start;
}

.closing-bl {
    grid-column: 1;
    grid-row: 2;
    align-self: end;
    display: flex;
    flex-direction: column;
    gap: clamp(0.3rem, 1vw, 0.75rem);
}

.closing-colophon {
    margin-bottom: 0;
}

/* ============================================
   Link Hover: warm glow, no underline
   ============================================ */

a {
    color: var(--text-primary);
    text-decoration: none;
    position: relative;
    transition: text-shadow 300ms ease;
}

a:hover {
    text-shadow: 0 0 20px rgba(196, 149, 106, 0.15);
}

/* ============================================
   Reveal Items: initial hidden state
   (animated by IntersectionObserver in JS)
   ============================================ */

.reveal-item {
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 800ms cubic-bezier(0.25, 0.1, 0.25, 1),
                transform 800ms cubic-bezier(0.25, 0.1, 0.25, 1);
}

.reveal-item.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Palimpsest effect: scrolled-past sections fade to 70% */
.plate.faded {
    opacity: 0.7;
}

/* ============================================
   Responsive: Tablet (768px)
   ============================================ */

@media (max-width: 768px) {
    .hero-grid,
    .entry-grid,
    .detail-columns,
    .closing-grid {
        grid-template-columns: 1fr;
    }

    .hero-tr {
        justify-self: start;
    }

    .entry-tr {
        justify-self: start;
    }

    .entry-br {
        justify-self: start;
        margin-top: 1rem;
    }

    .closing-tr {
        grid-column: 1;
        grid-row: 1;
    }

    .closing-bl {
        grid-column: 1;
        grid-row: 2;
    }

    .pull-quote {
        margin-left: 0;
        padding-left: clamp(1rem, 3vw, 2rem);
    }

    .primary-statement {
        font-size: clamp(2rem, 5vw, 3.2rem);
    }

    .breath-text {
        font-size: clamp(1.2rem, 2.5vw, 2rem);
    }

    .thumbnail {
        width: clamp(120px, 18vw, 160px);
        height: clamp(80px, 10vw, 110px);
    }
}

/* ============================================
   Responsive: Mobile (480px)
   Single column, bleed 5-10px past right edge
   ============================================ */

@media (max-width: 480px) {
    .plate {
        padding: 0 clamp(1rem, 3vw, 1.5rem);
    }

    /* Deliberate right-side bleed for "peering through a window" effect */
    .works-stream,
    .detail-plate {
        margin-right: -8px;
    }

    .hero-grid {
        min-height: 70vh;
        gap: 1.5rem 1rem;
    }

    .primary-statement {
        font-size: 2rem;
        line-height: 1.2;
    }

    .entry-grid {
        gap: 0.75rem 1rem;
    }

    .entry-title {
        font-size: 1.3rem;
    }

    .thumbnail {
        width: 100px;
        height: 70px;
    }

    .detail-columns {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .pull-quote {
        padding-left: 1rem;
    }

    .closing-plate {
        min-height: auto;
        padding-top: 2rem;
        padding-bottom: 2rem;
    }

    .closing-grid {
        min-height: auto;
    }

    .breath-text {
        font-size: clamp(1rem, 2vw, 1.5rem);
    }

    .wordmark {
        font-size: 0.75rem;
    }
}
