/* ============================================================
   bada.news — Deep-sea observatory / celestial reading room
   Palette: ethereal-blue · Typography: variable-fluid serifs
   Motif: star-celestial · Pattern: skeleton-loading
   Compliance tokens from DESIGN.md: IntersectionObserver fallback 100px rootMargin trigger → (Google
   ============================================================ */

:root {
    /* --- Color system (exact hexes from DESIGN.md) --- */
    --abyssal-ink: #060d1a;
    --mesopelagic: #0e1f3d;
    --bathypelagic: #0a1428;
    --dawn-mist: #e8f4fd;
    --bone-light: #d8e2ec;
    --deep-graphite: #1a2332;
    --cyan: #5bc4d6;
    --phosphor: #4de8b0;
    --kelp: #d4a853;
    --vent: #e85c5c;
    --celestial-veil: #1a3a5c;

    /* --- Active zone (driven by JS / scroll) --- */
    --zone-bg: var(--dawn-mist);
    --zone-text: var(--deep-graphite);
    --zone-text-soft: rgba(26, 35, 50, 0.72);
    --zone-accent: var(--cyan);
    --zone-accent-secondary: var(--phosphor);
    --zone-skeleton: rgba(26, 58, 92, 0.28);
    --zone-skeleton-shimmer: rgba(91, 196, 214, 0.32);
    --zone-line-height: 1.72;

    /* --- Easing --- */
    --ease-sink: cubic-bezier(0.25, 0.46, 0.45, 0.94);

    /* --- Layout --- */
    --col-width: min(92vw, 720px);
    --col-gap: clamp(3rem, 8vh, 6rem);
}

/* Zone overrides --------------------------------------------------- */
.zone-epi {
    --zone-bg: #e8f4fd;
    --zone-text: #1a2332;
    --zone-text-soft: rgba(26, 35, 50, 0.7);
    --zone-accent: #0e1f3d;
    --zone-accent-secondary: #5bc4d6;
    --zone-skeleton: rgba(26, 58, 92, 0.18);
    --zone-skeleton-shimmer: rgba(91, 196, 214, 0.35);
    --zone-line-height: 1.7;
}

.zone-meso {
    --zone-bg: #0e1f3d;
    --zone-text: #d8e2ec;
    --zone-text-soft: rgba(216, 226, 236, 0.72);
    --zone-accent: #5bc4d6;
    --zone-accent-secondary: #4de8b0;
    --zone-skeleton: rgba(26, 58, 92, 0.55);
    --zone-skeleton-shimmer: rgba(91, 196, 214, 0.28);
    --zone-line-height: 1.75;
}

.zone-bathy {
    --zone-bg: #0a1428;
    --zone-text: #d8e2ec;
    --zone-text-soft: rgba(216, 226, 236, 0.68);
    --zone-accent: #5bc4d6;
    --zone-accent-secondary: #4de8b0;
    --zone-skeleton: rgba(26, 58, 92, 0.7);
    --zone-skeleton-shimmer: rgba(91, 196, 214, 0.25);
    --zone-line-height: 1.8;
}

.zone-abysso {
    --zone-bg: #060d1a;
    --zone-text: #d8e2ec;
    --zone-text-soft: rgba(216, 226, 236, 0.65);
    --zone-accent: #5bc4d6;
    --zone-accent-secondary: #4de8b0;
    --zone-skeleton: rgba(26, 58, 92, 0.82);
    --zone-skeleton-shimmer: rgba(77, 232, 176, 0.22);
    --zone-line-height: 1.85;
}

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

html { scroll-behavior: smooth; }

body {
    background: var(--abyssal-ink);
    color: var(--bone-light);
    font-family: 'Source Serif 4', 'Lora', Georgia, serif;
    font-size: clamp(1rem, calc(1.15vw + 0.5rem), 1.2rem);
    line-height: 1.78;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;

    /* Continuous gradient from epipelagic mist -> abyssal ink.
       Sections paint their own tint on top for the zone feel. */
    background:
        linear-gradient(
            180deg,
            #e8f4fd 0%,
            #d8e9f5 9%,
            #8fb4d6 17%,
            #3b6ea3 26%,
            #1a3a5c 36%,
            #0e1f3d 50%,
            #0a1428 72%,
            #060d1a 100%
        );
    background-attachment: fixed;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--zone-accent-secondary); }

::selection { background: var(--cyan); color: var(--abyssal-ink); }

/* Utility: monospace metadata -------------------------------------- */
.mono {
    font-family: 'DM Mono', 'Space Mono', ui-monospace, Menlo, monospace;
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--zone-accent);
    font-weight: 400;
}

