/* =============================================================
   aiice.dev — Glacial Wonderland
   Crystallographic spatial logic + AI + ICE + Alice
   ============================================================= */

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

:root {
    /* Palette — exact from DESIGN.md */
    --bg-glacial:     #e8edf2;   /* Glacial White */
    --bg-deep:        #0b1628;   /* Midnight Frost */
    --accent-crystal: #4da8da;   /* Crystal Blue */
    --accent-violet:  #7b6fa6;   /* Violet Frost */
    --accent-mint:    #a3d9c8;   /* Aurora Mint */
    --accent-gold:    #c9a84c;   /* Refraction Gold */
    --text-primary:   #1a2332;   /* Ink Frost */
    --text-secondary: #6b7d8e;   /* Breath Grey */
    --border-ice:     #b8c6d4;   /* Ice Edge */

    --serif-display: 'Cormorant Garamond', 'Lora', Georgia, serif;
    --serif-body:    'Alegreya', 'Lora', Georgia, serif;
    --sans-tech:     'IBM Plex Sans', 'Inter', system-ui, sans-serif;
    --mono:          'Fira Code', 'Space Mono', ui-monospace, monospace;
}

html { scroll-behavior: smooth; }

body {
    min-height: 100vh;
    font-family: var(--serif-body);
    color: var(--text-primary);
    background: var(--bg-glacial);
    overflow-x: hidden;
    position: relative;
    line-height: 1.6;
}

/* =============================================================
   PAGE-LEVEL GLACIAL DEPTH GRADIENT (descent into deep ice)
   ============================================================= */
