/* matsurika.day — a quiet listening room
   midnight-blue 7-stop palette, HUD-overlay monograph chrome */

:root {
    --abyssal:  #05080F;  /* page background, baseline */
    --harbor:   #0A1428;  /* gradient mid-stop, panel base under blur */
    --horizon:  #16213E;  /* HUD chrome strokes, rule lines */
    --current:  #2A3F6B;  /* ambient 3D scene fill, secondary text */
    --lantern:  #7B96C9;  /* primary body text on dark, soft chrome glyphs */
    --aurora:   #C8D7F0;  /* display headline color, primary HUD readouts */
    --crest:    #E8F2FF;  /* single cold accent — active/current state, meridian */
    --warm:     #F4C77B;  /* distant lighthouse — used exactly twice */

    --focal-depth: 0;     /* 0..1, driven by scroll */
    --serif-display: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
    --serif-body:    'EB Garamond', Georgia, 'Times New Roman', serif;
    --mono:          'JetBrains Mono', 'Courier New', monospace;
    --micro:         'Inter', 'Helvetica Neue', Arial, sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
    background: radial-gradient(140% 120% at 50% -10%, var(--harbor) 0%, var(--abyssal) 55%, var(--abyssal) 100%);
    color: var(--lantern);
    font-family: var(--serif-body);
    text-rendering: geometricPrecision;
    -webkit-font-smoothing: antialiased;
    cursor: none;
    overflow-x: hidden;
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* ============ z0 : drifting 3D wave-form ribbon scene ============ */
.scene {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    background: radial-gradient(120% 100% at 50% 35%, var(--harbor) 0%, var(--abyssal) 60%);
    pointer-events: none;
}
.scene-fog {
    position: absolute;
    inset: -20%;
    background:
        radial-gradient(40% 30% at 30% 40%, rgba(42,63,107,0.30), transparent 70%),
        radial-gradient(45% 35% at 72% 62%, rgba(42,63,107,0.22), transparent 70%);
    filter: blur(40px);
    opacity: calc(0.7 - var(--focal-depth) * 0.45);
    transition: opacity 1.6s ease;
}
.scene-vignette {
    position: absolute;
    inset: 0;
    background: radial-gradient(110% 90% at 50% 45%, transparent 35%, rgba(5,8,15,0.55) 78%, rgba(5,8,15,0.92) 100%);
}

.ribbons { position: absolute; inset: 0; perspective: 1400px; }

.ribbon {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 260vw;
    height: 30vh;
    border-radius: 50%;
    background: linear-gradient(100deg,
        transparent 0%,
        rgba(123,150,201,0.04) 18%,
        rgba(200,215,240,0.16) 42%,
        rgba(123,150,201,0.10) 60%,
        rgba(42,63,107,0.04) 80%,
        transparent 100%);
    transform-origin: center;
    mix-blend-mode: screen;
    filter: blur(0.5px);
    will-change: transform, filter, opacity;
}

/* depth groups — blur shifts with --focal-depth (depth-of-field travel) */
.ribbon--far,  .ribbon--far2  { filter: blur(calc(2px + var(--focal-depth) * -1.6px)); opacity: calc(0.30 + var(--focal-depth) * 0.45); }
.ribbon--mid,  .ribbon--mid2  { filter: blur(calc(1px + (var(--focal-depth) - 0.5) * 2.2px)); opacity: 0.5; }
.ribbon--near, .ribbon--near2 { filter: blur(calc(0.5px + var(--focal-depth) * 5px)); opacity: calc(0.62 - var(--focal-depth) * 0.34); }

.ribbon--far  { transform: translate(-50%,-58%) rotateX(64deg) rotateZ(-8deg) scale(0.78); animation: drift-a 52s ease-in-out infinite; }
.ribbon--far2 { transform: translate(-50%,-30%) rotateX(70deg) rotateZ(7deg) scale(0.7);   animation: drift-b 61s ease-in-out infinite; }
.ribbon--mid  { transform: translate(-50%,-46%) rotateX(58deg) rotateZ(-4deg) scale(0.95); animation: drift-c 38s ease-in-out infinite; height: 22vh; }
.ribbon--mid2 { transform: translate(-50%,-12%) rotateX(62deg) rotateZ(5deg) scale(0.9);   animation: drift-a 44s ease-in-out infinite reverse; height: 24vh; }
.ribbon--near { transform: translate(-50%,-36%) rotateX(52deg) rotateZ(-3deg) scale(1.18); animation: drift-b 31s ease-in-out infinite; height: 18vh; }
.ribbon--near2{ transform: translate(-50%, 8%)  rotateX(56deg) rotateZ(4deg) scale(1.1);   animation: drift-c 27s ease-in-out infinite reverse; height: 16vh; }

/* glacial drift — minimum 24s loops, all far longer */
@keyframes drift-a {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 60% 50%; }
    100% { background-position: 0% 50%; }
}
@keyframes drift-b {
    0%   { background-position: 100% 50%; }
    50%  { background-position: 35% 50%; }
    100% { background-position: 100% 50%; }
}
@keyframes drift-c {
    0%   { background-position: 30% 50%; }
    50%  { background-position: 90% 50%; }
    100% { background-position: 30% 50%; }
}
.ribbon { background-size: 220% 100%; }

