/* ============================================================
   digitaltelomere.com - Styles
   Deep Burgundy | HUD-Overlay | Editorial Watercolor
   ============================================================ */

/* --- CSS Custom Properties --- */
:root {
    --bg-primary: #1E0A12;
    --bg-secondary: #3B1525;
    --accent-primary: #C4956A;
    --accent-secondary: #8A3B4D;
    --text-primary: #F2E6D9;
    --text-secondary: #BFA094;
    --highlight: #A4243B;
    --watercolor-wash: #D4A76A;
    --black: #000000;

    --font-display: 'Darker Grotesque', sans-serif;
    --font-body: 'Libre Baskerville', serif;
    --font-hud: 'Space Grotesk', sans-serif;
}

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
    background-color: var(--bg-primary);
}

body {
    font-family: var(--font-body);
    color: var(--text-primary);
    background-color: var(--bg-primary);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

::selection {
    background-color: var(--accent-secondary);
    color: var(--text-primary);
}

/* --- HUD Frame Overlay --- */
#hud-frame {
    position: fixed;
    top: 5vw;
    left: 5vw;
    right: 5vw;
    bottom: 5vw;
    border: 1px solid var(--accent-primary);
    opacity: 0;
    pointer-events: none;
    z-index: 100;
    transition: opacity 1.5s ease;
}

#hud-frame.visible {
    opacity: 0.4;
}

#hud-frame.fade-out {
    opacity: 0;
    transition: opacity 5s ease;
}

/* HUD Corner Marks */
.hud-corner {
    position: absolute;
    width: 20px;
    height: 20px;
}

.hud-corner::before,
.hud-corner::after {
    content: '';
    position: absolute;
    background-color: var(--accent-primary);
}

.hud-corner::before {
    width: 1px;
    height: 20px;
}

.hud-corner::after {
    width: 20px;
    height: 1px;
}

.hud-corner-tl {
    top: -1px;
    left: -1px;
}

.hud-corner-tl::before { top: 0; left: 0; }
.hud-corner-tl::after { top: 0; left: 0; }

.hud-corner-tr {
    top: -1px;
    right: -1px;
}

.hud-corner-tr::before { top: 0; right: 0; }
.hud-corner-tr::after { top: 0; right: 0; }

.hud-corner-bl {
    bottom: -1px;
    left: -1px;
}

.hud-corner-bl::before { bottom: 0; left: 0; }
.hud-corner-bl::after { bottom: 0; left: 0; }

.hud-corner-br {
    bottom: -1px;
    right: -1px;
}

.hud-corner-br::before { bottom: 0; right: 0; }
.hud-corner-br::after { bottom: 0; right: 0; }

/* HUD Registration Marks (+) */
.hud-registration {
    position: absolute;
    font-family: var(--font-hud);
    font-size: 8px;
    color: var(--accent-primary);
    opacity: 0.6;
    line-height: 1;
}

.hud-reg-top {
    top: -4px;
    left: 50%;
    transform: translateX(-50%);
}

.hud-reg-bottom {
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
}

.hud-reg-left {
    left: -6px;
    top: 50%;
    transform: translateY(-50%);
}

.hud-reg-right {
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
}

/* Corner blink animation for Act IV */
@keyframes cornerBlink {
    0%, 95% { opacity: 0.4; }
    97.5% { opacity: 0.8; }
    100% { opacity: 0.4; }
}

#hud-frame.corner-blink .hud-corner::before,
#hud-frame.corner-blink .hud-corner::after {
    animation: cornerBlink 10s ease-in-out infinite;
}

/* HUD Section Indicator (bottom bar) */
#hud-section-indicator {
    position: absolute;
    bottom: 12px;
    left: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.hud-label {
    font-family: var(--font-hud);
    font-size: clamp(0.65rem, 1vw, 0.8rem);
    font-weight: 500;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-secondary);
    opacity: 0.6;
}

#hud-section-name {
    font-family: var(--font-hud);
    font-size: clamp(0.65rem, 1vw, 0.8rem);
    font-weight: 500;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--accent-primary);
    transition: opacity 0.4s ease;
}

/* --- Dot Navigation --- */
#dot-nav {
    position: fixed;
    right: calc(5vw + 16px);
    top: 50%;
    transform: translateY(-50%);
    z-index: 110;
    display: flex;
    flex-direction: column;
    gap: 16px;
    opacity: 0;
    transition: opacity 1s ease;
}

#dot-nav.visible {
    opacity: 1;
}

.dot-nav-item {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1px solid var(--accent-primary);
    background: transparent;
    cursor: pointer;
    padding: 0;
    transition: background-color 0.3s ease, transform 0.3s ease;
}

.dot-nav-item:hover {
    transform: scale(1.4);
}

.dot-nav-item.active {
    background-color: var(--accent-primary);
}

/* --- Sections (Acts) --- */
.act {
    position: relative;
    min-height: 100vh;
    overflow: hidden;
    background-color: var(--bg-primary);
}