.glacial-depth {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -3;
    background:
        linear-gradient(180deg,
            #e8edf2 0%,
            #b8c6d4 40%,
            #4da8da 70%,
            #0b1628 100%);
}

/* Hex grid backdrop — barely-visible 5% pattern */
.hex-grid {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -2;
    opacity: 0.06;
    background-image:
        radial-gradient(circle at 50% 50%, var(--text-primary) 1px, transparent 1.5px);
    background-size: 60px 52px;
    background-position: 0 0, 30px 26px;
    mask-image: linear-gradient(180deg, transparent 0%, #000 20%, #000 80%, transparent 100%);
}

/* =============================================================
   FALLING PARTICLES (snow + data points)
   ============================================================= */
.particles {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}
.particle {
    position: absolute;
    top: -10px;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: rgba(232, 237, 242, 0.85);
    box-shadow: 0 0 6px rgba(163, 217, 200, 0.4);
    animation: drift 18s linear infinite;
    opacity: 0.7;
}
@keyframes drift {
    0%   { transform: translate3d(0, -10vh, 0) scale(0.6); opacity: 0; }
    10%  { opacity: 0.8; }
    90%  { opacity: 0.6; }
    100% { transform: translate3d(20px, 110vh, 0) scale(1); opacity: 0; }
}
@keyframes drift-slow {
    0%   { transform: translate3d(0, -10vh, 0) scale(0.4); opacity: 0; }
    20%  { opacity: 0.5; }
    80%  { opacity: 0.4; }
    100% { transform: translate3d(-30px, 110vh, 0) scale(0.9); opacity: 0; }
}

/* Distribute 30 particles across the viewport with varied delays/speeds */
.p1  { left: 4%;  width: 2px; height: 2px; animation: drift 22s linear infinite; animation-delay: -0s;   }
.p2  { left: 9%;  animation-delay: -2s;  animation-duration: 16s; }
.p3  { left: 13%; width: 4px; height: 4px; animation: drift-slow 24s linear infinite; animation-delay: -5s;  }
.p4  { left: 17%; animation-delay: -8s;  animation-duration: 19s; }
.p5  { left: 22%; width: 2px; height: 2px; animation-delay: -1s;  animation-duration: 14s; }
.p6  { left: 26%; animation-delay: -11s; animation-duration: 21s; }
.p7  { left: 30%; width: 4px; height: 4px; animation: drift-slow 26s linear infinite; animation-delay: -3s;  }
.p8  { left: 34%; animation-delay: -7s;  animation-duration: 17s; }
.p9  { left: 38%; width: 2px; height: 2px; animation-delay: -13s; animation-duration: 20s; }
.p10 { left: 42%; animation-delay: -4s;  animation-duration: 18s; }
.p11 { left: 46%; width: 3px; height: 3px; animation: drift-slow 23s linear infinite; animation-delay: -9s; }
.p12 { left: 50%; animation-delay: -15s; animation-duration: 16s; }
.p13 { left: 54%; width: 2px; height: 2px; animation-delay: -6s;  animation-duration: 22s; }
.p14 { left: 58%; animation-delay: -10s; animation-duration: 19s; }
.p15 { left: 62%; width: 4px; height: 4px; animation: drift-slow 25s linear infinite; animation-delay: -2s; }
.p16 { left: 66%; animation-delay: -12s; animation-duration: 17s; }
.p17 { left: 70%; width: 2px; height: 2px; animation-delay: -14s; animation-duration: 21s; }
.p18 { left: 74%; animation-delay: -3s;  animation-duration: 14s; }
.p19 { left: 78%; width: 3px; height: 3px; animation: drift-slow 27s linear infinite; animation-delay: -8s; }
.p20 { left: 81%; animation-delay: -1s;  animation-duration: 18s; }
.p21 { left: 84%; width: 2px; height: 2px; animation-delay: -16s; animation-duration: 20s; }
.p22 { left: 87%; animation-delay: -5s;  animation-duration: 15s; }
.p23 { left: 90%; width: 4px; height: 4px; animation: drift-slow 24s linear infinite; animation-delay: -11s;}
.p24 { left: 93%; animation-delay: -7s;  animation-duration: 19s; }
.p25 { left: 96%; width: 2px; height: 2px; animation-delay: -2s;  animation-duration: 22s; }
.p26 { left: 6%;  width: 3px; height: 3px; animation-delay: -17s; animation-duration: 16s; }
.p27 { left: 19%; width: 2px; height: 2px; animation-delay: -13s; animation-duration: 18s; }
.p28 { left: 44%; width: 3px; height: 3px; animation-delay: -6s;  animation-duration: 23s; }
.p29 { left: 68%; width: 4px; height: 4px; animation: drift-slow 25s linear infinite; animation-delay: -10s;}
.p30 { left: 88%; width: 2px; height: 2px; animation-delay: -4s;  animation-duration: 17s; }

/* =============================================================
   DEPTH GAUGE NAV
   ============================================================= */
.depth-gauge {
    position: fixed;
    top: 50%;
    right: 28px;
    transform: translateY(-50%);
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 22px;
    padding: 20px 0;
}
.gauge-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: linear-gradient(180deg,
        transparent,
        var(--border-ice) 15%,
        var(--accent-crystal) 50%,
        var(--accent-violet) 85%,
        transparent);
    opacity: 0.5;
}
.gauge-marker {
    position: relative;
    width: 14px;
    height: 14px;
    background: var(--bg-glacial);
    border: 1px solid var(--border-ice);
    clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
    cursor: pointer;
    transition: transform 0.4s ease, background 0.4s ease, border-color 0.4s ease;
}
.gauge-marker.active {
    background: var(--accent-crystal);
    border-color: var(--accent-mint);
    transform: scale(1.4);
    box-shadow: 0 0 12px rgba(77, 168, 218, 0.7);
}
.gauge-marker:hover { transform: scale(1.3); background: var(--accent-mint); }
.gauge-marker::after {
    content: attr(data-label);
    position: absolute;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    font-family: var(--sans-tech);
    font-size: 0.7rem;
    font-weight: 300;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-secondary);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}
.gauge-marker:hover::after,
.gauge-marker.active::after {
    opacity: 1;
    transform: translateY(-50%) translateX(-4px);
    color: var(--text-primary);
}

/* =============================================================
   STRATA — base
   ============================================================= */
.looking-glass-stack { position: relative; z-index: 2; }

.stratum {
    position: relative;
    min-height: 100vh;
    padding: 12vh 8vw;
    display: flex;
    align-items: center;
    isolation: isolate;
}
.stratum-inner {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    position: relative;
}
.stratum-label {
    font-family: var(--sans-tech);
    font-weight: 300;
    font-size: 0.72rem;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 1.2rem;
}
.stratum-title {
    font-family: var(--serif-display);
    font-weight: 400;
    font-size: clamp(2.5rem, 6vw, 7rem);
    line-height: 0.95;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-primary);
    margin-bottom: 3rem;
}
.stratum-title em {
    font-style: italic;
    font-weight: 300;
    color: var(--accent-violet);
    letter-spacing: 0.08em;
    text-transform: lowercase;
}

