:root {
    --abyss: #001219;
    --deep: #023047;
    --mid: #005f73;
    --thermo: #0a9396;
    --bio: #48cae4;
    --surface: #90e0ef;
    --foam: #caf0f8;
    --coral: #e07a5f;
    --font-display: 'Fraunces', serif;
    --font-body: 'Outfit', sans-serif;
    --font-data: 'Martian Mono', monospace;
}

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

body {
    background: var(--deep);
    color: var(--foam);
    font-family: var(--font-body);
    font-weight: 300;
    line-height: 1.6;
    overflow-x: hidden;
    background-image: repeating-radial-gradient(circle, #48cae4 0px, #48cae4 1px, transparent 1px, transparent 24px);
    background-size: 24px 24px;
    background-attachment: fixed;
    opacity: 1;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: var(--deep);
    opacity: 0.94;
    pointer-events: none;
    z-index: -1;
}

/* District base */
.district {
    position: relative;
    width: 100%;
}

/* District I — The Surface */
.district-surface {
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, var(--deep) 0%, var(--mid) 100%);
}

.surface-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.site-title {
    font-family: var(--font-display);
    font-size: clamp(4rem, 10vw, 8rem);
    font-weight: 900;
    font-variation-settings: 'SOFT' 100, 'WONK' 1;
    color: var(--foam);
    letter-spacing: -0.02em;
}

.sparkline-river {
    width: 100%;
    max-width: 900px;
    height: 60px;
}

.sparkline-path {
    stroke: var(--bio);
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    animation: sparkline-drift 12s linear infinite;
}

@keyframes sparkline-drift {
    0% { stroke-dashoffset: 2000; }
    100% { stroke-dashoffset: 0; }
}

.surface-caption {
    font-family: var(--font-body);
    font-size: clamp(0.9rem, 2vw, 1.2rem);
    color: var(--foam);
    opacity: 0.6;
    font-weight: 300;
}

.chevron-down {
    position: absolute;
    bottom: 3rem;
    animation: bounce-down 1.5s ease-in-out infinite;
    opacity: 0;
    animation-delay: 2s;
    animation-fill-mode: forwards;
}

@keyframes bounce-down {
    0%, 100% { transform: translateY(0); opacity: 0.8; }
    50% { transform: translateY(8px); opacity: 1; }
}

/* District II — The Thermocline */
.district-thermocline {
    min-height: 150vh;
    padding: 6rem 2rem;
    background: linear-gradient(180deg, var(--deep) 0%, var(--abyss) 100%);
}

/* District III — The Twilight Market */
.district-twilight {
    min-height: 150vh;
    padding: 6rem 2rem;
    background: var(--abyss);
}

/* District IV — The Abyssal Plain */
.district-abyss {
    min-height: 150vh;
    padding: 8rem 2rem;
    background: var(--abyss);
}

/* District V — The Ascent */
.district-ascent {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem 200px;
    background: linear-gradient(180deg, var(--abyss) 0%, var(--deep) 100%);
}

.ascent-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    max-width: 900px;
    width: 100%;
}

.ascent-domain {
    font-family: var(--font-data);
    font-size: clamp(0.7rem, 1.2vw, 0.85rem);
    color: var(--bio);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.ascent-closing {
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 4vw, 3rem);
    font-weight: 300;
    font-style: italic;
    color: var(--foam);
    opacity: 0.9;
}

/* District headers */
.district-header {
    text-align: center;
    margin-bottom: 4rem;
}

.herald-title {
    font-family: var(--font-display);
    font-size: clamp(2rem, 5vw, 4rem);
    font-weight: 900;
    font-variation-settings: 'SOFT' 100, 'WONK' 1;
    color: var(--foam);
}

/* Block Grid */
.block-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
}

/* Block base */
.block {
    border-radius: 8px 4px 8px 2px;
    padding: 2rem;
    transition: transform 300ms ease, box-shadow 300ms ease;
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 600ms ease-out, transform 600ms ease-out, box-shadow 300ms ease;
}

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

