/* ================================================
   mystical.quest - Seapunk Mysticism Stylesheet
   ================================================ */

/* --- CSS Custom Properties --- */
:root {
    --abyss-dark: #1A2030;
    --bioluminescent-teal: #40B8B0;
    --crystalline-purple: #8858B0;
    --honeyed-warm: #D0B878;
    --marine-snow: #C0D0D8;
    --deep-emerald: #2A6850;
    --pearl-white: #E8E4E0;
    --depth-factor: 0;
    --hex-size: 260px;
    --hex-gap: 12px;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Atkinson Hyperlegible', sans-serif;
    font-weight: 400;
    font-size: clamp(14px, 1vw, 16px);
    line-height: 1.75;
    color: var(--pearl-white);
    background-color: var(--abyss-dark);
    overflow-x: hidden;
}

/* --- Abyssal Gateway (Hero) --- */
#abyssal-gateway {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: var(--abyss-dark);
}

/* Bioluminescent pulses container */
#bioluminescent-pulses {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.bio-pulse {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(64, 184, 176, 0.35) 0%, rgba(64, 184, 176, 0) 70%);
    animation: pulse-glow 3s ease-in-out infinite;
    pointer-events: none;
}

.bio-pulse.purple {
    background: radial-gradient(circle, rgba(136, 88, 176, 0.25) 0%, rgba(136, 88, 176, 0) 70%);
}

@keyframes pulse-glow {
    0%, 100% {
        transform: scale(1);
        opacity: 0.4;
    }
    50% {
        transform: scale(1.3);
        opacity: 0.1;
    }
}

/* Marine snow container */
#marine-snow {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

.snow-particle {
    position: absolute;
    border-radius: 50%;
    background: var(--marine-snow);
    opacity: 0;
    animation: snow-fall linear infinite;
}

@keyframes snow-fall {
    0% {
        transform: translateY(-20px) translateX(0);
        opacity: 0;
    }
    10% {
        opacity: 0.4;
    }
    90% {
        opacity: 0.3;
    }
    100% {
        transform: translateY(100vh) translateX(30px);
        opacity: 0;
    }
}

/* Gateway content */
#gateway-content {
    position: relative;
    z-index: 5;
    text-align: center;
}

#site-title {
    font-family: 'Atkinson Hyperlegible', sans-serif;
    font-weight: 700;
    font-size: clamp(32px, 5vw, 64px);
    color: var(--pearl-white);
    text-shadow: 0 0 12px rgba(64, 184, 176, 0.5), 0 0 40px rgba(64, 184, 176, 0.2);
    opacity: 0;
    animation: title-fade-in 1.5s ease-out 0.3s forwards;
    letter-spacing: 0.02em;
}

@keyframes title-fade-in {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#site-tagline {
    font-family: 'Atkinson Hyperlegible', sans-serif;
    font-weight: 400;
    font-size: clamp(14px, 1.5vw, 20px);
    color: var(--honeyed-warm);
    opacity: 0;
    animation: title-fade-in 1.5s ease-out 0.8s forwards;
    margin-top: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* Crystalline shapes around title */
#crystalline-shapes {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 500px;
    height: 400px;
    pointer-events: none;
}

.crystal {
    position: absolute;
    opacity: 0;
    animation: crystal-fade-in 1s ease-out forwards;
    filter: drop-shadow(0 0 4px rgba(64, 184, 176, 0.4));
}

.crystal-1 {
    top: -30px;
    left: -60px;
    animation-delay: 1.2s;
    animation-duration: 1.5s;
}

.crystal-2 {
    top: -20px;
    right: -40px;
    animation-delay: 1.4s;
    animation-duration: 1.5s;
}

.crystal-3 {
    bottom: -10px;
    left: 20px;
    animation-delay: 1.6s;
    animation-duration: 1.5s;
}

.crystal-4 {
    bottom: -40px;
    right: -20px;
    animation-delay: 1.8s;
    animation-duration: 1.5s;
}

.crystal-5 {
    top: 50%;
    left: -80px;
    transform: translateY(-50%);
    animation-delay: 2.0s;
    animation-duration: 1.5s;
}

@keyframes crystal-fade-in {
    from {
        opacity: 0;
        transform: scale(0.8) rotate(-5deg);
    }
    to {
        opacity: 0.7;
        transform: scale(1) rotate(0deg);
    }
}

.crystal-5 {
    animation-name: crystal-fade-in-centered;
}

@keyframes crystal-fade-in-centered {
    from {
        opacity: 0;
        transform: translateY(-50%) scale(0.8) rotate(-5deg);
    }
    to {
        opacity: 0.7;
        transform: translateY(-50%) scale(1) rotate(0deg);
    }
}

