/* mujun.quest -- An expedition into contradiction
   Surreal aesthetic, f-pattern layout, scholarly parchment.
   Palette: parchment #F5EDD6, gold ink #B8962E, deep black #1A1812,
            luxury gold #D4AF37, sepia #8B7355, tropical teal #2E8B7A,
            paper shadow #D4C8A8.
*/

:root {
    --parchment: #F5EDD6;
    --gold-ink: #B8962E;
    --deep-black: #1A1812;
    --luxury-gold: #D4AF37;
    --sepia: #8B7355;
    --teal: #2E8B7A;
    --paper-shadow: #D4C8A8;

    --base-unit: 24px;
    --margin-rule: 15%;
    --content-max: 60%;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--parchment);
    color: var(--deep-black);
    font-family: "Cormorant Garamond", Georgia, serif;
    font-size: clamp(16px, 1.1vw, 18px);
    line-height: 1.9;
    overflow-x: hidden;
    position: relative;
    min-height: 100vh;
}

/* ------- Page-load fade overlay ------- */
.page-fade {
    position: fixed;
    inset: 0;
    background-color: var(--deep-black);
    z-index: 999;
    pointer-events: none;
    animation: pageOpen 1000ms ease-out forwards;
}

@keyframes pageOpen {
    0%   { opacity: 1; }
    100% { opacity: 0; visibility: hidden; }
}

/* ------- Paper / parchment textures ------- */
.parchment {
    position: relative;
    background-color: var(--parchment);
    overflow: hidden;
}

.vignette {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center,
        rgba(245, 237, 214, 0) 0%,
        rgba(139, 115, 85, 0.10) 70%,
        rgba(26, 24, 18, 0.18) 100%);
    pointer-events: none;
    z-index: 1;
}

.grain {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
    opacity: 0.08;
    background-image:
        radial-gradient(circle at 20% 30%, rgba(139, 115, 85, 0.6) 0.5px, transparent 1px),
        radial-gradient(circle at 70% 60%, rgba(184, 150, 46, 0.5) 0.5px, transparent 1px),
        radial-gradient(circle at 40% 80%, rgba(26, 24, 18, 0.5) 0.5px, transparent 1px),
        radial-gradient(circle at 85% 20%, rgba(139, 115, 85, 0.5) 0.5px, transparent 1px),
        radial-gradient(circle at 10% 90%, rgba(184, 150, 46, 0.4) 0.5px, transparent 1px);
    background-size: 7px 7px, 11px 11px, 13px 13px, 17px 17px, 19px 19px;
    mix-blend-mode: multiply;
}

/* Subtle paper fiber overlay using pseudo-elements */
.parchment::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, rgba(212, 200, 168, 0.18) 0%, transparent 12%, transparent 88%, rgba(212, 200, 168, 0.22) 100%),
        linear-gradient(90deg, rgba(212, 200, 168, 0.20) 0%, transparent 10%, transparent 90%, rgba(212, 200, 168, 0.25) 100%);
    pointer-events: none;
    z-index: 1;
}

/* ------- Title parchment ------- */
.title-parchment {
    height: 100vh;
    min-height: 640px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0 var(--base-unit);
}

.title-content {
    position: relative;
    z-index: 5;
    max-width: 760px;
    opacity: 0;
    animation: contentRise 800ms 200ms ease-out forwards;
}

@keyframes contentRise {
    0%   { opacity: 0; transform: translateY(12px); }
    100% { opacity: 1; transform: translateY(0); }
}

.title-meta {
    font-family: "Cormorant SC", "Cormorant Garamond", Georgia, serif;
    font-weight: 500;
    font-size: 13px;
    letter-spacing: 0.18em;
    color: var(--sepia);
    text-transform: uppercase;
    margin-bottom: calc(var(--base-unit) * 2);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 18px;
}

.meta-divider {
    color: var(--gold-ink);
    font-size: 16px;
    font-style: italic;
    font-family: "Cormorant Garamond", serif;
}

