/* ===================================================
   tsundere.webcam — Navy Metallic Glassmorphism
   =================================================== */

/* ---- Palette ----
   #0D1420 — Abyss Navy (primary bg)
   #1A2744 — Deep Navy (section bg, leather base)
   #2C3E6B — Spine Blue (timeline spine, structural)
   #4A6491 — Maritime (node dots, medium accent)
   #8A9BAD — Gunmetal Pale (secondary text, metadata)
   #C4CEDB — Vellum (body text, glass content)
   #E8EDF4 — Frost Silver (display text, wordmark)
   #8B2020 — Crimson Tension (REC indicator)
   #B8966A — Amber Confession (Node 4 only)
*/

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: #0D1420;
    color: #C4CEDB;
    font-family: 'Crimson Pro', Georgia, serif;
    font-size: 17px;
    line-height: 1.85;
    overflow-x: hidden;
    position: relative;
}

/* ---- Keyframes ---- */
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

@keyframes rec-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

@keyframes cursor-fade {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

@keyframes dot-pulse {
    0% { box-shadow: 0 0 0 0 rgba(74, 100, 145, 0.7); }
    70% { box-shadow: 0 0 0 8px rgba(74, 100, 145, 0); }
    100% { box-shadow: 0 0 0 0 rgba(74, 100, 145, 0); }
}

@keyframes spine-draw {
    from { transform: scaleY(0); }
    to { transform: scaleY(1); }
}

@keyframes seal-appear {
    from { transform: scale(0) rotate(-20deg); opacity: 0; }
    to { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* ---- Webcam Timestamp ---- */
#webcam-timestamp {
    position: fixed;
    top: 18px;
    left: 20px;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 7px;
    font-family: 'Space Mono', 'Courier New', monospace;
    font-size: 11px;
    letter-spacing: 0.06em;
    color: #8A9BAD;
    opacity: 0.75;
    pointer-events: none;
}

.rec-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #8B2020;
    animation: rec-pulse 1.2s ease-in-out infinite;
    flex-shrink: 0;
}

#timestamp-text {
    font-family: 'Space Mono', monospace;
}

/* ---- Spine ---- */
#spine-container {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 3px;
    height: 100vh;
    z-index: 10;
    pointer-events: none;
}

#spine {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 0;
    background-color: #2C3E6B;
    background-image:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 4px,
            rgba(44, 62, 107, 0.3) 4px,
            rgba(44, 62, 107, 0.3) 5px
        );
    filter: url(#leather-grain);
    transform-origin: top center;
    transition: height 0.15s linear;
    will-change: height;
}

/* ---- Spine Dots ---- */
.spine-dot {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #2C3E6B;
    border: 1px solid #4A6491;
    transition: all 400ms ease;
    z-index: 20;
    pointer-events: none;
}

.spine-dot.active {
    width: 12px;
    height: 12px;
    background-color: #4A6491;
    box-shadow: 0 0 12px rgba(74, 100, 145, 0.6);
    animation: dot-pulse 2s ease-out;
}

/* ---- Sections / Nodes ---- */
.node {
    position: relative;
    padding: 18vh 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.node-full {
    min-height: 100vh;
    padding: 0;
    align-items: center;
}

.node-left {
    justify-content: flex-start;
    padding-left: 8vw;
    padding-right: 55vw;
}

.node-right {
    justify-content: flex-end;
    padding-right: 8vw;
    padding-left: 55vw;
}

/* ---- Node 0 — Entry ---- */
#node-0 {
    background-color: #0D1420;
}

#node-0 .spine-dot {
    top: 50%;
    transform: translateX(-50%) translateY(-50%);
}

/* ---- Node 1 — Left Branch ---- */
#node-1 {
    background-color: #0D1420;
}

#node-1 .spine-dot {
    top: 50%;
    transform: translateX(-50%) translateY(-50%);
}

/* ---- Node 2 — Right Branch ---- */
#node-2 {
    background-color: #0D1420;
}