/* Scroll indicator */
#scroll-indicator {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    animation: scroll-bounce 2s ease-in-out infinite;
    opacity: 0.6;
}

@keyframes scroll-bounce {
    0%, 100% {
        transform: translateX(-50%) translateY(0);
    }
    50% {
        transform: translateX(-50%) translateY(10px);
    }
}

/* --- Coral Knowledge Grid --- */
.coral-grid {
    padding: 80px 20px;
    position: relative;
}

.section-label {
    font-family: 'Atkinson Hyperlegible', sans-serif;
    font-weight: 700;
    font-size: clamp(24px, 3vw, 44px);
    color: var(--pearl-white);
    text-align: center;
    margin-bottom: 50px;
    text-shadow: 0 0 8px rgba(64, 184, 176, 0.3);
}

/* Hexagonal Grid Layout */
.hex-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 900px;
    margin: 0 auto;
    gap: 0;
    padding: 0 10px;
}

.hex-cell {
    width: var(--hex-size);
    height: calc(var(--hex-size) * 1.1547);
    margin: calc(var(--hex-gap) / 2);
    position: relative;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.5s ease, transform 0.5s ease;
    perspective: 800px;
}

.hex-cell.visible {
    opacity: 1;
    transform: scale(1);
}

.hex-cell.wobble {
    animation: hex-wobble 0.4s ease-in-out;
}

@keyframes hex-wobble {
    0% { transform: scale(1) rotateY(0deg); }
    25% { transform: scale(1) rotateY(-2deg); }
    75% { transform: scale(1) rotateY(2deg); }
    100% { transform: scale(1) rotateY(0deg); }
}

/* Offset every other row for honeycomb packing */
.hex-cell:nth-child(3n+1) {
    margin-top: calc(var(--hex-size) * -0.14);
}

.hex-cell:nth-child(3n+2) {
    margin-top: calc(var(--hex-size) * 0.44);
}

.hex-cell:nth-child(3n) {
    margin-top: calc(var(--hex-size) * -0.14);
}

/* First row fix */
.hex-cell:nth-child(-n+3) {
    margin-top: 0;
}

.hex-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s ease;
    transform-style: preserve-3d;
}

.hex-cell.flippable .hex-inner.flipped {
    transform: rotateY(180deg);
}

.hex-face {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 20px;
    text-align: center;
    backface-visibility: hidden;
}

.hex-front {
    background: linear-gradient(180deg, rgba(26, 32, 48, 0.95), rgba(26, 32, 48, 0.85));
    border: none;
    box-shadow: inset 0 0 0 2px var(--bioluminescent-teal);
}

.hex-back {
    background: linear-gradient(180deg, rgba(42, 104, 80, 0.9), rgba(26, 32, 48, 0.95));
    transform: rotateY(180deg);
    box-shadow: inset 0 0 0 2px var(--bioluminescent-teal);
}

.cell-icon {
    margin-bottom: 10px;
    filter: drop-shadow(0 0 4px rgba(64, 184, 176, 0.4));
    flex-shrink: 0;
}

.cell-label {
    font-family: 'Atkinson Hyperlegible', sans-serif;
    font-weight: 400;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--bioluminescent-teal);
    margin-bottom: 6px;
}

.cell-text {
    font-family: 'Atkinson Hyperlegible', sans-serif;
    font-weight: 400;
    font-size: clamp(11px, 0.85vw, 13px);
    line-height: 1.6;
    color: var(--marine-snow);
}

/* Hex cell hover effects */
.hex-cell:hover {
    z-index: 10;
}

.hex-cell:hover .hex-front,
.hex-cell:hover .hex-back {
    box-shadow: inset 0 0 0 2px var(--bioluminescent-teal), 0 0 16px rgba(64, 184, 176, 0.4);
}

.hex-cell.flippable {
    cursor: pointer;
}

.hex-cell.flippable:hover .hex-inner:not(.flipped) {
    transform: rotateY(3deg);
}

/* --- Deep Trench Sections --- */
.deep-trench {
    position: relative;
    width: 100%;
    padding: 100px 0;
    text-align: center;
    overflow: hidden;
}

