/* ============================================
   MasqueradeProtocol.com - Styles
   Color Palette:
     Obsidian:        #0D0A07
     Burgundy Depths: #4A0E1B
     Worn Leather:    #2A1A0E
     Burnished Gold:  #C4953A
     Candlelight:     #E8C47C
     Aged Parchment:  #D4C5A9
     Foxed Paper:     #9B8E7A
     Ivory:           #F0E8D8
     Mask Red:        #8B1A2B
   ============================================ */

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

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

body {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 400;
    color: #D4C5A9;
    background-color: #0D0A07;
    line-height: 1.85;
    overflow-x: hidden;
    transition: background-color 600ms ease;
}

.svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* --- Chamber Base --- */
.chamber {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.chamber-content {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 1200px;
    padding: 15vh 5vw;
}

/* Noise overlay */
.noise-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    filter: url(#noise);
    opacity: 0.04;
    pointer-events: none;
    z-index: 1;
}

/* Candlelight ambient effect */
.candlelight-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at 50% 30%, rgba(196, 149, 58, 0.04) 0%, transparent 60%);
    pointer-events: none;
    z-index: 1;
    animation: candleflicker 4s ease-in-out infinite;
}

@keyframes candleflicker {
    0%, 100% { opacity: 0.02; }
    50% { opacity: 0.06; }
}

/* Vignette overlay */
.chamber-bg-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, transparent 40%, rgba(13, 10, 7, 0.6) 100%);
    pointer-events: none;
    z-index: 1;
}

/* --- Typography --- */
h1, h2 {
    font-family: 'Playfair Display', Georgia, serif;
    color: #F0E8D8;
}

h1 {
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

h2 {
    font-weight: 700;
    letter-spacing: 0.03em;
}

h3 {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
    color: #F0E8D8;
    font-variant: small-caps;
    letter-spacing: 0.05em;
}

.epigraph, blockquote {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-style: italic;
    font-weight: 300;
}

/* --- Fixed Mask Sigil --- */
.mask-sigil {
    position: fixed;
    top: 24px;
    left: 24px;
    width: 32px;
    height: 32px;
    z-index: 1000;
    opacity: 0.3;
    transition: opacity 600ms ease, width 800ms ease, height 800ms ease, top 800ms ease, left 800ms ease;
    pointer-events: none;
}

.mask-sigil.in-sanctum {
    width: 200px;
    height: 200px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 1;
}

.mask-svg {
    width: 100%;
    height: 100%;
}

.mask-sigil.pulse {
    animation: maskPulse 3s ease-in-out infinite;
}

@keyframes maskPulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.5; }
}

/* Eye clip animations controlled by JS via CSS custom properties */
.eye-clip-left,
.eye-clip-right {
    ry: var(--eye-openness, 2);
    transition: ry 300ms ease;
}

/* ============================================
   CHAMBER I - THE FOYER
   ============================================ */
.chamber-foyer {
    background-color: #0D0A07;
}

.foyer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 100vh;
    padding: 0 5vw;
}

.foyer-title {
    font-size: clamp(2.5rem, 6vw, 5.5rem);
    line-height: 1.1;
    margin-bottom: 2rem;
}

.foyer-title .char,
.foyer-title .char-space {
    display: inline-block;
    opacity: 0;
    transition: opacity 400ms ease;
}

.foyer-title .char-space {
    width: 0.3em;
}

.foyer-title .char.visible,
.foyer-title .char-space.visible {
    opacity: 1;
}

.gold-rule {
    width: 0%;
    height: 1px;
    background-color: #C4953A;
    margin: 0 auto 2.5rem;
    transition: width 800ms ease;
}

.gold-rule.expanded {
    width: 100%;
    max-width: 600px;
}

.epigraph {
    font-size: 1.25rem;
    color: #9B8E7A;
    max-width: 500px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 600ms ease 400ms, transform 600ms ease 400ms;
}

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

/* ============================================
   CHAMBER II - THE GALLERY
   ============================================ */
.chamber-gallery {
    background-color: #4A0E1B;
}

.gallery-content {
    display: flex;
    align-items: stretch;
    gap: 0;
    min-height: 100vh;
    padding: 15vh 5vw;
}

.gallery-left {
    flex: 0 0 35%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-right: 1rem;
}