/* Background canvases --------------------------------------------- */
.bg-canvas {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 0;
}
.bg-canvas--stars { z-index: 0; }
.bg-canvas--currents { z-index: 1; mix-blend-mode: screen; opacity: 0.75; }
.bg-canvas--constellations { z-index: 2; overflow: visible; }

.bg-canvas--constellations line {
    stroke: var(--cyan);
    stroke-width: 0.5;
    opacity: 0;
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    animation: constellation-draw 0.8s var(--ease-sink) forwards,
               constellation-fade 3s ease-out 0.8s forwards;
}
@keyframes constellation-draw {
    to { stroke-dashoffset: 0; opacity: 0.35; }
}
@keyframes constellation-fade {
    from { opacity: 0.35; }
    to   { opacity: 0; }
}

/* Depth rail (scroll indicator) ------------------------------------ */
.depth-rail {
    position: fixed;
    top: 0;
    left: 14px;
    bottom: 0;
    width: 2px;
    z-index: 10;
    pointer-events: none;
}
.depth-rail__track {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        180deg,
        rgba(91, 196, 214, 0.05),
        rgba(91, 196, 214, 0.2) 40%,
        rgba(77, 232, 176, 0.4) 100%
    );
}
.depth-rail__glow {
    position: absolute;
    top: 0;
    left: -3px;
    width: 8px;
    height: 0;
    background: linear-gradient(
        180deg,
        transparent,
        rgba(91, 196, 214, 0.35),
        rgba(77, 232, 176, 0.55)
    );
    filter: blur(4px);
    transition: height 0.2s linear;
}
.depth-rail__marks {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    pointer-events: none;
}
.depth-rail__mark {
    position: relative;
    width: 8px;
    height: 1px;
    background: var(--cyan);
    opacity: 0.45;
    margin-left: -3px;
}
.depth-rail__mark::after {
    content: attr(data-depth);
    position: absolute;
    left: 14px;
    top: -6px;
    font-family: 'DM Mono', ui-monospace, monospace;
    font-size: 0.6rem;
    letter-spacing: 0.15em;
    color: var(--cyan);
    opacity: 0.55;
}

/* Depth readout (top-left) ---------------------------------------- */
.depth-readout {
    position: fixed;
    top: 24px;
    left: 40px;
    z-index: 12;
    display: grid;
    grid-template-columns: auto auto;
    gap: 4px 12px;
    font-family: 'DM Mono', ui-monospace, monospace;
    font-size: 0.65rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    padding: 10px 14px;
    background: rgba(6, 13, 26, 0.35);
    border: 1px solid rgba(91, 196, 214, 0.25);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: var(--cyan);
    transition: color 800ms var(--ease-sink), border-color 800ms var(--ease-sink);
}
.depth-readout__label { opacity: 0.55; }
.depth-readout__value, .depth-readout__zone {
    color: var(--phosphor);
    font-weight: 500;
}

/* Radial nav ------------------------------------------------------- */
.radial-nav {
    position: fixed;
    right: 32px;
    bottom: 32px;
    z-index: 20;
    width: 64px;
    height: 64px;
}
.radial-toggle {
    all: unset;
    cursor: pointer;
    width: 64px;
    height: 64px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: rgba(6, 13, 26, 0.65);
    border: 1px solid rgba(91, 196, 214, 0.45);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: transform 600ms var(--ease-sink),
                box-shadow 600ms var(--ease-sink);
    box-shadow: 0 0 18px rgba(91, 196, 214, 0.2);
}
.radial-toggle:hover {
    box-shadow: 0 0 28px rgba(77, 232, 176, 0.45);
}
.radial-toggle__glyph {
    width: 44px;
    height: 44px;
    animation: glyph-rotate 90s linear infinite;
}
.glyph-ring {
    fill: none;
    stroke: var(--cyan);
    stroke-width: 0.6;
    opacity: 0.7;
}
.glyph-ring--inner { stroke-dasharray: 2 3; opacity: 0.5; }
.glyph-core { fill: var(--phosphor); }
.glyph-points path {
    fill: var(--cyan);
    opacity: 0.9;
}
@keyframes glyph-rotate {
    to { transform: rotate(360deg); transform-origin: center; }
}