/* =============================================================
   STRATUM 0 — THE SURFACE
   ============================================================= */
.stratum-0 {
    background: linear-gradient(180deg,
        #f0f4f8 0%,
        #e8edf2 60%,
        rgba(184, 198, 212, 0.6) 100%);
    text-align: center;
}
.surface-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    padding-top: 4vh;
}
.hero-crystal {
    position: relative;
    width: clamp(280px, 50vw, 520px);
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.crystal-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
}
.crystal-rotor {
    transform-origin: 0 0;
    animation: rotate-crystal 60s linear infinite;
}
@keyframes rotate-crystal {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}
.crystal-shell, .crystal-inner {
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
    animation: draw-shell 3s ease-out 0.2s forwards;
}
.crystal-inner {
    animation-delay: 1.2s;
    animation-duration: 2.4s;
}
@keyframes draw-shell {
    to { stroke-dashoffset: 0; }
}
.facet-line, .core-line {
    stroke-dasharray: 80;
    stroke-dashoffset: 80;
    animation: draw-shell 1.6s ease-out forwards;
}
.facet-line { animation-delay: 1.8s; }
.core-line  { animation-delay: 2.4s; }
.dendrites line {
    stroke-dasharray: 40;
    stroke-dashoffset: 40;
    animation: draw-shell 1.2s ease-out 3s forwards;
}
.crystal-core {
    transform-origin: 0 0;
    animation: pulse-core 4s ease-in-out 3.2s infinite both;
    opacity: 0;
}
@keyframes pulse-core {
    0%, 100% { opacity: 0.55; transform: scale(1); }
    50%      { opacity: 0.95; transform: scale(1.15); }
}

