/* ============================================
   archetype.boo -- Styles
   McBling + Celestial Atlas collision aesthetic
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --gold: #D4AF37;
    --violet: #7B68AE;
    --teal: #4A9E8E;
    --parchment-light: #F5EACC;
    --parchment-dark: #D9C9A1;
    --espresso: #3D2B1F;
    --obsidian: #1E1510;
    --crystal-white: #FFF8F0;
    --parchment-bg: #F0E6D3;

    --font-headline: 'Playfair Display', Georgia, serif;
    --font-body: 'Nunito', 'Segoe UI', sans-serif;
    --font-hud: 'Share Tech Mono', 'Courier New', monospace;

    --flow-oscillation: 15%;
    --hud-width: 48px;
}

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.2rem);
    line-height: 1.75;
    color: var(--espresso);
    background-color: var(--parchment-light);
    overflow-x: hidden;
    position: relative;
}

/* --- Paper-Aged Texture Overlay --- */
#paper-texture {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    opacity: 0.08;
    background-image:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 40px,
            rgba(61, 43, 31, 0.03) 40px,
            rgba(61, 43, 31, 0.03) 41px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 40px,
            rgba(61, 43, 31, 0.02) 40px,
            rgba(61, 43, 31, 0.02) 41px
        ),
        radial-gradient(ellipse at 20% 50%, rgba(61, 43, 31, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(61, 43, 31, 0.04) 0%, transparent 40%),
        radial-gradient(ellipse at 60% 80%, rgba(61, 43, 31, 0.05) 0%, transparent 45%),
        radial-gradient(circle at 35% 35%, rgba(61, 43, 31, 0.08) 0%, transparent 3%),
        radial-gradient(circle at 72% 68%, rgba(61, 43, 31, 0.06) 0%, transparent 2%),
        radial-gradient(circle at 15% 80%, rgba(61, 43, 31, 0.07) 0%, transparent 2.5%),
        radial-gradient(circle at 85% 40%, rgba(61, 43, 31, 0.05) 0%, transparent 2%),
        radial-gradient(circle at 50% 10%, rgba(61, 43, 31, 0.04) 0%, transparent 3%),
        radial-gradient(circle at 25% 65%, rgba(61, 43, 31, 0.06) 0%, transparent 2.5%);
    background-attachment: fixed;
}

/* --- Sparkle Container --- */
#sparkle-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
    overflow: hidden;
}

.sparkle {
    position: absolute;
    width: 0;
    height: 0;
    animation: sparkle-life var(--sparkle-duration, 5s) ease-in-out forwards;
}

.sparkle::before,
.sparkle::after {
    content: '';
    position: absolute;
    background: var(--sparkle-color, var(--crystal-white));
}

