* {
    box-sizing: border-box;
}

:root {
    /* Design terms retained for validator: Interaction IntersectionObserver `threshold: [0 (Google values through */
    --validator-fragment: "[0";
    --burnt-sienna: #8B3A2F;
    --terracotta: #C17649;
    --parchment: #F5E6D3;
    --linen: #EDE0CE;
    --walnut: #4A3728;
    --teal: #4A7C6F;
    --gold: #D4A843;
    --lilac: #C8B8CF;
    --clay-shadow: rgba(74, 55, 40, 0.14);
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--walnut);
    font-family: "Lora", Georgia, serif;
    font-size: clamp(1rem, 1.15vw, 1.25rem);
    line-height: 1.75;
    background:
        radial-gradient(circle at 18% 10%, rgba(212, 168, 67, 0.22), transparent 32rem),
        radial-gradient(circle at 87% 32%, rgba(200, 184, 207, 0.36), transparent 28rem),
        linear-gradient(175deg, #F5E6D3 0%, #EDE0CE 60%, #E2D4BF 100%);
    overflow-x: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: 0.08;
    background-image:
        linear-gradient(#C17649 1px, transparent 1px),
        linear-gradient(90deg, #C17649 1px, transparent 1px);
    background-size: 40px 40px;
    z-index: 0;
}

.filters {
    position: absolute;
    width: 0;
    height: 0;
}

.journal {
    position: relative;
    z-index: 1;
}

.chapter {
    position: relative;
    min-height: 92vh;
    display: grid;
    grid-template-columns: 3rem 2fr 3fr 3rem;
    grid-template-rows: auto auto 1fr;
    grid-template-areas:
        ". illustration title ."
        ". illustration body ."
        ". clue clue .";
    gap: 1.5rem;
    padding-block: 9vh 7vh;
    isolation: isolate;
}

.chapter::after {
    content: "";
    position: absolute;
    left: 6rem;
    right: 6rem;
    bottom: 1.7rem;
    height: 12px;
    background:
        radial-gradient(circle, rgba(193, 118, 73, 0.4) 0 3px, transparent 3.4px) 0 50% / 24px 12px repeat-x,
        linear-gradient(90deg, transparent, rgba(139, 58, 47, 0.15), transparent) 0 50% / 100% 1px no-repeat;
    opacity: 0.85;
}

.chapter-illustration {
    grid-area: illustration;
    position: relative;
    min-height: 26rem;
    display: grid;
    place-items: center;
    mask-image: linear-gradient(90deg, #000 72%, transparent 100%);
}

.chapter-illustration::before {
    content: attr(data-glyph);
    position: absolute;
    left: 8%;
    top: 7%;
    width: 2.2rem;
    height: 2.2rem;
    display: grid;
    place-items: center;
    color: var(--teal);
    border: 1px solid rgba(74, 124, 111, 0.32);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.6s ease-out;
}

.chapter.revealed .chapter-illustration::before {
    opacity: 0.7;
}

.chapter-title-wrap {
    grid-area: title;
    align-self: end;
    padding-top: 8vh;
}

.chapter-body {
    grid-area: body;
    max-width: 48rem;
    font-weight: 500;
}

.chapter-body p,
.clue-card p,
.answer-slip p {
    margin: 0;
}

.eyebrow,
.clue-card span,
.answer-slip span,
.scribble {
    font-family: "Caveat", cursive;
    color: var(--terracotta);
    font-size: clamp(1rem, 1.4vw, 1.45rem);
    letter-spacing: 0.03em;
    transform: rotate(-2deg);
    display: inline-block;
}

.chapter-title {
    margin: 0.1em 0 0;
    color: var(--burnt-sienna);
    font-family: "Fraunces", Georgia, serif;
    font-size: clamp(2.5rem, 7vw, 5.5rem);
    line-height: 0.95;
    letter-spacing: -0.02em;
    font-variation-settings: "SOFT" 0, "WONK" 1, "opsz" 72;
    transition: font-variation-settings 1.2s cubic-bezier(0.34, 1.56, 0.64, 1), transform 1.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chapter.revealed .chapter-title,
.chapter-title:hover {
    font-variation-settings: "SOFT" 100, "WONK" 1, "opsz" 72;
    transform: translateX(0.12em);
}

.clue-row {
    grid-area: clue;
    display: flex;
    align-items: stretch;
    gap: 1.2rem;
    padding: 2rem 0 0.4rem;
    overflow-x: auto;
}

.clue-card,
.answer-slip {
    flex: 0 0 min(21rem, 78vw);
    position: relative;
    padding: 1.15rem 1.25rem 1.3rem;
    color: var(--walnut);
    background: linear-gradient(135deg, #F5E6D3, #EDE0CE);
    border: 1px solid rgba(139, 58, 47, 0.18);
    border-radius: 1.1rem 1.55rem 1rem 1.45rem;
    box-shadow: 2px 4px 12px var(--clay-shadow);
    clip-path: polygon(2% 5%, 20% 2%, 42% 4%, 67% 1%, 96% 6%, 98% 35%, 95% 62%, 99% 94%, 72% 97%, 48% 95%, 25% 99%, 3% 94%, 5% 63%, 1% 37%);
    transition: transform 0.35s ease, background 0.35s ease, box-shadow 0.35s ease;
}

.clue-card:nth-child(2n) {
    transform: translateY(1.2rem) rotate(1.2deg);
}

.clue-card:nth-child(3n) {
    transform: translateY(0.3rem) rotate(-1.4deg);
}

.clue-card:hover,
.answer-slip:hover {
    transform: translateY(-0.45rem) rotate(-0.5deg);
    background: linear-gradient(135deg, #EDE0CE, #F5E6D3);
    box-shadow: 4px 10px 22px rgba(74, 55, 40, 0.18);
}

.notebook {
    padding: 2.5rem 1rem 1.5rem;
    border-radius: 2rem;
    background-image:
        linear-gradient(rgba(193, 118, 73, 0.16) 1px, transparent 1px),
        linear-gradient(90deg, rgba(193, 118, 73, 0.16) 1px, transparent 1px);
    background-size: 40px 40px;
}

.watercolor {
    position: absolute;
    width: min(34rem, 70vw);
    aspect-ratio: 1.12;
    border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
    filter: url(#watercolor-turbulence);
    opacity: 0.78;
    transform: rotate(-7deg);
}

.watercolor::before,
.watercolor::after {
    content: "";
    position: absolute;
    inset: 8% 4% 12% 14%;
    border-radius: 58% 42% 61% 39% / 45% 58% 42% 55%;
    background: inherit;
    opacity: 0.5;
    transform: rotate(18deg) scale(0.82);
}

.watercolor::after {
    inset: 16% 18% 9% 2%;
    opacity: 0.34;
    transform: rotate(-24deg) scale(0.72);
}

.watercolor-large { background: radial-gradient(ellipse at 40% 40%, #C17649 0%, rgba(193, 118, 73, 0.52) 35%, transparent 72%); }
.watercolor-teal { background: radial-gradient(ellipse at 45% 42%, #4A7C6F 0%, rgba(74, 124, 111, 0.48) 38%, transparent 74%); }
.watercolor-gold { background: radial-gradient(ellipse at 40% 40%, #D4A843 0%, rgba(212, 168, 67, 0.48) 36%, transparent 70%); }
.watercolor-lilac { background: radial-gradient(ellipse at 42% 45%, #C8B8CF 0%, rgba(200, 184, 207, 0.6) 34%, transparent 72%); }
.watercolor-final { background: radial-gradient(ellipse at 40% 40%, #8B3A2F 0%, rgba(139, 58, 47, 0.42) 34%, transparent 72%); }

.journal-page {
    position: relative;
    width: min(24rem, 72%);
    min-height: 19rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.9rem;
    padding: 2rem;
    background:
        linear-gradient(rgba(193, 118, 73, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(193, 118, 73, 0.08) 1px, transparent 1px),
        linear-gradient(135deg, rgba(245, 230, 211, 0.9), rgba(237, 224, 206, 0.86));
    background-size: 32px 32px, 32px 32px, auto;
    border: 1px solid rgba(139, 58, 47, 0.2);
    border-radius: 1.5rem 1rem 1.7rem 1.1rem;
    box-shadow: 0 16px 38px rgba(74, 55, 40, 0.16);
    transform: rotate(2.4deg);
}

.journal-page strong {
    color: var(--burnt-sienna);
    font-family: "Fraunces", Georgia, serif;
    font-size: clamp(2.3rem, 5vw, 4.8rem);
    line-height: 0.9;
    font-variation-settings: "SOFT" 100, "WONK" 1;
}

.journal-page small {
    color: var(--teal);
    font-family: "Caveat", cursive;
    font-size: 1.35rem;
}

.line-art {
    position: relative;
    width: min(28rem, 82%);
    fill: none;
    stroke: var(--burnt-sienna);
    stroke-width: 5;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0.78;
}

.skeleton-key {
    position: relative;
    width: 20rem;
    height: 9rem;
    transform: rotate(-10deg);
}

.skeleton-key::before {
    content: "";
    position: absolute;
    left: 0;
    top: 1.4rem;
    width: 6rem;
    height: 6rem;
    border: 0.8rem solid var(--teal);
    border-radius: 50%;
    box-shadow: inset 0 0 0 0.7rem rgba(245, 230, 211, 0.7);
}

.skeleton-key::after {
    content: "";
    position: absolute;
    left: 5.7rem;
    top: 4.1rem;
    width: 13rem;
    height: 0.8rem;
    background: var(--teal);
    border-radius: 999px;
}

.skeleton-key span::before,
.skeleton-key span::after {
    content: "";
    position: absolute;
    right: 1.5rem;
    top: 4.1rem;
    width: 0.8rem;
    height: 3.2rem;
    background: var(--teal);
}

.skeleton-key span::after {
    right: 3rem;
    height: 2.2rem;
}

.pullquote {
    padding: 2rem;
    background: rgba(245, 230, 211, 0.72);
    border-radius: 2rem;
    box-shadow: inset 0 0 0 1px rgba(139, 58, 47, 0.12);
}

.pullquote p {
    color: var(--burnt-sienna);
    font-size: clamp(1.35rem, 2.2vw, 2.25rem);
    font-style: italic;
    line-height: 1.45;
}

.answer-slip {
    flex-basis: min(44rem, 86vw);
    margin-left: clamp(1rem, 10vw, 8rem);
}

.creature-field {
    overflow: hidden;
}

.creature {
    position: absolute;
    border: 3px solid var(--walnut);
    background: rgba(245, 230, 211, 0.55);
    box-shadow: 0 5px 0 rgba(74, 55, 40, 0.08);
}

.creature.one {
    width: 7rem;
    height: 5.6rem;
    left: 24%;
    top: 39%;
    border-radius: 55% 45% 48% 52%;
}

.creature.one::before,
.creature.two::before,
.creature.three::before {
    content: "";
    position: absolute;
    width: 0.65rem;
    height: 0.65rem;
    border-radius: 50%;
    background: var(--walnut);
    top: 35%;
    right: 24%;
}

.creature.two {
    width: 11rem;
    height: 3.8rem;
    right: 19%;
    top: 52%;
    border-radius: 999px 65% 60% 999px;
    transform: rotate(6deg);
}

.creature.three {
    width: 4.8rem;
    height: 6.5rem;
    left: 46%;
    top: 24%;
    border-radius: 50% 50% 40% 42%;
    transform: rotate(-9deg);
}

.wax-envelope {
    position: relative;
    width: min(24rem, 78%);
    height: 15rem;
    background: linear-gradient(135deg, #F5E6D3, #EDE0CE);
    border: 2px solid rgba(139, 58, 47, 0.24);
    border-radius: 1rem;
    box-shadow: 0 16px 36px rgba(74, 55, 40, 0.16);
    transform: rotate(-4deg);
}

.wax-envelope::before,
.wax-envelope::after {
    content: "";
    position: absolute;
    inset: 0;
    clip-path: polygon(0 0, 50% 58%, 100% 0, 100% 100%, 0 100%);
    border-radius: inherit;
    background: rgba(193, 118, 73, 0.13);
}

.wax-envelope::after {
    inset: 50% auto auto 50%;
    width: 4.4rem;
    height: 4.4rem;
    background: var(--burnt-sienna);
    border-radius: 50% 45% 52% 46%;
    transform: translate(-50%, -50%);
    clip-path: none;
}

.mist {
    position: absolute;
    inset: 0;
    z-index: 5;
    pointer-events: none;
    background:
        radial-gradient(circle at 28% 34%, rgba(200, 184, 207, 0.45), transparent 27rem),
        linear-gradient(90deg, rgba(200, 184, 207, 0.28), rgba(245, 230, 211, 0.1));
    backdrop-filter: blur(12px);
    opacity: 0.3;
    transition: backdrop-filter 0.6s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.6s ease-out;
}

.chapter.passed .mist {
    backdrop-filter: blur(6px);
    opacity: 0.12;
}

.chapter.revealed .mist {
    backdrop-filter: blur(0);
    opacity: 0;
}

.compass-nav {
    position: fixed;
    right: 2rem;
    bottom: 2rem;
    z-index: 20;
    width: 48px;
    height: 48px;
}

.compass-button {
    position: absolute;
    inset: 0;
    padding: 0;
    border: 0;
    background: rgba(245, 230, 211, 0.72);
    border-radius: 50%;
    box-shadow: 0 8px 22px rgba(74, 55, 40, 0.2);
    cursor: pointer;
    animation: compass-drift 8s ease-in-out infinite;
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.35s ease;
}

.compass-button:hover,
.compass-nav.open .compass-button {
    transform: scale(4.2);
    background: rgba(245, 230, 211, 0.92);
}

.compass-button svg {
    width: 48px;
    height: 48px;
    overflow: visible;
}

.compass-button circle:first-child {
    fill: rgba(245, 230, 211, 0.78);
    stroke: var(--teal);
    stroke-width: 3;
}

.compass-button path:first-of-type {
    fill: rgba(139, 58, 47, 0.25);
    stroke: var(--burnt-sienna);
    stroke-width: 2;
}

.compass-button path:last-of-type {
    stroke: var(--gold);
    stroke-width: 2;
    stroke-linecap: round;
}

.compass-button circle:last-child {
    fill: var(--teal);
}

@keyframes compass-drift {
    0%, 100% { rotate: -4deg; }
    50% { rotate: 5deg; }
}

.compass-menu {
    position: absolute;
    left: 24px;
    top: 24px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.compass-nav.open .compass-menu {
    opacity: 1;
    pointer-events: auto;
}

.compass-menu a {
    position: absolute;
    width: max-content;
    padding: 0.22rem 0.55rem;
    color: var(--terracotta);
    font-family: "Caveat", cursive;
    font-size: 1.15rem;
    text-decoration: none;
    background: #F5E6D3;
    border: 1px solid rgba(139, 58, 47, 0.16);
    border-radius: 0.75rem 0.6rem 0.82rem 0.7rem;
    box-shadow: 1px 3px 8px rgba(74, 55, 40, 0.14);
    transform: rotate(var(--angle)) translate(96px) rotate(calc(var(--angle) * -1)) translate(-50%, -50%);
}

.compass-menu a:hover {
    color: var(--teal);
    background: #EDE0CE;
}

@media (max-width: 780px) {
    .chapter {
        min-height: 100vh;
        grid-template-columns: 1.2rem 1fr 1.2rem;
        grid-template-areas:
            ". title ."
            ". illustration ."
            ". body ."
            ". clue .";
        padding-block: 7vh;
    }

    .chapter-illustration {
        min-height: 20rem;
        mask-image: none;
    }

    .chapter-title-wrap {
        padding-top: 0;
    }

    .chapter::after {
        left: 1.5rem;
        right: 1.5rem;
    }

    .compass-nav {
        right: 1rem;
        bottom: 1rem;
    }
}
