/* MasqueradeProtocol.com — Venetian masquerade × covert intelligence briefing */

:root {
    --bg-abyss: #0a0e1a;
    --bg-midnight: #111833;
    --bg-slate: #1c2541;
    --text-parchment: #e8dcc8;
    --accent-gold: #c9a227;
    --accent-indigo: #3a506b;
    --accent-rose: #8b5e83;
    --font-body: 'Nunito', sans-serif;
    --font-display: 'Cormorant Garamond', serif;
    --font-typewriter: 'Special Elite', cursive;
    --breath-duration: 8s;
    --curtain-speed: 1.2s;
    --typewriter-min-delay: 40ms;
    --typewriter-max-delay: 120ms;
    --margin-breath: 10vw;
}

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

html, body {
    background: var(--bg-abyss);
    color: var(--text-parchment);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.8;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

body {
    background:
        radial-gradient(ellipse at 20% 10%, rgba(28,37,65,0.65) 0%, transparent 55%),
        radial-gradient(ellipse at 80% 80%, rgba(17,24,51,0.55) 0%, transparent 60%),
        var(--bg-abyss);
    min-height: 100vh;
    position: relative;
}

/* ---------- Circuit / hex pattern background ---------- */
.circuit-layer {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0.07;
    transform: translate3d(0, 0, 0);
    will-change: transform;
}
.circuit-svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* ---------- Scroll progress rail ---------- */
.progress-rail {
    position: fixed;
    top: 0;
    right: 18px;
    height: 100vh;
    width: 14px;
    z-index: 50;
    pointer-events: none;
}
.progress-line {
    position: absolute;
    top: 8vh; bottom: 8vh; left: 50%;
    width: 2px;
    background: var(--accent-indigo);
    transform: translateX(-50%);
    opacity: 0.6;
}
.progress-fill {
    position: absolute;
    top: 8vh; left: 50%;
    width: 2px;
    height: 0%;
    background: linear-gradient(to bottom, var(--accent-gold), rgba(201,162,39,0.1));
    transform: translateX(-50%);
    transition: height 120ms linear;
    box-shadow: 0 0 8px rgba(201,162,39,0.4);
}
.progress-dot {
    position: absolute;
    left: 50%;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-gold);
    transform: translate(-50%, -50%);
    box-shadow: 0 0 6px rgba(201,162,39,0.5);
    opacity: 0.85;
}
.progress-dot[data-pos="0.05"] { top: calc(8vh + (100vh - 16vh) * 0.05); }
.progress-dot[data-pos="0.22"] { top: calc(8vh + (100vh - 16vh) * 0.22); }
.progress-dot[data-pos="0.40"] { top: calc(8vh + (100vh - 16vh) * 0.40); }
.progress-dot[data-pos="0.58"] { top: calc(8vh + (100vh - 16vh) * 0.58); }
.progress-dot[data-pos="0.76"] { top: calc(8vh + (100vh - 16vh) * 0.76); }
.progress-dot[data-pos="0.92"] { top: calc(8vh + (100vh - 16vh) * 0.92); }

/* ---------- Page wrapper with breathing margins ---------- */
.page {
    position: relative;
    z-index: 2;
    padding-left: var(--margin-breath);
    padding-right: var(--margin-breath);
    transition: padding 600ms ease-out;
}

/* ---------- Articles ---------- */
.article {
    position: relative;
    width: 100%;
    min-height: 200vh;
    padding: 22vh 0 22vh 0;
    overflow: hidden;
    isolation: isolate;
}
.article-cover { min-height: 100vh; padding: 0; }
.article-gallery { min-height: 180vh; }