.sparkle::before {
    width: var(--sparkle-size, 4px);
    height: 1px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.sparkle::after {
    width: 1px;
    height: var(--sparkle-size, 4px);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

@keyframes sparkle-life {
    0% {
        opacity: 0;
        transform: scale(0) rotate(0deg);
    }
    15% {
        opacity: 1;
        transform: scale(1) rotate(20deg);
    }
    40% {
        opacity: 0.9;
        transform: scale(1.3) rotate(35deg);
    }
    60% {
        opacity: 0.7;
        transform: scale(1.1) rotate(55deg);
    }
    85% {
        opacity: 0.4;
        transform: scale(0.7) rotate(75deg);
    }
    100% {
        opacity: 0;
        transform: scale(0) rotate(90deg);
    }
}

/* --- HUD Corner Brackets --- */
.hud-corner {
    position: fixed;
    width: 40px;
    height: 40px;
    z-index: 90;
    opacity: 0;
    transition: opacity 1.5s ease, border-color 600ms ease;
    pointer-events: none;
}

.hud-corner.visible {
    opacity: 1;
    animation: hud-pulse 3s ease-in-out infinite;
}

.hud-corner-tl {
    top: 16px;
    left: 16px;
    border-top: 2px solid rgba(212, 175, 55, 0.4);
    border-left: 2px solid rgba(212, 175, 55, 0.4);
}

.hud-corner-tr {
    top: 16px;
    right: 16px;
    border-top: 2px solid rgba(212, 175, 55, 0.4);
    border-right: 2px solid rgba(212, 175, 55, 0.4);
}

.hud-corner-bl {
    bottom: 16px;
    left: 16px;
    border-bottom: 2px solid rgba(212, 175, 55, 0.4);
    border-left: 2px solid rgba(212, 175, 55, 0.4);
}

.hud-corner-br {
    bottom: 16px;
    right: 16px;
    border-bottom: 2px solid rgba(212, 175, 55, 0.4);
    border-right: 2px solid rgba(212, 175, 55, 0.4);
}

/* Footer deep-space: HUD corners become more prominent */
.hud-corner.footer-mode {
    border-color: rgba(212, 175, 55, 0.7);
}
.hud-corner.footer-mode.hud-corner-tl,
.hud-corner.footer-mode.hud-corner-tr,
.hud-corner.footer-mode.hud-corner-bl,
.hud-corner.footer-mode.hud-corner-br {
    border-color: rgba(212, 175, 55, 0.7);
}

@keyframes hud-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* --- HUD Sidebars --- */
.hud-sidebar {
    position: fixed;
    top: 0;
    width: var(--hud-width);
    height: 100vh;
    z-index: 80;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 20px;
    padding: 20px 6px;
    opacity: 0;
    transition: opacity 1.5s ease;
    pointer-events: none;
    background: linear-gradient(to bottom, rgba(30, 21, 16, 0.02), rgba(30, 21, 16, 0.06), rgba(30, 21, 16, 0.02));
    border-color: rgba(212, 175, 55, 0.2);
    box-shadow: 0 0 8px rgba(212, 175, 55, 0.15);
}

.hud-sidebar.visible {
    opacity: 1;
}

#hud-left {
    left: 0;
    border-right: 1px solid rgba(212, 175, 55, 0.2);
}

#hud-right {
    right: 0;
    border-left: 1px solid rgba(212, 175, 55, 0.2);
}

.hud-section {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.hud-label {
    font-family: var(--font-hud);
    font-size: 7px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--gold);
    opacity: 0.7;
}

.hud-value {
    font-family: var(--font-hud);
    font-size: 8px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--violet);
    opacity: 0.6;
    transition: opacity 300ms ease;
    line-height: 1.4;
    word-break: break-all;
}

.hud-value.fading {
    opacity: 0;
}

#hud-scroll-map {
    width: 20px;
    height: 100px;
}

#hud-scroll-map svg {
    width: 100%;
    height: 100%;
}

#scroll-indicator {
    transition: cy 100ms ease-out;
    filter: drop-shadow(0 0 4px rgba(212, 175, 55, 0.6));
}

/* Signal bars */
#hud-signal {
    display: flex;
    gap: 2px;
    align-items: flex-end;
    height: 20px;
}

.signal-bar {
    width: 3px;
    background: var(--gold);
    opacity: 0.6;
    animation: signal-pulse 2s ease-in-out infinite;
}

.signal-bar:nth-child(1) { height: 4px; animation-delay: 0s; }
.signal-bar:nth-child(2) { height: 7px; animation-delay: 0.2s; }
.signal-bar:nth-child(3) { height: 11px; animation-delay: 0.4s; }
.signal-bar:nth-child(4) { height: 15px; animation-delay: 0.6s; }
.signal-bar:nth-child(5) { height: 19px; animation-delay: 0.8s; }

@keyframes signal-pulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.8; }
}

/* --- HUD Mobile Pill --- */
#hud-mobile-pill {
    display: none;
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 80;
    background: rgba(30, 21, 16, 0.85);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 20px;
    padding: 6px 16px;
    gap: 8px;
    align-items: center;
    box-shadow: 0 0 8px rgba(212, 175, 55, 0.15);
    opacity: 0;
    transition: opacity 1.5s ease;
    pointer-events: none;
    backdrop-filter: blur(8px);
}

#hud-mobile-pill.visible {
    opacity: 1;
}

