/* ============================================================
   concurrent.quest — "Marble Tag"
   one corridor, four tags, eight grays, infinite breath.
   ============================================================ */

:root {
    --carrara-white: #F4F4F2;
    --carrara-veil:  #E6E5E2;
    --foglight:      #BDBDBD;
    --solder:        #9A9A9A;
    --slate:         #7A7A7A;
    --coalstroke:    #3C3C3C;
    --ink:           #1B1B1B;
    --specular:      #FFFFFF;
    --chrome-edge:   #C9C9C9;
    --rail-soft:     #E9E9E9;

    --honey: cubic-bezier(0.22, 0.61, 0.36, 1);

    --hud-h: 44px;
    --hud-w: 56px;
}

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

html, body {
    width: 100%;
    background: var(--carrara-white);
    color: var(--slate);
    font-family: 'Inter', 'Helvetica', system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html {
    scroll-behavior: smooth;
    scroll-snap-type: y proximity;
}

body {
    position: relative;
    overflow-x: hidden;
    cursor: none; /* replaced by .cursor */
    background:
        radial-gradient(ellipse at 30% 20%, #FFFFFF 0%, var(--carrara-white) 60%, var(--carrara-veil) 100%),
        var(--carrara-white);
}

body.loading {
    overflow-y: hidden;
    height: 100vh;
}

/* SVG defs holder */
.filters {
    position: absolute;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* ============================================================
   HUD frame (z:60 fixed, never scrolls)
   ============================================================ */

.hud {
    position: fixed;
    z-index: 60;
    color: var(--solder);
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.42em;
    text-transform: uppercase;
    font-feature-settings: "tnum" 1, "ss01" 1;
    pointer-events: none;
    opacity: 0;
    transition: opacity 800ms var(--honey);
}

body.hud-on .hud {
    opacity: 1;
}

/* Top rail */
.hud-top {
    top: 0;
    left: 0;
    right: 0;
    height: var(--hud-h);
    display: flex;
    align-items: center;
    padding: 0 80px;
    border-bottom: 1px solid transparent;
    background:
        linear-gradient(var(--carrara-white), var(--carrara-white)) padding-box,
        linear-gradient(to right, var(--chrome-edge), var(--rail-soft), var(--chrome-edge)) border-box;
    border-bottom: 1px solid transparent;
}

.hud-top::after {
    content: "";
    position: absolute;
    left: 0; right: 0;
    bottom: 0;
    height: 1px;
    background: linear-gradient(to right, var(--chrome-edge) 0%, var(--rail-soft) 50%, var(--chrome-edge) 100%);
    pointer-events: none;
}

.hud-glyph {
    color: var(--foglight);
    font-size: 14px;
    letter-spacing: 0;
}
.hud-glyph-l { margin-right: auto; padding-left: 0; }
.hud-glyph-r { margin-left: auto; padding-right: 0; transform: scaleX(-1); }

.hud-title {
    color: var(--solder);
    margin-left: 24px;
}

.hud-thread {
    color: var(--solder);
    margin-left: auto;
    margin-right: 24px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.2em;
}

#thread-count {
    color: var(--slate);
    font-variant-numeric: tabular-nums;
}

/* Bottom rail */
.hud-bottom {
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--hud-h);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 0 80px;
    background: var(--carrara-white);
}

.hud-bottom::before {
    content: "";
    position: absolute;
    left: 0; right: 0;
    top: 0;
    height: 1px;
    background: linear-gradient(to right, var(--chrome-edge) 0%, var(--rail-soft) 50%, var(--chrome-edge) 100%);
}

.hud-field {
    font-family: 'JetBrains Mono', monospace;
    color: var(--slate);
    letter-spacing: 0.18em;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.hud-sep {
    color: var(--foglight);
    font-size: 11px;
}

#drift-readout {
    color: var(--slate);
    transition: color 200ms var(--honey);
    display: inline-block;
    min-width: 4ch;
}

#drift-readout.flicker {
    color: var(--solder);
}

/* Left/right rails */
.hud-left, .hud-right {
    top: var(--hud-h);
    bottom: var(--hud-h);
    width: var(--hud-w);
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    padding: 24px 0;
}

.hud-left {
    left: 0;
}
.hud-left::after {
    content: "";
    position: absolute;
    top: 12px; bottom: 12px;
    right: 0;
    width: 1px;
    background: linear-gradient(to bottom, transparent 0%, var(--chrome-edge) 12%, var(--rail-soft) 50%, var(--chrome-edge) 88%, transparent 100%);
}

.hud-right {
    right: 0;
}
.hud-right::after {
    content: "";
    position: absolute;
    top: 12px; bottom: 12px;
    left: 0;
    width: 1px;
    background: linear-gradient(to bottom, transparent 0%, var(--chrome-edge) 12%, var(--rail-soft) 50%, var(--chrome-edge) 88%, transparent 100%);
}