.act-specimen {
    height: 100vh;
}

.act-cartography {
    min-height: 90vh;
    padding-top: 10vh;
    padding-bottom: 10vh;
}

.act-observatory {
    min-height: 90vh;
    padding-top: 10vh;
    padding-bottom: 10vh;
}

.act-synthesis {
    min-height: 90vh;
    padding-top: 10vh;
    padding-bottom: 10vh;
}

.act-endcap {
    min-height: 80vh;
    padding-top: 10vh;
    padding-bottom: 10vh;
}

/* Breathing space between sections */
.act + .act {
    margin-top: 20vh;
}

/* --- Watercolor Backgrounds --- */
.watercolor-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    opacity: 0;
    transition: opacity 2s ease, transform 2s ease;
    transform: scale(1.05);
}

.watercolor-bg.visible {
    opacity: 1;
    transform: scale(1.0);
}

/* Continuous watercolor morph */
@keyframes watercolorDrift1 {
    0% { transform: scale(1.0) rotate(0deg); }
    25% { transform: scale(1.02) rotate(0.3deg); }
    50% { transform: scale(1.0) rotate(0deg); }
    75% { transform: scale(0.99) rotate(-0.3deg); }
    100% { transform: scale(1.0) rotate(0deg); }
}

@keyframes watercolorDrift2 {
    0% { transform: scale(1.0) rotate(0deg); }
    33% { transform: scale(1.01) rotate(-0.2deg); }
    66% { transform: scale(0.99) rotate(0.2deg); }
    100% { transform: scale(1.0) rotate(0deg); }
}

.watercolor-bg.visible g {
    animation: watercolorDrift1 45s ease-in-out infinite;
}

#watercolor-2.visible g {
    animation: watercolorDrift2 40s ease-in-out infinite;
}

/* Membrane pulse for Act III */
@keyframes membranePulse {
    0% { transform: scale(1.0); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1.0); }
}

.membrane-circle {
    animation: membranePulse 8s ease-in-out infinite;
    transform-origin: center;
}

.membrane-circle-inner {
    animation: membranePulse 8s ease-in-out infinite reverse;
    transform-origin: center;
}

/* --- Scanlines --- */
.scanlines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 3px,
        rgba(196, 149, 106, 0.03) 3px,
        rgba(196, 149, 106, 0.03) 4px
    );
    opacity: 0;
    transition: opacity 1s ease;
}

.scanlines.visible {
    opacity: 1;
}

.act-observatory .scanlines.visible {
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 3px,
        rgba(196, 149, 106, 0.05) 3px,
        rgba(196, 149, 106, 0.05) 4px
    );
}

/* --- Section Dividers --- */
.section-divider {
    position: relative;
    z-index: 10;
    display: flex;
    justify-content: center;
    padding: 0 10vw;
    margin-bottom: 6vh;
}

.divider-line {
    width: 100%;
    max-width: 800px;
    height: 2px;
}

.divider-line line {
    transition: stroke-dashoffset 1.2s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.section-divider.visible .divider-line line {
    stroke-dashoffset: 0;
}

/* --- ACT I: The Specimen --- */
.act-1-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-left: 10vw;
    padding-top: 5vh;
}

#main-title {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(3rem, 8vw, 7rem);
    color: var(--text-primary);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    line-height: 1;
    margin-bottom: 0;
}

#main-title .char {
    display: inline-block;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

#main-title .char.visible {
    opacity: 1;
    transform: translateY(0);
}

.title-hidden {
    opacity: 0;
}

#title-line {
    width: 0;
    height: 1px;
    background-color: var(--accent-primary);
    margin: 1.5rem 0;
    transition: width 0.8s cubic-bezier(0.25, 0.1, 0.25, 1);
}

#title-line.visible {
    width: min(400px, 50vw);
}

.title-line-hidden {
    width: 0;
}

#subtitle {
    font-family: var(--font-body);
    font-style: italic;
    font-size: clamp(1rem, 2vw, 1.5rem);
    color: var(--text-secondary);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 1s ease 0.3s, transform 1s ease 0.3s;
}

#subtitle.visible {
    opacity: 1;
    transform: translateY(0);
}

.subtitle-hidden {
    opacity: 0;
}

/* --- Data Annotations --- */
.data-annotations {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    pointer-events: none;
}

.annotation {
    position: absolute;
    font-family: var(--font-hud);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-secondary);
    opacity: 0;
    transition: opacity 0.6s ease;
}

.annotation.visible {
    opacity: 0.5;
}

.annotation.fade-out {
    opacity: 0;
    transition: opacity 1.5s ease;
}

/* --- Editorial Layout (Acts II & IV) --- */
.editorial-layout {
    position: relative;
    z-index: 10;
    display: grid;
    grid-template-columns: 28% 10% 62%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 8vw;
    align-items: start;
}