.hud-pill-label {
    font-family: var(--font-hud);
    font-size: 9px;
    letter-spacing: 0.08em;
    color: var(--gold);
    text-transform: uppercase;
}

.hud-pill-value {
    font-family: var(--font-hud);
    font-size: 9px;
    letter-spacing: 0.05em;
    color: var(--violet);
    text-transform: uppercase;
}

/* --- Main Content Flow --- */
#content-flow {
    position: relative;
    z-index: 10;
    padding: 0;
    max-width: 100vw;
    overflow-x: hidden;
}

/* --- Hero Section --- */
#hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: linear-gradient(
        180deg,
        var(--obsidian) 0%,
        rgba(30, 21, 16, 0.97) 40%,
        rgba(30, 21, 16, 0.95) 70%,
        var(--espresso) 100%
    );
    overflow: hidden;
}

/* Dark section paper texture inversion */
#hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.05;
    pointer-events: none;
    background-image:
        radial-gradient(circle at 30% 40%, rgba(245, 234, 204, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 70% 60%, rgba(245, 234, 204, 0.06) 0%, transparent 35%),
        radial-gradient(circle at 50% 20%, rgba(245, 234, 204, 0.04) 0%, transparent 30%);
}

.hero-inner {
    position: relative;
    text-align: center;
    padding: 2rem;
}

.hero-constellation {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(80vw, 600px);
    height: min(80vw, 600px);
    opacity: 0.6;
    z-index: 0;
}

.hero-title {
    font-family: var(--font-headline);
    font-weight: 900;
    font-size: clamp(3rem, 8vw, 7rem);
    letter-spacing: -0.02em;
    color: var(--gold);
    text-shadow:
        1px 1px 2px rgba(212, 175, 55, 0.3),
        0 0 40px rgba(212, 175, 55, 0.15),
        0 0 80px rgba(212, 175, 55, 0.05);
    position: relative;
    z-index: 1;
    opacity: 0;
    transform: translateY(30px);
    animation: hero-reveal 1.2s cubic-bezier(0.23, 1, 0.32, 1) 0.5s forwards;
}

.hero-subtitle {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.9rem, 2vw, 1.3rem);
    color: var(--parchment-bg);
    margin-top: 1rem;
    position: relative;
    z-index: 1;
    opacity: 0;
    transform: translateY(20px);
    animation: hero-reveal 1s cubic-bezier(0.23, 1, 0.32, 1) 1s forwards;
}

/* Hero gradient fade to parchment */
.hero-gradient-fade {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 120px;
    background: linear-gradient(
        180deg,
        transparent 0%,
        var(--parchment-light) 100%
    );
    z-index: 2;
    pointer-events: none;
}

