/* ============================================
   MasqueradeProtocol.com - Styles
   Dark-Academia / Venetian Masquerade
   ============================================ */

/* === CSS Custom Properties === */
:root {
    --midnight-ink: #0B0A0F;
    --obsidian-teal: #1A2A2E;
    --storm-coast: #2C3E50;
    --venetian-gold: #C4A35A;
    --aged-copper: #B87333;
    --bleached-linen: #E8E0D4;
    --faded-manuscript: #A99E8D;
    --deep-adriatic: #1B4F72;
    --carnelian: #8B1A1A;
    --burnt-umber: #3D2B1F;
    --mono-text: #8A7968;

    --font-heading: 'Space Grotesk', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-accent: 'Libre Baskerville', serif;
    --font-mono: 'IBM Plex Mono', monospace;

    --grid-gap: 2px;
    --cell-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    --cell-shadow-hover: 0 4px 20px rgba(0, 0, 0, 0.6);
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: var(--font-body);
    background-color: var(--midnight-ink);
    color: var(--bleached-linen);
    line-height: 1.7;
    letter-spacing: 0.005em;
    overflow-x: hidden;
}

/* === Parchment Grain Texture (SVG-based) === */
.cell-texture {
    position: absolute;
    inset: 0;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23noise)' opacity='0.5'/%3E%3C/svg%3E");
    background-size: 200px 200px;
    pointer-events: none;
    z-index: 0;
}

/* === Section Base === */
.section {
    position: relative;
    width: 100%;
}

/* === Section Transitions (clip-path doorway) === */
.section-transition {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--venetian-gold);
    opacity: 0.3;
    z-index: 5;
}

/* ============================================
   THE ANTECHAMBER (Hero)
   ============================================ */
.antechamber {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--midnight-ink) 0%, var(--obsidian-teal) 40%, var(--deep-adriatic) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.antechamber-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    width: 100%;
    height: 100vh;
    max-width: 1400px;
}

