/* ============================================================
   mystical.quest v2 — seapunk hexagonal-honeycomb
   Palette: honeyed-neutral with seapunk teal
============================================================ */

:root {
    --abyss: #1A2030;
    --abyss-deep: #11161F;
    --abyss-shallow: #1F2A3A;
    --teal: #40B8B0;
    --teal-soft: rgba(64, 184, 176, 0.55);
    --purple: #8858B0;
    --purple-soft: rgba(136, 88, 176, 0.5);
    --honey: #D0B878;
    --emerald: #2A6850;
    --snow: #C0D0D8;
    --pearl: #E8E4E0;

    --depth: 0;
    --bg-current: #1A2030;
}

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

html, body {
    height: 100%;
    background: var(--abyss);
    color: var(--pearl);
    font-family: "Atkinson Hyperlegible", system-ui, sans-serif;
    font-weight: 400;
    line-height: 1.75;
    overflow-x: hidden;
}

body {
    background: var(--bg-current);
    transition: background-color 0.6s ease;
    position: relative;
    min-height: 100vh;
}

/* ----------------------------------------------------------
   Bioluminescent ambient pulses
---------------------------------------------------------- */
.bio-pulse {
    position: fixed;
    width: 460px;
    height: 460px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    filter: blur(28px);
    opacity: 0.32;
    animation: bio-pulse 7s ease-in-out infinite;
}

.bio-pulse--a {
    background: radial-gradient(circle, var(--teal) 0%, transparent 65%);
    top: -10%; left: -8%;
    animation-delay: 0s;
}
.bio-pulse--b {
    background: radial-gradient(circle, var(--purple) 0%, transparent 65%);
    top: 38%; right: -10%;
    animation-delay: 1.4s;
}
.bio-pulse--c {
    background: radial-gradient(circle, var(--teal) 0%, transparent 65%);
    bottom: 6%; left: 18%;
    animation-delay: 2.8s;
    width: 360px; height: 360px;
}
.bio-pulse--d {
    background: radial-gradient(circle, var(--emerald) 0%, transparent 65%);
    top: 70%; right: 28%;
    animation-delay: 4.2s;
    width: 320px; height: 320px;
}

@keyframes bio-pulse {
    0%, 100% { transform: scale(1); opacity: 0.18; }
    50%      { transform: scale(1.3); opacity: 0.40; }
}

/* ----------------------------------------------------------
   Marine snow particle field
---------------------------------------------------------- */
.marine-snow {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}
.snow-flake {
    position: absolute;
    border-radius: 50%;
    background: var(--snow);
    opacity: 0.45;
    animation: snow-drift linear infinite;
}
@keyframes snow-drift {
    0%   { transform: translateY(-10vh) translateX(0); opacity: 0; }
    10%  { opacity: 0.45; }
    90%  { opacity: 0.45; }
    100% { transform: translateY(110vh) translateX(20px); opacity: 0; }
}

/* ----------------------------------------------------------
   Section frame
---------------------------------------------------------- */
section { position: relative; z-index: 2; }

/* ----------------------------------------------------------
   Abyssal Gateway (hero)
---------------------------------------------------------- */
.abyssal-gateway {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 8vh 6vw;
    text-align: center;
    overflow: hidden;
}

.gateway-crystals {
    position: absolute;
    inset: 0;
    pointer-events: none;
}
.crystal {
    position: absolute;
    filter: drop-shadow(0 0 6px rgba(64, 184, 176, 0.45));
    opacity: 0;
    animation: crystal-fade 1.4s ease forwards 1.1s, crystal-drift 14s ease-in-out infinite;
}
.crystal--alpha   { top: 12%; left: 10%; width: 80px; height: 90px; animation-delay: 1.0s, 0s;    }
.crystal--beta    { top: 22%; right: 14%; width: 60px; height: 70px; animation-delay: 1.2s, 1.5s; }
.crystal--gamma   { bottom: 18%; left: 18%; width: 50px; height: 58px; animation-delay: 1.4s, 3s; }
.crystal--delta   { bottom: 14%; right: 10%; width: 70px; height: 80px; animation-delay: 1.6s, 4.5s; filter: drop-shadow(0 0 6px rgba(208, 184, 120, 0.4)); }
.crystal--epsilon { top: 56%; left: 6%; width: 64px; height: 74px; animation-delay: 1.8s, 6s; }

@keyframes crystal-fade {
    to { opacity: 0.7; }
}
@keyframes crystal-drift {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50%      { transform: translateY(-14px) rotate(2deg); }
}