#node-2 .spine-dot {
    top: 50%;
    transform: translateX(-50%) translateY(-50%);
}

/* ---- Node 3 — Full Leather Interlude ---- */
#node-3 {
    background-color: #1A2744;
    background-image:
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 12px,
            rgba(44, 62, 107, 0.08) 12px,
            rgba(44, 62, 107, 0.08) 13px
        );
    filter: url(#leather-grain);
    min-height: 100vh;
}

#node-3::after {
    content: '';
    position: absolute;
    inset: 0;
    background-color: #1A2744;
    opacity: 0;
    pointer-events: none;
}

#node-3 .spine-dot {
    top: 50%;
    transform: translateX(-50%) translateY(-50%);
}

/* ---- Node 4 — Closing / Warm ---- */
#node-4 {
    background-color: #0D1420;
}

#node-4 .spine-dot {
    top: 40%;
    transform: translateX(-50%) translateY(-50%);
}

.amber-bleed {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(184, 150, 106, 0.06) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* ---- Node Number Background ---- */
.node-number-bg {
    position: absolute;
    font-family: 'Jost', sans-serif;
    font-size: clamp(120px, 25vw, 260px);
    font-weight: 600;
    letter-spacing: -0.02em;
    color: #E8EDF4;
    opacity: 0.025;
    user-select: none;
    pointer-events: none;
    z-index: 1;
    line-height: 1;
}

.node-number-large {
    position: absolute;
    font-family: 'Jost', sans-serif;
    font-size: clamp(180px, 35vw, 400px);
    font-weight: 600;
    letter-spacing: -0.04em;
    color: #E8EDF4;
    opacity: 0.04;
    user-select: none;
    pointer-events: none;
    z-index: 1;
    line-height: 1;
}

/* ---- Glass Panels ---- */
.glass-panel {
    background: rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(14px) saturate(1.2);
    -webkit-backdrop-filter: blur(14px) saturate(1.2);
    border: 1px solid rgba(232, 237, 244, 0.07);
    border-radius: 2px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    padding: 40px 48px;
    position: relative;
    z-index: 30;
    transform: translateY(24px);
    opacity: 0;
    transition:
        transform 700ms cubic-bezier(0.16, 1, 0.3, 1),
        opacity 700ms ease;
}

.glass-panel.visible {
    transform: translateY(0);
    opacity: 1;
}

.panel-center {
    max-width: 520px;
    width: 90vw;
    text-align: center;
    transform: translateY(24px);
}

.panel-center.visible {
    transform: translateY(0);
}

.panel-left {
    max-width: 480px;
    width: 100%;
    transform: translateX(-24px) translateY(0);
}

.panel-left.visible {
    transform: translateX(0) translateY(0);
}

.panel-right {
    max-width: 480px;
    width: 100%;
    transform: translateX(24px) translateY(0);
}

.panel-right.visible {
    transform: translateX(0) translateY(0);
}

.panel-video {
    max-width: 560px;
    width: 90vw;
}

.panel-warm {
    background: rgba(184, 150, 106, 0.06);
    border-color: rgba(184, 150, 106, 0.12);
}

/* ---- Node Label ---- */
.node-label {
    display: block;
    font-family: 'Space Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.12em;
    color: #8A9BAD;
    text-transform: uppercase;
    margin-bottom: 20px;
    opacity: 0.8;
}

/* ---- Wordmark ---- */
.wordmark {
    font-family: 'Jost', sans-serif;
    font-size: clamp(28px, 5vw, 52px);
    font-weight: 300;
    letter-spacing: 0.25em;
    color: #E8EDF4;
    text-transform: uppercase;
    line-height: 1.1;
    margin-bottom: 14px;
}

.wordmark-sub {
    font-family: 'Space Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.1em;
    color: #8A9BAD;
    opacity: 0.6;
}

/* ---- Prose ---- */
.prose {
    font-family: 'Crimson Pro', Georgia, serif;
    font-size: 17px;
    line-height: 1.85;
    color: #C4CEDB;
    margin-bottom: 1.2em;
}

.prose:last-child {
    margin-bottom: 0;
}

/* ---- Large Quote / Typewriter ---- */
.large-quote {
    font-family: 'Jost', sans-serif;
    font-size: clamp(22px, 3.2vw, 36px);
    font-weight: 300;
    line-height: 1.4;
    color: #E8EDF4;
    letter-spacing: 0.02em;
    border: none;
    padding: 0;
    margin: 12px 0 0 0;
    quotes: none;
}

.typewriter-target {
    display: inline;
}

.cursor {
    display: inline-block;
    color: #E8EDF4;
    font-weight: 300;
    animation: blink 1.2s step-end infinite;
}

.cursor.fading {
    animation: cursor-fade 1.5s ease forwards;
}

/* ---- Leather Tile (Node 1) ---- */
.leather-tile {
    position: absolute;
    right: 8vw;
    top: 50%;
    transform: translateY(-50%);
    width: 120px;
    height: 120px;
    background-color: #1A2744;
    background-image: linear-gradient(135deg, #1A2744, #0D1420);
    filter: url(#leather-grain);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(44, 62, 107, 0.6);
    z-index: 25;
    opacity: 0;
    transition: opacity 700ms ease 150ms;
}

.leather-tile.visible {
    opacity: 1;
}

.embossed-initials {
    font-family: 'Jost', sans-serif;
    font-size: 26px;
    font-weight: 600;
    letter-spacing: 0.15em;
    color: #2C3E6B;
    text-shadow:
        1px 1px 0 rgba(232, 237, 244, 0.07),
        -1px -1px 0 rgba(0, 0, 0, 0.8),
        0 2px 4px rgba(0, 0, 0, 0.6);
}

/* ---- Video Panel (Node 3) ---- */
.video-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background-color: #0D1420;
    border: 1px solid rgba(44, 62, 107, 0.3);
    margin: 16px 0 12px;
}

#noise-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0.85;
}

#noise-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
}

