/* mybadge.page — Candlelit Archive */

:root {
    --bg-primary: #1a140e;
    --bg-secondary: #2b2218;
    --text-gold: #c9a96e;
    --text-parchment: #a08b6d;
    --accent-glow: #e8b84b;
    --border-bronze: #5a4a35;
    --highlight-ember: #d4956a;
    --subtle-smoke: #3d3228;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-gold);
    font-family: 'Crimson Pro', Georgia, serif;
    font-size: clamp(1rem, 1.8vw, 1.25rem);
    line-height: 2.0;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ========================
   EMBER PARTICLES
   ======================== */

#ember-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.ember {
    position: absolute;
    border-radius: 50%;
    background: var(--accent-glow);
    pointer-events: none;
}

@keyframes ember-rise {
    0% {
        opacity: 0;
        transform: translateY(0) translateX(0);
    }
    10% {
        opacity: var(--ember-opacity, 0.3);
    }
    90% {
        opacity: var(--ember-opacity, 0.3);
    }
    100% {
        opacity: 0;
        transform: translateY(-100vh) translateX(var(--ember-drift, 20px));
    }
}

/* ========================
   CANDLE NAVIGATION
   ======================== */

#candle-nav {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 100;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    animation: candle-flicker 3s ease-in-out infinite;
}

@keyframes candle-flicker {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    33% {
        opacity: 0.75;
        transform: scale(0.98);
    }
    66% {
        opacity: 0.9;
        transform: scale(1.02);
    }
}

/* ========================
   NAV OVERLAY
   ======================== */

#nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(26, 20, 14, 0.95);
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.5s ease;
}

#nav-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#chamber-nav {
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
    align-items: center;
}

.nav-link {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 600;
    font-size: clamp(2rem, 5vw, 4rem);
    font-variant: small-caps;
    letter-spacing: 0.15em;
    color: var(--text-parchment);
    text-decoration: none;
    transition: color 0.4s ease;
}

.nav-link:hover {
    color: var(--accent-glow);
}

/* ========================
   CHAMBERS — GENERAL
   ======================== */

.chamber {
    position: relative;
    width: 100%;
    overflow: hidden;
}

/* ========================
   CHAMBER I — ANTECHAMBER
   ======================== */

.chamber-1 {
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-primary);
}

.light-pool {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
}

