/* ============================================================
   continua.st - Deep Burgundy Marble HUD
   ============================================================ */

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

:root {
    --primary-burgundy: #4A0E1E;
    --secondary-burgundy: #8B2D42;
    --tertiary-burgundy: #5C1A2A;
    --marble-white: #F2EDE8;
    --marble-gray: #C4B8AD;
    --marble-dark: #3B2F2A;
    --accent-gold: #B8965A;
    --deep-black: #1A1210;

    --font-heading: 'Playfair Display', Georgia, serif;
    --font-label: 'Cormorant Garamond', Garamond, serif;
    --font-body: 'Source Serif 4', 'Source Serif Pro', Georgia, serif;
    --font-data: 'IBM Plex Mono', 'Courier New', monospace;

    --hud-inset: 24px;
    --panel-gap: 48px;
    --base-unit: 64px;
}

html {
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: var(--secondary-burgundy) var(--deep-black);
}

body {
    background: var(--deep-black);
    color: var(--marble-dark);
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 17px;
    line-height: 1.65;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

::selection {
    background: var(--secondary-burgundy);
    color: var(--marble-white);
}

/* --- Marble Background Canvas --- */
#marble-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

/* --- Scan Lines --- */
#scan-lines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    background: repeating-linear-gradient(
        to bottom,
        transparent,
        transparent 199px,
        rgba(139, 45, 66, 0.08) 199px,
        rgba(139, 45, 66, 0.08) 200px
    );
}

/* --- Grid Coordinates --- */
#grid-coordinates {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}

.grid-coord {
    position: absolute;
    font-family: var(--font-data);
    font-size: 9px;
    color: rgba(196, 184, 173, 0.25);
    user-select: none;
}

/* --- HUD Frame (z-index 20) --- */
#hud-frame {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20;
    pointer-events: none;
}

#hud-frame > * {
    pointer-events: auto;
}

.hud-border {
    position: absolute;
    background: rgba(139, 45, 66, 0.3);
}

.hud-border-top {
    top: var(--hud-inset);
    left: var(--hud-inset);
    right: var(--hud-inset);
    height: 1px;
}

.hud-border-bottom {
    bottom: var(--hud-inset);
    left: var(--hud-inset);
    right: var(--hud-inset);
    height: 1px;
}

.hud-border-left {
    top: var(--hud-inset);
    left: var(--hud-inset);
    bottom: var(--hud-inset);
    width: 1px;
}

.hud-border-right {
    top: var(--hud-inset);
    right: var(--hud-inset);
    bottom: var(--hud-inset);
    width: 1px;
}

/* --- HUD Corners --- */
.hud-corner {
    position: absolute;
    width: 16px;
    height: 16px;
}

.hud-corner::before,
.hud-corner::after {
    content: '';
    position: absolute;
    background: var(--secondary-burgundy);
}

.hud-corner-tl {
    top: var(--hud-inset);
    left: var(--hud-inset);
}
.hud-corner-tl::before { top: 0; left: 0; width: 16px; height: 1px; }
.hud-corner-tl::after { top: 0; left: 0; width: 1px; height: 16px; }

.hud-corner-tr {
    top: var(--hud-inset);
    right: var(--hud-inset);
}
.hud-corner-tr::before { top: 0; right: 0; width: 16px; height: 1px; }
.hud-corner-tr::after { top: 0; right: 0; width: 1px; height: 16px; }

.hud-corner-bl {
    bottom: var(--hud-inset);
    left: var(--hud-inset);
}
.hud-corner-bl::before { bottom: 0; left: 0; width: 16px; height: 1px; }
.hud-corner-bl::after { bottom: 0; left: 0; width: 1px; height: 16px; }

.hud-corner-br {
    bottom: var(--hud-inset);
    right: var(--hud-inset);
}
.hud-corner-br::before { bottom: 0; right: 0; width: 16px; height: 1px; }
.hud-corner-br::after { bottom: 0; right: 0; width: 1px; height: 16px; }

/* --- Wordmark --- */
#hud-wordmark {
    position: absolute;
    top: calc(var(--hud-inset) + 12px);
    left: calc(var(--hud-inset) + 16px);
    z-index: 25;
}

.wordmark-text {
    font-family: var(--font-label);
    font-weight: 500;
    font-variant: small-caps;
    font-size: 14px;
    letter-spacing: 0.15em;
    color: var(--marble-dark);
}

.wordmark-rule {
    width: 100%;
    height: 1px;
    background: var(--accent-gold);
    margin-top: 4px;
}

/* --- Pulse Ring --- */
#pulse-ring {
    position: absolute;
    top: calc(var(--hud-inset) + 16px);
    right: calc(var(--hud-inset) + 16px);
    width: 16px;
    height: 16px;
    pointer-events: none;
}