.arch-frame {
    clip-path: polygon(0% 8%, 5% 3%, 15% 0.5%, 30% 0%, 50% 0%, 70% 0%, 85% 0.5%, 95% 3%, 100% 8%, 100% 100%, 0% 100%);
    border-radius: 50% 50% 0 0 / 15% 15% 0 0;
    overflow: hidden;
    width: 100%;
    max-width: 300px;
}

.vintage-photo {
    position: relative;
    width: 100%;
}

.vintage-photo svg {
    width: 100%;
    height: auto;
    display: block;
}

.vintage-photo::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, transparent 30%, rgba(13, 10, 7, 0.5) 100%);
    mix-blend-mode: multiply;
    pointer-events: none;
}

.book-spine-divider {
    flex: 0 0 12px;
    display: flex;
    align-items: center;
}

.book-spine-divider svg {
    width: 12px;
    height: 100%;
    min-height: 300px;
}

.gallery-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-left: 3rem;
}

.gallery-heading {
    font-size: clamp(1.8rem, 3vw, 2.8rem);
    margin-bottom: 1.5rem;
    color: #F0E8D8;
}

.gallery-text {
    font-size: 1.1rem;
    line-height: 1.85;
    color: #D4C5A9;
    margin-bottom: 1.5rem;
    max-width: 600px;
}

/* ============================================
   CHAMBER III - THE STUDY
   ============================================ */
.chamber-study {
    background-color: #2A1A0E;
}

.study-content {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.card-fan {
    display: flex;
    gap: 2.5rem;
    align-items: center;
    justify-content: center;
    perspective: 1000px;
    width: 100%;
}

.book-card {
    flex: 0 0 280px;
    min-height: 380px;
    background: linear-gradient(135deg, #2A1A0E 0%, #1A100A 100%);
    border: 1px solid #C4953A;
    box-shadow: 0 0 8px rgba(196, 149, 58, 0.15);
    padding: 2.5rem 2rem;
    position: relative;
    cursor: pointer;
    transition: transform 600ms ease, box-shadow 400ms ease, opacity 600ms ease, flex 600ms ease;
    overflow: hidden;
}

.book-card:hover {
    transform: translateY(-8px) rotate(0deg) !important;
    box-shadow: 0 0 20px rgba(196, 149, 58, 0.35);
}

.card-left {
    transform: rotate(-2deg);
}

.card-center {
    transform: rotate(0deg);
}

.card-right {
    transform: rotate(2deg);
}

.card-spine-edge {
    position: absolute;
    left: 0;
    top: 0;
    width: 8px;
    height: 100%;
    background-color: #C4953A;
    opacity: 0.2;
}

.card-title {
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
    color: #F0E8D8;
}

.card-subtitle {
    font-family: 'IM Fell English', serif;
    font-size: 0.9rem;
    color: #9B8E7A;
    margin-bottom: 1.5rem;
    letter-spacing: 0.05em;
}

.card-expanded-content {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 600ms ease, opacity 400ms ease 200ms;
}

.card-expanded-content p {
    font-size: 1rem;
    line-height: 1.85;
    color: #D4C5A9;
    padding-top: 1rem;
    border-top: 1px solid rgba(196, 149, 58, 0.2);
}

.book-card.card-open .card-expanded-content {
    max-height: 300px;
    opacity: 1;
}

.book-card.card-open {
    flex: 1 0 400px;
}

.book-card.card-faded {
    opacity: 0.2;
}

/* ============================================
   CHAMBER IV - THE ARCHIVE
   ============================================ */
.chamber-archive {
    background-color: #0D0A07;
    min-height: auto;
}

.archive-content {
    position: relative;
    padding: 15vh 5vw;
    min-height: 100vh;
}

.archive-spine {
    position: absolute;
    left: 50%;
    top: 15vh;
    bottom: 15vh;
    width: 2px;
    background-color: #C4953A;
    opacity: 0.3;
    transform: translateX(-50%);
    z-index: 1;
}

.archive-entry {
    position: relative;
    width: 45%;
    margin-bottom: 8vh;
    padding: 2rem;
}

.archive-entry.entry-left {
    margin-right: auto;
    margin-left: 0;
    text-align: right;
    padding-right: 5%;
}

.archive-entry.entry-right {
    margin-left: auto;
    margin-right: 0;
    text-align: left;
    padding-left: 5%;
}

.entry-mask {
    position: absolute;
    width: 24px;
    height: 24px;
}

.entry-left .entry-mask {
    right: -12px;
    top: 50%;
    transform: translateY(-50%);
}

.entry-right .entry-mask {
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
}

.mask-icon {
    width: 24px;
    height: 24px;
}

.archive-quote {
    position: relative;
}

.quote-mark {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 8rem;
    color: #C4953A;
    opacity: 0.3;
    position: absolute;
    line-height: 1;
    font-style: normal;
}

.entry-left .quote-mark {
    top: -2rem;
    right: 0;
}

.entry-right .quote-mark {
    top: -2rem;
    left: 0;
}

.archive-quote p {
    position: relative;
    z-index: 2;
    font-size: 1.15rem;
    line-height: 1.85;
    color: #D4C5A9;
    font-style: italic;
    font-weight: 300;
}

/* ============================================
   CHAMBER V - THE INNER SANCTUM
   ============================================ */
.chamber-sanctum {
    background-color: #0D0A07;
}

.sanctum-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    text-align: center;
}

.sanctum-seal {
    width: 200px;
    height: 200px;
    margin-bottom: 3rem;
}

.seal-svg {
    width: 100%;
    height: 100%;
    animation: sealRotate 30s linear infinite;
}

@keyframes sealRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.sanctum-cta {
    margin-top: 2rem;
}

.protocol-button {
    display: inline-block;
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #F0E8D8;
    text-decoration: none;
    padding: 1rem 3rem;
    border: 1px solid #C4953A;
    box-shadow: 0 0 8px rgba(196, 149, 58, 0.15);
    background: transparent;
    position: relative;
    overflow: hidden;
    transition: box-shadow 400ms ease, color 400ms ease, border-color 400ms ease;
    cursor: pointer;
}

.protocol-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(196, 149, 58, 0.1), transparent);
    transition: left 600ms ease;
}