.antechamber-left {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.antechamber-right {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

/* Gold border trace animation */
.gold-border-trace {
    position: absolute;
    inset: 12px;
    border: 1.5px solid transparent;
    z-index: 2;
    pointer-events: none;
}

.gold-border-trace.animate {
    animation: traceBorderCW 3s ease-in-out forwards;
}

@keyframes traceBorderCW {
    0% {
        border-color: transparent;
        clip-path: polygon(0 0, 0 0, 0 0, 0 0);
    }
    25% {
        clip-path: polygon(0 0, 100% 0, 100% 0, 0 0);
    }
    50% {
        clip-path: polygon(0 0, 100% 0, 100% 100%, 0 0);
    }
    75% {
        clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
    }
    100% {
        border-color: var(--venetian-gold);
        clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
    }
}

.gold-border-trace-right {
    position: absolute;
    inset: 12px;
    border: 1.5px solid transparent;
    z-index: 2;
    pointer-events: none;
}

.gold-border-trace-right.animate {
    animation: traceBorderCCW 3s ease-in-out forwards;
}

@keyframes traceBorderCCW {
    0% {
        border-color: transparent;
        clip-path: polygon(100% 100%, 100% 100%, 100% 100%, 100% 100%);
    }
    25% {
        clip-path: polygon(0 100%, 100% 100%, 100% 100%, 0 100%);
    }
    50% {
        clip-path: polygon(0 0, 0 100%, 100% 100%, 100% 100%);
    }
    75% {
        clip-path: polygon(0 0, 0 100%, 100% 100%, 100% 0);
    }
    100% {
        border-color: var(--venetian-gold);
        clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
    }
}

/* Hero mask silhouette */
.mask-silhouette {
    position: relative;
    z-index: 1;
}

.hero-mask-svg {
    width: 280px;
    height: 340px;
    filter: drop-shadow(0 0 20px rgba(196, 163, 90, 0.2));
    opacity: 0;
    animation: fadeInMask 2s 1s ease-out forwards;
}

@keyframes fadeInMask {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Hero title (vertical on right panel) */
.hero-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: clamp(2rem, 4.5vw, 5rem);
    letter-spacing: -0.03em;
    text-transform: uppercase;
    color: var(--bleached-linen);
    writing-mode: vertical-rl;
    text-orientation: mixed;
    line-height: 1;
    z-index: 1;
}

.title-line {
    display: block;
    overflow: hidden;
}

.title-line span {
    display: inline-block;
    opacity: 0;
    transform: translateY(12px);
}

.hero-subtitle {
    font-family: var(--font-accent);
    font-style: italic;
    font-weight: 400;
    font-size: 0.95rem;
    color: var(--faded-manuscript);
    margin-top: 2rem;
    writing-mode: vertical-rl;
    z-index: 1;
    opacity: 0;
    animation: fadeInSubtitle 1.5s 2.5s ease-out forwards;
}

@keyframes fadeInSubtitle {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.meta-label {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    color: var(--mono-text);
    opacity: 0.7;
}

.antechamber-right .meta-label {
    margin-top: 2rem;
    writing-mode: vertical-rl;
    z-index: 1;
    opacity: 0;
    animation: fadeInSubtitle 1.5s 3s ease-out forwards;
}

.protocol-num, .protocol-date {
    display: block;
    margin-bottom: 0.5rem;
}

/* Mask fragment watermarks */
.mask-fragment {
    position: absolute;
    pointer-events: none;
    z-index: 0;
}

.mask-fragment-left {
    bottom: 10%;
    left: 5%;
    width: 200px;
    opacity: 0.07;
}

.mask-fragment-right {
    top: 15%;
    right: 3%;
    width: 250px;
    opacity: 0.06;
}

/* ============================================
   THE ARCHIVE (Content Grid)
   ============================================ */
.archive {
    padding: 6rem 2rem;
    background-color: var(--midnight-ink);
    position: relative;
}

.section-header {
    text-align: center;
    margin-bottom: 3rem;
}

.section-icon {
    width: 48px;
    height: 48px;
    filter: drop-shadow(0 0 3px rgba(196, 163, 90, 0.3));
    margin-bottom: 1rem;
}

.section-heading {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: clamp(1.4rem, 2.5vw, 2.8rem);
    letter-spacing: -0.03em;
    color: var(--bleached-linen);
    margin-bottom: 0.5rem;
}

.section-header .meta-label {
    display: block;
    margin-top: 0.5rem;
}

/* Bento Grid */
.bento-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: var(--grid-gap);
    max-width: 1200px;
    margin: 0 auto;
}

/* Grid gap lines (burnt umber) */
.bento-grid {
    background-color: var(--burnt-umber);
    padding: var(--grid-gap);
    border-radius: 2px;
}

/* Bento Cell Base */
.bento-cell {
    position: relative;
    background-color: var(--obsidian-teal);
    box-shadow: var(--cell-shadow);
    overflow: hidden;
    transition: box-shadow 300ms ease, transform 300ms ease;
    will-change: transform, box-shadow;
    /* Entry animation defaults */
    opacity: 0;
}

.bento-cell.visible {
    opacity: 1;
}

.bento-cell:nth-child(odd).visible {
    animation: slideInLeft 600ms cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.bento-cell:nth-child(even).visible {
    animation: slideInRight 600ms cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Bento cell hover interactions */
.bento-cell:hover {
    box-shadow: var(--cell-shadow-hover);
    transform: translateY(-3px);
}

.bento-cell:hover .cell-icon,
.bento-cell:hover .cell-icon-large {
    transform: scale(1.08);
}

.bento-cell::after {
    content: '';
    position: absolute;
    inset: 0;
    border: 1px solid var(--burnt-umber);
    transition: border-color 400ms ease;
    pointer-events: none;
    z-index: 3;
}

.bento-cell:hover::after {
    border-color: var(--venetian-gold);
}

/* Bento cell alternate coloring */
.bento-alt {
    background-color: var(--storm-coast);
}

/* Cell sizes */
.bento-large {
    grid-column: span 8;
    grid-row: span 2;
    min-height: 340px;
}

.bento-medium {
    grid-column: span 4;
    min-height: 200px;
}

.bento-small {
    grid-column: span 4;
    min-height: 180px;
}

/* Cell content */
.cell-content {
    position: relative;
    padding: 2rem;
    z-index: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.cell-number {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    color: var(--mono-text);
    opacity: 0.7;
    display: block;
    margin-bottom: 0.75rem;
}

.cell-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: clamp(1.1rem, 1.8vw, 1.5rem);
    letter-spacing: -0.02em;
    color: var(--bleached-linen);
    margin-bottom: 0.75rem;
}

.cell-text {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--bleached-linen);
    opacity: 0.9;
    flex-grow: 1;
}

.cell-caption {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    color: var(--faded-manuscript);
    opacity: 0.6;
    text-transform: uppercase;
    margin-top: 0.5rem;
}

.cell-icon {
    width: 48px;
    height: 48px;
    margin-top: auto;
    padding-top: 1rem;
    filter: drop-shadow(0 0 3px rgba(196, 163, 90, 0.3));
    transition: transform 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cell-icon-large {
    width: 64px;
    height: 64px;
    margin: auto;
    filter: drop-shadow(0 0 3px rgba(196, 163, 90, 0.3));
    transition: transform 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Ornamental cell */
.bento-ornamental {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--storm-coast);
}

.bento-ornamental .cell-content {
    align-items: center;
    justify-content: center;
}

/* Filigree corner decorations */
.cell-filigree {
    position: absolute;
    width: 40px;
    height: 40px;
    z-index: 2;
    pointer-events: none;
}

.cell-filigree-tl {
    top: -2px;
    left: -2px;
}

.cell-filigree-br {
    bottom: -2px;
    right: -2px;
}

/* ============================================
   THE INNER SANCTUM (Feature Section)
   ============================================ */
.inner-sanctum {
    background-color: var(--midnight-ink);
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6rem 2rem;
    position: relative;
    overflow: hidden;
}

.sanctum-container {
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 1100px;
    width: 100%;
    position: relative;
}

.sanctum-mask {
    flex-shrink: 0;
    width: 160px;
}

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

.sanctum-mask-left svg {
    animation: rotateMaskLeft 10s ease-in-out infinite;
}

.sanctum-mask-right svg {
    transform: scaleX(-1);
    animation: rotateMaskRight 10s ease-in-out infinite;
}

@keyframes rotateMaskLeft {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(2deg); }
}

@keyframes rotateMaskRight {
    0%, 100% { transform: scaleX(-1) rotate(0deg); }
    50% { transform: scaleX(-1) rotate(-2deg); }
}

.sanctum-content {
    text-align: center;
    padding: 0 3rem;
    max-width: 680px;
}

.sanctum-quote {
    margin-bottom: 2rem;
}

.sanctum-quote p {
    font-family: var(--font-accent);
    font-weight: 700;
    font-size: clamp(1.3rem, 2.5vw, 1.8rem);
    line-height: 1.55;
    color: var(--venetian-gold);
    position: relative;
}

.sanctum-quote p::before {
    content: '\201C';
    position: absolute;
    left: -0.6em;
    top: -0.2em;
    font-size: 2em;
    color: var(--venetian-gold);
    opacity: 0.3;
}

.sanctum-text {
    font-family: var(--font-accent);
    font-style: italic;
    font-weight: 400;
    font-size: 1rem;
    line-height: 1.7;
    color: var(--faded-manuscript);
    margin-bottom: 2rem;
}

.sanctum-divider {
    display: flex;
    justify-content: center;
}

.sanctum-divider svg {
    width: 200px;
    height: 20px;
}

/* ============================================
   THE CORRESPONDENCE (Footer)
   ============================================ */
.correspondence {
    padding: 4rem 2rem 2rem;
    background-color: var(--midnight-ink);
    position: relative;
}

.footer-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--grid-gap);
    max-width: 1200px;
    margin: 0 auto;
    background-color: var(--burnt-umber);
    padding: var(--grid-gap);
}

.footer-cell {
    position: relative;
    background-color: var(--obsidian-teal);
    padding: 2rem;
    box-shadow: var(--cell-shadow);
    overflow: hidden;
}

.footer-identity {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.footer-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.6rem;
    letter-spacing: -0.03em;
    color: var(--bleached-linen);
    margin-bottom: 0.5rem;
}

.footer-tagline {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    color: var(--faded-manuscript);
    opacity: 0.7;
    margin-bottom: 1rem;
}

.footer-icon {
    width: 36px;
    height: 36px;
    filter: drop-shadow(0 0 3px rgba(196, 163, 90, 0.3));
}

/* Wax Seal */
.footer-seal {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.wax-seal {
    position: relative;
    width: 80px;
    height: 80px;
    margin-bottom: 0.75rem;
}

.wax-seal svg {
    width: 80px;
    height: 80px;
}

.seal-press {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    width: 40px;
    height: 60px;
    opacity: 0;
    pointer-events: none;
}

.wax-seal.animate .seal-press {
    animation: sealStamp 800ms ease-out forwards;
}

@keyframes sealStamp {
    0% {
        opacity: 1;
        transform: translateX(-50%) translateY(-20px);
    }
    60% {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
    80% {
        opacity: 0.5;
        transform: translateX(-50%) translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(0);
    }
}

.wax-seal.animate .wax-blob {
    animation: waxSpread 800ms ease-out forwards;
}

@keyframes waxSpread {
    0% {
        transform: scale(0.6);
        opacity: 0.5;
    }
    100% {
        transform: scale(1);
        opacity: 0.9;
    }
}

.wax-seal.animate .wax-glow {
    animation: waxGlow 800ms ease-out forwards;
}

@keyframes waxGlow {
    0% {
        opacity: 0;
        r: 20;
    }
    50% {
        opacity: 0.6;
    }
    100% {
        opacity: 0.2;
        r: 36;
    }
}

.seal-label {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 0.12em;
    color: var(--faded-manuscript);
    opacity: 0.6;
    text-transform: uppercase;
}

/* Footer Navigation */
.footer-nav {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.footer-navigation {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.nav-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    color: var(--faded-manuscript);
    opacity: 0.6;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--bleached-linen);
    text-decoration: none;
    font-family: var(--font-accent);
    font-style: italic;
    font-size: 0.9rem;
    transition: color 300ms ease;
    position: relative;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 28px;
    right: 0;
    height: 1px;
    background-color: var(--aged-copper);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 300ms ease;
}

.nav-link:hover::after {
    transform: scaleX(1);
}

.nav-link:hover {
    color: var(--venetian-gold);
}

.key-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    transition: transform 300ms ease;
    filter: drop-shadow(0 0 3px rgba(196, 163, 90, 0.3));
}

.nav-link:hover .key-icon {
    transform: rotate(90deg);
}

/* Footer bottom */
.footer-bottom {
    text-align: center;
    padding: 2rem 0 1rem;
}

.footer-bottom .meta-label {
    font-size: 0.65rem;
}

/* ============================================
   CLIP-PATH SECTION TRANSITION
   ============================================ */
.section {
    clip-path: inset(0);
    transition: clip-path 800ms ease-in-out;
}

.section.clip-enter {
    clip-path: inset(0 49.8% 0 49.8%);
}

.section.clip-reveal {
    clip-path: inset(0);
}

/* ============================================
   RESPONSIVE (Mobile < 768px)
   ============================================ */
@media (max-width: 768px) {
    .antechamber-grid {
        grid-template-columns: 1fr;
        height: auto;
        min-height: 100vh;
    }

    .antechamber-left {
        min-height: 50vh;
        padding: 3rem 2rem;
    }

    .antechamber-right {
        padding: 2rem;
        align-items: flex-start;
    }

    .hero-title {
        writing-mode: horizontal-tb;
        font-size: clamp(2rem, 8vw, 3.5rem);
    }

    .hero-subtitle {
        writing-mode: horizontal-tb;
        margin-top: 1rem;
    }

    .antechamber-right .meta-label {
        writing-mode: horizontal-tb;
        margin-top: 1rem;
    }

    .hero-mask-svg {
        width: 200px;
        height: 240px;
    }

    .bento-grid {
        grid-template-columns: 1fr;
    }

    .bento-large,
    .bento-medium,
    .bento-small {
        grid-column: span 1;
        grid-row: span 1;
        min-height: 200px;
    }

    .sanctum-container {
        flex-direction: column;
    }

    .sanctum-mask {
        width: 100px;
    }

    .sanctum-content {
        padding: 2rem 1rem;
    }

    .footer-grid {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .bento-large {
        grid-column: span 12;
    }

    .bento-medium {
        grid-column: span 6;
    }

    .bento-small {
        grid-column: span 6;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.gpu-accelerated {
    will-change: transform, box-shadow;
    transform: translateZ(0);
}

/* SVG icon glow filter */
.cell-icon,
.cell-icon-large,
.section-icon,
.footer-icon {
    filter: drop-shadow(0 0 3px rgba(196, 163, 90, 0.3));
}