.domain-title {
    font-family: "Cinzel Decorative", "Cormorant Garamond", serif;
    font-weight: 700;
    font-size: clamp(48px, 7vw, 96px);
    color: var(--deep-black);
    letter-spacing: 0.04em;
    line-height: 1.05;
    margin-bottom: calc(var(--base-unit) * 1.25);
    opacity: 0;
    animation: titleFade 800ms 400ms ease-out forwards;
}

@keyframes titleFade {
    0%   { opacity: 0; letter-spacing: 0.10em; }
    100% { opacity: 1; letter-spacing: 0.04em; }
}

.subtitle-wrap {
    position: relative;
    display: inline-block;
    margin-bottom: calc(var(--base-unit) * 2);
}

.subtitle {
    font-family: "Cormorant SC", "Cormorant Garamond", serif;
    font-weight: 500;
    font-size: clamp(14px, 1.2vw, 17px);
    letter-spacing: 0.22em;
    color: var(--deep-black);
    text-transform: uppercase;
    padding-bottom: 8px;
    opacity: 0;
    animation: subFade 600ms 1000ms ease-out forwards;
}

@keyframes subFade {
    0%   { opacity: 0; }
    100% { opacity: 1; }
}

.subtitle-underline {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 4px;
    overflow: visible;
}

.subtitle-underline line {
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
    animation: drawLine 1100ms 1400ms ease-out forwards;
}

@keyframes drawLine {
    0%   { stroke-dashoffset: 400; }
    100% { stroke-dashoffset: 0; }
}

.seal {
    font-family: "Cormorant Garamond", serif;
    font-style: italic;
    color: var(--gold-ink);
    font-size: 22px;
    letter-spacing: 0.24em;
    margin-bottom: calc(var(--base-unit) * 3);
    opacity: 0;
    animation: subFade 600ms 1800ms ease-out forwards;
}

.scroll-cue {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: var(--sepia);
    font-family: "Cormorant SC", serif;
    font-size: 11px;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    opacity: 0;
    animation: subFade 800ms 2400ms ease-out forwards;
}

.scroll-cue svg {
    width: 18px;
    height: 30px;
    animation: bobDown 2.4s ease-in-out infinite;
}

@keyframes bobDown {
    0%, 100% { transform: translateY(0); opacity: 0.6; }
    50%      { transform: translateY(6px); opacity: 1; }
}

/* ------- Codex (paradox entries) ------- */
.codex {
    position: relative;
    padding: calc(var(--base-unit) * 4) 0 calc(var(--base-unit) * 6);
    max-width: 1400px;
    margin: 0 auto;
    z-index: 4;
}

.margin-rule {
    position: absolute;
    top: calc(var(--base-unit) * 2);
    bottom: calc(var(--base-unit) * 2);
    left: var(--margin-rule);
    width: 1px;
    background: linear-gradient(180deg,
        rgba(184, 150, 46, 0) 0%,
        rgba(184, 150, 46, 0.35) 8%,
        rgba(184, 150, 46, 0.55) 50%,
        rgba(184, 150, 46, 0.35) 92%,
        rgba(184, 150, 46, 0) 100%);
    z-index: 3;
    transition: opacity 400ms ease;
}

.margin-rule.dim {
    opacity: 0.45;
}

/* Each paradox uses an f-pattern: title left at 15%, body 60% width */
.paradox {
    padding: calc(var(--base-unit) * 4) var(--base-unit) calc(var(--base-unit) * 4) var(--margin-rule);
    margin-bottom: calc(var(--base-unit) * 2);
    opacity: 0;
    transform: translateY(18px);
    transition: opacity 700ms ease-out, transform 700ms ease-out;
    position: relative;
}

.paradox.in-view {
    opacity: 1;
    transform: translateY(0);
}

.paradox-head {
    margin-left: -64px;
    display: flex;
    align-items: baseline;
    gap: 16px;
    margin-bottom: calc(var(--base-unit) * 1.25);
}