.ghosted-number {
    position: absolute;
    top: -5vh;
    left: 5%;
    font-family: var(--font-display);
    font-weight: 900;
    font-size: 20vw;
    color: var(--bg-secondary);
    opacity: 0.15;
    line-height: 1;
    z-index: -1;
    pointer-events: none;
    user-select: none;
}

/* Caption block (left column) */
.editorial-left {
    padding-top: 2rem;
}

.caption-block {
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: sticky;
    top: 30vh;
}

.caption-label {
    font-family: var(--font-hud);
    font-size: clamp(0.65rem, 1vw, 0.8rem);
    font-weight: 500;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--accent-primary);
}

.caption-title {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    color: var(--text-primary);
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.caption-meta {
    font-family: var(--font-body);
    font-style: italic;
    font-size: clamp(0.85rem, 1.2vw, 1rem);
    color: var(--text-secondary);
    line-height: 1.5;
    margin-top: 4px;
}

/* Right column content */
.editorial-right {
    grid-column: 3;
}

.editorial-right p {
    font-family: var(--font-body);
    font-size: clamp(0.95rem, 1.8vw, 1.15rem);
    line-height: 1.72;
    color: var(--text-primary);
    margin-bottom: 1.5em;
}

/* Drop Caps */
.drop-cap::first-letter {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: 4.5em;
    float: left;
    line-height: 0.75;
    margin-right: 0.1em;
    margin-top: 0.1em;
    color: var(--text-primary);
    border-bottom: 2px solid var(--accent-primary);
    padding-bottom: 4px;
}

/* Section Headings */
.section-heading {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.5rem, 3vw, 2.2rem);
    color: var(--text-primary);
    letter-spacing: -0.02em;
    margin-bottom: 1.5rem;
    margin-top: 2rem;
}

.section-heading:first-child {
    margin-top: 0;
}

/* Pull Quotes */
.pull-quote {
    position: relative;
    padding: 2rem 0 2rem 2rem;
    margin: 2.5rem 0;
    border: none;
}

.pull-quote-line {
    position: absolute;
    left: 0;
    top: 0;
    width: 2px;
    height: 100%;
    background-color: var(--accent-primary);
}

.pull-quote p {
    font-family: var(--font-body);
    font-style: italic;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem) !important;
    line-height: 1.6 !important;
    color: var(--text-primary);
}

/* --- ACT III: Observatory --- */
.observatory-content {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}

.observatory-text {
    max-width: 32ch;
    text-align: left;
}

.observatory-text p {
    font-family: var(--font-body);
    font-size: clamp(0.95rem, 1.8vw, 1.15rem);
    line-height: 1.72;
    color: var(--text-primary);
    margin-bottom: 1.5em;
}

/* --- ACT V: Endcap --- */
.act-endcap {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#particle-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.endcap-content {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 2rem;
}

.endcap-title {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(2rem, 5vw, 4.5rem);
    color: var(--text-primary);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1.5s ease, transform 1.5s ease;
}

.endcap-title.visible {
    opacity: 1;
    transform: translateY(0);
}

.endcap-closing {
    font-family: var(--font-body);
    font-style: italic;
    font-size: clamp(1rem, 2vw, 1.4rem);
    color: var(--text-secondary);
    opacity: 0;
    transition: opacity 2s ease 0.5s;
}

.endcap-closing.visible {
    opacity: 1;
}

/* Background transition to black at end */
.act-endcap::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 30vh;
    background: linear-gradient(to bottom, transparent, var(--black));
    z-index: 2;
    pointer-events: none;
}

/* --- Scroll-triggered reveal animations --- */
.act-content {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 1.2s ease, transform 1.2s ease;
}

.act-content.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Act I content is special - positioned absolutely */
.act-1-content {
    opacity: 1;
    transform: none;
}

.act-1-content.visible {
    opacity: 1;
    transform: none;
}

/* --- Responsive --- */
@media (max-width: 900px) {
    #hud-frame {
        top: 3vw;
        left: 3vw;
        right: 3vw;
        bottom: 3vw;
    }

    .editorial-layout {
        display: flex;
        flex-direction: column;
        padding: 0 6vw;
    }

    .editorial-right {
        grid-column: auto;
    }

    .editorial-left {
        margin-bottom: 3rem;
    }

    .caption-block {
        position: relative;
        top: auto;
    }

    .ghosted-number {
        font-size: 30vw;
    }

    .act-1-content {
        padding-left: 6vw;
        padding-right: 6vw;
    }

    .observatory-text {
        max-width: 90%;
    }

    #dot-nav {
        right: calc(3vw + 10px);
    }

    .pull-quote p {
        font-size: clamp(1rem, 2vw, 1.4rem) !important;
    }
}

@media (max-width: 600px) {
    #main-title {
        font-size: clamp(2rem, 10vw, 4rem);
    }

    .editorial-layout {
        padding: 0 5vw;
    }

    .act-content.editorial-layout {
        padding: 0 5vw;
    }

    .drop-cap::first-letter {
        font-size: 3em;
    }
}
