/* ================================================================
   mechanic.stream — a drowned mechanism
   Palette (no pure black, no pure white, no gradient)
   #06141B abyssal-ink   #0E2A33 shelf-shadow   #1B4351 thermocline
   #3E7A85 nereid        #A8C9C2 seafoam-haze   #D9C49A barnacle-gold
   #B85C38 rust-bloom    #F4ECDD page-vellum
   ================================================================ */

:root {
    --abyssal-ink:   #06141B;
    --shelf-shadow:  #0E2A33;
    --thermocline:   #1B4351;
    --nereid:        #3E7A85;
    --seafoam:       #A8C9C2;
    --barnacle-gold: #D9C49A;
    --rust-bloom:    #B85C38;
    --vellum:        #F4ECDD;

    --salt-margin-w: 96px;
    --gutter:        clamp(20px, 5vw, 96px);
    --max-prose:     540px;
    --max-prose-wide:720px;

    --ease-tide:     cubic-bezier(0.36, 0.04, 0.32, 1);
    --ease-breath:   cubic-bezier(0.45, 0.1, 0.4, 1);

    --depth-progress: 0;        /* updated via JS, 0 -> 1 */
    --pressure-flat:  0;        /* 0 = upright, 1 = flat */
    --header-wdth:    78;       /* breathing letter-spacing */
}

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

html {
    background: var(--shelf-shadow);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body {
    font-family: "Spectral", "EB Garamond", Georgia, serif;
    font-weight: 300;
    font-size: 19px;
    line-height: 1.78;
    color: var(--seafoam);
    background: var(--shelf-shadow);
    overflow-x: hidden;
    letter-spacing: 0.005em;
    cursor: crosshair;
    position: relative;
}

/* Persistent silt grain — animated fractal noise overlay */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 60;
    background-image:
        radial-gradient(rgba(168,201,194,0.025) 1px, transparent 1px),
        radial-gradient(rgba(217,196,154,0.018) 1px, transparent 1px);
    background-size: 3px 3px, 7px 7px;
    background-position: 0 0, 1px 2px;
    opacity: 0.65;
    mix-blend-mode: overlay;
    animation: silt-shift 7.2s var(--ease-breath) infinite alternate;
}

/* Settled-silt vignette — denser at edges */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    background:
        radial-gradient(ellipse at center,
            transparent 30%,
            rgba(6, 20, 27, 0.35) 70%,
            rgba(6, 20, 27, 0.7) 100%);
    mix-blend-mode: multiply;
}

@keyframes silt-shift {
    0%   { background-position: 0 0,        1px 2px;     opacity: 0.62; }
    50%  { background-position: 0.4px 0.7px,1.4px 2.6px; opacity: 0.68; }
    100% { background-position: 0.7px 1.1px,1.8px 3.0px; opacity: 0.6;  }
}

.defs-only {
    position: absolute;
    width: 0; height: 0;
    overflow: hidden;
}

/* ================================================================
   BREATHING HEADER — three glyphs only
   ================================================================ */
.breath-header {
    position: fixed;
    top: 28px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: clamp(18px, 3.5vw, 44px);
    z-index: 80;
    padding: 8px 22px;
    color: var(--seafoam);
    background: rgba(14, 42, 51, 0.42);
    backdrop-filter: blur(14px) saturate(0.85);
    -webkit-backdrop-filter: blur(14px) saturate(0.85);
    border: 1px solid rgba(168, 201, 194, 0.08);
    border-radius: 2px;
    transition: padding 1.6s var(--ease-breath), background 2.0s var(--ease-tide);
}

.breath-header .tide-mark,
.breath-header .compass-rose {
    font-family: "Cormorant Garamond", serif;
    font-size: 22px;
    color: var(--nereid);
    line-height: 1;
    transform: translateY(1px);
}

.breath-header .compass-rose {
    color: var(--barnacle-gold);
    opacity: 0.78;
}

.breath-header .brand {
    font-family: "Cormorant Garamond", serif;
    font-style: italic;
    font-weight: 400;
    font-size: 15px;
    letter-spacing: 0.18em;
    color: var(--seafoam);
    font-variation-settings: "wdth" var(--header-wdth);
    transition: font-variation-settings 2.6s var(--ease-breath), letter-spacing 2.6s var(--ease-breath);
}

/* ================================================================
   SALT MARGIN — right column, perpetual upward drift
   ================================================================ */
.salt-margin {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--salt-margin-w);
    height: 100vh;
    z-index: 40;
    pointer-events: none;
    overflow: hidden;
    border-left: 1px solid rgba(168, 201, 194, 0.07);
    background: linear-gradient(
        180deg,
        rgba(14, 42, 51, 0.0) 0%,
        rgba(14, 42, 51, 0.18) 50%,
        rgba(6, 20, 27, 0.28) 100%
    );
}

