
/* Color palette per DESIGN.md */
:root {
    --ivory-parchment: #F6F1E7;
    --warm-vellum: #EDE4D3;
    --deep-walnut: #2E1F14;
    --sepia-ink: #6B5443;
    --antiquarian-gold: #C9A96E;
    --angelfish-cyan: #00E5D4;
    --discus-magenta: #FF3D8A;
    --tetra-electric: #7BFF4F;
    --abyssal-umber: #1A120B;
}

/* ========================================
   miris.tech — Light-Academia Research Aquarium
   ======================================== */

/* Parchment Texture via SVG Filter */
@keyframes glow-pulse {
    0%, 100% { filter: drop-shadow(0px 0px 12px var(--glow-color)); }
    50% { filter: drop-shadow(0px 0px 28px var(--glow-color)); }
}

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

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

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

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

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

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

body {
    font-family: 'Source Serif 4', Georgia, serif;
    color: #2E1F14;
    background-color: #F6F1E7;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractal' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ---- Typography ---- */
h1, h2 {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 900;
    color: #2E1F14;
    letter-spacing: -0.03em;
    line-height: 0.92;
}

h1 {
    font-size: clamp(4.5rem, 11vw, 12rem);
}

h2 {
    font-size: clamp(2.5rem, 5vw, 5rem);
    font-weight: 700;
}

p {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-size: clamp(1.05rem, 1.3vw, 1.25rem);
    line-height: 1.75;
    letter-spacing: 0.01em;
    color: #2E1F14;
}

.specimen-label,
.archive-text {
    font-family: 'Special Elite', 'Courier New', monospace;
    font-weight: 400;
    font-size: clamp(0.85rem, 1.1vw, 1rem);
    line-height: 1.6;
    letter-spacing: 0.04em;
    color: #6B5443;
}

/* ---- Gallery Base ---- */
.gallery {
    min-height: 100vh;
    position: relative;
    overflow: hidden;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(16, 1fr);
    gap: clamp(24px, 3vw, 48px);
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 clamp(16px, 2vw, 32px);
    min-height: 100vh;
}

/* ---- Gold Filigree Rule ---- */
.gold-rule {
    width: 100%;
    height: 1px;
    background: linear-gradient(to right, transparent 0%, #C9A96E 20%, #C9A96E 80%, transparent 100%);
    position: absolute;
    bottom: 0;
    left: 0;
}

/* ==============================
   Gallery 1: The Foyer
   ============================== */
.gallery-foyer {
    height: 100vh;
}

.gallery-foyer .gallery-grid {
    align-content: start;
    min-height: 100vh;
}

.foyer-headline {
    grid-column: 2 / 8;
    padding-top: 15vh;
    align-self: start;
}

.foyer-subtitle {
    margin-top: 2rem;
    font-style: italic;
    color: #6B5443;
    font-size: clamp(1rem, 1.3vw, 1.2rem);
}

.fade-in {
    opacity: 0;
    animation: fadeIn 1.5s ease-out 1.5s forwards;
}

.foyer-fish {
    grid-column: 10 / 16;
    align-self: end;
    justify-self: center;
    padding-bottom: 15vh;
    position: relative;
}

/* ---- Fish Glow Halos ---- */
.fish-halo {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    pointer-events: none;
}

.fish-halo--cyan {
    width: 400px;
    height: 440px;
    background: radial-gradient(circle, rgba(0, 229, 212, 0.25) 0%, transparent 70%);
}

.fish-halo--magenta {
    width: 440px;
    height: 360px;
    background: radial-gradient(circle, rgba(255, 61, 138, 0.25) 0%, transparent 70%);
}

.fish-halo--green {
    width: 400px;
    height: 200px;
    background: radial-gradient(circle, rgba(123, 255, 79, 0.25) 0%, transparent 70%);
}

.fish-halo--dual {
    width: 480px;
    height: 400px;
    background: radial-gradient(circle, rgba(0, 229, 212, 0.15) 0%, rgba(255, 61, 138, 0.1) 40%, transparent 70%);
}

/* ---- Fish Specimens ---- */
.fish-specimen {
    display: block;
    position: relative;
    z-index: 1;
    --glow-color: rgba(0, 229, 212, 0.6);
    animation: glow-pulse 4s ease-in-out infinite;
}

.fish-float {
    animation: glow-pulse 4s ease-in-out infinite, float 6s ease-in-out infinite;
}

.specimen-1 .fish-specimen {
    --glow-color: rgba(255, 61, 138, 0.6);
}

.specimen-2 .fish-specimen {
    --glow-color: rgba(123, 255, 79, 0.6);
}

.specimen-3 .fish-specimen {
    --glow-color: rgba(0, 229, 212, 0.4);
}

.specimen-display {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ==============================
   Gallery 2: The Reading Room
   ============================== */
.gallery-reading {
    background-color: #EDE4D3;
}

.gallery-reading .gallery-grid {
    align-content: start;
}

.reading-block-1 {
    grid-column: 2 / 7;
    padding-top: 20vh;
}

.reading-block-2 {
    grid-column: 9 / 15;
    padding-top: 40vh;
}

/* ---- Scroll Reveal ---- */
.scroll-reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.scroll-reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ==============================
   Gallery 3: The Specimen Wall
   ============================== */
.gallery-specimens {
    min-height: 100vh;
}

.gallery-specimens .gallery-grid {
    align-content: start;
    padding-top: 10vh;
    padding-bottom: 10vh;
}

.specimen {
    position: relative;
}

.specimen-1 {
    grid-column: 2 / 8;
    margin-top: 12vh;
}

.specimen-2 {
    grid-column: 7 / 13;
    margin-top: 8vh;
}

.specimen-3 {
    grid-column: 10 / 16;
    margin-top: 18vh;
}

.specimen-label {
    text-align: center;
    margin-top: 1.5rem;
    min-height: 1.6em;
}

/* ---- Typewriter ---- */
.typewriter-cursor {
    animation: blink 530ms step-end infinite;
    color: #6B5443;
    font-family: 'Special Elite', 'Courier New', monospace;
}

.typewriter-cursor.fade-out {
    animation: cursorFadeOut 0.5s ease-out forwards;
}

.typewriter-cursor.hidden {
    display: none;
}

/* ==============================
   Gallery 4: The Archive
   ============================== */
.gallery-archive .gallery-grid {
    align-items: center;
    justify-items: center;
}

.archive-block {
    grid-column: 3 / 14;
    text-align: center;
}

.archive-text {
    font-size: clamp(0.95rem, 1.2vw, 1.1rem);
    line-height: 1.8;
    min-height: 6em;
}

/* Ink splatter decoration */
.archive-block::before {
    content: '';
    position: absolute;
    top: -20px;
    left: 10%;
    width: 80%;
    height: calc(100% + 40px);
    background-image:
        radial-gradient(circle 2px, rgba(107, 84, 67, 0.3) 100%, transparent 100%),
        radial-gradient(circle 1.5px, rgba(107, 84, 67, 0.2) 100%, transparent 100%),
        radial-gradient(circle 3px, rgba(107, 84, 67, 0.15) 100%, transparent 100%),
        radial-gradient(circle 1px, rgba(107, 84, 67, 0.25) 100%, transparent 100%),
        radial-gradient(circle 2px, rgba(107, 84, 67, 0.2) 100%, transparent 100%);
    background-position: 12% 8%, 78% 15%, 45% 92%, 88% 45%, 22% 70%;
    background-repeat: no-repeat;
    background-size: 4px 4px, 3px 3px, 6px 6px, 2px 2px, 4px 4px;
    pointer-events: none;
    z-index: 0;
}

.archive-block {
    position: relative;
}

/* ==============================
   Gallery 5: The Closing
   ============================== */
.gallery-closing {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.ghost-koi-bg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60vw;
    max-width: 900px;
    opacity: 0.3;
    pointer-events: none;
}

.fish-ghost-koi {
    width: 100%;
    height: auto;
}

.closing-content {
    position: relative;
    z-index: 1;
    text-align: center;
}

.closing-title {
    font-size: clamp(6rem, 12vw, 14rem);
    font-weight: 900;
    letter-spacing: -0.03em;
    line-height: 0.92;
}

.closing-rule {
    width: 200px;
    height: 1px;
    background-color: #C9A96E;
    margin: 4rem auto 0;
}

.closing-tagline {
    margin-top: 2rem;
    font-family: 'Source Serif 4', Georgia, serif;
    font-style: italic;
    font-size: clamp(0.9rem, 1.1vw, 1.05rem);
    color: #6B5443;
}

/* ==============================
   Reduced Motion
   ============================== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .scroll-reveal {
        opacity: 1;
        transform: none;
    }

    .fade-in {
        opacity: 1;
    }
}

/* ==============================
   Responsive
   ============================== */
@media (max-width: 1024px) {
    .gallery-grid {
        grid-template-columns: repeat(12, 1fr);
    }

    .foyer-headline {
        grid-column: 1 / 8;
    }

    .foyer-fish {
        grid-column: 8 / 13;
    }

    .reading-block-1 {
        grid-column: 1 / 7;
    }

    .reading-block-2 {
        grid-column: 6 / 13;
        padding-top: 25vh;
    }

    .specimen-1 {
        grid-column: 1 / 7;
    }

    .specimen-2 {
        grid-column: 4 / 10;
    }

    .specimen-3 {
        grid-column: 7 / 13;
    }

    .archive-block {
        grid-column: 2 / 12;
    }
}

@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(8, 1fr);
        gap: 16px;
    }

    .foyer-headline {
        grid-column: 1 / 7;
        padding-top: 12vh;
    }

    .foyer-fish {
        grid-column: 3 / 8;
        padding-bottom: 8vh;
    }

    .foyer-fish .fish-halo--cyan {
        width: 250px;
        height: 275px;
    }

    .foyer-fish .fish-specimen {
        width: 140px;
        height: auto;
    }

    .reading-block-1 {
        grid-column: 1 / 8;
    }

    .reading-block-2 {
        grid-column: 1 / 8;
        padding-top: 8vh;
    }

    .specimen-1,
    .specimen-2,
    .specimen-3 {
        grid-column: 1 / 9;
        margin-top: 8vh;
    }

    .specimen-display svg {
        max-width: 180px;
        height: auto;
    }

    .archive-block {
        grid-column: 1 / 9;
    }

    .closing-title {
        font-size: clamp(3rem, 14vw, 6rem);
    }

    .ghost-koi-bg {
        width: 85vw;
    }

    .fish-halo--magenta,
    .fish-halo--green,
    .fish-halo--dual {
        width: 280px;
        height: 280px;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: clamp(3rem, 14vw, 5rem);
    }

    .foyer-headline {
        grid-column: 1 / 9;
    }

    .foyer-fish {
        grid-column: 2 / 8;
    }
}