.wordmark {
    position: relative;
    font-family: var(--serif-display);
    font-weight: 500;
    font-size: clamp(2.2rem, 6vw, 5rem);
    letter-spacing: 0.42em;
    text-transform: uppercase;
    color: var(--text-primary);
    z-index: 2;
    user-select: none;
    text-shadow: 0 0 40px rgba(232, 237, 242, 0.85),
                 0 0 80px rgba(232, 237, 242, 0.6);
    margin-left: 0.4em;       /* compensate letter-spacing */
}
.wordmark .char {
    display: inline-block;
    opacity: 0;
    filter: blur(14px);
    transform: scale(1.6);
    animation: frost-in 0.55s cubic-bezier(.2,.7,.3,1) forwards;
    animation-delay: calc(0.6s + var(--i) * 0.18s);
}
@keyframes frost-in {
    0%   { opacity: 0; filter: blur(14px); transform: scale(1.6); }
    60%  { opacity: 1; filter: blur(2px); transform: scale(1.05); }
    100% { opacity: 1; filter: blur(0);  transform: scale(1); }
}
.tld {
    position: relative;
    z-index: 2;
    font-family: var(--sans-tech);
    font-weight: 300;
    font-size: 0.95rem;
    letter-spacing: 0.5em;
    text-transform: lowercase;
    color: var(--accent-crystal);
    margin-top: 0.3rem;
    opacity: 0;
    animation: fade-up 1s ease-out 2.4s forwards;
}
.tld-dev { color: var(--accent-violet); }
@keyframes fade-up {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.surface-whisper {
    position: relative;
    font-family: var(--serif-body);
    font-style: italic;
    font-size: clamp(1rem, 1.4vw, 1.2rem);
    color: var(--text-secondary);
    margin-top: 1.5rem;
    max-width: 540px;
    min-height: 1.6em;
}
.surface-whisper.typewriter::before {
    content: attr(data-text);
    display: inline;
    background: linear-gradient(90deg,
        var(--text-primary) 0%,
        var(--text-primary) var(--tw-pos, 0%),
        transparent var(--tw-pos, 0%));
    -webkit-background-clip: text;
            background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    transition: --tw-pos 6s linear;
}
.surface-whisper.typewriter.run::before { --tw-pos: 100%; }
@property --tw-pos {
    syntax: '<percentage>';
    initial-value: 0%;
    inherits: false;
}
.surface-whisper.typewriter::after {
    content: '|';
    margin-left: 2px;
    color: var(--accent-crystal);
    animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.descend-prompt {
    position: relative;
    margin-top: 4rem;
    height: 80px;
    width: 30px;
}
.descend-particle {
    position: absolute;
    left: 50%;
    top: 0;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--accent-crystal);
    box-shadow: 0 0 8px var(--accent-crystal);
    transform: translateX(-50%);
    animation: descend-fall 2.6s ease-in-out infinite;
}
.descend-particle:nth-child(2) { animation-delay: 0.7s; }
.descend-particle:nth-child(3) { animation-delay: 1.4s; }
@keyframes descend-fall {
    0%   { top: 0;   opacity: 0; }
    20%  { opacity: 1; }
    80%  { opacity: 0.7; }
    100% { top: 60px; opacity: 0; }
}
.descend-label {
    position: absolute;
    top: 86px;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--sans-tech);
    font-weight: 300;
    font-size: 0.65rem;
    letter-spacing: 0.4em;
    text-transform: uppercase;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* =============================================================
   PARALLAX TRANSITION ZONES
   ============================================================= */
.parallax-zone {
    position: relative;
    height: 30vh;
    overflow: hidden;
    pointer-events: none;
}
.parallax-layer {
    position: absolute;
    inset: -10% 0;
    background-repeat: repeat;
    opacity: 0.18;
}
.parallax-layer.pl-1 {
    background-image:
        linear-gradient(60deg,  transparent 47%, rgba(123,111,166,0.4) 50%, transparent 53%),
        linear-gradient(-60deg, transparent 47%, rgba(77,168,218,0.4) 50%, transparent 53%);
    background-size: 80px 138px;
    transform: translateY(0);
    animation: pl-drift-1 22s linear infinite;
}
.parallax-layer.pl-2 {
    background-image:
        linear-gradient(60deg,  transparent 48%, rgba(163,217,200,0.5) 50%, transparent 52%),
        linear-gradient(-60deg, transparent 48%, rgba(184,198,212,0.5) 50%, transparent 52%);
    background-size: 120px 208px;
    opacity: 0.13;
    animation: pl-drift-2 30s linear infinite;
}
.parallax-layer.pl-3 {
    background-image:
        radial-gradient(circle at 50% 50%, rgba(77,168,218,0.4) 1px, transparent 2px);
    background-size: 50px 50px;
    opacity: 0.2;
    animation: pl-drift-3 18s linear infinite;
}
@keyframes pl-drift-1 { from { background-position: 0 0; }   to { background-position: 80px 138px; } }
@keyframes pl-drift-2 { from { background-position: 0 0; }   to { background-position: -120px 208px; } }
@keyframes pl-drift-3 { from { background-position: 0 0; }   to { background-position: 50px 50px; } }

/* =============================================================
   STRATUM 1 — THE FRACTURE
   ============================================================= */
.stratum-1 {
    background: linear-gradient(180deg,
        rgba(184, 198, 212, 0.4) 0%,
        rgba(123, 111, 166, 0.18) 100%);
}
.fracture-inner {
    display: grid;
    gap: 3rem;
}
.fracture-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-auto-rows: minmax(180px, auto);
    gap: 1.5rem;
    position: relative;
}
/* Fracture lines as SVG-less decorative overlay */
.fracture-grid::before,
.fracture-grid::after {
    content: '';
    position: absolute;
    background: linear-gradient(90deg, transparent, var(--accent-violet), transparent);
    height: 1px;
    width: 60%;
    pointer-events: none;
    opacity: 0.45;
}
.fracture-grid::before {
    top: 25%;
    left: -10%;
    transform: rotate(-8deg);
}
.fracture-grid::after {
    bottom: 18%;
    right: -10%;
    transform: rotate(7deg);
}

