/* ================================================================
   historical.quest — goblincore cabinet of curiosities
   Palette:
     #f5efe1 Parchment Cream   #e8ddc8 Mushroom Cap
     #3b2f1e Dark Loam         #5a4a35 Warm Bark
     #7a6b52 Lichen Grey       #6b8f5e Moss Green
     #5e9b8a Oxidized Copper   #c8943e Amber Specimen
     #8a7b62 Wet Stone         #3a6b6e Deep Pool
   Typography:
     Abril Fatface  — display / headlines
     Crimson Pro    — body / narrative
     Caveat         — annotations / handwriting
     Courier Prime  — monospace / data
   ================================================================= */

:root {
    --cream: #f5efe1;
    --mushroom: #e8ddc8;
    --loam: #3b2f1e;
    --bark: #5a4a35;
    --lichen: #7a6b52;
    --moss: #6b8f5e;
    --moss-deep: #4a7044;
    --moss-pale: #8aab7e;
    --copper: #5e9b8a;
    --amber: #c8943e;
    --stone: #8a7b62;
    --pool: #3a6b6e;
    --cream-tint: #efe7d3;
    --emboss: #d4c9a8;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background: var(--cream);
    color: var(--bark);
    font-family: 'Crimson Pro', Georgia, serif;
    font-weight: 400;
    line-height: 1.8;
    overflow-x: hidden;
    min-height: 100vh;
    position: relative;
    /* subtle dappled texture using layered radial spots */
    background-image:
        radial-gradient(circle at 18% 22%, rgba(232,221,200,0.55) 0px, rgba(232,221,200,0) 120px),
        radial-gradient(circle at 72% 8%, rgba(232,221,200,0.40) 0px, rgba(232,221,200,0) 180px),
        radial-gradient(circle at 85% 60%, rgba(232,221,200,0.45) 0px, rgba(232,221,200,0) 200px),
        radial-gradient(circle at 28% 78%, rgba(232,221,200,0.50) 0px, rgba(232,221,200,0) 160px),
        radial-gradient(circle at 55% 42%, rgba(232,221,200,0.35) 0px, rgba(232,221,200,0) 220px);
}

/* ================================================================
   Moss borders (fixed decorative edges)
   ================================================================= */

.moss-border {
    position: fixed;
    pointer-events: none;
    z-index: 5;
    transition: opacity 0.6s ease-out;
}

.moss-top {
    top: 0;
    left: 0;
    right: 0;
    height: 90px;
}

.moss-left {
    top: 0;
    left: 0;
    bottom: 0;
    width: 90px;
}

.moss-dot {
    position: absolute;
    border-radius: 50%;
    filter: blur(0.6px);
}

/* ================================================================
   Bubble layer
   ================================================================= */

.bubble-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 4;
    overflow: hidden;
}

.bubble {
    position: absolute;
    bottom: -60px;
    border-radius: 50%;
    border: 1px solid rgba(94,155,138,0.40);
    background: radial-gradient(circle at 32% 30%,
        rgba(94,155,138,0.18) 0%,
        rgba(94,155,138,0.08) 38%,
        rgba(94,155,138,0) 72%);
    box-shadow: inset 2px 3px 0 rgba(245,239,225,0.35);
    will-change: transform, opacity;
    opacity: 0;
}

@keyframes rise {
    0%   { transform: translate(0, 0) scale(0.85);  opacity: 0; }
    10%  { opacity: 0.75; }
    85%  { opacity: 0.75; }
    100% { transform: translate(0, -110vh) scale(1.05); opacity: 0; }
}

@keyframes drift {
    0%   { margin-left: 0; }
    25%  { margin-left: var(--drift); }
    50%  { margin-left: 0; }
    75%  { margin-left: calc(var(--drift) * -1); }
    100% { margin-left: 0; }
}

/* ================================================================
   Water surface overlay (for submersion zone)
   ================================================================= */

.water-surface {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 3;
    opacity: 0;
    transition: opacity 0.4s ease-out;
    background: linear-gradient(
        to bottom,
        rgba(58,107,110,0) 0%,
        rgba(58,107,110,0.10) 35%,
        rgba(58,107,110,0.28) 75%,
        rgba(58,107,110,0.42) 100%
    );
    backdrop-filter: blur(0.4px);
    -webkit-backdrop-filter: blur(0.4px);
}

.water-surface.active {
    opacity: 1;
}

.water-surface.deep {
    backdrop-filter: blur(1.4px);
    -webkit-backdrop-filter: blur(1.4px);
}

/* ================================================================
   Main scroll container
   ================================================================= */