.video-timestamp {
    font-family: 'Space Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.08em;
    color: #8A9BAD;
    opacity: 0.6;
    text-align: right;
}

#video-timestamp-text {
    font-family: 'Space Mono', monospace;
}

/* ---- Spine Seal (Node 4) ---- */
.spine-seal {
    position: absolute;
    left: 50%;
    bottom: 60px;
    transform: translateX(-50%) scale(0) rotate(-20deg);
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background-color: #1A2744;
    background-image: linear-gradient(135deg, #2C3E6B, #1A2744);
    filter: url(#leather-grain);
    border: 1px solid rgba(44, 62, 107, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 25;
    opacity: 0;
    transition: all 0ms;
}

.spine-seal.visible {
    animation: seal-appear 600ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.seal-inner {
    font-family: 'Jost', sans-serif;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 0.1em;
    color: #4A6491;
    text-shadow:
        1px 1px 0 rgba(0,0,0,0.8),
        0 0 8px rgba(74, 100, 145, 0.4);
}

/* ---- End Spacer ---- */
.end-spacer {
    height: 20vh;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .node-left {
        padding-left: 5vw;
        padding-right: 5vw;
        justify-content: center;
    }

    .node-right {
        padding-left: 5vw;
        padding-right: 5vw;
        justify-content: center;
    }

    .panel-left,
    .panel-right {
        max-width: 100%;
        width: 100%;
        transform: translateY(24px) !important;
    }

    .panel-left.visible,
    .panel-right.visible {
        transform: translateY(0) !important;
    }

    .leather-tile {
        position: static;
        transform: none;
        margin-top: 24px;
        width: 80px;
        height: 80px;
    }

    #node-1 {
        flex-direction: column;
        align-items: center;
        padding-left: 5vw;
        padding-right: 5vw;
    }

    .spine-seal {
        bottom: 40px;
    }
}