.frost-pane {
    background: rgba(232, 237, 242, 0.55);
    backdrop-filter: blur(16px) saturate(0.85) brightness(1.05);
    -webkit-backdrop-filter: blur(16px) saturate(0.85) brightness(1.05);
    border: 1px solid var(--border-ice);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.55),
        0 18px 40px -20px rgba(11, 22, 40, 0.18);
    padding: 2.2rem 2rem;
    position: relative;
    background-image: linear-gradient(135deg,
        rgba(77, 168, 218, 0.08) 0%,
        rgba(123, 111, 166, 0.04) 50%,
        rgba(163, 217, 200, 0.08) 100%);
    transition: transform 0.6s cubic-bezier(.2,.7,.3,1), box-shadow 0.6s ease;
}
.frost-pane:hover {
    transform: translateY(-4px);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.7),
        0 30px 56px -20px rgba(11, 22, 40, 0.28);
}
.frost-pane h3 {
    font-family: var(--serif-display);
    font-weight: 500;
    font-size: clamp(1.4rem, 2vw, 2rem);
    letter-spacing: 0.04em;
    color: var(--text-primary);
    margin: 0.6rem 0 0.8rem;
}
.frost-pane p {
    font-family: var(--serif-body);
    font-size: 1.05rem;
    line-height: 1.75;
    color: var(--text-primary);
    opacity: 0.85;
}
.pane-meta {
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--accent-crystal);
    letter-spacing: 0.1em;
    margin-bottom: 0.4rem;
}
.pane-tag {
    display: inline-block;
    margin-top: 1rem;
    font-family: var(--sans-tech);
    font-size: 0.62rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--accent-violet);
    padding: 4px 10px;
    border: 1px solid var(--border-ice);
    border-radius: 999px;
    background: rgba(232, 237, 242, 0.5);
}

/* Trapezoidal clip paths for shattered ice panes */
.pane-a {
    grid-column: 1 / span 6;
    grid-row: 1;
    clip-path: polygon(0 0, 100% 4%, 96% 100%, 4% 96%);
    transform: rotate(-1.2deg);
}
.pane-b {
    grid-column: 7 / span 6;
    grid-row: 1;
    clip-path: polygon(4% 0, 100% 0, 100% 96%, 0 100%);
    transform: rotate(1deg);
    margin-top: 30px;
}
.pane-c {
    grid-column: 2 / span 6;
    grid-row: 2;
    clip-path: polygon(0 4%, 96% 0, 100% 100%, 4% 96%);
    transform: rotate(0.8deg);
    margin-top: -10px;
}
.pane-d {
    grid-column: 7 / span 5;
    grid-row: 2;
    clip-path: polygon(4% 0, 100% 4%, 100% 100%, 0 96%);
    transform: rotate(-0.8deg);
    margin-top: 40px;
}

.ai-whisper {
    margin-top: 1.5rem;
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--accent-violet);
    opacity: 0.7;
    letter-spacing: 0.04em;
}
.ai-whisper code {
    color: var(--accent-crystal);
    background: rgba(77, 168, 218, 0.08);
    padding: 2px 8px;
    border-radius: 3px;
}
.whisper-prefix { color: var(--accent-mint); margin-right: 0.4em; }

/* =============================================================
   STRATUM 2 — THE CHAMBER (ma negative-space)
   ============================================================= */
.stratum-2 {
    background: linear-gradient(180deg,
        rgba(77, 168, 218, 0.35) 0%,
        rgba(11, 22, 40, 0.45) 100%);
    color: #e8edf2;
    overflow: hidden;
}
.chamber-inner {
    padding: 4vh 4vw;
    position: relative;
}
.stratum-2 .stratum-label { color: rgba(232, 237, 242, 0.6); }
.chamber-title { color: #f3f6fa; }
.chamber-content {
    max-width: 1100px;
    margin: 0 auto;
    position: relative;
}
.lead-quote {
    font-family: var(--serif-display);
    font-style: italic;
    font-weight: 300;
    font-size: clamp(1.6rem, 3vw, 2.6rem);
    line-height: 1.3;
    letter-spacing: 0.01em;
    color: rgba(232, 237, 242, 0.95);
    max-width: 680px;
    margin: 4rem 0 6rem 8%;
    border-left: 1px solid var(--accent-mint);
    padding-left: 2rem;
}
.chamber-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 2.5rem;
    margin: 5rem 0;
    position: relative;
}
/* Hidden hexagonal grid revealed on hover (chamber) */
.chamber-grid::before {
    content: '';
    position: absolute;
    inset: -40px;
    background-image:
        linear-gradient(60deg,  transparent 49%, var(--accent-mint) 50%, transparent 51%),
        linear-gradient(-60deg, transparent 49%, var(--accent-mint) 50%, transparent 51%);
    background-size: 80px 138px;
    opacity: 0;
    transition: opacity 0.8s ease;
    pointer-events: none;
}
.chamber-grid:hover::before { opacity: 0.06; }