/* ---------- Curtains ---------- */
.curtain {
    position: absolute;
    top: 0;
    height: 100%;
    width: 52%;
    z-index: 5;
    pointer-events: none;
    will-change: transform;
    transition: transform var(--curtain-speed) cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.curtain-left {
    left: -2%;
    background:
        repeating-linear-gradient(91deg, rgba(232,220,200,0.025) 0 1px, transparent 1px 8px),
        linear-gradient(100deg, var(--bg-midnight) 0%, rgba(28,37,65,0.85) 80%, rgba(28,37,65,0.0) 100%);
    border-right: 1px solid rgba(201,162,39,0.18);
    box-shadow: inset -20px 0 60px -20px rgba(10,14,26,0.9);
}
.curtain-right {
    right: -2%;
    background:
        repeating-linear-gradient(89deg, rgba(232,220,200,0.025) 0 1px, transparent 1px 8px),
        linear-gradient(260deg, var(--bg-midnight) 0%, rgba(28,37,65,0.85) 80%, rgba(28,37,65,0.0) 100%);
    border-left: 1px solid rgba(201,162,39,0.18);
    box-shadow: inset 20px 0 60px -20px rgba(10,14,26,0.9);
}
.article.parted .curtain-left  { transform: translateX(-100%); }
.article.parted .curtain-right { transform: translateX(100%); }

/* Cover article — curtains start parted slightly so title is visible, then fully part */
.article-cover .curtain-left  { transform: translateX(-15%); }
.article-cover .curtain-right { transform: translateX(15%); }
.article-cover.parted .curtain-left  { transform: translateX(-100%); }
.article-cover.parted .curtain-right { transform: translateX(100%); }

/* ---------- Cover ---------- */
.cover-inner {
    position: relative;
    z-index: 2;
    height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr auto auto auto;
    align-content: center;
    justify-items: start;
    gap: 3vh;
    padding: 10vh 4vw;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1.4s ease-out 0.4s, transform 1.4s ease-out 0.4s;
}
.article-cover.parted .cover-inner { opacity: 1; transform: translateY(0); }

.wordmark {
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--accent-gold);
    font-family: var(--font-display);
    letter-spacing: 0.2em;
}
.wordmark-mark {
    font-size: 1.6rem;
    border: 1px solid var(--accent-gold);
    width: 38px; height: 38px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%;
}
.wordmark-rule {
    width: 80px; height: 1px;
    background: var(--accent-gold);
    opacity: 0.6;
}
.wordmark-sub {
    font-family: var(--font-typewriter);
    font-size: 0.78rem;
    letter-spacing: 0.15em;
    color: var(--accent-rose);
    text-transform: lowercase;
}

.display-title {
    font-family: var(--font-display);
    font-weight: 500;
    color: var(--text-parchment);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    line-height: 0.95;
    font-size: clamp(2.5rem, 9vw, 7rem);
    align-self: center;
}
.display-title .line { display: block; }
.display-title .line-offset {
    margin-left: clamp(40px, 8vw, 140px);
    color: var(--accent-gold);
    font-style: italic;
    font-weight: 400;
}

.cover-meta {
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--accent-rose);
    font-family: var(--font-typewriter);
    font-size: 0.78rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}
.meta-divider {
    width: 28px; height: 1px;
    background: var(--accent-indigo);
}
.cover-whisper {
    max-width: 560px;
    color: var(--text-parchment);
    font-family: var(--font-display);
    font-style: italic;
    font-size: clamp(1rem, 1.6vw, 1.4rem);
    line-height: 1.7;
    opacity: 0.86;
}
.cover-seal {
    position: absolute;
    right: 6vw;
    bottom: 14vh;
    width: 140px; height: 140px;
    opacity: 0.85;
}
.seal-svg { width: 100%; height: 100%; }

.scroll-hint {
    position: absolute;
    left: 50%;
    bottom: 4vh;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: var(--accent-rose);
    font-family: var(--font-typewriter);
    font-size: 0.74rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    opacity: 0.7;
    animation: hint-pulse 3.6s ease-in-out infinite;
}
.scroll-hint-line {
    width: 1px; height: 60px;
    background: linear-gradient(to bottom, var(--accent-gold), transparent);
}
@keyframes hint-pulse {
    0%, 100% { opacity: 0.4; transform: translate(-50%, 0); }
    50%      { opacity: 0.85; transform: translate(-50%, 6px); }
}

/* ---------- Article inner organic grid ---------- */
.article-inner {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: 28% 36% 28%;
    column-gap: 4%;
    width: 100%;
    padding: 0 2vw;
}
.island {
    grid-row: auto;
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 1.2s ease-out, transform 1.2s ease-out;
}
.article.parted .island { opacity: 1; transform: translateY(0); }

.col-left  { grid-column: 1 / 2; }
.col-mid   { grid-column: 2 / 3; }
.col-right { grid-column: 3 / 4; }
.offset-1 { margin-top: 8vh; }
.offset-2 { margin-top: 14vh; }
.offset-3 { margin-top: 10vh; }
.offset-4 { margin-top: 12vh; }