#pulse-ring::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1px solid var(--accent-gold);
    opacity: 0.3;
    animation: pulseRing 3s ease-in-out infinite;
}

@keyframes pulseRing {
    0%, 100% { width: 8px; height: 8px; opacity: 0; }
    50% { width: 16px; height: 16px; opacity: 0.3; }
}

/* --- Scroll Progress --- */
#scroll-progress {
    position: absolute;
    top: var(--hud-inset);
    left: calc(var(--hud-inset) - 4px);
    width: 2px;
    height: calc(100% - var(--hud-inset) * 2);
    background: transparent;
    pointer-events: none;
}

#scroll-progress-fill {
    width: 100%;
    height: 0%;
    background: var(--accent-gold);
    transition: height 0.1s linear;
}

/* --- Navigation Rail --- */
#nav-rail {
    position: absolute;
    right: calc(var(--hud-inset) + 12px);
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: flex-end;
}

.nav-rail-item {
    font-family: var(--font-label);
    font-weight: 500;
    font-variant: small-caps;
    font-size: 11px;
    letter-spacing: 0.15em;
    color: var(--marble-gray);
    text-decoration: none;
    transition: color 0.3s ease, letter-spacing 0.3s ease;
    white-space: nowrap;
    overflow: hidden;
}

.nav-rail-item:hover {
    color: var(--secondary-burgundy);
}

.nav-rail-item.active {
    color: var(--accent-gold);
}

/* --- Data Ticker --- */
#data-ticker {
    position: absolute;
    bottom: calc(var(--hud-inset) + 4px);
    left: calc(var(--hud-inset) + 16px);
    right: calc(var(--hud-inset) + 16px);
    height: 14px;
    overflow: hidden;
    pointer-events: none;
}

#data-ticker-content {
    font-family: var(--font-data);
    font-size: 10px;
    color: rgba(139, 45, 66, 0.5);
    white-space: nowrap;
    will-change: transform;
}

/* --- Content Layer (z-index 10) --- */
#content-layer {
    position: relative;
    z-index: 10;
    padding: calc(var(--hud-inset) + var(--panel-gap)) calc(var(--hud-inset) + var(--panel-gap));
    max-width: 100%;
}

.content-section {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: calc(var(--base-unit) * 0.75);
    padding: var(--base-unit) 0;
    align-items: center;
}

/* --- Breath Moments --- */
.breath-moment {
    height: 60vh;
    position: relative;
}