.waypoint {
    width: 8px;
    height: 8px;
    border: 1px solid var(--foglight);
    background: transparent;
    transition: all 600ms var(--honey);
}

.waypoint.active {
    animation: pulse-waypoint 2400ms var(--honey) infinite;
}

@keyframes pulse-waypoint {
    0%,100% {
        background: transparent;
        box-shadow: 0 0 0 0 rgba(189,189,189,0.0);
    }
    50% {
        background: var(--foglight);
        box-shadow: 0 0 0 3px rgba(189,189,189,0.25);
    }
}

.numeral {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    letter-spacing: 0.42em;
    color: var(--solder);
    opacity: 0.18;
    transition: opacity 800ms var(--honey), color 600ms var(--honey);
}

.numeral.active {
    opacity: 1;
    color: var(--slate);
}

/* Corner crops */
.corner {
    position: fixed;
    width: 28px;
    height: 28px;
    z-index: 61;
    pointer-events: none;
    opacity: 0;
    transition: opacity 800ms var(--honey);
}
body.hud-on .corner {
    opacity: 1;
}

.corner-tl {
    top: 8px; left: 8px;
    border-top: 1px solid var(--foglight);
    border-left: 1px solid var(--foglight);
    box-shadow: inset 2px 2px 0 0 #FFFFFF;
}
.corner-tr {
    top: 8px; right: 8px;
    border-top: 1px solid var(--foglight);
    border-right: 1px solid var(--foglight);
    box-shadow: inset -2px 2px 0 0 #FFFFFF;
}
.corner-bl {
    bottom: 8px; left: 8px;
    border-bottom: 1px solid var(--foglight);
    border-left: 1px solid var(--foglight);
    box-shadow: inset 2px -2px 0 0 #FFFFFF;
}
.corner-br {
    bottom: 8px; right: 8px;
    border-bottom: 1px solid var(--foglight);
    border-right: 1px solid var(--foglight);
    box-shadow: inset -2px -2px 0 0 #FFFFFF;
}

/* ============================================================
   Corridor + marble veins
   ============================================================ */

.corridor {
    position: relative;
    width: 100%;
    z-index: 10;
    padding: 0 var(--hud-w);
    padding-top: var(--hud-h);
    padding-bottom: var(--hud-h);
}