.salt-track {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    will-change: transform;
}

.salt-floater {
    width: 100%;
    padding: 18px 8px 28px;
    text-align: center;
    opacity: 0.78;
    filter: drop-shadow(0 0 6px rgba(244, 236, 221, 0.06));
}

.salt-floater svg {
    display: block;
    margin: 0 auto;
}

.salt-floater figcaption {
    font-family: "EB Garamond", serif;
    font-style: italic;
    font-size: 9px;
    line-height: 1.4;
    color: var(--vellum);
    opacity: 0.78;
    margin-top: 8px;
    letter-spacing: 0.06em;
}

/* ================================================================
   PARTICLE FIELD + EXHALE TRAIL
   ================================================================ */
.particle-field,
.exhale-trail {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 50;
}

.particle-field { z-index: 35; }
.exhale-trail   { z-index: 70; }

/* ================================================================
   DIVE — main current container
   ================================================================ */
.dive {
    position: relative;
    z-index: 10;
    padding-right: var(--salt-margin-w);
}

/* Each current — 1.4 viewport heights, organic-flow */
.current {
    position: relative;
    min-height: 140vh;
    padding: clamp(80px, 14vh, 220px) var(--gutter) clamp(120px, 18vh, 260px);
    isolation: isolate;
}

.current-inner {
    max-width: var(--max-prose);
    margin: 0 auto;
    position: relative;
    z-index: 5;
}

.current-inner.wide      { max-width: var(--max-prose-wide); text-align: center; }
.current-inner.two-third-right {
    max-width: 1080px;
    display: grid;
    grid-template-columns: minmax(280px, 1fr) minmax(0, 1.7fr);
    gap: clamp(24px, 4vw, 80px);
    align-items: start;
}

/* per-current backgrounds */
.current-01 { background: var(--shelf-shadow); }
.current-02 {
    background: linear-gradient(180deg, var(--shelf-shadow) 0%, var(--thermocline) 100%);
}
.current-03 { background: var(--thermocline); perspective: 1400px; }
.current-04 {
    background: var(--thermocline);
    background-image:
        radial-gradient(circle at 50% 50%, rgba(217, 196, 154, 0.06), transparent 60%);
}
.current-05 { background: var(--abyssal-ink); }
.current-06 {
    background: linear-gradient(180deg, var(--abyssal-ink) 0%, var(--thermocline) 60%, var(--shelf-shadow) 100%);
}

.current.dither-bg {
    position: relative;
}
.current.dither-bg::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image: radial-gradient(rgba(27, 67, 81, 0.28) 1px, transparent 1px);
    background-size: 2px 2px;
    mix-blend-mode: overlay;
    opacity: 0.5;
    z-index: 0;
}

.bloom-current  { padding-block: 22vh 26vh; }
.abyssal        { color: var(--seafoam); }

/* ================================================================
   KELP-STEM DIVIDERS
   ================================================================ */