.light-pool-hero {
    width: 60vw;
    height: 60vw;
    max-width: 800px;
    max-height: 800px;
    background: radial-gradient(circle, rgba(232, 184, 75, 0.08) 0%, transparent 70%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.badge-hero {
    position: relative;
    z-index: 2;
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 2s ease, transform 2s ease;
}

.badge-hero.visible {
    opacity: 1;
    transform: scale(1);
}

.badge-svg-hero {
    width: clamp(250px, 40vw, 500px);
    height: clamp(250px, 40vw, 500px);
}

.hero-title {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 600;
    font-variant: small-caps;
    font-size: clamp(1.5rem, 3vw, 2.8rem);
    letter-spacing: 0.08em;
    color: var(--text-gold);
    margin-top: 4rem;
    position: relative;
    z-index: 2;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 2s ease 0.5s, transform 2s ease 0.5s;
}

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

/* ========================
   BADGE BORDER TRACE ANIMATION
   ======================== */

.badge-border-trace {
    stroke-dasharray: 975;
    stroke-dashoffset: 975;
    transition: stroke-dashoffset 1.5s ease-in-out;
}

.badge-border-trace.traced {
    stroke-dashoffset: 0;
}

/* rect border trace for collection badges */
.badge-svg-collection .badge-border-trace {
    stroke-dasharray: 1120;
    stroke-dashoffset: 1120;
}

.badge-svg-collection .badge-border-trace.traced {
    stroke-dashoffset: 0;
}

/* Seal continuous trace */
.seal-border-trace {
    stroke-dasharray: 1445;
    stroke-dashoffset: 1445;
    animation: seal-trace 8s linear infinite;
}

@keyframes seal-trace {
    0% {
        stroke-dashoffset: 1445;
        stroke: var(--border-bronze);
    }
    33% {
        stroke: var(--accent-glow);
    }
    66% {
        stroke: var(--highlight-ember);
    }
    100% {
        stroke-dashoffset: 0;
        stroke: var(--border-bronze);
    }
}

/* ========================
   CHAMBER II — COLLECTION HALL
   ======================== */

.chamber-2 {
    min-height: 150vh;
    background-color: var(--bg-primary);
    padding: 10vh 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.badge-procession {
    position: relative;
    padding: 4rem 0;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease 0.3s, transform 0.8s ease 0.3s;
}

.badge-procession.visible {
    opacity: 1;
    transform: translateY(0);
}

.badge-procession .light-pool {
    width: 50vw;
    height: 50vw;
    max-width: 500px;
    max-height: 500px;
    background: radial-gradient(circle, rgba(232, 184, 75, 0.05) 0%, transparent 70%);
    top: 50%;
    transform: translateY(-50%);
}

.badge-left {
    padding-left: 15%;
}

.badge-left .light-pool {
    left: 5%;
}

.badge-right {
    padding-left: 55%;
}

.badge-right .light-pool {
    left: 45%;
}

.badge-frame {
    position: relative;
    z-index: 2;
}

.badge-svg-collection {
    width: clamp(200px, 40vw, 380px);
    height: clamp(200px, 40vw, 380px);
}

/* Dividers */

.divider {
    width: 0%;
    height: 1px;
    background-color: var(--border-bronze);
    margin: 2rem auto;
    transition: width 1s ease-in-out;
}

.divider.visible {
    width: 70vw;
}

/* ========================
   CHAMBER III — INSCRIPTION WALL
   ======================== */

.chamber-3 {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-secondary);
    position: relative;
    padding: 8vh 2rem;
}

.noise-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
    pointer-events: none;
}

.inscription-text {
    max-width: 65ch;
    position: relative;
    z-index: 2;
    opacity: 0;
    transition: opacity 2s ease;
}

.inscription-text.visible {
    opacity: 1;
}

.inscription-text p {
    font-family: 'Crimson Pro', Georgia, serif;
    font-size: clamp(1rem, 1.8vw, 1.4rem);
    line-height: 2.0;
    letter-spacing: 0.03em;
    color: var(--text-gold);
    margin-bottom: 2em;
}

.inscription-text p:last-child {
    margin-bottom: 0;
}

/* ========================
   CHAMBER IV — SEAL ROOM
   ======================== */

.chamber-4 {
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-primary);
    position: relative;
}

.light-pool-seal {
    width: 70vw;
    height: 70vw;
    max-width: 900px;
    max-height: 900px;
    background: radial-gradient(circle, rgba(232, 184, 75, 0.06) 0%, transparent 70%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -55%);
}

.seal-badge {
    position: relative;
    z-index: 2;
}

.badge-svg-seal {
    width: clamp(280px, 60vw, 600px);
    height: clamp(280px, 60vw, 600px);
}

.colophon {
    margin-top: 3rem;
    position: relative;
    z-index: 2;
}

.colophon-text {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 300;
    font-style: italic;
    font-size: clamp(0.9rem, 1.5vw, 1.2rem);
    color: var(--text-parchment);
    letter-spacing: 0.05em;
    animation: colophon-pulse 5s ease-in-out infinite;
}

.roman-year {
    font-feature-settings: 'onum' 1;
}

@keyframes colophon-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

/* ========================
   RESPONSIVE
   ======================== */

@media (max-width: 768px) {
    .badge-left {
        padding-left: 5%;
    }

    .badge-right {
        padding-left: 40%;
    }

    .badge-svg-collection {
        width: clamp(180px, 55vw, 300px);
        height: clamp(180px, 55vw, 300px);
    }
}

@media (max-width: 480px) {
    .badge-left,
    .badge-right {
        padding-left: 10%;
    }

    .badge-svg-collection {
        width: 80vw;
        height: 80vw;
    }

    .chamber-2 {
        align-items: center;
    }

    .badge-procession .light-pool {
        left: 0;
    }
}