/* --- Panels --- */
.panel {
    position: relative;
    max-width: 800px;
    width: 100%;
    padding: 0;
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.panel[data-enter="left"] {
    transform: translateX(-60px);
}

.panel[data-enter="right"] {
    transform: translateX(60px);
}

.panel[data-enter="bottom"] {
    transform: translateY(40px);
}

.panel.panel-visible {
    opacity: 1;
    transform: translate(0, 0);
}

/* Panel Sizes */
.panel-hero {
    max-width: 700px;
    text-align: center;
    margin-top: 20vh;
}

.panel-wide {
    max-width: 760px;
}

.panel-medium {
    max-width: 620px;
}

.panel-narrow {
    max-width: 460px;
}

.panel-feature {
    max-width: 800px;
}

.panel-closing {
    max-width: 500px;
    text-align: center;
    margin-bottom: 20vh;
}

.panel-data-accent {
    max-width: 340px;
}

/* Panel offsets */
.panel-offset-right {
    align-self: flex-end;
    margin-right: 0;
}

.panel-offset-left {
    align-self: flex-start;
    margin-left: 0;
}

.panel-overlap {
    margin-top: -32px;
}

/* --- Panel Brackets (L-shaped corners) --- */
.panel-brackets {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 3;
}

.bracket {
    position: absolute;
    width: 16px;
    height: 16px;
    opacity: 0;
    transition: opacity 0.2s ease, width 0.2s ease, height 0.2s ease;
}

.panel.panel-visible .bracket {
    opacity: 1;
}

.bracket::before,
.bracket::after {
    content: '';
    position: absolute;
    background: rgba(92, 26, 42, 0.4);
}

.bracket-tl { top: 0; left: 0; }
.bracket-tl::before { top: 0; left: 0; width: 16px; height: 1px; }
.bracket-tl::after { top: 0; left: 0; width: 1px; height: 16px; }

.bracket-tr { top: 0; right: 0; }
.bracket-tr::before { top: 0; right: 0; width: 16px; height: 1px; }
.bracket-tr::after { top: 0; right: 0; width: 1px; height: 16px; }

.bracket-bl { bottom: 0; left: 0; }
.bracket-bl::before { bottom: 0; left: 0; width: 16px; height: 1px; }
.bracket-bl::after { bottom: 0; left: 0; width: 1px; height: 16px; }

.bracket-br { bottom: 0; right: 0; }
.bracket-br::before { bottom: 0; right: 0; width: 16px; height: 1px; }
.bracket-br::after { bottom: 0; right: 0; width: 1px; height: 16px; }

/* Hover: extend bracket arms */
.panel:hover .bracket {
    width: 24px;
    height: 24px;
}

.panel:hover .bracket-tl::before,
.panel:hover .bracket-tr::before,
.panel:hover .bracket-bl::before,
.panel:hover .bracket-br::before {
    width: 24px;
}

.panel:hover .bracket-tl::after,
.panel:hover .bracket-tr::after,
.panel:hover .bracket-bl::after,
.panel:hover .bracket-br::after {
    height: 24px;
}

/* --- Panel Border Lines --- */
.panel-border {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 2;
}

.panel-border .border-top,
.panel-border .border-bottom {
    position: absolute;
    left: 0;
    height: 1px;
    width: 0;
    background: rgba(92, 26, 42, 0.4);
    transition: width 0.4s ease 0.2s;
}

.panel-border .border-top { top: 0; }
.panel-border .border-bottom { bottom: 0; }

.panel-border .border-left,
.panel-border .border-right {
    position: absolute;
    top: 0;
    width: 1px;
    height: 0;
    background: rgba(92, 26, 42, 0.4);
    transition: height 0.4s ease 0.2s;
}

.panel-border .border-left { left: 0; }
.panel-border .border-right { right: 0; }

.panel.panel-visible .border-top,
.panel.panel-visible .border-bottom {
    width: 100%;
}

.panel.panel-visible .border-left,
.panel.panel-visible .border-right {
    height: 100%;
}

/* Hover: increase border opacity */
.panel:hover .panel-border .border-top,
.panel:hover .panel-border .border-bottom,
.panel:hover .panel-border .border-left,
.panel:hover .panel-border .border-right {
    background: rgba(92, 26, 42, 0.7);
}

/* --- Panel Glass (Frosted) --- */
.panel-glass {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(242, 237, 232, 0.85);
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
    transition: backdrop-filter 0.2s ease 0.6s, -webkit-backdrop-filter 0.2s ease 0.6s;
    z-index: 0;
    border-radius: 0;
}

.panel.panel-visible .panel-glass {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.panel:hover .panel-glass {
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.panel-glass-dark {
    background: rgba(74, 14, 30, 0.75);
}

/* --- Panel Content --- */
.panel-content {
    position: relative;
    z-index: 1;
    padding: 40px 48px;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.4s ease 0.8s, transform 0.4s ease 0.8s;
}

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

.panel-content-light {
    color: var(--marble-white);
}

/* --- Registration Marks --- */
.registration-marks {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 4;
}

.reg-mark {
    position: absolute;
    font-family: var(--font-data);
    font-size: 12px;
    line-height: 1;
    color: rgba(139, 45, 66, 0.4);
    opacity: 0;
    transition: opacity 0.3s ease 1s, transform 0.3s ease 1s;
}

.panel.panel-visible .reg-mark {
    opacity: 1;
}

.reg-tl { top: -6px; left: -6px; }
.reg-tr { top: -6px; right: -6px; }
.reg-bl { bottom: -6px; left: -6px; }
.reg-br { bottom: -6px; right: -6px; }

.panel.panel-visible .reg-mark.pulse {
    animation: regPulse 0.3s ease;
}

@keyframes regPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

/* --- Typography --- */
.display-heading {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 80px;
    line-height: 1.05;
    letter-spacing: -0.02em;
    color: var(--marble-dark);
    margin-bottom: 16px;
}

.subtitle {
    font-family: var(--font-label);
    font-weight: 500;
    font-size: 22px;
    color: var(--marble-gray);
    letter-spacing: 0.05em;
}

.section-heading {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 56px;
    line-height: 1.05;
    letter-spacing: -0.02em;
    color: var(--marble-dark);
    margin-bottom: 24px;
}

.panel-content-light .section-heading {
    color: var(--marble-white);
}

.panel-label {
    font-family: var(--font-label);
    font-weight: 500;
    font-variant: small-caps;
    font-size: 18px;
    letter-spacing: 0.1em;
    color: var(--secondary-burgundy);
    margin-bottom: 16px;
}

.panel-content-light .panel-label {
    color: var(--accent-gold);
}

.body-text {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 17px;
    line-height: 1.65;
    color: var(--marble-dark);
    max-width: 68ch;
}

.panel-content-light .body-text {
    color: rgba(242, 237, 232, 0.9);
}

.body-text + .body-text {
    margin-top: 1.2em;
}

.gold-accent {
    color: var(--accent-gold);
    font-style: inherit;
}

.panel-content-light .gold-accent {
    color: var(--accent-gold);
}

/* --- Data Accent Panel --- */
.panel-data-accent .panel-content {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 24px;
    padding: 24px 32px;
}

.data-label {
    font-family: var(--font-data);
    font-size: 10px;
    letter-spacing: 0.1em;
    color: var(--marble-gray);
    text-transform: uppercase;
    width: 100%;
}

.data-label:not(:first-child) {
    margin-top: 8px;
}

.data-value {
    font-family: var(--font-data);
    font-size: 14px;
    color: rgba(139, 45, 66, 0.7);
    width: 100%;
}

/* --- Closing --- */
.closing-text {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 36px;
    letter-spacing: -0.02em;
    color: var(--marble-dark);
    margin-bottom: 8px;
}

.closing-meta {
    font-family: var(--font-label);
    font-weight: 500;
    font-variant: small-caps;
    font-size: 13px;
    letter-spacing: 0.15em;
    color: var(--marble-gray);
}

/* --- Links --- */
a {
    color: var(--marble-dark);
    text-decoration: none;
    border-bottom: 1px solid var(--primary-burgundy);
    transition: border-color 0.25s ease, border-width 0.25s ease, color 0.25s ease;
}

a:hover {
    border-bottom-width: 2px;
    border-bottom-color: var(--accent-gold);
    color: var(--accent-gold);
}

/* --- HUD Breathing State --- */
body.hud-breathing #hud-frame .hud-border {
    transition: all 0.6s ease-in-out;
}

body.hud-breathing .hud-border-top { top: 0; left: 0; right: 0; }
body.hud-breathing .hud-border-bottom { bottom: 0; left: 0; right: 0; }
body.hud-breathing .hud-border-left { top: 0; left: 0; bottom: 0; }
body.hud-breathing .hud-border-right { top: 0; right: 0; bottom: 0; }

body.hud-breathing .hud-corner-tl { top: 0; left: 0; }
body.hud-breathing .hud-corner-tr { top: 0; right: 0; }
body.hud-breathing .hud-corner-bl { bottom: 0; left: 0; }
body.hud-breathing .hud-corner-br { bottom: 0; right: 0; }

/* --- Responsive: Mobile --- */
@media (max-width: 768px) {
    :root {
        --hud-inset: 12px;
        --panel-gap: 24px;
    }

    #content-layer {
        padding: calc(var(--hud-inset) + var(--panel-gap)) calc(var(--hud-inset) + 16px);
    }

    .content-section {
        gap: calc(var(--base-unit) * 0.5);
    }

    #nav-rail {
        display: none;
    }

    #grid-coordinates {
        display: none;
    }

    .hud-border-left,
    .hud-border-right {
        display: none;
    }

    .hud-corner {
        display: none;
    }

    .display-heading {
        font-size: 48px;
    }

    .section-heading {
        font-size: 36px;
    }

    .panel-hero {
        margin-top: 10vh;
    }

    .panel {
        max-width: 100%;
    }

    .panel-offset-right,
    .panel-offset-left {
        align-self: center;
    }

    .panel-overlap {
        margin-top: 0;
    }

    .panel:nth-child(odd) {
        transform: rotate(0.5deg);
    }

    .panel:nth-child(even) {
        transform: rotate(-0.5deg);
    }

    .panel.panel-visible {
        transform: rotate(0deg);
    }

    .panel-content {
        padding: 28px 24px;
    }

    .panel-data-accent .panel-content {
        padding: 20px 24px;
    }

    .breath-moment {
        height: 30vh;
    }

    #data-ticker {
        bottom: calc(var(--hud-inset) + 16px);
    }

    /* Simplified entrance on mobile */
    .bracket {
        display: none;
    }

    .panel-border .border-top,
    .panel-border .border-bottom,
    .panel-border .border-left,
    .panel-border .border-right {
        transition: none;
    }

    .panel.panel-visible .border-top,
    .panel.panel-visible .border-bottom {
        width: 100%;
    }

    .panel.panel-visible .border-left,
    .panel.panel-visible .border-right {
        height: 100%;
    }
}

@media (max-width: 480px) {
    .display-heading {
        font-size: 36px;
    }

    .section-heading {
        font-size: 28px;
    }

    .subtitle {
        font-size: 18px;
    }

    .body-text {
        font-size: 15px;
    }

    .panel-content {
        padding: 20px 16px;
    }
}