.article-header {
    border-left: 1px solid var(--accent-indigo);
    padding-left: 22px;
}
.article-no {
    display: block;
    font-family: var(--font-typewriter);
    font-size: 0.8rem;
    letter-spacing: 0.22em;
    color: var(--accent-gold);
    text-transform: uppercase;
    margin-bottom: 8px;
}
.article-title {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: clamp(2.2rem, 5.4vw, 4.6rem);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-parchment);
    line-height: 1;
    margin-bottom: 10px;
}
.article-sub {
    display: block;
    font-family: var(--font-display);
    font-style: italic;
    color: var(--accent-rose);
    font-size: 1.05rem;
    letter-spacing: 0.04em;
}

.body-text {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 1.075rem;
    line-height: 1.85;
    color: var(--text-parchment);
}
.body-text.annot {
    font-family: var(--font-typewriter);
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--accent-rose);
}
.annot-mark {
    color: var(--accent-gold);
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 0.75rem;
}
.redact {
    background: rgba(139,94,131,0.18);
    color: rgba(232,220,200,0.55);
    padding: 0 6px;
    border-bottom: 1px dashed rgba(139,94,131,0.55);
}

/* ---------- Mask anchors ---------- */
.mask-anchor {
    width: 100%;
    max-width: 320px;
    aspect-ratio: 1 / 1.05;
    background: rgba(28,37,65,0.45);
    border: 1px solid rgba(58,80,107,0.6);
    border-radius: 4px;
    padding: 18px;
    box-shadow: 0 30px 60px -30px rgba(0,0,0,0.7),
                inset 0 0 80px rgba(10,14,26,0.5);
    position: relative;
}
.mask-anchor::before, .mask-anchor::after {
    content: '';
    position: absolute;
    width: 14px; height: 14px;
    border: 1px solid var(--accent-gold);
    opacity: 0.7;
}
.mask-anchor::before { top: 6px; left: 6px; border-right: none; border-bottom: none; }
.mask-anchor::after  { bottom: 6px; right: 6px; border-left: none; border-top: none; }
.mask-svg { width: 100%; height: 100%; display: block; }
.mask-svg path, .mask-svg ellipse, .mask-svg circle, .mask-svg line { vector-effect: non-scaling-stroke; }

/* SVG line-draw animation prep (set per-path via JS) */
.mask-svg [data-len] {
    stroke-dasharray: var(--len);
    stroke-dashoffset: var(--len);
}
.mask-svg.drawn [data-len] {
    animation: draw-line 2.4s cubic-bezier(0.65, 0, 0.35, 1) forwards;
    animation-delay: var(--delay, 0ms);
}
@keyframes draw-line {
    to { stroke-dashoffset: 0; }
}

/* ---------- Typewriter blocks ---------- */
.typewriter-block {
    background: rgba(17,24,51,0.55);
    border: 1px solid rgba(58,80,107,0.45);
    border-left: 2px solid var(--accent-gold);
    padding: 22px 26px;
    position: relative;
}
.typewriter-label {
    display: block;
    font-family: var(--font-typewriter);
    font-size: 0.74rem;
    color: var(--accent-rose);
    letter-spacing: 0.18em;
    margin-bottom: 10px;
    text-transform: uppercase;
}
.typewriter-text {
    font-family: var(--font-typewriter);
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--text-parchment);
    min-height: 2em;
    position: relative;
}
.typewriter-text .tw-char {
    display: inline-block;
    opacity: 0;
    transform: translateY(2px);
    transition: opacity 120ms ease-out, transform 160ms ease-out;
    white-space: pre;
}
.typewriter-text .tw-char.in {
    opacity: 1;
    transform: translateY(0);
}
.typewriter-text.typing::after {
    content: '';
    display: inline-block;
    width: 9px;
    height: 1.1em;
    background: var(--accent-gold);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: blink 0.8s step-end infinite;
}
@keyframes blink {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0; }
}

/* ---------- Seal rows ---------- */
.seal-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 4vh 0;
    opacity: 0.85;
}
.mini-seal {
    width: 80px; height: 80px;
}
.seal-row.big-seal .mini-seal {
    width: 160px; height: 160px;
}
.seal-label {
    font-family: var(--font-typewriter);
    font-size: 0.74rem;
    letter-spacing: 0.22em;
    color: var(--accent-gold);
    text-transform: uppercase;
}

/* ---------- Mask Gallery ---------- */
.gallery-inner {
    grid-template-columns: 1fr;
    gap: 6vh;
}
.gallery-header {
    text-align: center;
    margin-bottom: 6vh;
    border-left: none;
    padding-left: 0;
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 1.2s ease-out, transform 1.2s ease-out;
}
.article.parted .gallery-header { opacity: 1; transform: translateY(0); }
.gallery-header .article-title { letter-spacing: 0.15em; }