@keyframes hero-reveal {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Content Clusters & Organic Flow --- */
.content-cluster {
    position: relative;
    margin: clamp(4rem, 8vh, 10rem) auto;
    max-width: 700px;
    padding: 0 2rem;
}

.cluster-drift-right {
    transform: translateX(calc(var(--flow-oscillation) * 0.5));
}

.cluster-drift-left {
    transform: translateX(calc(var(--flow-oscillation) * -0.5));
}

.cluster-drift-center {
    transform: translateX(0);
}

/* --- Content Blocks --- */
.content-block {
    margin-bottom: clamp(2rem, 4vh, 4rem);
    opacity: 0;
    transform: translateY(40px) translateX(0px) rotate(0deg);
    transition: opacity 800ms cubic-bezier(0.23, 1, 0.32, 1),
                transform 800ms cubic-bezier(0.23, 1, 0.32, 1);
}

.content-block.visible {
    opacity: 1;
    transform: translateY(0) translateX(0) rotate(0deg);
}

/* Drift directions for organic feel */
.drift-element[data-drift="1"] { transform: translateY(40px) translateX(20px) rotate(1deg); }
.drift-element[data-drift="2"] { transform: translateY(40px) translateX(-15px) rotate(-1.5deg); }
.drift-element[data-drift="3"] { transform: translateY(40px) translateX(-20px) rotate(1.5deg); }
.drift-element[data-drift="4"] { transform: translateY(40px) translateX(15px) rotate(-1deg); }
.drift-element[data-drift="5"] { transform: translateY(40px) translateX(20px) rotate(2deg); }
.drift-element[data-drift="6"] { transform: translateY(40px) translateX(-20px) rotate(-1.5deg); }
.drift-element[data-drift="7"] { transform: translateY(40px) translateX(-15px) rotate(1deg); }
.drift-element[data-drift="8"] { transform: translateY(40px) translateX(20px) rotate(-2deg); }
.drift-element[data-drift="9"] { transform: translateY(40px) translateX(15px) rotate(1.5deg); }
.drift-element[data-drift="10"] { transform: translateY(40px) translateX(-20px) rotate(-1deg); }
.drift-element[data-drift="11"] { transform: translateY(40px) translateX(-15px) rotate(2deg); }
.drift-element[data-drift="12"] { transform: translateY(40px) translateX(20px) rotate(-1.5deg); }
.drift-element[data-drift="13"] { transform: translateY(40px) translateX(15px) rotate(1.5deg); }
.drift-element[data-drift="14"] { transform: translateY(40px) translateX(-20px) rotate(-1deg); }
.drift-element[data-drift="15"] { transform: translateY(40px) translateX(0px) rotate(1deg); }

.drift-element.visible {
    transform: translateY(0) translateX(0) rotate(0deg) !important;
}

/* Hover interactions */
.content-block:hover {
    transition: transform 300ms ease, box-shadow 300ms ease;
}

.content-block.visible:hover {
    transform: rotate(0.5deg) !important;
    box-shadow: 0 0 24px rgba(212, 175, 55, 0.08);
}

/* --- Typography --- */
.section-heading {
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: clamp(1.8rem, 4vw, 3.2rem);
    color: var(--espresso);
    letter-spacing: -0.02em;
    text-shadow: 1px 1px 2px rgba(212, 175, 55, 0.3);
    margin-bottom: 1.2rem;
    line-height: 1.2;
}

.content-block p {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.2rem);
    line-height: 1.75;
    color: var(--espresso);
    margin-bottom: 1rem;
}

.content-block p:last-child {
    margin-bottom: 0;
}

/* Emphasized text within paragraphs */
.content-block p strong,
.content-block p em {
    font-weight: 600;
}

/* --- Section Illustrations --- */
.section-illustration {
    display: block;
    width: min(100%, 300px);
    height: auto;
    margin: 0 auto;
}

.section-illustration:hover .star-node {
    filter: drop-shadow(0 0 6px var(--gold));
    transform-origin: center;
}

/* --- SVG Path Drawing Animation --- */
.draw-path {
    stroke-dasharray: var(--path-length, 1000);
    stroke-dashoffset: var(--path-length, 1000);
    transition: stroke-dashoffset 1s cubic-bezier(0.23, 1, 0.32, 1);
}

.draw-path.drawn {
    stroke-dashoffset: 0;
}

/* Hero paths draw slightly slower for drama */
.hero-path {
    transition: stroke-dashoffset 1.4s cubic-bezier(0.23, 1, 0.32, 1);
}

.star-node {
    transition: opacity 600ms ease, filter 300ms ease;
}

.star-node.visible {
    opacity: 1;
}

/* --- Constellation Connectors --- */
.constellation-connector {
    max-width: 500px;
    margin: clamp(2rem, 4vh, 5rem) auto;
    padding: 0 2rem;
    opacity: 0.7;
}

.constellation-connector svg {
    width: 100%;
    height: auto;
}

/* --- Rhinestone Dividers --- */
.rhinestone-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 1.5rem;
}

.rhinestone {
    width: 8px;
    height: 8px;
    background: radial-gradient(circle at 30% 30%, var(--crystal-white), var(--gold));
    transform: rotate(45deg);
    box-shadow: 0 0 4px rgba(212, 175, 55, 0.4);
    animation: rhinestone-shimmer 3s ease-in-out infinite;
}