/* ============ z1 : backdrop-blurred glass plane + headline ============ */
.focal-plane {
    position: fixed;
    inset: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.focal-plane::before {
    content: "";
    position: absolute;
    left: 22vw; right: 22vw;
    top: 28px;
    height: calc(82vh - 28px);
    background: rgba(10,20,40,0.18);
    -webkit-backdrop-filter: blur(28px) saturate(140%);
    backdrop-filter: blur(28px) saturate(140%);
    -webkit-mask-image: radial-gradient(120% 100% at 50% 50%, #000 55%, transparent 92%);
    mask-image: radial-gradient(120% 100% at 50% 50%, #000 55%, transparent 92%);
}
.focal-headline {
    position: relative;
    text-align: center;
    color: var(--aurora);
    font-family: var(--serif-display);
    font-weight: 300;
    font-style: italic;
    line-height: 1.04;
    letter-spacing: -0.025em;
    font-feature-settings: "liga" 1, "dlig" 1;
    text-shadow: 0 0 60px rgba(123,150,201,0.25);
    transition: opacity 6s cubic-bezier(.22,.61,.36,1);
    padding: 0 4vw;
}
.focal-headline__line {
    display: block;
    font-size: clamp(2.6rem, 7.2vw, 6.6rem);
}
.focal-headline.is-fading { opacity: 0; }

/* ============ z2 : pin-sharp HUD chrome ============ */

/* top strip — 28px tall frosted glass */
.hud-top {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 28px;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 0 16px;
    background: rgba(10,20,40,0.55);
    -webkit-backdrop-filter: blur(24px) saturate(130%);
    backdrop-filter: blur(24px) saturate(130%);
    border-bottom: 0.5px solid var(--horizon);
    font-family: var(--mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--lantern);
}
.hud-top__mark { color: var(--aurora); white-space: nowrap; }
.hud-top__nav {
    display: flex;
    gap: 1.4rem;
    overflow: hidden;
    flex-wrap: nowrap;
}
.hud-top__nav a {
    color: var(--lantern);
    opacity: 0.62;
    transition: opacity 1.2s ease, color 1.2s ease;
    white-space: nowrap;
}
.hud-top__nav a:hover { opacity: 1; color: var(--crest); }
.hud-top__nav a.is-active { opacity: 1; color: var(--crest); }
.hud-top__stamp { color: var(--current); white-space: nowrap; }

/* left vertical reading rail of metadata */
.hud-rail {
    position: fixed;
    top: 28px;
    left: 0;
    bottom: 64px;
    width: 22vw;
    max-width: 320px;
    z-index: 25;
    padding: 2.4rem 1.6rem 2.4rem 16px;
    display: flex;
    flex-direction: column;
    gap: 1.8rem;
    background: linear-gradient(90deg, rgba(10,20,40,0.5) 0%, rgba(10,20,40,0.18) 70%, transparent 100%);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border-right: 0.5px solid rgba(22,33,62,0.7);
    font-family: var(--mono);
}
.hud-rail__group { display: flex; flex-direction: column; gap: 0.35rem; }
.hud-rail__group--bottom { margin-top: auto; }
.hud-rail__label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.32em;
    color: var(--current);
}
.hud-rail__value {
    font-size: 11px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--lantern);
}
.hud-rail__meridian {
    position: relative;
    width: 1px;
    flex: 1;
    margin: 0.6rem 0 0.6rem 2px;
    background: rgba(22,33,62,0.9);
    overflow: hidden;
}
.hud-rail__meridian span {
    position: absolute;
    left: -0.5px;
    top: 0;
    width: 2px;
    height: 0%;
    background: var(--crest);
    box-shadow: 0 0 8px rgba(232,242,255,0.6);
    transition: height 1.2s cubic-bezier(.22,.61,.36,1);
}

/* bottom instrumentation strip — calibration ticks + coordinate readout */
.hud-bottom {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 30;
    height: 64px;
    background: rgba(10,20,40,0.6);
    -webkit-backdrop-filter: blur(24px) saturate(130%);
    backdrop-filter: blur(24px) saturate(130%);
    border-top: 0.5px solid var(--horizon);
    font-family: var(--mono);
}
.hud-bottom__ticks {
    position: relative;
    height: 18px;
    border-bottom: 0.5px solid rgba(22,33,62,0.6);
}
.hud-bottom__ticks .tick {
    position: absolute;
    bottom: 0;
    width: 1px;
    background: rgba(123,150,201,0.5);
}
.hud-bottom__ticks .tick--label::after {
    content: attr(data-coord);
    position: absolute;
    bottom: 100%;
    left: 0;
    transform: translateX(-50%) translateY(-2px);
    font-size: 8px;
    letter-spacing: 0.14em;
    color: var(--current);
    white-space: nowrap;
}
.hud-bottom__row {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    height: 46px;
    padding: 0 16px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
}
.hud-bottom__coord { color: var(--aurora); white-space: nowrap; }
.hud-bottom__meridian {
    position: relative;
    flex: 1;
    height: 1px;
    background: rgba(22,33,62,0.9);
    overflow: hidden;
}
.hud-bottom__meridian span {
    position: absolute;
    left: 0; top: -0.5px;
    height: 2px;
    width: 0%;
    background: var(--crest);
    box-shadow: 0 0 8px rgba(232,242,255,0.6);
    transition: width 1.2s cubic-bezier(.22,.61,.36,1);
}
.hud-bottom__link {
    color: var(--lantern);
    opacity: 0.62;
    transition: opacity 1.2s ease, color 1.2s ease;
    white-space: nowrap;
    text-transform: lowercase;
    letter-spacing: 0.1em;
}
.hud-bottom__link:hover { opacity: 1; color: var(--crest); }

/* ============ monograph chapters ============ */
.monograph {
    position: relative;
    z-index: 10;
    padding-top: 28px;
}
.chapter {
    position: relative;
    min-height: 100vh;
    padding: 18vh 24vw 22vh 24vw;
    display: grid;
    align-content: center;
}
.chapter--left  { justify-items: start; text-align: left; }
.chapter--right { justify-items: end; text-align: right; }
.chapter--center { justify-items: center; text-align: center; padding-bottom: 30vh; }

.chapter__halo {
    position: absolute;
    width: 600px; height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(42,63,107,0.18) 0%, transparent 65%);
    pointer-events: none;
    z-index: -1;
}
.chapter--left  .chapter__halo { left: 14vw; bottom: 14vh; }
.chapter--right .chapter__halo { right: 14vw; bottom: 14vh; }
.chapter--center .chapter__halo { left: 50%; top: 30%; transform: translateX(-50%); }
.chapter__halo--warm {
    background: radial-gradient(circle, rgba(244,199,123,0.10) 0%, transparent 60%);
    width: 700px; height: 700px;
}