.gateway-inscription {
    position: relative;
    z-index: 3;
    max-width: 680px;
    opacity: 0;
    animation: gate-fade 1.4s ease forwards 0.4s;
}
@keyframes gate-fade {
    to { opacity: 1; }
}

.sigil-line {
    color: var(--teal);
    letter-spacing: 0.4em;
    font-size: 14px;
    margin-bottom: 1.6rem;
    opacity: 0.8;
}

.gateway-title {
    font-weight: 700;
    font-size: clamp(36px, 6vw, 72px);
    color: var(--pearl);
    letter-spacing: -0.01em;
    text-shadow: 0 0 14px rgba(64, 184, 176, 0.55), 0 0 32px rgba(64, 184, 176, 0.18);
    margin-bottom: 1.4rem;
}

.gateway-subtitle {
    color: var(--honey);
    font-style: italic;
    font-size: clamp(15px, 1.4vw, 19px);
    max-width: 540px;
    margin: 0 auto 2.4rem;
}

.gateway-meta {
    color: var(--snow);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    justify-content: center;
}
.meta-cell { color: var(--snow); }
.meta-divider { color: var(--teal); opacity: 0.6; }

.gateway-scroll-cue {
    position: absolute;
    bottom: 4vh;
    left: 50%;
    transform: translateX(-50%);
    color: var(--teal);
    font-size: 11px;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    text-align: center;
    z-index: 3;
    opacity: 0;
    animation: cue-fade 1s ease forwards 2.4s;
}
@keyframes cue-fade {
    to { opacity: 0.85; }
}
.cue-arrow {
    display: block;
    margin-top: 0.4rem;
    font-size: 18px;
    animation: cue-bounce 2.2s ease-in-out infinite;
}
@keyframes cue-bounce {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(8px); }
}

/* ----------------------------------------------------------
   Section heads
---------------------------------------------------------- */
.section-head {
    text-align: center;
    max-width: 720px;
    margin: 0 auto 4rem;
    padding: 0 6vw;
}
.section-eyebrow {
    color: var(--teal);
    font-size: 11px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    margin-bottom: 1rem;
}
.section-title {
    font-weight: 700;
    font-size: clamp(26px, 3.4vw, 44px);
    color: var(--pearl);
    margin-bottom: 1.2rem;
    text-shadow: 0 0 10px rgba(64, 184, 176, 0.25);
}
.section-lede {
    color: var(--snow);
    font-size: clamp(14px, 1vw, 16px);
    max-width: 580px;
    margin: 0 auto;
}

/* ----------------------------------------------------------
   Coral knowledge grid (hexagonal honeycomb)
---------------------------------------------------------- */
.coral-grid {
    padding: 10vh 4vw 12vh;
}

.hex-honeycomb {
    --hex-w: 240px;
    --hex-h: 270px;
    --hex-gap-x: 24px;
    --hex-gap-y: -54px; /* negative for honeycomb tessellation */
    max-width: 980px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(3, var(--hex-w));
    column-gap: var(--hex-gap-x);
    row-gap: var(--hex-gap-y);
    justify-content: center;
}
.hex-honeycomb > .hex[data-row="2"] {
    transform: translateX(calc((var(--hex-w) + var(--hex-gap-x)) / 2));
}

.hex {
    width: var(--hex-w);
    height: var(--hex-h);
    position: relative;
    perspective: 1200px;
    opacity: 0;
    transform: scale(0.92);
    transition: opacity 0.6s ease, transform 0.6s ease;
}
.hex.is-visible {
    opacity: 1;
    transform: scale(1);
}
.hex-honeycomb > .hex[data-row="2"].is-visible {
    transform: translateX(calc((var(--hex-w) + var(--hex-gap-x)) / 2)) scale(1);
}

.hex-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.7s cubic-bezier(0.4, 0.1, 0.2, 1);
}

/* hex shape via clip-path */
.hex-face,
.hex--static .hex-inner {
    position: absolute;
    inset: 0;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
    background: linear-gradient(160deg, rgba(40, 56, 78, 0.7) 0%, rgba(26, 32, 48, 0.85) 100%);
    border: 1px solid var(--teal-soft);
    padding: 30px 22px 26px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    backdrop-filter: blur(2px);
    box-shadow: inset 0 0 18px rgba(64, 184, 176, 0.08);
    transition: box-shadow 0.4s ease, border-color 0.4s ease;
}

/* static cells display directly */
.hex--static .hex-inner {
    /* uses the shared face style above */
}

