/* =============================================
   memorial.wiki - Styles
   Cottagecore Elegiac / High-Contrast Memorial
   ============================================= */

/* --- CSS Custom Properties --- */
:root {
    /* Backgrounds */
    --crypt-dark: #1a1a1a;
    --weathered-ivory: #f0ebe3;
    --void: #0d0d0d;
    --pure-black: #000000;

    /* Accents */
    --tarnished-gold: #c9a96e;
    --oxidized-copper: #7a9e7e;

    /* Text */
    --parchment: #d4cbbf;
    --charcoal-depth: #2a2520;
    --aged-silver: #8a8279;

    /* Highlight */
    --candlelight: #e8c87a;

    /* Ornament */
    --iron-gate: #4a443d;
    --lichen-green: #6b7c62;

    /* Typography */
    --font-mono: 'Share Tech Mono', monospace;
    --font-serif: 'Lora', serif;
    --font-sans: 'Space Grotesk', sans-serif;
}

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

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    background-color: var(--crypt-dark);
    color: var(--parchment);
    font-family: var(--font-serif);
    font-size: clamp(1rem, 1.4vw, 1.25rem);
    line-height: 1.75;
    overflow-x: hidden;
}

/* --- Grain Overlay --- */
.grain-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.15;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
    background-size: 200px 200px;
    background-repeat: repeat;
}

/* Reduce grain on light sections via a local override */
.stone-light .grain-overlay-local {
    opacity: 0.08;
}

/* --- THE GATE (Hero) --- */
.gate {
    position: relative;
    width: 100%;
    height: 100vh;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--crypt-dark);
    overflow: hidden;
}

.gate::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.15;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
    background-size: 200px 200px;
    background-repeat: repeat;
    z-index: 1;
}

/* Interlocking Circles Background */
.circles-bg {
    position: absolute;
    width: 150vmin;
    height: 150vmin;
    left: 70%;
    top: 40%;
    transform: translate(-50%, -50%);
    z-index: 0;
    fill: none;
    stroke: var(--iron-gate);
    stroke-width: 0.5;
    opacity: 0.08;
}

/* Gate Content */
.gate-content {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 0 2rem;
}

.gate-title {
    font-family: var(--font-mono);
    font-size: clamp(2.5rem, 7vw, 6rem);
    font-weight: 400;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--tarnished-gold);
    display: inline-block;
}

.gate-title .char {
    display: inline-block;
    opacity: 0;
    min-width: 0.65em;
}

.gate-title .char.revealed {
    opacity: 1;
}

.gate-title .char.animating {
    color: var(--candlelight);
}

.gate-title .dot {
    min-width: 0.35em;
}

/* Gate Horizontal Line */
.gate-line {
    width: 60vw;
    max-width: 60vw;
    height: 1px;
    background-color: var(--tarnished-gold);
    opacity: 0;
    margin: 1.5rem auto;
    transform: scaleX(0);
    transform-origin: center;
    transition: none;
}

.gate-line.animate {
    opacity: 0.4;
    transform: scaleX(1);
    transition: transform 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 0.3s ease;
}

/* Gate Tagline */
.gate-tagline {
    font-family: var(--font-serif);
    font-size: clamp(0.95rem, 1.3vw, 1.15rem);
    font-style: italic;
    color: var(--parchment);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.gate-tagline.animate {
    opacity: 1;
    transform: translateY(0);
}

/* --- THE PATH (Narrative Body) --- */
.path {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--crypt-dark);
    padding: 6rem 2rem;
}

.path::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.15;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
    background-size: 200px 200px;
    background-repeat: repeat;
    z-index: 1;
}

.path-content {
    position: relative;
    z-index: 2;
    max-width: 65ch;
    width: 100%;
}

.body-text {
    font-family: var(--font-serif);
    font-size: clamp(1rem, 1.4vw, 1.25rem);
    line-height: 1.75;
    color: var(--parchment);
    margin-bottom: 3rem;
}

/* Epitaph Block */
.epitaph-block {
    text-align: center;
    margin: 3rem 0;
    position: relative;
    z-index: 2;
}

.epitaph-text {
    font-family: var(--font-serif);
    font-size: clamp(1rem, 1.4vw, 1.25rem);
    line-height: 1.75;
    color: var(--parchment);
    font-style: italic;
    padding: 1.5rem 0;
}

.epitaph-text-dark {
    color: var(--charcoal-depth);
}

/* --- ORNAMENT GENERAL --- */
.ornament {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
    will-change: opacity, transform;
}

.ornament.visible {
    opacity: 1;
    transform: translateY(0);
}

.ornament.done {
    will-change: auto;
}

/* Diamond Lattice */
.diamond-lattice {
    width: 100%;
    overflow: hidden;
    padding: 0.5rem 0;
}

.diamond-lattice svg {
    width: 100%;
    height: 40px;
    display: block;
    fill: none;
    stroke: var(--iron-gate);
    stroke-width: 0.5;
}

.diamond-lattice svg rect {
    fill: none;
    stroke: var(--iron-gate);
    stroke-width: 0.5;
}

.diamond-lattice svg pattern rect {
    fill: none;
    stroke: var(--iron-gate);
    stroke-width: 0.5;
}

.diamond-lattice.visible {
    opacity: 0.3;
}