.main-scroll {
    position: relative;
    z-index: 10;
}

.section {
    padding: 8vh 6vw 10vh;
    position: relative;
}

/* ================================================================
   SECTION 1 — The Specimen Wall
   ================================================================= */

.specimen-wall {
    min-height: 100vh;
    padding-top: 110px;
}

.section-intro {
    max-width: 780px;
    margin: 0 auto 5vh;
    text-align: center;
    padding: 0 2vw;
}

.section-kicker {
    font-family: 'Caveat', cursive;
    font-size: clamp(0.95rem, 1.4vw, 1.15rem);
    color: var(--lichen);
    letter-spacing: 0.02em;
    margin-bottom: 1.2rem;
    transform: rotate(-1.5deg);
    display: inline-block;
}

.section-title {
    font-family: 'Abril Fatface', serif;
    font-weight: 400;
    font-size: clamp(3rem, 8vw, 7rem);
    color: var(--loam);
    letter-spacing: 0.04em;
    line-height: 1.05;
    text-shadow: 1px 1px 0 var(--emboss);
    margin-bottom: 1.5rem;
}

.section-title .dot {
    color: var(--amber);
}

.section-lede {
    font-family: 'Crimson Pro', serif;
    font-weight: 300;
    font-size: clamp(1.05rem, 1.7vw, 1.25rem);
    color: var(--bark);
    max-width: 560px;
    margin: 0 auto;
    font-style: italic;
}

/* --- honeycomb container ------------------------------------------------ */

.honeycomb-perspective {
    perspective: 1200px;
    perspective-origin: 50% 50%;
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
    padding: 2vw 0;
}

.honeycomb {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    transform-style: preserve-3d;
    transition: transform 0.35s ease-out;
    will-change: transform;
    position: relative;
}

.hex-row {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: center;
    margin: -32px 0;  /* pull rows together to honeycomb-tile */
}

.hex-row.offset {
    margin-left: 70px;  /* stagger every other row */
}

/* Hexagon cell */
.hex {
    --size: 180px;
    --tz: 0px;
    position: relative;
    width: var(--size);
    height: calc(var(--size) * 1.1547);  /* flat-top ratio */
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: var(--cream);
    transform: translateZ(var(--tz)) scale(0.85) translateY(10px);
    opacity: 0;
    transition:
        transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
        opacity 0.6s ease-out,
        background 0.4s ease-out,
        filter 0.4s ease-out;
    cursor: default;
    will-change: transform, opacity;
}

.hex.visible {
    opacity: 1;
    transform: translateZ(var(--tz)) scale(1) translateY(0);
}

.hex.size-s { --size: 140px; --tz: 0px; }
.hex.size-m { --size: 190px; --tz: 8px; }
.hex.size-l { --size: 260px; --tz: 15px; }

/* alternating cream / mushroom tiles */
.hex:nth-child(odd)  { background: var(--mushroom); }
.hex:nth-child(even) { background: var(--cream); }

.hex-row.offset .hex:nth-child(odd)  { background: var(--cream-tint); }
.hex-row.offset .hex:nth-child(even) { background: var(--mushroom); }

.hex.featured {
    background: var(--cream);
    filter: drop-shadow(0 6px 8px rgba(59,47,30,0.10));
}

.hex:hover {
    transform: translateZ(calc(var(--tz) + 8px)) scale(1.04);
    filter: drop-shadow(0 6px 10px rgba(94,155,138,0.22));
}

.hex-inner {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 18% 14%;
    text-align: center;
    gap: 0.3rem;
}

/* --- hex content variants --------------------------------------------- */

.hex-year {
    font-family: 'Abril Fatface', serif;
    font-weight: 400;
    font-size: clamp(2rem, 3.2vw, 3.2rem);
    color: var(--loam);
    letter-spacing: 0.03em;
    line-height: 1;
    text-shadow: 1px 1px 0 var(--emboss);
    transform: rotate(-4deg);
    display: inline-block;
}

.hex-year.small {
    font-size: clamp(1.4rem, 2.4vw, 2.2rem);
}

.hex-year.deep {
    color: var(--cream);
    text-shadow: 1px 1px 0 rgba(58,107,110,0.5);
}

.hex-label {
    font-family: 'Caveat', cursive;
    font-size: clamp(0.75rem, 1.1vw, 0.95rem);
    color: var(--lichen);
    margin-top: 0.3rem;
}

.type-date.featured {
    background: var(--cream) !important;
}

.type-date.featured::before {
    content: "";
    position: absolute;
    inset: 8%;
    border: 1.5px solid rgba(94,155,138,0.55);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    pointer-events: none;
}