.block:hover {
    transform: scale(1.008);
    box-shadow: 0 8px 32px rgba(0, 180, 216, 0.08);
}

.block.visible:hover {
    transform: translateY(0) scale(1.008);
}

/* Block types */
.data-block {
    background: linear-gradient(135deg, var(--mid) 0%, var(--deep) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.story-block {
    background: var(--deep);
    border: 1px solid rgba(10, 147, 150, 0.2);
    transform: rotate(-0.3deg);
    position: relative;
}

.story-block.visible {
    transform: rotate(-0.3deg) translateY(0);
}

.story-block.visible:hover {
    transform: rotate(-0.3deg) scale(1.008);
}

.story-block p {
    font-family: var(--font-body);
    font-size: clamp(0.95rem, 1.5vw, 1.1rem);
    color: var(--surface);
    line-height: 1.7;
}

.herald-block {
    background: linear-gradient(90deg, var(--thermo) 0%, var(--mid) 50%, var(--thermo) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    position: relative;
    overflow: hidden;
}

.herald-block.seigaiha::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 100%, transparent 68%, var(--thermo) 69%, var(--thermo) 70%, transparent 71%);
    background-size: 40px 40px;
    opacity: 0.08;
}

.herald-text {
    font-family: var(--font-display);
    font-size: clamp(1.2rem, 3vw, 2rem);
    font-weight: 700;
    color: var(--foam);
    position: relative;
    z-index: 1;
}

.void-block {
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 150px;
}

/* Wide blocks */
.block.wide {
    grid-column: span 2;
}

.block.tall {
    grid-row: span 2;
}

/* Data Label */
.data-label {
    font-family: var(--font-data);
    font-size: clamp(0.7rem, 1.2vw, 0.85rem);
    color: var(--bio);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* Depth Gauge */
.depth-gauge {
    width: 120px;
    height: 120px;
    position: relative;
}

.depth-gauge svg {
    width: 100%;
    height: 100%;
}

.depth-gauge .gauge-value {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-data);
    font-size: 1.2rem;
    color: var(--bio);
}

/* Bar Shoals */
.bar-shoals {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bar {
    height: 12px;
    border-radius: 1px 4px 4px 1px;
    width: 0%;
    transition: width 800ms ease-out;
}

.bar:nth-child(1) { background: var(--mid); }
.bar:nth-child(2) { background: var(--thermo); }
.bar:nth-child(3) { background: var(--bio); }
.bar:nth-child(4) { background: var(--surface); }
.bar:nth-child(5) { background: var(--mid); }

.block.visible .bar {
    width: var(--target-width);
}

/* Dot Matrix */
.dot-matrix {
    display: grid;
    gap: 8px;
}

.dot-matrix .dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--bio);
    animation: dot-pulse 3s ease-in-out infinite;
}

@keyframes dot-pulse {
    0%, 100% { opacity: var(--base-opacity); }
    50% { opacity: var(--peak-opacity); }
}

/* Sonar Viz */
.sonar-viz {
    width: 160px;
    height: 160px;
}

.sonar-line {
    stroke: var(--bio);
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
    animation: sparkline-drift 12s linear infinite;
}

/* Abyss specifics */
.abyss-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 3rem;
}

.abyss-story .contemplative {
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    font-weight: 300;
    font-style: italic;
    color: var(--foam);
    line-height: 1.4;
}

/* Circle Stamp */
.circle-stamp {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--coral);
    position: absolute;
    top: 1rem;
    right: 1rem;
    transition: transform 300ms ease;
}

.circle-stamp:hover {
    transform: rotate(15deg);
}

/* Cracked Glaze Lines (via SVG in JS) */
.crack-lines {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

/* Responsive */
@media (max-width: 768px) {
    .block.wide {
        grid-column: span 1;
    }
    .block-grid {
        grid-template-columns: 1fr;
    }
}