.rhinestone-sm {
    width: 5px;
    height: 5px;
}

@keyframes rhinestone-shimmer {
    0%, 100% { box-shadow: 0 0 4px rgba(212, 175, 55, 0.4); }
    50% { box-shadow: 0 0 8px rgba(212, 175, 55, 0.7), 0 0 16px rgba(255, 248, 240, 0.3); }
}

/* --- Gold Filigree Panels --- */
.gold-filigree-panel {
    position: relative;
    padding: clamp(2rem, 4vw, 3.5rem);
    background: rgba(217, 201, 161, 0.3);
    border-radius: 2px;
}

.filigree-corner {
    position: absolute;
    width: 40px;
    height: 40px;
}

.filigree-tl { top: 0; left: 0; }
.filigree-tr { top: 0; right: 0; }
.filigree-bl { bottom: 0; left: 0; }
.filigree-br { bottom: 0; right: 0; }

.panel-quote {
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: clamp(1.1rem, 2.5vw, 1.5rem);
    line-height: 1.6;
    color: var(--espresso);
    text-align: center;
    font-style: italic;
    text-shadow: 1px 1px 2px rgba(212, 175, 55, 0.2);
}

/* --- Footer --- */
#site-footer {
    position: relative;
    padding: clamp(4rem, 10vh, 10rem) 2rem clamp(3rem, 6vh, 6rem);
    text-align: center;
    background: linear-gradient(
        180deg,
        var(--parchment-light) 0%,
        var(--espresso) 30%,
        var(--obsidian) 100%
    );
}

/* Dark-panel paper texture for footer */
#site-footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.05;
    pointer-events: none;
    background-image:
        radial-gradient(circle at 40% 50%, rgba(245, 234, 204, 0.06) 0%, transparent 35%),
        radial-gradient(circle at 65% 30%, rgba(245, 234, 204, 0.04) 0%, transparent 30%);
}

.footer-constellation {
    display: block;
    width: min(80%, 400px);
    height: auto;
    margin: 0 auto 2rem;
    opacity: 0.8;
}

.footer-text {
    font-family: var(--font-headline);
    font-weight: 900;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    color: var(--gold);
    text-shadow:
        1px 1px 2px rgba(212, 175, 55, 0.3),
        0 0 30px rgba(212, 175, 55, 0.1);
    letter-spacing: -0.02em;
}

.footer-meta {
    font-family: var(--font-hud);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--violet);
    opacity: 0.6;
    margin-top: 0.5rem;
}

/* --- Responsive: Tablet --- */
@media (max-width: 1200px) and (min-width: 769px) {
    :root {
        --flow-oscillation: 8%;
    }

    .hud-sidebar {
        display: none !important;
    }

    .content-cluster {
        max-width: 600px;
    }
}

/* --- Responsive: Mobile --- */
@media (max-width: 768px) {
    :root {
        --flow-oscillation: 4%;
    }

    .hud-sidebar {
        display: none !important;
    }

    #hud-mobile-pill {
        display: flex;
    }

    .content-cluster {
        max-width: 100%;
        padding: 0 1.5rem;
    }

    .cluster-drift-right,
    .cluster-drift-left {
        transform: translateX(0);
    }

    .hero-constellation {
        width: 90vw;
        height: 90vw;
    }

    .gold-filigree-panel {
        padding: 1.5rem;
    }

    .filigree-corner {
        width: 30px;
        height: 30px;
    }

    .hud-corner {
        width: 25px;
        height: 25px;
    }

    .constellation-connector {
        max-width: 90%;
    }
}

/* --- Dark section text override --- */
#hero .hero-subtitle {
    color: var(--parchment-bg);
}

#site-footer .footer-text {
    color: var(--gold);
}

#site-footer .footer-meta {
    color: var(--violet);
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--parchment-light);
}

::-webkit-scrollbar-thumb {
    background: rgba(212, 175, 55, 0.3);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(212, 175, 55, 0.5);
}

/* --- Selection --- */
::selection {
    background: rgba(212, 175, 55, 0.3);
    color: var(--obsidian);
}