.kelp-divider {
    position: absolute;
    width: 200px;
    height: 100%;
    top: 0;
    pointer-events: none;
    opacity: 0.85;
    z-index: 2;
    transform-origin: bottom center;
    animation: kelp-sway 16.6s ease-in-out infinite alternate;
    filter: url(#swell);
}

.kelp-top  { left: 6%; }
.kelp-left { left: 4%; }
.kelp-right{ right: 5%; left: auto; }

.kelp-coil {
    width: 480px;
    height: 480px;
    right: -80px;
    top: 22%;
    opacity: 0.4;
    animation: kelp-coil-spin 10s linear infinite;
    filter: url(#swell);
}

.kelp-path {
    stroke-dasharray: 8 12 6 14 9 11;
    stroke-dashoffset: 0;
    animation: kelp-flow 18s linear infinite;
}

.numeral {
    font-family: "EB Garamond", serif;
    font-style: italic;
    font-size: 22px;
    fill: var(--rust-bloom);
    letter-spacing: 0.04em;
}

@keyframes kelp-sway {
    0%   { transform: rotate(-2.4deg); }
    50%  { transform: rotate(1.6deg); }
    100% { transform: rotate(-1.2deg); }
}

@keyframes kelp-flow {
    from { stroke-dashoffset: 0;   }
    to   { stroke-dashoffset: -300;}
}

@keyframes kelp-coil-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ================================================================
   TYPOGRAPHY — headlines, prose, labels
   ================================================================ */
.section-label {
    font-family: "EB Garamond", serif;
    font-style: italic;
    font-size: 13px;
    letter-spacing: 0.16em;
    color: var(--barnacle-gold);
    margin-bottom: 22px;
    opacity: 0.86;
}

.headline {
    line-height: 1.04;
    letter-spacing: -0.005em;
    color: var(--nereid);
    margin: 8px 0 36px;
    will-change: font-variation-settings;
    transition: font-variation-settings 2.6s var(--ease-breath);
}

.headline.cormorant {
    font-family: "Cormorant Garamond", "Cormorant", serif;
    font-weight: 300;
    font-style: normal;
    font-size: clamp(2.4rem, 6.4vw, 5.6rem);
    font-variation-settings: "wght" 320;
}

.headline.cormorant.fuller {
    font-variation-settings: "wght" 380;
}

.headline.fraunces {
    font-family: "Fraunces", "Cormorant Garamond", serif;
    font-weight: 400;
    font-size: clamp(2.0rem, 5.4vw, 4.6rem);
    font-variation-settings: "opsz" 100, "SOFT" 60, "WONK" 1;
    transition: font-variation-settings 2.4s var(--ease-breath);
}
.headline.fraunces:hover {
    font-variation-settings: "opsz" 120, "SOFT" 30, "WONK" 0;
}
.headline.fraunces.small { font-size: clamp(1.7rem, 3.8vw, 3.2rem); }

.headline .g {
    display: inline-block;
    opacity: 0;
    filter: blur(2px);
    transition: opacity 1.6s var(--ease-tide), filter 1.6s var(--ease-tide), transform 1.6s var(--ease-tide);
    transform: translateY(8px);
}
.in-view .headline .g {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0);
}

/* sequential reveal */
.in-view .headline .g:nth-child(1)  { transition-delay: 0.05s; }
.in-view .headline .g:nth-child(2)  { transition-delay: 0.10s; }
.in-view .headline .g:nth-child(3)  { transition-delay: 0.15s; }
.in-view .headline .g:nth-child(4)  { transition-delay: 0.20s; }
.in-view .headline .g:nth-child(5)  { transition-delay: 0.25s; }
.in-view .headline .g:nth-child(6)  { transition-delay: 0.30s; }
.in-view .headline .g:nth-child(7)  { transition-delay: 0.35s; }
.in-view .headline .g:nth-child(8)  { transition-delay: 0.40s; }
.in-view .headline .g:nth-child(9)  { transition-delay: 0.45s; }
.in-view .headline .g:nth-child(10) { transition-delay: 0.50s; }
.in-view .headline .g:nth-child(11) { transition-delay: 0.55s; }
.in-view .headline .g:nth-child(12) { transition-delay: 0.60s; }
.in-view .headline .g:nth-child(13) { transition-delay: 0.65s; }
.in-view .headline .g:nth-child(14) { transition-delay: 0.70s; }
.in-view .headline .g:nth-child(15) { transition-delay: 0.75s; }
.in-view .headline .g:nth-child(16) { transition-delay: 0.80s; }
.in-view .headline .g:nth-child(17) { transition-delay: 0.85s; }
.in-view .headline .g:nth-child(18) { transition-delay: 0.90s; }
.in-view .headline .g:nth-child(19) { transition-delay: 0.95s; }
.in-view .headline .g:nth-child(20) { transition-delay: 1.00s; }
.in-view .headline .g:nth-child(21) { transition-delay: 1.05s; }
.in-view .headline .g:nth-child(22) { transition-delay: 1.10s; }
.in-view .headline .g:nth-child(23) { transition-delay: 1.15s; }
.in-view .headline .g:nth-child(24) { transition-delay: 1.20s; }
.in-view .headline .g:nth-child(25) { transition-delay: 1.25s; }
.in-view .headline .g:nth-child(26) { transition-delay: 1.30s; }
.in-view .headline .g:nth-child(27) { transition-delay: 1.35s; }
.in-view .headline .g:nth-child(28) { transition-delay: 1.40s; }
.in-view .headline .g:nth-child(29) { transition-delay: 1.45s; }
.in-view .headline .g:nth-child(30) { transition-delay: 1.50s; }

.prose {
    font-family: "Spectral", Georgia, serif;
    font-weight: 300;
    font-size: 19px;
    line-height: 1.78;
    color: var(--seafoam);
    text-align: justify;
    hyphens: auto;
    -webkit-hyphens: auto;
    letter-spacing: 0.005em;
    max-width: var(--max-prose);
    margin-bottom: 1.4em;
    transition: transform 3.2s var(--ease-breath);
    transform: rotate(var(--tilt, 0deg));
}

.prose + .prose { text-indent: 1.4em; }

.prose-block .prose-indent { padding-left: 2.4em; }

.prose.tilt-cw  { transform: rotate(var(--tilt, 1.5deg)); }
.prose.tilt-ccw { transform: rotate(var(--tilt, -1.7deg));}

.prose.narrow      { max-width: 460px; margin-left: auto; margin-right: auto; }
.prose.fuller-prose { max-width: var(--max-prose-wide); margin-inline: auto; font-size: 20px; line-height: 1.82; }

em {
    color: var(--barnacle-gold);
    font-style: italic;
    border-bottom: 1px dotted rgba(217, 196, 154, 0.4);
    padding-bottom: 1px;
}

.section-label em,
.engraving-caption em,
.italic-caption em,
.dive-footer em,
.headline em {
    border-bottom: none;
    color: inherit;
}

/* ================================================================
   PROSE LAYOUTS — row, stack, anchor
   ================================================================ */
.prose-row {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(220px, 1fr);
    gap: clamp(20px, 4vw, 64px);
    align-items: start;
}

.prose-row-flip {
    grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1fr);
}