.full-bleed-divider {
    position: relative;
    z-index: 2;
}

/* Crosshatch Border */
.crosshatch-border {
    width: 100%;
    max-width: 30ch;
    margin: 0 auto;
    height: 4px;
}

.crosshatch-border svg {
    width: 100%;
    height: 4px;
    display: block;
    stroke: var(--aged-silver);
    stroke-width: 0.5;
}

.crosshatch-border.visible {
    opacity: 0.5;
}

.crosshatch-light svg {
    stroke: var(--lichen-green);
}

/* Honeycomb Fragment */
.honeycomb-fragment {
    position: absolute;
    width: 200px;
    height: 200px;
    fill: none;
    stroke: var(--tarnished-gold);
    stroke-width: 0.75;
    z-index: 0;
}

.honeycomb-fragment.visible {
    opacity: 0.15;
}

.honeycomb-tr {
    top: 2rem;
    right: 2rem;
}

.honeycomb-bl {
    bottom: 2rem;
    left: 2rem;
}

/* --- THE STONES (Memorial Feature Blocks) --- */
.stone {
    position: relative;
    width: 100%;
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6rem 2rem;
    overflow: hidden;
}

.stone::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
    background-size: 200px 200px;
    background-repeat: repeat;
    z-index: 1;
}

.stone-dark {
    background-color: var(--crypt-dark);
}

.stone-dark::after {
    opacity: 0.25;
}

.stone-light {
    background-color: var(--weathered-ivory);
}

.stone-light::after {
    opacity: 0.08;
}

.stone-content {
    position: relative;
    z-index: 2;
    max-width: 65ch;
    width: 100%;
}

.stone-heading {
    font-family: var(--font-mono);
    font-size: clamp(1.4rem, 3vw, 2.5rem);
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--bone-white, #e8e0d4);
    margin-bottom: 0.75rem;
}

.stone-heading-dark {
    color: var(--charcoal-depth);
}

.stone-date {
    font-family: var(--font-mono);
    font-size: clamp(0.9rem, 1.2vw, 1.1rem);
    letter-spacing: 0.08em;
    color: var(--aged-silver);
    margin-bottom: 2rem;
}

.stone-date-dark {
    color: var(--charcoal-depth);
    opacity: 0.7;
}

.date-sep {
    margin: 0 0.5em;
    color: var(--tarnished-gold);
    opacity: 0.5;
}

.stone-body {
    font-family: var(--font-serif);
    font-size: clamp(1rem, 1.4vw, 1.25rem);
    line-height: 1.75;
    color: var(--parchment);
    margin-bottom: 2.5rem;
}

.stone-body-dark {
    color: var(--charcoal-depth);
}

/* Counter-animate numbers */
.counter-num {
    display: inline-block;
    position: relative;
    min-width: 0.65em;
    text-align: center;
}

.counter-num.animating {
    color: var(--candlelight);
}

/* --- Links --- */
a {
    color: var(--oxidized-copper);
    text-decoration: none;
    background-image: linear-gradient(var(--oxidized-copper), var(--oxidized-copper));
    background-size: 0% 1px;
    background-position: left bottom;
    background-repeat: no-repeat;
    transition: background-size 0.3s ease;
}

a:hover {
    background-size: 100% 1px;
}

/* --- THE HORIZON (Footer) --- */
.horizon {
    position: relative;
    width: 100%;
    min-height: 50vh;
    background: linear-gradient(to bottom, var(--crypt-dark) 0%, var(--void) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding: 4rem 2rem 2rem;
    overflow: hidden;
}

.horizon::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.15;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
    background-size: 200px 200px;
    background-repeat: repeat;
    z-index: 1;
}

/* Lattice Strips */
.lattice-strip {
    width: 100%;
    position: relative;
    z-index: 2;
    margin-bottom: 1rem;
}

.lattice-strip svg {
    width: 100%;
    height: 30px;
    display: block;
    fill: none;
    stroke: var(--iron-gate);
    stroke-width: 0.5;
}

.lattice-strip svg pattern rect {
    fill: none;
    stroke: var(--iron-gate);
    stroke-width: 0.5;
}

.lattice-1.visible { opacity: 0.1; }
.lattice-2.visible { opacity: 0.15; }
.lattice-3.visible { opacity: 0.2; }
.lattice-4.visible { opacity: 0.25; }

.horizon-text {
    position: relative;
    z-index: 2;
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 300;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--aged-silver);
    opacity: 0.6;
    margin-top: auto;
    padding-top: 4rem;
    padding-bottom: 1rem;
}

/* --- Selection --- */
::selection {
    background-color: var(--tarnished-gold);
    color: var(--crypt-dark);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .honeycomb-fragment {
        width: 120px;
        height: 120px;
    }

    .honeycomb-tr {
        top: 1rem;
        right: 1rem;
    }

    .honeycomb-bl {
        bottom: 1rem;
        left: 1rem;
    }

    .gate-title {
        letter-spacing: 0.08em;
    }

    .gate-line {
        width: 80vw;
        max-width: 80vw;
    }

    .stone {
        padding: 4rem 1.5rem;
    }
}

@media (max-width: 480px) {
    .honeycomb-fragment {
        display: none;
    }
}