.radial-nav__items {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 64px;
    height: 64px;
    list-style: none;
    pointer-events: none;
}
.radial-nav__item {
    position: absolute;
    right: 8px;
    bottom: 8px;
    width: 150px;
    padding: 10px 14px;
    background: rgba(6, 13, 26, 0.8);
    border: 1px solid rgba(91, 196, 214, 0.35);
    color: var(--bone-light);
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-family: 'Source Serif 4', Lora, Georgia, serif;
    font-size: 0.95rem;
    opacity: 0;
    transform: translate(0, 0) scale(0.8);
    transition: opacity 500ms var(--ease-sink),
                transform 600ms var(--ease-sink);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    pointer-events: none;
}
.radial-nav__item:hover {
    border-color: var(--phosphor);
    color: var(--phosphor);
}
.radial-nav__depth {
    font-family: 'DM Mono', ui-monospace, monospace;
    font-size: 0.6rem;
    letter-spacing: 0.15em;
    color: var(--cyan);
    text-transform: uppercase;
}
.radial-nav__name {
    font-style: italic;
}

.radial-nav.is-open .radial-nav__items { pointer-events: auto; }
.radial-nav.is-open .radial-nav__item {
    opacity: 1;
    pointer-events: auto;
}
.radial-nav.is-open li:nth-child(1) .radial-nav__item { transform: translate(0, -80px); }
.radial-nav.is-open li:nth-child(2) .radial-nav__item { transform: translate(0, -150px); }
.radial-nav.is-open li:nth-child(3) .radial-nav__item { transform: translate(0, -220px); }
.radial-nav.is-open li:nth-child(4) .radial-nav__item { transform: translate(0, -290px); }

.radial-nav.is-open .radial-toggle {
    transform: rotate(45deg);
    box-shadow: 0 0 32px rgba(77, 232, 176, 0.5);
}

/* Shell ----------------------------------------------------------- */
.shell {
    position: relative;
    z-index: 5;
    width: 100%;
    padding-bottom: 0;
}

/* Masthead -------------------------------------------------------- */
.masthead {
    min-height: 100vh;
    width: var(--col-width);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: clamp(3rem, 10vh, 8rem) 0;
    color: var(--deep-graphite);
    position: relative;
    text-align: left;
}
.masthead__meta {
    display: flex;
    gap: 1.6rem;
    flex-wrap: wrap;
    color: #0e1f3d;
    margin-bottom: clamp(3rem, 9vh, 6rem);
    opacity: 0.8;
}
.masthead__meta .mono, .masthead .mono { color: #0e1f3d; }

.masthead__wordmark {
    font-family: 'Instrument Serif', 'Lora', Georgia, serif;
    font-weight: 400;
    font-size: clamp(3rem, 10vw, 7rem);
    line-height: 0.95;
    letter-spacing: -0.01em;
    color: var(--deep-graphite);
    display: flex;
    align-items: baseline;
    gap: 0.15em;
    transition: font-variation-settings 800ms var(--ease-sink);
}
.masthead__wordmark:hover {
    font-variation-settings: "wght" 500;
}
.wordmark__ko {
    font-weight: 400;
    font-style: normal;
}
.wordmark__dot {
    color: var(--cyan);
    font-size: 0.7em;
    position: relative;
    top: -0.25em;
}
.wordmark__news {
    font-style: italic;
    font-weight: 400;
    color: #0e1f3d;
}

.masthead__tagline {
    font-family: 'Instrument Serif', 'Lora', Georgia, serif;
    font-style: italic;
    font-size: clamp(1.15rem, 1.6vw + 0.4rem, 1.6rem);
    color: rgba(26, 35, 50, 0.75);
    line-height: 1.5;
    max-width: 34em;
    margin-top: clamp(1.5rem, 4vh, 2.5rem);
}

.masthead__dots {
    margin-top: clamp(3rem, 10vh, 6rem);
    color: #0e1f3d;
    font-size: 0.95rem;
    letter-spacing: 0.6em;
    opacity: 0.7;
}

.masthead__descend {
    position: absolute;
    bottom: clamp(2rem, 6vh, 4rem);
    left: 0;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    color: #0e1f3d;
    opacity: 0.7;
}
.arrow-down {
    display: inline-block;
    width: 1px;
    height: 48px;
    background: linear-gradient(180deg, #0e1f3d, transparent);
    position: relative;
    animation: descend-pulse 4s var(--ease-sink) infinite;
}
.arrow-down::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: -3px;
    width: 7px;
    height: 7px;
    border-right: 1px solid #0e1f3d;
    border-bottom: 1px solid #0e1f3d;
    transform: rotate(45deg);
}
@keyframes descend-pulse {
    0%, 100% { opacity: 0.3; transform: translateY(0); }
    50%      { opacity: 0.9; transform: translateY(8px); }
}

/* Zone sections --------------------------------------------------- */
.zone {
    width: var(--col-width);
    margin: 0 auto;
    padding: clamp(4rem, 14vh, 10rem) 0 clamp(3rem, 9vh, 6rem);
    position: relative;
    color: var(--zone-text);
    transition: color 900ms var(--ease-sink);
}

/* Thin bioluminescent zone-boundary line */
.zone::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(91, 196, 214, 0.4) 30%,
        rgba(77, 232, 176, 0.5) 50%,
        rgba(91, 196, 214, 0.4) 70%,
        transparent
    );
    animation: boundary-pulse 6s ease-in-out infinite;
}
@keyframes boundary-pulse {
    0%, 100% { opacity: 0.25; }
    50%      { opacity: 0.9; }
}