.chamber-cell {
    padding: 2rem;
    background: rgba(11, 22, 40, 0.35);
    backdrop-filter: blur(14px) brightness(1.05);
    -webkit-backdrop-filter: blur(14px) brightness(1.05);
    border: 1px solid rgba(184, 198, 212, 0.18);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.chamber-cell p {
    font-family: var(--serif-body);
    font-size: 1.05rem;
    line-height: 1.85;
    color: rgba(232, 237, 242, 0.92);
}
.cell-meta {
    font-family: var(--mono);
    font-size: 0.7rem;
    letter-spacing: 0.22em;
    color: var(--accent-mint);
    margin-bottom: 0.8rem;
    opacity: 0.85;
}
.offset-1 { grid-column: 1 / span 4; }
.offset-2 { grid-column: 6 / span 4; transform: translateY(60px); }
.offset-3 { grid-column: 9 / span 4; transform: translateY(-30px); }

.tenniel-divider {
    width: 100%;
    max-width: 800px;
    margin: 5rem auto 2rem;
    display: block;
}
.tenniel-divider .td-path {
    stroke-dasharray: 1500;
    stroke-dashoffset: 1500;
}
.tenniel-divider.in-view .td-path {
    animation: draw-divider 2.4s ease-out forwards;
}
.tenniel-divider .td-node {
    opacity: 0;
}
.tenniel-divider.in-view .td-node {
    animation: node-pop 0.5s ease-out forwards;
    animation-delay: 1.8s;
}
.tenniel-divider .td-hex {
    transform-origin: 400px 26px;
    transform-box: fill-box;
    opacity: 0;
}
.tenniel-divider.in-view .td-hex {
    animation: node-pop 0.6s ease-out 2.2s forwards, slow-spin 30s linear 2.8s infinite;
}
@keyframes draw-divider { to { stroke-dashoffset: 0; } }
@keyframes node-pop { from { opacity: 0; transform: scale(0.3); } to { opacity: 1; transform: scale(1); } }
@keyframes slow-spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }

/* Looking-glass reflection */
.reflection {
    margin-top: 5rem;
    text-align: left;
    position: relative;
    height: 70px;
    overflow: hidden;
}
.reflection span {
    display: block;
    font-family: var(--serif-display);
    font-style: italic;
    font-size: clamp(1.4rem, 2.4vw, 2.2rem);
    letter-spacing: 0.08em;
    color: rgba(232, 237, 242, 0.4);
    transform: scaleY(-1);
    filter: blur(0.5px);
    -webkit-mask-image: linear-gradient(180deg, transparent 0%, rgba(0,0,0,0.7) 70%, #000 100%);
            mask-image: linear-gradient(180deg, transparent 0%, rgba(0,0,0,0.7) 70%, #000 100%);
}

/* =============================================================
   STRATUM 3 — THE CORE
   ============================================================= */
.stratum-3 {
    background: var(--bg-deep);
    color: #e8edf2;
    overflow: hidden;
}
.core-inner {
    position: relative;
    z-index: 2;
}
.stratum-3 .stratum-label,
.core-label { color: rgba(163, 217, 200, 0.7); }
.core-title {
    color: #f3f6fa;
    text-shadow: 0 0 32px rgba(77, 168, 218, 0.25);
}

/* Neural frost backdrop */
.neural-frost {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.6;
}
.nf-edge {
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
    animation: nf-breathe 6s ease-in-out infinite;
}
.nf-edge:nth-child(1)  { animation-delay: -0.0s; }
.nf-edge:nth-child(2)  { animation-delay: -0.4s; }
.nf-edge:nth-child(3)  { animation-delay: -0.8s; }
.nf-edge:nth-child(4)  { animation-delay: -1.2s; }
.nf-edge:nth-child(5)  { animation-delay: -1.6s; }
.nf-edge:nth-child(6)  { animation-delay: -2.0s; }
.nf-edge:nth-child(7)  { animation-delay: -2.4s; }
.nf-edge:nth-child(8)  { animation-delay: -2.8s; }
.nf-edge:nth-child(9)  { animation-delay: -3.2s; }
.nf-edge:nth-child(10) { animation-delay: -3.6s; }
.nf-edge:nth-child(11) { animation-delay: -4.0s; }
.nf-edge:nth-child(12) { animation-delay: -4.4s; }
.nf-edge:nth-child(13) { animation-delay: -4.8s; }
.nf-edge:nth-child(14) { animation-delay: -5.2s; }
.nf-edge:nth-child(15) { animation-delay: -5.6s; }
.nf-edge:nth-child(16) { animation-delay: -6.0s; }
@keyframes nf-breathe {
    0%, 100% { stroke-dashoffset: 400; opacity: 0.1; }
    50%      { stroke-dashoffset: 0;   opacity: 0.45; }
}
.nf-node {
    transform-origin: center;
    transform-box: fill-box;
    animation: nf-pulse 4s ease-in-out infinite;
}
.nf-node:nth-child(odd)  { animation-delay: -1.5s; }
.nf-node:nth-child(even) { animation-delay: -3s;   }
@keyframes nf-pulse {
    0%, 100% { opacity: 0.2; transform: scale(1); }
    50%      { opacity: 0.6; transform: scale(1.4); }
}

/* Masonry */
.masonry {
    margin-top: 3rem;
    column-count: 3;
    column-gap: 1.4rem;
    position: relative;
    z-index: 2;
}
@media (max-width: 980px) { .masonry { column-count: 2; } }
@media (max-width: 640px) { .masonry { column-count: 1; } }

.card {
    break-inside: avoid;
    margin-bottom: 1.4rem;
    perspective: 1200px;
    position: relative;
    transform-style: preserve-3d;
    height: 280px;
}
.card.card-tall { height: 360px; }
.card.card-wide { height: 240px; }

.card-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    padding: 1.6rem 1.4rem;
    border: 1px solid rgba(184, 198, 212, 0.22);
    background: rgba(26, 35, 50, 0.55);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
    display: flex;
    flex-direction: column;
    transition: transform 0.7s cubic-bezier(.6,.05,.2,1);
    transform-style: preserve-3d;
}
.card-back {
    transform: rotateY(0deg);
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 50% 50%, rgba(77,168,218,0.12), transparent 70%),
        rgba(11, 22, 40, 0.6);
}
.card-back svg { width: 60%; height: auto; opacity: 0.7; }
.card-front {
    transform: rotateY(180deg);
}
.card.flipped .card-back  { transform: rotateY(-180deg); }
.card.flipped .card-front { transform: rotateY(0deg); }

.card h4 {
    font-family: var(--serif-display);
    font-weight: 500;
    font-size: 1.5rem;
    letter-spacing: 0.04em;
    color: #f3f6fa;
    margin-bottom: 0.7rem;
}
.card p {
    font-family: var(--serif-body);
    font-size: 0.98rem;
    line-height: 1.7;
    color: rgba(232, 237, 242, 0.84);
}
.card-meta {
    font-family: var(--mono);
    font-size: 0.68rem;
    letter-spacing: 0.18em;
    color: var(--accent-mint);
    margin-bottom: 0.5rem;
}
.card-snippet {
    margin-top: auto;
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--accent-crystal);
    opacity: 0.8;
}
.card-snippet code {
    background: rgba(77, 168, 218, 0.08);
    padding: 4px 8px;
    border-radius: 3px;
    border: 1px solid rgba(77, 168, 218, 0.2);
}

.tenniel-flourish {
    width: 100%;
    max-width: 600px;
    margin: 5rem auto 2rem;
    display: block;
}
.tenniel-flourish .tf-path {
    stroke-dasharray: 1400;
    stroke-dashoffset: 1400;
}
.tenniel-flourish.in-view .tf-path {
    animation: draw-divider 2.6s ease-out forwards;
}
.tenniel-flourish .tf-hex {
    opacity: 0;
    transform-box: fill-box;
    transform-origin: 300px 38px;
}
.tenniel-flourish.in-view .tf-hex {
    animation: node-pop 0.7s ease-out 2s forwards, slow-spin 28s linear 2.7s infinite;
}