.type-date.featured .hex-year {
    color: var(--loam);
}

.hex-quote {
    font-family: 'Caveat', cursive;
    font-size: clamp(0.85rem, 1.15vw, 1rem);
    color: var(--bark);
    line-height: 1.5;
    transform: rotate(-1.5deg);
}

.hex-quote-lg {
    font-family: 'Caveat', cursive;
    font-size: clamp(0.95rem, 1.4vw, 1.2rem);
    color: var(--loam);
    line-height: 1.5;
    transform: rotate(-2deg);
}

.hex-quote-lg em {
    color: var(--amber);
    font-style: italic;
}

.catalog {
    font-family: 'Courier Prime', monospace;
    font-size: 0.78rem;
    color: var(--stone);
    letter-spacing: 0.08em;
    margin-top: 0.35rem;
}

.artifact {
    width: 55%;
    height: auto;
}

.artifact.big {
    width: 65%;
}

.type-empty .cross {
    font-family: 'Abril Fatface', serif;
    color: var(--stone);
    font-size: 1.8rem;
    opacity: 0.45;
}

/* bubble-filled hex cells */
.type-bubble .hex-inner {
    padding: 0;
    overflow: hidden;
}

.mini-bubbles {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.mini-bubble {
    position: absolute;
    bottom: -20px;
    border-radius: 50%;
    border: 1px solid rgba(94,155,138,0.5);
    background: radial-gradient(circle at 32% 30%,
        rgba(94,155,138,0.15) 0%,
        rgba(94,155,138,0.04) 50%,
        transparent 80%);
}

@keyframes mini-rise {
    0%   { transform: translateY(0); opacity: 0; }
    12%  { opacity: 0.85; }
    88%  { opacity: 0.85; }
    100% { transform: translateY(-200px); opacity: 0; }
}

/* --- grid-line SVG overlay -------------------------------------------- */

.grid-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.grid-line {
    fill: none;
    stroke: var(--moss);
    stroke-width: 1.2;
    opacity: 0.28;
    transition: opacity 0.4s ease-out;
}

.grid-line.active {
    opacity: 0.65;
}

.grid-pulse {
    fill: var(--amber);
    r: 3;
    opacity: 0;
}

/* ================================================================
   SECTION 2 — The Curiosity Drawer
   ================================================================= */

.curiosity-drawer {
    background:
        radial-gradient(circle at 10% 5%, rgba(232,221,200,0.55) 0, rgba(232,221,200,0) 300px),
        radial-gradient(circle at 90% 90%, rgba(232,221,200,0.5) 0, rgba(232,221,200,0) 280px);
    padding-top: 12vh;
    padding-bottom: 14vh;
}

.drawer-header {
    max-width: 720px;
    margin: 0 auto 6vh;
    text-align: center;
    padding: 0 2vw;
}

.drawer-kicker {
    font-family: 'Courier Prime', monospace;
    font-size: 0.8rem;
    color: var(--stone);
    letter-spacing: 0.22em;
    margin-bottom: 1rem;
}

.drawer-title {
    font-family: 'Abril Fatface', serif;
    font-weight: 400;
    font-size: clamp(2.2rem, 5vw, 4.2rem);
    color: var(--loam);
    letter-spacing: 0.03em;
    text-shadow: 1px 1px 0 var(--emboss);
    line-height: 1.1;
    margin-bottom: 1.2rem;
}

.drawer-lede {
    font-family: 'Caveat', cursive;
    font-size: clamp(1.05rem, 1.6vw, 1.3rem);
    color: var(--lichen);
    transform: rotate(-0.5deg);
    display: inline-block;
}

.drawer-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 30px 18px;
    max-width: 1200px;
    margin: 0 auto;
    perspective: 1200px;
}