.marble-veins {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.vein-large path,
.vein-capillary path {
    stroke-dasharray: 2200;
    stroke-dashoffset: 2200;
    animation: draw-vein 1400ms var(--honey) forwards;
}

@keyframes draw-vein {
    to { stroke-dashoffset: 0; }
}

.vein-large path:nth-child(1) { animation-delay: 0ms; }
.vein-large path:nth-child(2) { animation-delay: 60ms; }
.vein-large path:nth-child(3) { animation-delay: 120ms; }
.vein-large path:nth-child(4) { animation-delay: 180ms; }
.vein-large path:nth-child(5) { animation-delay: 240ms; }
.vein-large path:nth-child(6) { animation-delay: 300ms; }
.vein-large path:nth-child(7) { animation-delay: 360ms; }
.vein-large path:nth-child(8) { animation-delay: 420ms; }

.vein-capillary path {
    stroke-dasharray: 240;
    stroke-dashoffset: 240;
    animation-duration: 900ms;
    animation-delay: 600ms;
}

/* Specular grain (procedural via SVG noise data-uri) */
.grain {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
    opacity: 0.06;
    mix-blend-mode: soft-light;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='96' height='96'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.55 0 0 0 0 0.55 0 0 0 0 0.55 0 0 0 1 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
    background-size: 96px 96px;
    background-repeat: repeat;
}

/* ============================================================
   Movements
   ============================================================ */

.movement {
    position: relative;
    width: 100%;
    height: 100vh;
    min-height: 720px;
    z-index: 3;
    scroll-snap-align: start;
    overflow: hidden;
}

.m-i    { height: 1125px; }
.m-ii   { height: 1125px; }
.m-iii  { height: 1125px; }
.m-iv   { height: 1125px; }

.movement-label {
    position: absolute;
    top: 32px;
    left: 32px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.42em;
    color: var(--foglight);
    text-transform: uppercase;
    z-index: 5;
    opacity: 0.72;
}

/* Display tags (concurrent. and quest.) */
.tag-display {
    font-family: 'Caveat', 'Caveat Brush', cursive;
    font-weight: 700;
    line-height: 0.82;
    letter-spacing: -0.04em;
    color: var(--solder);
    text-shadow:
        0 1px 0 #FFFFFF,
        0 0 24px rgba(189,189,189,0.45),
        0 0 60px rgba(122,122,122,0.18);
    background: linear-gradient(180deg, var(--slate) 0%, #FFFFFF 42%, var(--foglight) 62%, var(--coalstroke) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    user-select: none;
    pointer-events: none;
    position: absolute;
    z-index: 4;
}

.tag-concurrent {
    font-size: clamp(120px, 16vw, 260px);
    bottom: 18%;
    left: 6vw;
    transform-origin: left bottom;
}

.tag-quest {
    font-size: clamp(140px, 18vw, 280px);
    top: 20%;
    right: 6vw;
    text-align: right;
    transform-origin: right top;
}

/* Descender / ascender connecting curves */
.descender, .ascender {
    position: absolute;
    width: 110%;
    height: 60%;
    z-index: 3;
    pointer-events: none;
}

.descender {
    bottom: -10%;
    left: -5%;
}

.ascender {
    top: -10%;
    left: -5%;
}

/* ============================================================
   Movement II — spline + 7 quest sub-tags
   ============================================================ */

.spline {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    pointer-events: none;
}

.spline-line {
    transition: opacity 1200ms var(--honey);
    stroke-dasharray: 4000;
    stroke-dashoffset: 0;
}

.m-ii.magnetic-active .spline-line {
    opacity: 0.12;
}

.quest-tag {
    position: absolute;
    font-family: 'Caveat Brush', 'Caveat', cursive;
    font-weight: 400;
    font-size: clamp(28px, 3.4vw, 48px);
    line-height: 1;
    letter-spacing: -0.01em;
    color: var(--solder);
    background: linear-gradient(180deg, var(--slate) 0%, #FFFFFF 38%, var(--foglight) 62%, var(--coalstroke) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 12px rgba(189,189,189,0.3);
    user-select: none;
    pointer-events: none;
    z-index: 5;
    left: var(--rx);
    top: var(--ry);
    transform: translate(-50%, -50%);
    transition: transform 600ms var(--honey), opacity 900ms var(--honey);
    will-change: transform;
}

.quest-tag::before {
    /* 30px tangent line connecting tag to vein */
    content: "";
    position: absolute;
    left: -36px;
    top: 50%;
    width: 30px;
    height: 1px;
    background: var(--solder);
    opacity: 0;
    transform: scaleX(0);
    transform-origin: left center;
    transition: opacity 1200ms var(--honey), transform 1200ms var(--honey);
}

.quest-tag.lit::before {
    opacity: 0.6;
    transform: scaleX(1);
}

/* ============================================================
   Movement IV — plinth + chrome breath
   ============================================================ */

.m-iv {
    display: flex;
    align-items: center;
    justify-content: center;
}

.plinth {
    position: relative;
    width: 320px;
    padding: 28px 18px;
    text-align: center;
    color: var(--solder);
    margin-top: -10vh;
}

.plinth-text {
    display: block;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    letter-spacing: 0.18em;
    color: var(--slate);
    text-shadow: 0 0 18px rgba(189,189,189,0.35);
    animation: chrome-breath 6s linear infinite;
}

.plinth-rule {
    display: block;
    width: 120px;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--foglight), transparent);
    margin: 18px auto 0;
    animation: chrome-breath 6s linear infinite;
    animation-delay: -3s;
}

@keyframes chrome-breath {
    0%,100% { opacity: 0.4; }
    50%     { opacity: 0.7; }
}

/* ============================================================
   Custom cursor (spray-can)
   ============================================================ */

.cursor {
    position: fixed;
    top: 0;
    left: 0;
    width: 22px;
    height: 22px;
    pointer-events: none;
    z-index: 100;
    transform: translate(-50%, -50%);
    transition: opacity 600ms var(--honey);
    opacity: 0;
}

body.hud-on .cursor {
    opacity: 1;
}

.cursor svg {
    display: block;
    transition: transform 200ms var(--honey);
    transform-origin: 50% 60%;
}

/* ============================================================
   Initial reveal: hide tags, fade in after load
   ============================================================ */

body.loading .tag-display,
body.loading .quest-tag,
body.loading .plinth {
    opacity: 0;
}

.tag-display {
    transition: opacity 1200ms var(--honey);
}

body.tag-on .tag-display,
body.tag-on .quest-tag,
body.tag-on .plinth {
    opacity: 1;
}

/* ============================================================
   Reduced motion
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
    body { cursor: auto; }
    .cursor { display: none; }
    .vein-large path,
    .vein-capillary path {
        stroke-dashoffset: 0;
    }
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 720px) {
    .hud-top, .hud-bottom { padding: 0 24px; }
    .hud-thread { display: none; }
    .hud-bottom { gap: 8px; font-size: 10px; }
    .hud-bottom .hud-field:last-of-type { display: none; }
    .corridor { padding-left: 32px; padding-right: 32px; }
    .hud-left, .hud-right { width: 32px; }
    .corner { width: 18px; height: 18px; }
    .tag-concurrent { left: 4vw; font-size: clamp(80px, 22vw, 180px); }
    .tag-quest { right: 4vw; font-size: clamp(90px, 24vw, 200px); }
}