.zone__header {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: clamp(3rem, 8vh, 5rem);
}
.zone__constellation {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.zone__constellation svg {
    width: 200px;
    height: 120px;
    flex-shrink: 0;
}
.constellation-lines line {
    stroke: var(--zone-accent);
    stroke-width: 0.6;
    opacity: 0.45;
}
.constellation-stars circle {
    fill: var(--zone-accent-secondary);
    filter: drop-shadow(0 0 3px var(--zone-accent-secondary));
    animation: twinkle 4s ease-in-out infinite;
}
.constellation-stars circle:nth-child(2) { animation-delay: 0.8s; }
.constellation-stars circle:nth-child(3) { animation-delay: 1.6s; }
.constellation-stars circle:nth-child(4) { animation-delay: 2.4s; }
.constellation-stars circle:nth-child(5) { animation-delay: 3.2s; }
@keyframes twinkle {
    0%, 100% { opacity: 0.5; }
    50%      { opacity: 1; }
}
.zone__constellation-label {
    font-size: 0.65rem;
    opacity: 0.65;
}

.zone__title-block {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.zone__depth {
    font-size: 0.7rem;
    opacity: 0.8;
}
.zone__title {
    font-family: 'Instrument Serif', 'Lora', Georgia, serif;
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    font-weight: 400;
    line-height: 1;
    letter-spacing: -0.02em;
    color: var(--zone-text);
    margin-top: 0.3rem;
    transition: font-variation-settings 800ms var(--ease-sink), color 800ms var(--ease-sink);
}
.zone__title:hover { font-variation-settings: "wght" 500; }
.zone__subtitle {
    font-family: 'Instrument Serif', 'Lora', Georgia, serif;
    font-style: italic;
    font-size: clamp(1rem, 1.2vw + 0.4rem, 1.3rem);
    color: var(--zone-text-soft);
    margin-top: 0.25rem;
}

/* Articles --------------------------------------------------------- */
.piece {
    padding: clamp(1.5rem, 4vh, 3rem) 0;
    border-top: 1px solid rgba(91, 196, 214, 0.12);
    position: relative;
    transition: color 800ms var(--ease-sink);
}
.piece:first-of-type { border-top: none; }

.piece__flag {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.9rem;
    color: var(--zone-accent);
}
.dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
    background: var(--cyan);
    box-shadow: 0 0 6px currentColor;
}
.dot--alert { background: var(--vent); color: var(--vent); animation: alert-pulse 1.8s ease-in-out infinite; }
.dot--featured { background: var(--kelp); color: var(--kelp); }
@keyframes alert-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50%      { transform: scale(1.35); opacity: 0.65; }
}

.piece__headline {
    font-family: 'Instrument Serif', 'Lora', Georgia, serif;
    font-weight: 400;
    font-size: clamp(1.75rem, 4.5vw, 3.5rem);
    line-height: 1.05;
    letter-spacing: -0.015em;
    margin-bottom: 1.1rem;
    color: var(--zone-text);
    transition: font-variation-settings 800ms var(--ease-sink);
}
.piece__headline:hover { font-variation-settings: "wght" 500; }

.piece__headline a {
    background-image: linear-gradient(currentColor, currentColor);
    background-size: 0% 1px;
    background-repeat: no-repeat;
    background-position: 0 100%;
    transition: background-size 700ms var(--ease-sink), color 500ms var(--ease-sink);
    padding-bottom: 4px;
}
.piece__headline a:hover {
    color: var(--zone-accent-secondary);
    background-size: 100% 1px;
}

.piece__body {
    font-family: 'Source Serif 4', Lora, Georgia, serif;
    font-size: clamp(1rem, 1.15vw + 0.5rem, 1.2rem);
    line-height: var(--zone-line-height);
    color: var(--zone-text);
    opacity: 0.92;
    margin-bottom: 1rem;
    max-width: 38em;
}
.piece__body em {
    font-style: italic;
    color: var(--zone-accent);
}