.paradox-num {
    font-family: "Cinzel Decorative", serif;
    font-weight: 700;
    font-size: clamp(20px, 2vw, 28px);
    color: var(--gold-ink);
    letter-spacing: 0.06em;
    flex-shrink: 0;
    width: 56px;
    text-align: right;
}

.paradox-title {
    font-family: "Cormorant Garamond", serif;
    font-weight: 600;
    font-size: clamp(28px, 3.5vw, 56px);
    line-height: 1.15;
    letter-spacing: 0.02em;
    color: var(--deep-black);
    transition: text-shadow 400ms ease;
    cursor: default;
}

.paradox-title:hover {
    text-shadow: 0 0 8px rgba(184, 150, 46, 0.3);
}

.paradox-title .key {
    font-style: italic;
    color: var(--gold-ink);
    position: relative;
    display: inline-block;
}

.paradox-body {
    max-width: var(--content-max);
    color: var(--deep-black);
    font-size: clamp(16px, 1.1vw, 18px);
    line-height: 1.9;
}

.paradox-body p {
    margin-bottom: var(--base-unit);
    position: relative;
}

.paradox-body p:first-of-type {
    text-indent: 0;
}

.paradox-body em {
    font-style: italic;
    color: var(--sepia);
}

/* Drop caps */
.dropcap {
    font-family: "Cinzel Decorative", serif;
    font-weight: 700;
    font-size: 4.2em;
    line-height: 0.85;
    color: var(--gold-ink);
    float: left;
    margin: 0.05em 14px -0.1em 0;
    padding: 8px 12px 4px 12px;
    border: 1px solid rgba(184, 150, 46, 0.55);
    position: relative;
    transition: transform 380ms ease;
    background:
        radial-gradient(circle at 20% 20%, rgba(184, 150, 46, 0.08), transparent 60%),
        rgba(245, 237, 214, 0.2);
}

.dropcap::before,
.dropcap::after {
    content: "";
    position: absolute;
    width: 6px;
    height: 6px;
    border: 1px solid var(--gold-ink);
}

.dropcap::before {
    top: -3px;
    left: -3px;
    border-right: none;
    border-bottom: none;
}

.dropcap::after {
    bottom: -3px;
    right: -3px;
    border-left: none;
    border-top: none;
}

.dropcap:hover {
    transform: scale(1.05);
}

/* Animated underlines on key terms */
.paradox-body .key {
    position: relative;
    color: var(--deep-black);
    font-style: italic;
    display: inline-block;
}

.paradox-body .key::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -2px;
    width: 100%;
    height: 1.5px;
    background: var(--gold-ink);
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform 600ms ease-out;
}

.paradox.in-view .paradox-body .key::after {
    transform: scaleX(1);
}

.paradox-body .key:hover {
    color: var(--luxury-gold);
}

/* Ornate horizontal rule */
.ornate-rule {
    margin-top: calc(var(--base-unit) * 3);
    width: 100%;
    max-width: 700px;
    height: 24px;
    opacity: 0.85;
}

.ornate-rule svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* ------- Illumination panels ------- */
.illumination {
    position: relative;
    width: 100%;
    margin: calc(var(--base-unit) * 4) 0;
    padding: calc(var(--base-unit) * 4) var(--base-unit);
    background: var(--parchment);
    border-top: 1px solid rgba(184, 150, 46, 0.25);
    border-bottom: 1px solid rgba(184, 150, 46, 0.25);
    overflow: hidden;
    transform: scale(0.98);
    opacity: 0.8;
    transition: transform 800ms ease-out, opacity 800ms ease-out;
}

.illumination.in-view {
    transform: scale(1);
    opacity: 1;
}

.illum-inner {
    max-width: 760px;
    margin: 0 auto;
    text-align: center;
    position: relative;
    z-index: 5;
}

.illum-label {
    font-family: "Cormorant SC", serif;
    font-weight: 500;
    letter-spacing: 0.28em;
    font-size: 13px;
    text-transform: uppercase;
    color: var(--sepia);
    margin-bottom: calc(var(--base-unit) * 1.5);
}