.chapter__numeral {
    font-family: var(--serif-display);
    font-weight: 300;
    font-size: clamp(8rem, 22vw, 20rem);
    line-height: 0.8;
    letter-spacing: -0.025em;
    color: var(--aurora);
    opacity: 0.9;
    margin-bottom: 0.1em;
    font-feature-settings: "liga" 1;
    text-shadow: 0 0 80px rgba(123,150,201,0.2);
}
.chapter--left  .chapter__numeral { align-self: end; }
.chapter--right .chapter__numeral { align-self: end; }

.chapter__crosshair {
    position: absolute;
    font-family: var(--mono);
    font-size: 10px;
    line-height: 1;
    color: var(--lantern);
    opacity: 0.5;
    transform: translate(-50%, -50%);
}
.chapter--left  .chapter__crosshair { left: 14vw; top: 28%; }
.chapter--right .chapter__crosshair { right: 14vw; top: 28%; transform: translate(50%, -50%); }

.chapter__lantern {
    font-size: clamp(2rem, 5vw, 3.4rem);
    color: var(--warm);
    text-shadow: 0 0 40px rgba(244,199,123,0.5), 0 0 90px rgba(244,199,123,0.25);
    margin-bottom: 1.2em;
    transition: text-shadow 2s ease;
}

.chapter__body { max-width: 60ch; display: flex; flex-direction: column; gap: 0.9rem; }
.chapter--right .chapter__body { align-items: flex-end; }
.chapter--center .chapter__body--center { align-items: center; max-width: 56ch; }