.hex--static:hover .hex-inner,
.hex--flip:hover .hex-face {
    border-color: var(--teal);
    box-shadow: inset 0 0 22px rgba(64, 184, 176, 0.18), 0 0 22px rgba(64, 184, 176, 0.35);
}

/* feature variant */
.hex--feature .hex-inner {
    background: linear-gradient(160deg, rgba(48, 80, 96, 0.65) 0%, rgba(26, 32, 48, 0.9) 100%);
    border-color: var(--teal);
    box-shadow: inset 0 0 24px rgba(64, 184, 176, 0.18);
}

/* luminous variant for deeper grid */
.hex--luminous .hex-face,
.hex--luminous.hex--static .hex-inner {
    background: linear-gradient(160deg, rgba(20, 40, 60, 0.85) 0%, rgba(14, 18, 30, 0.95) 100%);
    border-color: var(--teal);
    box-shadow: inset 0 0 26px rgba(64, 184, 176, 0.22), 0 0 18px rgba(64, 184, 176, 0.18);
}

/* flip card faces */
.hex--flip .hex-face {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    cursor: pointer;
}
.hex--flip .hex-face--back {
    transform: rotateY(180deg);
    background: linear-gradient(160deg, rgba(40, 24, 60, 0.8) 0%, rgba(20, 14, 30, 0.92) 100%);
    border-color: var(--purple-soft);
    box-shadow: inset 0 0 22px rgba(136, 88, 176, 0.22);
}
.hex--flip.is-flipped .hex-inner {
    transform: rotateY(180deg);
}
.hex--flip:hover:not(.is-flipped) .hex-inner {
    transform: rotateY(3deg);
}
.hex--flip.is-wobble .hex-inner {
    animation: hex-wobble 0.6s ease;
}
@keyframes hex-wobble {
    0%   { transform: rotateY(0deg); }
    25%  { transform: rotateY(-3deg); }
    75%  { transform: rotateY(3deg); }
    100% { transform: rotateY(0deg); }
}

.hex--flip:focus-visible .hex-face {
    outline: none;
    border-color: var(--honey);
    box-shadow: inset 0 0 22px rgba(208, 184, 120, 0.22), 0 0 0 2px rgba(208, 184, 120, 0.45);
}

/* hex content */
.hex-emblem {
    width: 56px;
    height: 56px;
    margin-bottom: 14px;
    filter: drop-shadow(0 0 4px rgba(64, 184, 176, 0.35));
}
.hex-emblem--lg {
    width: 64px;
    height: 64px;
}
.hex-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--teal);
    margin-bottom: 8px;
}
.hex-label--back { color: var(--purple); }

.hex-title {
    font-weight: 700;
    font-size: 15px;
    line-height: 1.35;
    color: var(--pearl);
    margin-bottom: 10px;
    max-width: 180px;
}
.hex-text {
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--snow);
    max-width: 180px;
}
.hex-text em { color: var(--honey); font-style: italic; }
.hex-text--prompt { color: var(--teal); font-style: italic; opacity: 0.85; }
.hex-text--reveal { color: var(--pearl); }

/* sparse layout for deeper chambers */
.hex-honeycomb--sparse {
    grid-template-columns: repeat(3, var(--hex-w));
    column-gap: 64px;
    row-gap: 24px;
}
.hex-honeycomb--sparse > .hex[data-row="2"] {
    transform: translateX(0);
}
.hex-honeycomb--sparse > .hex[data-row="2"].is-visible {
    transform: scale(1);
}

/* ----------------------------------------------------------
   Deep Trench Scroll
---------------------------------------------------------- */
.trench {
    padding: 16vh 6vw;
    background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.45) 50%, transparent 100%);
    position: relative;
}
.trench::before, .trench::after {
    content: "";
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 1px;
    height: 60px;
    background: linear-gradient(180deg, transparent, var(--teal-soft), transparent);
}
.trench::before { top: 0; }
.trench::after { bottom: 0; }

.trench-inner {
    max-width: 760px;
    margin: 0 auto;
    text-align: center;
}
.trench-eyebrow {
    color: var(--teal);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.25em;
    margin-bottom: 1.6rem;
}
.trench-eyebrow span { color: var(--honey); }
.trench-title {
    font-weight: 700;
    font-size: clamp(24px, 3vw, 38px);
    color: var(--pearl);
    margin-bottom: 1.8rem;
    text-shadow: 0 0 14px rgba(64, 184, 176, 0.3);
}
.trench-body {
    color: var(--snow);
    font-size: clamp(15px, 1.1vw, 18px);
    line-height: 1.85;
    margin-bottom: 2.4rem;
}
.trench-body em { color: var(--honey); font-style: italic; }