.impossible-art {
    margin: 0 auto calc(var(--base-unit) * 1.5) auto;
    width: clamp(220px, 28vw, 320px);
    aspect-ratio: 1.1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.impossible-art svg {
    width: 100%;
    height: 100%;
    display: block;
    transition: transform 12s linear;
}

.illumination.in-view .impossible-art svg {
    animation: slowSpin 60s linear infinite;
}

.illumination.in-view .impossible-art .penrose {
    animation-name: gentleTilt;
    animation-duration: 18s;
    animation-iteration-count: infinite;
    animation-timing-function: ease-in-out;
}

.illumination.in-view .impossible-art .impossible-cube {
    animation-name: gentleTilt;
    animation-duration: 22s;
}

.illumination.in-view .impossible-art .mobius {
    animation-name: gentleTilt;
    animation-duration: 26s;
}

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

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

.illum-caption {
    font-family: "Cormorant Garamond", serif;
    font-style: italic;
    font-size: clamp(15px, 1.2vw, 19px);
    color: var(--sepia);
    letter-spacing: 0.02em;
}

/* ------- Floating fish layer (page-wide decorative) ------- */
.fish-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 6;
    overflow: hidden;
}

.fish {
    position: absolute;
    color: var(--teal);
    will-change: transform;
    /* Tropical teal accent on the fish */
    filter: drop-shadow(0 0 1px rgba(46, 139, 122, 0.4));
}

.fish path,
.fish circle {
    stroke: var(--teal);
}

.fish-1 {
    width: 120px;
    height: 48px;
    top: 18%;
    left: -160px;
    animation: drift1 22s linear infinite;
    animation-delay: 1.6s;
}

.fish-2 {
    width: 160px;
    height: 72px;
    top: 58%;
    left: -200px;
    animation: drift2 28s linear infinite;
    animation-delay: 5s;
    opacity: 0.85;
}

.fish-3 {
    width: 60px;
    height: 96px;
    top: 80%;
    right: -120px;
    animation: drift3 24s linear infinite;
    animation-delay: 8s;
    opacity: 0.75;
}

.fish-4 {
    width: 90px;
    height: 36px;
    top: 38%;
    right: -120px;
    animation: drift4 18s linear infinite;
    animation-delay: 3s;
    opacity: 0.65;
    transform: scaleX(-1);
}

@keyframes drift1 {
    0%   { transform: translate(0, 0) scaleX(1); }
    25%  { transform: translate(35vw, -14px) scaleX(1); }
    50%  { transform: translate(70vw, 10px) scaleX(1); }
    75%  { transform: translate(105vw, -8px) scaleX(1); }
    100% { transform: translate(120vw, 0) scaleX(1); }
}

@keyframes drift2 {
    0%   { transform: translate(0, 0); }
    33%  { transform: translate(40vw, 18px); }
    66%  { transform: translate(80vw, -16px); }
    100% { transform: translate(125vw, 6px); }
}

@keyframes drift3 {
    0%   { transform: translate(0, 0); }
    50%  { transform: translate(-50vw, -24px); }
    100% { transform: translate(-110vw, 0); }
}

@keyframes drift4 {
    0%   { transform: translate(0, 0) scaleX(-1); }
    50%  { transform: translate(-55vw, 20px) scaleX(-1); }
    100% { transform: translate(-115vw, 0) scaleX(-1); }
}

.fish.flee {
    transition: transform 1200ms cubic-bezier(0.18, 0.7, 0.22, 1);
}

/* ------- Final parchment ------- */
.final-parchment {
    height: 100vh;
    min-height: 640px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0 var(--base-unit);
    position: relative;
}

.final-content {
    position: relative;
    z-index: 5;
    max-width: 720px;
}

.final-label {
    font-family: "Cormorant SC", serif;
    font-weight: 500;
    letter-spacing: 0.32em;
    font-size: 13px;
    text-transform: uppercase;
    color: var(--sepia);
    margin-bottom: calc(var(--base-unit) * 2);
}