.drawer-hex {
    --dsize: 240px;
    width: var(--dsize);
    height: calc(var(--dsize) * 1.1547);
    position: relative;
    cursor: pointer;
    transition:
        transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
        width 0.55s cubic-bezier(0.34, 1.56, 0.64, 1),
        height 0.55s cubic-bezier(0.34, 1.56, 0.64, 1),
        margin 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.drawer-hex:nth-child(3n+1) { margin-top: 40px; }
.drawer-hex:nth-child(3n+2) { margin-top: 0; }
.drawer-hex:nth-child(3n+3) { margin-top: 40px; }

.drawer-hex-inner {
    position: absolute;
    inset: 0;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: var(--mushroom);
    transition: background 0.4s ease-out, transform 0.4s ease-out;
}

.drawer-hex:nth-child(even) .drawer-hex-inner { background: var(--cream); }
.drawer-hex.featured .drawer-hex-inner {
    background: var(--cream);
    box-shadow: inset 0 0 0 2px rgba(200,148,62,0.45);
}

.drawer-face {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 18% 14%;
    text-align: center;
    transition: opacity 0.3s ease-out;
}

.drawer-year {
    font-family: 'Abril Fatface', serif;
    font-size: clamp(2.4rem, 4.2vw, 3.8rem);
    color: var(--loam);
    letter-spacing: 0.03em;
    text-shadow: 1px 1px 0 var(--emboss);
    line-height: 1;
    transform: rotate(-3deg);
}

.drawer-label {
    font-family: 'Caveat', cursive;
    font-size: 1.05rem;
    color: var(--lichen);
    margin-top: 0.3rem;
}

.drawer-body {
    position: absolute;
    inset: 0;
    padding: 14% 12%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.6rem;
    opacity: 0;
    transition: opacity 0.4s ease-out 0.1s;
    pointer-events: none;
    overflow: hidden;
}

.drawer-body h3 {
    font-family: 'Abril Fatface', serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.4vw, 1.15rem);
    color: var(--loam);
    letter-spacing: 0.02em;
    line-height: 1.2;
}

.drawer-body p {
    font-family: 'Crimson Pro', serif;
    font-weight: 300;
    font-size: clamp(0.78rem, 1vw, 0.88rem);
    color: var(--bark);
    line-height: 1.5;
}

.drawer-hex:hover {
    transform: translateY(-4px) scale(1.02);
}

.drawer-hex:hover .drawer-hex-inner {
    box-shadow: inset 0 0 0 2px rgba(107,143,94,0.55);
}

.drawer-hex.open {
    --dsize: 340px;
    z-index: 20;
}

.drawer-hex.open .drawer-face {
    opacity: 0;
}

.drawer-hex.open .drawer-body {
    opacity: 1;
    pointer-events: auto;
}

.drawer-hex.open .drawer-hex-inner {
    background: var(--cream);
    box-shadow: inset 0 0 0 2px rgba(94,155,138,0.6);
}

.drawer-hex.nudge-left  { transform: translateX(-14px); }
.drawer-hex.nudge-right { transform: translateX(14px); }
.drawer-hex.nudge-up    { transform: translateY(-12px); }
.drawer-hex.nudge-down  { transform: translateY(12px); }

/* ================================================================
   SECTION 3 — The Submersion Zone
   ================================================================= */

.submersion-zone {
    background:
        linear-gradient(to bottom,
            var(--cream) 0%,
            rgba(58,107,110,0.12) 40%,
            rgba(58,107,110,0.28) 85%,
            rgba(58,107,110,0.45) 100%);
    color: var(--cream);
    padding-top: 12vh;
    padding-bottom: 18vh;
    position: relative;
    overflow: hidden;
}

.submersion-zone::before {
    /* a faint water-surface line at the top */
    content: "";
    position: absolute;
    left: 0; right: 0;
    top: 8vh;
    height: 1px;
    background: linear-gradient(to right,
        transparent 0%, rgba(58,107,110,0.4) 20%,
        rgba(58,107,110,0.4) 80%, transparent 100%);
}

.submerge-header {
    max-width: 720px;
    margin: 0 auto 6vh;
    text-align: center;
    padding: 0 2vw;
    color: var(--bark);
}

.submerge-kicker {
    font-family: 'Courier Prime', monospace;
    font-size: 0.8rem;
    color: var(--pool);
    letter-spacing: 0.22em;
    margin-bottom: 1rem;
}

.submerge-title {
    font-family: 'Abril Fatface', serif;
    font-weight: 400;
    font-size: clamp(2.2rem, 5vw, 4.2rem);
    color: var(--loam);
    letter-spacing: 0.03em;
    text-shadow: 1px 1px 0 var(--emboss);
    line-height: 1.1;
    margin-bottom: 1.2rem;
}

.submerge-lede {
    font-family: 'Caveat', cursive;
    font-size: clamp(1.05rem, 1.6vw, 1.3rem);
    color: var(--pool);
    transform: rotate(-0.5deg);
    display: inline-block;
}

.submerge-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 24px 16px;
    max-width: 1200px;
    margin: 0 auto;
}

.sub-hex {
    --subsize: 260px;
    width: var(--subsize);
    height: calc(var(--subsize) * 1.1547);
    position: relative;
    filter: blur(0px);
    transition: filter 0.4s ease-out, transform 0.5s ease-out;
}