.deep-trench[data-depth="2"] {
    background: linear-gradient(180deg, var(--abyss-dark), #141A28);
}

.deep-trench[data-depth="3"] {
    background: linear-gradient(180deg, #141A28, #0E1220);
}

.trench-content {
    max-width: 700px;
    margin: 0 auto;
    padding: 0 30px;
    position: relative;
    z-index: 3;
}

.trench-title {
    font-family: 'Atkinson Hyperlegible', sans-serif;
    font-weight: 700;
    font-size: clamp(24px, 3vw, 44px);
    color: var(--pearl-white);
    margin-bottom: 24px;
    text-shadow: 0 0 10px rgba(64, 184, 176, 0.4);
}

.trench-text {
    font-family: 'Atkinson Hyperlegible', sans-serif;
    font-weight: 400;
    color: var(--honeyed-warm);
    font-size: clamp(14px, 1.1vw, 17px);
    line-height: 1.85;
    margin-bottom: 30px;
}

.trench-text em,
.trench-text strong {
    font-weight: 700;
    font-style: italic;
    color: var(--bioluminescent-teal);
}

.trench-decoration {
    opacity: 0.6;
}

.trench-decoration svg {
    max-width: 100%;
    height: auto;
}

/* Bioluminescent pulse overlays for trench sections */
.deep-trench::before,
.deep-trench::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
}

.deep-trench::before {
    width: 300px;
    height: 300px;
    top: 20%;
    left: -100px;
    background: radial-gradient(circle, rgba(64, 184, 176, 0.15) 0%, transparent 70%);
    animation: pulse-glow 4s ease-in-out infinite;
}

.deep-trench::after {
    width: 250px;
    height: 250px;
    bottom: 10%;
    right: -80px;
    background: radial-gradient(circle, rgba(136, 88, 176, 0.12) 0%, transparent 70%);
    animation: pulse-glow 5s ease-in-out 1.5s infinite;
}

/* --- Coral Grid depth backgrounds --- */
#coral-grid-1 {
    background: var(--abyss-dark);
}

#coral-grid-2 {
    background: #161C2C;
}

#coral-grid-3 {
    background: #111824;
}

/* --- Abyssal Floor (Final Section) --- */
#abyssal-floor {
    position: relative;
    padding: 120px 30px;
    text-align: center;
    background: linear-gradient(180deg, #0E1220, #080C18);
    overflow: hidden;
}

#abyssal-floor::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 400px;
    height: 400px;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, rgba(64, 184, 176, 0.12) 0%, transparent 60%);
    animation: pulse-glow 5s ease-in-out infinite;
    pointer-events: none;
}

.floor-content {
    position: relative;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.floor-crystal {
    filter: drop-shadow(0 0 8px rgba(64, 184, 176, 0.5));
    margin-bottom: 40px;
    animation: floor-crystal-rotate 20s linear infinite;
}

@keyframes floor-crystal-rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.floor-text {
    font-family: 'Atkinson Hyperlegible', sans-serif;
    font-weight: 400;
    font-size: clamp(14px, 1.2vw, 18px);
    line-height: 1.85;
    color: var(--marine-snow);
    max-width: 600px;
    margin-bottom: 40px;
}

.floor-sigil {
    font-size: 36px;
    color: var(--bioluminescent-teal);
    text-shadow: 0 0 12px rgba(64, 184, 176, 0.6);
    animation: sigil-pulse 3s ease-in-out infinite;
}

@keyframes sigil-pulse {
    0%, 100% {
        opacity: 0.6;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.1);
    }
}

/* --- Responsive --- */
@media (max-width: 860px) {
    :root {
        --hex-size: 200px;
    }

    .hex-grid {
        max-width: 660px;
    }

    .cell-text {
        font-size: 11px;
    }

    #crystalline-shapes {
        width: 350px;
        height: 280px;
    }
}

@media (max-width: 640px) {
    :root {
        --hex-size: 160px;
    }

    .hex-grid {
        max-width: 520px;
    }

    .hex-face {
        padding: 20px 14px;
    }

    .cell-text {
        font-size: 10px;
        line-height: 1.4;
    }

    .cell-icon {
        width: 32px;
        height: 32px;
    }

    .trench-content {
        padding: 0 20px;
    }

    #crystalline-shapes {
        width: 280px;
        height: 220px;
    }

    .crystal {
        transform: scale(0.7);
    }
}

@media (max-width: 440px) {
    :root {
        --hex-size: 140px;
    }

    .hex-grid {
        max-width: 340px;
    }

    .hex-cell:nth-child(3n+2) {
        margin-top: calc(var(--hex-size) * 0.3);
    }

    .hex-face {
        padding: 16px 10px;
    }

    .cell-icon {
        width: 28px;
        height: 28px;
        margin-bottom: 4px;
    }

    .cell-label {
        font-size: 9px;
    }

    .cell-text {
        font-size: 9px;
    }
}