.prose-stack > .prose { max-width: 540px; }

.prose-block { max-width: var(--max-prose); }
.prose-block.aldine .prose-indent { padding-left: 2.4em; }

/* ================================================================
   ENGRAVINGS — mixed-media (ink + offset bleed)
   ================================================================ */
.engraving {
    margin: clamp(20px, 3vh, 44px) 0;
    transform: rotate(-1.1deg);
    transition: transform 4s var(--ease-breath);
    text-align: center;
}

.engraving svg {
    display: block;
    margin: 0 auto;
    filter: drop-shadow(0 4px 24px rgba(6, 20, 27, 0.6));
}

.engraving .bleed-layer { mix-blend-mode: screen; }
.engraving .ink-layer   { mix-blend-mode: normal; }

.bleed-rotator {
    transform-origin: 160px 240px;
    animation: bleed-rotate 18s linear infinite;
}
@keyframes bleed-rotate {
    from { transform: translate(2.4px, 0) rotate(0deg);   }
    to   { transform: translate(2.4px, 0) rotate(-360deg);}
}

.engraving-caption,
.italic-caption {
    font-family: "EB Garamond", serif;
    font-style: italic;
    font-size: 11px;
    line-height: 1.4;
    color: var(--seafoam);
    opacity: 0.74;
    letter-spacing: 0.08em;
    margin-top: 8px;
}

.engraving-floater {
    float: right;
    width: 240px;
    margin: 4px 0 18px 32px;
}

.engraving-large { margin: clamp(24px, 5vh, 56px) auto; }

.bloom-engraving {
    position: relative;
    margin-block: clamp(40px, 8vh, 100px);
}
.bloom-engraving::after {
    content: "";
    position: absolute;
    inset: -8% -12%;
    background: radial-gradient(circle, rgba(217, 196, 154, 0.10), transparent 65%);
    pointer-events: none;
    z-index: -1;
    mix-blend-mode: screen;
}

.anchor-engraving { transform: rotate(-2.4deg); }
.anchor-left      { justify-self: start; }
.anchor-right     { transform: rotate(1.8deg); }

.engraving-center { margin: clamp(40px, 6vh, 80px) auto; transform: rotate(0deg); }

#sand-dollar-rotator {
    transform-origin: 160px 160px;
    animation: sand-dollar 64s linear infinite;
}
@keyframes sand-dollar {
    from { transform: rotate(0deg);   }
    to   { transform: rotate(360deg); }
}

/* ================================================================
   PERSPECTIVE PANEL — §03 pressure
   ================================================================ */
.perspective-frame {
    perspective: 1400px;
    perspective-origin: 50% 30%;
}

.perspective-panel {
    transform-style: preserve-3d;
    transform: rotateX(8deg) rotateY(-3deg) rotateZ(0.6deg);
    transition: transform 2.4s var(--ease-breath);
}

/* JS will recompute --pressure-flat to flatten panel as scroll deepens */

/* ================================================================
   BLOOM — pull-quote
   ================================================================ */
.pull-quote {
    font-family: "Cormorant Garamond", serif;
    font-style: italic;
    font-weight: 400;
    font-size: clamp(2.4rem, 4.4vw, 4.4rem);
    line-height: 1.1;
    color: var(--barnacle-gold);
    max-width: 720px;
    margin: clamp(40px, 6vh, 80px) 0 clamp(40px, 6vh, 80px) 38%;
    transform: rotate(-1.4deg);
    position: relative;
}
.cormorant-italic { font-style: italic; }