.protocol-button:hover {
    box-shadow: 0 0 20px rgba(196, 149, 58, 0.35);
    color: #E8C47C;
    border-color: #E8C47C;
}

.protocol-button:hover::before {
    left: 100%;
}

/* ============================================
   SCROLL REVEAL ANIMATIONS
   ============================================ */
.reveal-element {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 600ms ease, transform 600ms ease;
}

.reveal-element.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Stagger children */
.reveal-element:nth-child(1) { transition-delay: 0ms; }
.reveal-element:nth-child(2) { transition-delay: 150ms; }
.reveal-element:nth-child(3) { transition-delay: 300ms; }
.reveal-element:nth-child(4) { transition-delay: 450ms; }

/* Card specific reveal - rotate to alignment */
.book-card.reveal-element.revealed {
    transform: translateY(0);
}

.book-card.card-left.reveal-element.revealed {
    transform: rotate(-2deg);
}

.book-card.card-right.reveal-element.revealed {
    transform: rotate(2deg);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 900px) {
    .gallery-content {
        flex-direction: column;
        align-items: center;
        gap: 2rem;
    }

    .gallery-left {
        flex: none;
        width: 60%;
        max-width: 300px;
        padding-right: 0;
    }

    .book-spine-divider {
        display: none;
    }

    .gallery-right {
        padding-left: 0;
        text-align: center;
        align-items: center;
    }

    .gallery-text {
        text-align: left;
    }

    .card-fan {
        flex-direction: column;
        gap: 2rem;
    }

    .book-card {
        flex: none !important;
        width: 100%;
        max-width: 340px;
        min-height: auto;
    }

    .card-left,
    .card-center,
    .card-right {
        transform: rotate(0deg);
    }

    .book-card.card-left.reveal-element.revealed,
    .book-card.card-right.reveal-element.revealed {
        transform: rotate(0deg);
    }

    .archive-entry {
        width: 80%;
        margin-left: auto !important;
        margin-right: auto !important;
        text-align: left !important;
        padding-left: 2rem !important;
        padding-right: 2rem !important;
    }

    .archive-spine {
        left: 10%;
    }

    .entry-mask {
        position: relative;
        left: 0 !important;
        right: auto !important;
        top: auto !important;
        transform: none !important;
        margin-bottom: 1rem;
    }

    .entry-left .quote-mark,
    .entry-right .quote-mark {
        left: 0;
        right: auto;
    }

    .mask-sigil.in-sanctum {
        width: 140px;
        height: 140px;
    }
}

@media (max-width: 600px) {
    .foyer-title {
        font-size: clamp(2rem, 8vw, 3.5rem);
    }

    .book-card {
        padding: 1.5rem;
    }

    .sanctum-seal {
        width: 150px;
        height: 150px;
    }

    .archive-entry {
        width: 90%;
    }
}