.final-paradox {
    font-family: "Cormorant Garamond", serif;
    font-style: italic;
    font-weight: 400;
    font-size: clamp(24px, 3vw, 38px);
    line-height: 1.6;
    color: var(--deep-black);
    margin-bottom: calc(var(--base-unit) * 2);
    letter-spacing: 0.02em;
}

.final-paradox em {
    font-style: italic;
}

.seal-mark {
    width: 80px;
    height: 80px;
    margin: 0 auto calc(var(--base-unit) * 1.5) auto;
    opacity: 0.85;
}

.seal-mark svg {
    width: 100%;
    height: 100%;
    display: block;
    animation: sealBreathe 4.8s ease-in-out infinite;
}

@keyframes sealBreathe {
    0%, 100% { transform: scale(1); opacity: 0.78; }
    50%      { transform: scale(1.04); opacity: 1; }
}

.colophon {
    font-family: "Cormorant SC", serif;
    letter-spacing: 0.22em;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--sepia);
}

/* Circling fish around the final coda */
.circle-fish-layer {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.orbit {
    position: absolute;
    width: 120px;
    height: 48px;
    transform-origin: center center;
    color: var(--teal);
}

.orbit svg {
    width: 100%;
    height: 100%;
    display: block;
}

.orbit svg path {
    stroke: var(--teal);
}

.orbit-a {
    animation: orbitA 26s linear infinite;
    opacity: 0.85;
}

.orbit-b {
    width: 90px;
    height: 36px;
    animation: orbitB 32s linear infinite reverse;
    opacity: 0.7;
}

.orbit-c {
    width: 70px;
    height: 28px;
    animation: orbitC 22s linear infinite;
    opacity: 0.6;
}

@keyframes orbitA {
    0%   { transform: rotate(0deg) translateX(280px) rotate(0deg); }
    100% { transform: rotate(360deg) translateX(280px) rotate(-360deg); }
}

@keyframes orbitB {
    0%   { transform: rotate(0deg) translateX(360px) rotate(0deg); }
    100% { transform: rotate(360deg) translateX(360px) rotate(-360deg); }
}

@keyframes orbitC {
    0%   { transform: rotate(0deg) translateX(220px) rotate(0deg); }
    100% { transform: rotate(360deg) translateX(220px) rotate(-360deg); }
}

/* ------- Responsive adjustments ------- */
@media (max-width: 900px) {
    :root {
        --margin-rule: 10%;
        --content-max: 84%;
    }

    .paradox {
        padding-left: 12%;
        padding-right: 6%;
    }

    .paradox-head {
        margin-left: -42px;
    }

    .paradox-num {
        width: 36px;
        font-size: 18px;
    }

    .domain-title {
        font-size: clamp(40px, 12vw, 64px);
    }

    .final-paradox {
        font-size: clamp(20px, 5vw, 30px);
    }

    .orbit-a { animation-name: orbitASmall; }
    .orbit-b { animation-name: orbitBSmall; }
    .orbit-c { animation-name: orbitCSmall; }

    @keyframes orbitASmall {
        0%   { transform: rotate(0deg) translateX(160px) rotate(0deg); }
        100% { transform: rotate(360deg) translateX(160px) rotate(-360deg); }
    }
    @keyframes orbitBSmall {
        0%   { transform: rotate(0deg) translateX(200px) rotate(0deg); }
        100% { transform: rotate(360deg) translateX(200px) rotate(-360deg); }
    }
    @keyframes orbitCSmall {
        0%   { transform: rotate(0deg) translateX(130px) rotate(0deg); }
        100% { transform: rotate(360deg) translateX(130px) rotate(-360deg); }
    }
}

@media (max-width: 600px) {
    :root {
        --base-unit: 18px;
    }

    .paradox-body {
        max-width: 100%;
    }

    .dropcap {
        font-size: 3.4em;
    }

    .title-meta {
        gap: 10px;
        font-size: 11px;
    }
}