.gallery-viewport {
    width: 100%;
    overflow: hidden;
    background:
        linear-gradient(90deg, var(--bg-abyss), transparent 8%, transparent 92%, var(--bg-abyss)),
        rgba(17,24,51,0.5);
    border-top: 1px solid rgba(58,80,107,0.4);
    border-bottom: 1px solid rgba(58,80,107,0.4);
    padding: 8vh 0;
    position: relative;
}
.gallery-track {
    display: flex;
    align-items: center;
    gap: 0;
    padding-left: 8vw;
    padding-right: 8vw;
    transform: translateX(0);
    transition: transform 800ms cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform;
}
.mask-card {
    flex: 0 0 38vw;
    min-width: 320px;
    margin-left: -5vw;
    background: rgba(28,37,65,0.6);
    border: 1px solid rgba(58,80,107,0.7);
    padding: 28px 22px 18px 22px;
    position: relative;
    aspect-ratio: 0.9 / 1;
    box-shadow: 0 30px 70px -30px rgba(0,0,0,0.85);
    display: flex;
    flex-direction: column;
    transform-origin: center;
    transition: transform 600ms ease-out, opacity 600ms ease-out, box-shadow 600ms ease-out;
}
.mask-card:first-child { margin-left: 0; }
.mask-card:nth-child(odd)  { transform: translateY(2vh) rotate(-1.2deg); }
.mask-card:nth-child(even) { transform: translateY(-2vh) rotate(1deg); }
.mask-card:hover {
    transform: translateY(0) rotate(0);
    box-shadow: 0 40px 90px -20px rgba(201,162,39,0.18), 0 30px 70px -30px rgba(0,0,0,0.95);
    border-color: var(--accent-gold);
}
.mask-card .mask-svg {
    flex: 1;
    width: 100%;
    height: auto;
    max-height: 70%;
}
.mask-card figcaption {
    font-family: var(--font-typewriter);
    font-size: 0.82rem;
    letter-spacing: 0.1em;
    color: var(--accent-rose);
    text-align: center;
    padding-top: 18px;
    border-top: 1px solid rgba(58,80,107,0.5);
    margin-top: 12px;
}

.gallery-hint {
    text-align: center;
    margin-top: 4vh;
    color: var(--accent-rose);
    font-family: var(--font-typewriter);
    font-size: 0.78rem;
    letter-spacing: 0.18em;
    opacity: 0.6;
}

/* ---------- Colophon ---------- */
.colophon {
    padding: 18vh 0 12vh 0;
    text-align: center;
    border-top: 1px solid rgba(58,80,107,0.35);
    margin-top: 10vh;
    position: relative;
    z-index: 2;
}
.colophon-inner {
    display: flex;
    flex-direction: column;
    gap: 14px;
    align-items: center;
}
.colophon-line {
    font-family: var(--font-display);
    font-style: italic;
    color: var(--text-parchment);
    font-size: 1rem;
    letter-spacing: 0.05em;
    opacity: 0.85;
}
.colophon-line.whisper {
    color: var(--accent-rose);
    font-size: 0.9rem;
}
.colophon-line.micro {
    font-family: var(--font-typewriter);
    font-size: 0.74rem;
    letter-spacing: 0.3em;
    color: var(--accent-gold);
    text-transform: uppercase;
    margin-top: 14px;
    opacity: 0.7;
}

/* ---------- Ink wash ---------- */
.ink-wash {
    position: fixed;
    inset: 0;
    z-index: 60;
    pointer-events: none;
    background: radial-gradient(circle at center,
        rgba(10,14,26,0.95) 0%,
        rgba(10,14,26,0.4) 40%,
        rgba(10,14,26,0) 70%);
    opacity: 0;
    transform: scale(0.4);
    transition: opacity 0.6s ease-out, transform 1.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.ink-wash.active {
    opacity: 1;
    transform: scale(2.2);
}

/* ---------- Responsive tweaks ---------- */
@media (max-width: 900px) {
    .article-inner {
        grid-template-columns: 1fr;
    }
    .col-left, .col-mid, .col-right { grid-column: 1 / -1; }
    .offset-1, .offset-2, .offset-3, .offset-4 { margin-top: 6vh; }
    .display-title .line-offset { margin-left: 4vw; }
    .progress-rail { right: 8px; }
    .cover-seal { right: 4vw; bottom: 18vh; width: 100px; height: 100px; }
    .mask-card { flex: 0 0 80vw; margin-left: -4vw; }
    .article { min-height: auto; padding: 14vh 0; }
}