.quote-mark {
    color: var(--rust-bloom);
    opacity: 0.7;
    font-size: 1.05em;
    margin: 0 0.05em;
}

/* ================================================================
   WRECK — §05 inset
   ================================================================ */
.wreck-inset {
    position: relative;
    margin: clamp(40px, 8vh, 120px) auto;
    max-width: 620px;
    padding: clamp(28px, 5vh, 60px) clamp(24px, 4vw, 56px);
    background: rgba(6, 20, 27, 0.55);
    border: 1px solid rgba(184, 92, 56, 0.18);
    transform: rotate(-4.2deg);
    box-shadow: 0 24px 64px rgba(6, 20, 27, 0.6);
    backdrop-filter: blur(14px) saturate(0.85);
    -webkit-backdrop-filter: blur(14px) saturate(0.85);
}

.wreck-inset .headline { margin-bottom: 22px; }
.wreck-engraving {
    float: right;
    margin: 0 0 12px 18px;
    transform: rotate(2.6deg);
}

/* ================================================================
   SURVEYOR-MARKS — depth & coordinate ticks
   ================================================================ */
.surveyor-mark,
.depth-mark {
    font-family: "EB Garamond", serif;
    font-style: italic;
    font-size: 11px;
    color: var(--seafoam);
    opacity: 0.5;
    letter-spacing: 0.14em;
    margin-top: 32px;
    position: relative;
}

.surveyor-mark::before {
    content: "";
    display: inline-block;
    width: 18px;
    height: 1px;
    background: currentColor;
    vertical-align: middle;
    margin-right: 10px;
    opacity: 0.6;
}

.surveyor-right { text-align: right; }
.center-surveyor{ text-align: center; }

.depth-mark {
    position: absolute;
    top: 36px;
    font-size: 10px;
    color: var(--barnacle-gold);
    opacity: 0.6;
    letter-spacing: 0.22em;
    text-transform: lowercase;
    z-index: 3;
}

.depth-mark-left  { left: var(--gutter); }
.depth-mark-right { right: calc(var(--gutter) + 16px); }

.depth-mark::after {
    content: "";
    position: absolute;
    top: 50%;
    left: -36px;
    width: 28px;
    height: 1px;
    background: currentColor;
    opacity: 0.6;
}
.depth-mark-right::after {
    left: auto;
    right: -36px;
}

/* ================================================================
   FOOTER
   ================================================================ */
.dive-footer {
    margin-top: clamp(60px, 10vh, 120px);
    text-align: center;
}

.footer-line {
    font-family: "EB Garamond", serif;
    font-style: italic;
    font-size: 13px;
    color: var(--seafoam);
    letter-spacing: 0.18em;
    opacity: 0.82;
}

/* ================================================================
   PRESSURE — flatten currents as user descends
   transform-tilt is ambient on each .current; JS adjusts var
   ================================================================ */
.current {
    transform: rotateX(calc((var(--tilt-x, 3deg)) * (1 - var(--pressure-flat))))
               rotateY(calc((var(--tilt-y, -1deg)) * (1 - var(--pressure-flat))))
               rotateZ(calc((var(--tilt-z, 1deg)) * 0.4));
    transition: transform 1.8s var(--ease-breath);
    transform-style: preserve-3d;
    perspective: 1800px;
}

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 900px) {
    .salt-margin { width: 64px; }
    :root { --salt-margin-w: 64px; }

    .current-inner.two-third-right {
        grid-template-columns: 1fr;
    }
    .anchor-engraving { transform: rotate(-1.2deg); margin: 0 auto; }
    .engraving-floater { float: none; margin: 24px auto; }
    .pull-quote { margin-left: 6%; }
    .wreck-inset { padding: 24px 18px; }
    .wreck-engraving { float: none; display: block; margin: 0 auto 18px; }
    .prose-row,
    .prose-row.prose-row-flip { grid-template-columns: 1fr; }
    .breath-header .brand { font-size: 13px; letter-spacing: 0.14em; }
}

@media (max-width: 560px) {
    body { font-size: 17px; line-height: 1.72; }
    .prose { font-size: 17px; line-height: 1.72; }
    .salt-margin { width: 48px; }
    :root { --salt-margin-w: 48px; }
    .salt-floater svg { width: 40px; height: 65px; }
    .salt-floater figcaption { font-size: 8px; }
    .depth-mark { font-size: 9px; }
}

/* ================================================================
   REDUCED MOTION
   ================================================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
    .salt-track { animation: none !important; transform: none !important; }
    .kelp-divider { animation: none !important; }
}