.trench-tenets {
    list-style: none;
    text-align: left;
    max-width: 540px;
    margin: 0 auto;
    border-left: 1px solid var(--teal-soft);
    padding-left: 1.4rem;
}
.trench-tenets li {
    color: var(--snow);
    font-size: 14px;
    line-height: 1.7;
    margin-bottom: 0.8rem;
}
.tenet-mark {
    color: var(--teal);
    font-weight: 700;
    font-style: italic;
    margin-right: 0.6rem;
}

.trench-quote {
    border-left: 2px solid var(--purple-soft);
    padding: 1rem 1.4rem;
    text-align: left;
    max-width: 580px;
    margin: 0 auto;
}
.trench-quote p {
    color: var(--pearl);
    font-style: italic;
    font-size: clamp(15px, 1.2vw, 18px);
    margin-bottom: 0.8rem;
}
.trench-quote p em { color: var(--honey); }
.trench-quote cite {
    color: var(--snow);
    font-size: 12px;
    letter-spacing: 0.12em;
    font-style: normal;
}

/* ----------------------------------------------------------
   Closing chamber
---------------------------------------------------------- */
.closing-chamber {
    min-height: 80vh;
    padding: 14vh 6vw;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    position: relative;
    overflow: hidden;
}
.closing-crystals {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.5;
}
.closing-crystals .crystal--alpha { top: 14%; left: 12%; width: 80px; height: 90px; opacity: 0.6; animation: crystal-drift 16s ease-in-out infinite; }
.closing-crystals .crystal--beta { bottom: 16%; right: 14%; width: 64px; height: 74px; opacity: 0.55; animation: crystal-drift 18s ease-in-out infinite reverse; }

.closing-inner {
    position: relative;
    z-index: 2;
    max-width: 640px;
}
.closing-eyebrow {
    color: var(--teal);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.25em;
    margin-bottom: 1.4rem;
}
.closing-title {
    font-weight: 700;
    font-size: clamp(26px, 3.6vw, 46px);
    color: var(--pearl);
    margin-bottom: 1.8rem;
    text-shadow: 0 0 14px rgba(64, 184, 176, 0.45);
}
.closing-body {
    color: var(--snow);
    font-size: clamp(15px, 1.1vw, 18px);
    line-height: 1.85;
    margin-bottom: 2.4rem;
}
.closing-mark {
    color: var(--teal);
    letter-spacing: 0.4em;
    font-size: 14px;
    margin-bottom: 1rem;
    opacity: 0.8;
}
.closing-domain {
    color: var(--honey);
    font-style: italic;
    font-size: 14px;
    letter-spacing: 0.2em;
    text-transform: lowercase;
}

/* ----------------------------------------------------------
   Responsive
---------------------------------------------------------- */
@media (max-width: 880px) {
    .hex-honeycomb {
        --hex-w: 200px;
        --hex-h: 226px;
        grid-template-columns: repeat(2, var(--hex-w));
        column-gap: 18px;
        row-gap: -44px;
    }
    .hex-honeycomb > .hex[data-row="2"] {
        transform: translateX(calc((var(--hex-w) + 18px) / 2));
    }
    .hex-honeycomb > .hex[data-row="2"].is-visible {
        transform: translateX(calc((var(--hex-w) + 18px) / 2)) scale(1);
    }
    .hex-honeycomb--sparse {
        grid-template-columns: repeat(2, var(--hex-w));
        column-gap: 28px;
        row-gap: 18px;
    }
}

@media (max-width: 540px) {
    .hex-honeycomb {
        --hex-w: 240px;
        --hex-h: 270px;
        grid-template-columns: 1fr;
        row-gap: 18px;
        column-gap: 0;
        justify-items: center;
    }
    .hex-honeycomb > .hex[data-row="2"] {
        transform: scale(0.92);
    }
    .hex-honeycomb > .hex[data-row="2"].is-visible {
        transform: scale(1);
    }
    .hex-honeycomb--sparse {
        grid-template-columns: 1fr;
        justify-items: center;
        row-gap: 18px;
    }
    .gateway-title { font-size: clamp(32px, 9vw, 50px); }
    .crystal { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .bio-pulse, .crystal, .cue-arrow { animation: none; }
    .snow-flake { display: none; }
    .hex { transition: opacity 0.3s; transform: none; }
    .hex.is-visible { transform: none; }
    .hex--flip:hover:not(.is-flipped) .hex-inner { transform: none; }
}