.sub-hex:nth-child(even) { margin-top: 50px; }

.sub-hex-inner {
    position: absolute;
    inset: 0;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: linear-gradient(
        135deg,
        rgba(245,239,225,0.88) 0%,
        rgba(232,221,200,0.75) 100%);
    padding: 14% 12%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 0.5rem;
    backdrop-filter: blur(1px);
    -webkit-backdrop-filter: blur(1px);
}

.sub-hex.deep .sub-hex-inner {
    background: linear-gradient(
        135deg,
        rgba(245,239,225,0.78) 0%,
        rgba(138,123,98,0.30) 100%);
}

.sub-hex .hex-year {
    color: var(--loam);
    text-shadow: 1px 1px 0 var(--emboss);
    font-size: clamp(1.6rem, 2.8vw, 2.4rem);
}

.sub-hex .hex-label {
    color: var(--lichen);
    font-size: 1rem;
}

.deep-note {
    font-family: 'Crimson Pro', serif;
    font-weight: 300;
    font-style: italic;
    font-size: clamp(0.82rem, 1.1vw, 0.95rem);
    color: var(--bark);
    line-height: 1.55;
    margin-top: 0.4rem;
}

.sub-hex:hover {
    filter: blur(0);
    transform: translateY(-4px);
}

.seabed {
    text-align: center;
    margin-top: 10vh;
    padding: 4vh 2vw 2vh;
    color: var(--cream);
}

.seabed .caveat {
    font-family: 'Caveat', cursive;
    font-size: 1.25rem;
    color: var(--pool);
    display: block;
    margin-bottom: 1.5rem;
    transform: rotate(-1deg);
}

.footer-cite {
    font-family: 'Courier Prime', monospace;
    font-size: 0.8rem;
    color: var(--stone);
    letter-spacing: 0.08em;
}

.courier {
    color: var(--amber);
}

/* ================================================================
   Specimen Tray — floating nav
   ================================================================= */

.specimen-tray {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 50;
    display: flex;
    flex-wrap: wrap;
    max-width: 180px;
    gap: 4px;
    padding: 8px;
    border-radius: 6px;
    background: rgba(245,239,225,0.75);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    box-shadow: 0 6px 24px rgba(59,47,30,0.18);
}

.tray-hex {
    width: 44px;
    height: 50px;
    background: var(--cream);
    color: var(--lichen);
    border: none;
    padding: 10px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    cursor: pointer;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.tray-hex svg {
    width: 100%;
    height: 100%;
}

.tray-hex:hover {
    background: var(--mushroom);
    color: var(--moss);
    transform: rotate(30deg) scale(1.1);
}

.tray-hex.active {
    color: var(--amber);
    background: var(--mushroom);
}

/* ================================================================
   Responsive
   ================================================================= */

@media (max-width: 900px) {
    .hex.size-l { --size: 180px; }
    .hex.size-m { --size: 140px; }
    .hex.size-s { --size: 110px; }
    .hex-row.offset { margin-left: 50px; }

    .drawer-hex { --dsize: 180px; }
    .drawer-hex.open { --dsize: 260px; }

    .sub-hex { --subsize: 200px; }
}

@media (max-width: 640px) {
    .section { padding: 6vh 4vw 8vh; }

    .hex.size-l { --size: 130px; }
    .hex.size-m { --size: 110px; }
    .hex.size-s { --size: 90px; }
    .hex-row { gap: 4px; margin: -24px 0; }
    .hex-row.offset { margin-left: 38px; }

    .honeycomb { transform: none !important; }
    .grid-lines { display: none; }

    .drawer-grid {
        gap: 20px 12px;
    }
    .drawer-hex { --dsize: 150px; }
    .drawer-hex:nth-child(3n+1),
    .drawer-hex:nth-child(3n+2),
    .drawer-hex:nth-child(3n+3) { margin-top: 10px; }
    .drawer-hex.open { --dsize: 300px; }

    .sub-hex { --subsize: 170px; }
    .sub-hex:nth-child(even) { margin-top: 30px; }

    .specimen-tray {
        bottom: 12px;
        right: 12px;
        max-width: 140px;
    }
    .tray-hex {
        width: 36px;
        height: 42px;
        padding: 8px;
    }

    .moss-top { height: 60px; }
    .moss-left { width: 60px; }
}

@media (prefers-reduced-motion: reduce) {
    .hex, .drawer-hex, .sub-hex,
    .bubble, .mini-bubble,
    .honeycomb, .tray-hex {
        transition-duration: 0.01s !important;
        animation: none !important;
    }
}