.piece__meta {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    margin-top: 1.2rem;
    color: var(--zone-accent);
    opacity: 0.85;
}
.piece__meta span { white-space: nowrap; }

.piece--lead .piece__headline { font-size: clamp(2.2rem, 5.5vw, 4rem); }
.piece--featured { padding: clamp(2rem, 6vh, 4rem) 0; }
.piece--featured .piece__headline { color: var(--zone-text); }
.piece--deep .piece__headline { font-size: clamp(2rem, 5vw, 3.8rem); }
.piece--archive .piece__headline { font-style: italic; }
.piece--reflection { opacity: 0.92; }

.zone__divider {
    text-align: center;
    margin-top: clamp(3rem, 8vh, 5rem);
    font-size: 1.2rem;
    letter-spacing: 0.8em;
    color: var(--zone-accent);
    opacity: 0.55;
}

/* Skeleton loading ------------------------------------------------- */
[data-reveal] {
    position: relative;
}
[data-reveal].is-skeleton .piece__flag,
[data-reveal].is-skeleton .piece__headline,
[data-reveal].is-skeleton .piece__body,
[data-reveal].is-skeleton .piece__meta {
    color: transparent !important;
    background: linear-gradient(
        90deg,
        var(--zone-skeleton) 0%,
        var(--zone-skeleton-shimmer) 50%,
        var(--zone-skeleton) 100%
    );
    background-size: 200% 100%;
    background-repeat: no-repeat;
    border-radius: 2px;
    animation: shimmer 1.5s linear infinite;
    user-select: none;
}
[data-reveal].is-skeleton .piece__flag { display: inline-block; min-height: 0.8em; }
[data-reveal].is-skeleton .piece__headline { border-radius: 4px; }
[data-reveal].is-skeleton .piece__headline a { color: transparent; background: none; }
[data-reveal].is-skeleton .piece__body { min-height: 4em; }
[data-reveal].is-skeleton .piece__meta { display: inline-block; min-height: 0.9em; min-width: 10em; }
[data-reveal].is-skeleton .dot { background: transparent; box-shadow: none; }

[data-reveal].is-resolving .piece__flag,
[data-reveal].is-resolving .piece__headline,
[data-reveal].is-resolving .piece__body,
[data-reveal].is-resolving .piece__meta {
    animation: shimmer 1.5s linear infinite, resolve-fade 300ms var(--ease-sink) forwards;
}

[data-reveal] {
    opacity: 0;
    transform: translateY(18px);
    transition: opacity 700ms var(--ease-sink), transform 900ms var(--ease-sink);
}
[data-reveal].is-visible {
    opacity: 1;
    transform: translateY(0);
}

@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
@keyframes resolve-fade {
    to { background: none; animation: none; color: inherit !important; }
}

/* Abyss footer ---------------------------------------------------- */
.abyss-footer {
    padding: clamp(4rem, 12vh, 8rem) 0 clamp(4rem, 10vh, 6rem);
    text-align: center;
    color: var(--zone-text);
    display: flex;
    flex-direction: column;
    gap: 1.4rem;
    align-items: center;
}
.abyss-footer__coords {
    color: var(--cyan);
    opacity: 0.75;
    letter-spacing: 0.18em;
}
.abyss-footer__note {
    font-family: 'Instrument Serif', 'Lora', Georgia, serif;
    font-style: italic;
    font-size: clamp(1.1rem, 1.5vw + 0.4rem, 1.5rem);
    max-width: 28em;
    color: rgba(216, 226, 236, 0.75);
    line-height: 1.55;
}
.abyss-footer__logo {
    font-family: 'Instrument Serif', 'Lora', Georgia, serif;
    font-size: 2rem;
    color: var(--bone-light);
    display: flex;
    align-items: baseline;
    gap: 0.15em;
}
.abyss-footer__legal {
    font-size: 0.6rem;
    letter-spacing: 0.22em;
    color: rgba(91, 196, 214, 0.55);
    margin-top: 1.2rem;
}

/* Responsive ------------------------------------------------------- */
@media (max-width: 640px) {
    .depth-readout { top: 14px; left: 30px; font-size: 0.55rem; padding: 8px 10px; }
    .depth-rail { left: 8px; }
    .depth-rail__mark::after { font-size: 0.52rem; }
    .radial-nav { right: 16px; bottom: 16px; }
    .zone__constellation { flex-direction: column; align-items: flex-start; gap: 0.6rem; }
    .zone__constellation svg { width: 160px; height: 96px; }
    .masthead__descend { position: static; margin-top: 3rem; }
}

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