.chapter__eyebrow {
    font-family: var(--micro);
    font-weight: 500;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.32em;
    color: var(--current);
}
.chapter__eyebrow--warm { color: var(--warm); opacity: 0.85; }

.chapter__title {
    font-family: var(--serif-display);
    font-weight: 500;
    font-style: italic;
    font-size: clamp(2.2rem, 4.4vw, 4rem);
    line-height: 1.05;
    letter-spacing: -0.02em;
    color: var(--aurora);
    font-feature-settings: "liga" 1, "dlig" 1;
}

.chapter__prose {
    font-family: var(--serif-body);
    font-weight: 400;
    font-size: 19px;
    line-height: 1.7;
    color: var(--lantern);
    max-width: 60ch;
    font-feature-settings: "onum" 1, "liga" 1;
}

.chapter__stamp {
    margin-top: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-family: var(--mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--current);
    border-left: 0.5px solid var(--horizon);
    padding-left: 0.9rem;
}
.chapter--right .chapter__stamp {
    border-left: none;
    border-right: 0.5px solid var(--horizon);
    padding-left: 0;
    padding-right: 0.9rem;
    align-items: flex-end;
}
.chapter--center .chapter__stamp { border-left: none; padding-left: 0; align-items: center; }

.chapter__wave {
    width: 60ch;
    max-width: 100%;
    height: 24px;
    margin-top: 2.4rem;
    opacity: 0.3;
}
.chapter__wave path {
    fill: none;
    stroke: var(--lantern);
    stroke-width: 0.5;
    vector-effect: non-scaling-stroke;
}

/* ============ custom crosshair cursor ============ */
.cursor {
    position: fixed;
    top: 0; left: 0;
    width: 16px; height: 16px;
    z-index: 100;
    pointer-events: none;
    transform: translate(-50%, -50%);
    opacity: 0.6;
    transition: opacity 0.4s ease;
}
.cursor::before, .cursor::after {
    content: "";
    position: absolute;
    background: var(--aurora);
}
.cursor::before { left: 50%; top: 0; width: 1px; height: 100%; transform: translateX(-50%); }
.cursor::after  { top: 50%; left: 0; height: 1px; width: 100%; transform: translateY(-50%); }
.cursor.is-hidden { opacity: 0; }

/* ============ entrance state ============ */
.chapter__body, .chapter__numeral, .chapter__lantern, .chapter__wave {
    opacity: 0;
    transform: translateY(18px);
    transition: opacity 1.6s cubic-bezier(.22,.61,.36,1), transform 1.6s cubic-bezier(.22,.61,.36,1);
}
.chapter.is-visible .chapter__body,
.chapter.is-visible .chapter__numeral,
.chapter.is-visible .chapter__lantern,
.chapter.is-visible .chapter__wave {
    opacity: 1;
    transform: translateY(0);
}
.chapter.is-visible .chapter__numeral { transition-delay: 0.15s; }
.chapter.is-visible .chapter__wave { transition-delay: 0.4s; }

/* ============ responsive — collapse rail / margins on small screens ============ */
@media (max-width: 900px) {
    .hud-rail { display: none; }
    .focal-plane::before { left: 6vw; right: 6vw; }
    .chapter { padding: 16vh 8vw 22vh 8vw; }
    .chapter--left .chapter__halo,
    .chapter--right .chapter__halo { left: 50%; transform: translateX(-50%); }
    .hud-top__nav { gap: 0.9rem; }
    .hud-top__stamp { display: none; }
    .chapter__wave, .chapter__body { width: auto; }
}
@media (max-width: 560px) {
    .hud-top__nav a:nth-child(n+4) { display: none; }
    .chapter__numeral { font-size: 7rem; }
}