.core-footer {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(184, 198, 212, 0.15);
    text-align: center;
}
.footer-mark {
    font-family: var(--serif-display);
    font-weight: 500;
    font-size: 1.6rem;
    letter-spacing: 0.4em;
    text-transform: uppercase;
    color: #f3f6fa;
}
.footer-mark .dot {
    color: var(--accent-gold);
    text-shadow: 0 0 14px rgba(201, 168, 76, 0.5);
}
.footer-line {
    font-family: var(--serif-body);
    font-style: italic;
    color: rgba(232, 237, 242, 0.65);
    margin-top: 0.7rem;
    font-size: 0.95rem;
}
.footer-meta {
    font-family: var(--mono);
    font-size: 0.7rem;
    letter-spacing: 0.18em;
    color: rgba(163, 217, 200, 0.6);
    margin-top: 1rem;
}

/* =============================================================
   CHESHIRE GRIN — pure CSS easter egg, materializes on idle
   (body gets .idle class via JS-free dwell using animation chain)
   ============================================================= */
.cheshire-grin {
    position: fixed;
    bottom: 22vh;
    right: 16vw;
    width: 90px;
    height: 90px;
    pointer-events: none;
    z-index: 3;
    opacity: 0;
    transform: rotate(20deg);
    animation: cheshire-cycle 28s ease-in-out infinite;
}
.cheshire-grin::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border-bottom: 2px solid var(--accent-gold);
    border-right: 2px solid var(--accent-gold);
    box-shadow: 0 0 24px rgba(201, 168, 76, 0.4);
    transform: rotate(45deg) scaleY(0.55);
}
@keyframes cheshire-cycle {
    0%, 60%   { opacity: 0; transform: rotate(20deg) scale(0.9); }
    72%       { opacity: 0.7; transform: rotate(15deg) scale(1); }
    82%       { opacity: 0.45; }
    95%, 100% { opacity: 0; transform: rotate(20deg) scale(0.9); }
}

/* =============================================================
   STRATUM IN-VIEW REVEAL HELPERS
   ============================================================= */
.frost-pane,
.chamber-cell {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 1s ease, transform 1s cubic-bezier(.2,.7,.3,1);
}
.frost-pane.in-view,
.chamber-cell.in-view {
    opacity: 1;
    transform: translateY(0);
}
.chamber-cell.offset-2.in-view { transform: translateY(60px); }
.chamber-cell.offset-3.in-view { transform: translateY(-30px); }

/* =============================================================
   RESPONSIVE — Crystallography compresses
   ============================================================= */
@media (max-width: 880px) {
    .stratum { padding: 12vh 5vw; }
    .stratum-title { font-size: clamp(2rem, 9vw, 4.5rem); }

    .fracture-grid { display: flex; flex-direction: column; gap: 1rem; }
    .pane-a, .pane-b, .pane-c, .pane-d {
        grid-column: auto;
        grid-row: auto;
        margin: 0;
        transform: none;
        clip-path: polygon(0 4%, 100% 0, 100% 96%, 0 100%);
    }
    .fracture-grid::before, .fracture-grid::after { display: none; }

    .chamber-grid { display: flex; flex-direction: column; gap: 1.5rem; }
    .offset-1, .offset-2, .offset-3 { grid-column: auto; transform: none; }
    .lead-quote { margin-left: 0; padding-left: 1.2rem; }

    .depth-gauge {
        top: auto;
        bottom: 18px;
        right: 50%;
        transform: translateX(50%);
        flex-direction: row;
        gap: 18px;
    }
    .gauge-line {
        top: 50%;
        left: 0;
        right: 0;
        bottom: auto;
        height: 1px;
        width: 100%;
        background: linear-gradient(90deg,
            transparent,
            var(--border-ice) 15%,
            var(--accent-crystal) 50%,
            var(--accent-violet) 85%,
            transparent);
    }
    .gauge-marker::after {
        right: auto;
        top: -28px;
        left: 50%;
        transform: translateX(-50%);
    }
    .gauge-marker:hover::after,
    .gauge-marker.active::after {
        transform: translateX(-50%) translateY(-2px);
    }

    /* Reduce particle density on small screens */
    .p2, .p4, .p6, .p8, .p10, .p12, .p14, .p16, .p18, .p20, .p22, .p24, .p26, .p28, .p30 {
        display: none;
    }
}
