/* ============================================
   p9r.xyz - Fairycore Submerged
   Bioluminescent tide pool aesthetic
   ============================================ */

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

:root {
    --abyssal-ink: #0B1D2C;
    --midnight-kelp: #122A3A;
    --sea-foam-white: #D4E8F0;
    --bioluminescent-teal: #4FC3C7;
    --shallow-turquoise: #80DEEA;
    --coral-blush: #E0A9C8;
    --deep-current: #1A3A4A;
    --phosphorescent-green: #A8E6CF;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--abyssal-ink);
    color: var(--sea-foam-white);
    font-family: 'Quicksand', sans-serif;
    font-weight: 300;
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    line-height: 1.75;
    letter-spacing: 0.02em;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Typography --- */
h1, h2 {
    font-family: 'Poiret One', cursive;
    font-weight: 400;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--bioluminescent-teal);
}

h1 {
    font-size: clamp(2.8rem, 7vw, 5.2rem);
    text-shadow: 0 0 30px rgba(79, 195, 199, 0.3);
}

h2 {
    font-size: clamp(1.6rem, 4vw, 2.6rem);
    margin-bottom: 1.5rem;
    text-shadow: 0 0 20px rgba(79, 195, 199, 0.15);
}

.micro-label {
    display: block;
    font-family: 'Quicksand', sans-serif;
    font-weight: 600;
    font-size: 0.7rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--shallow-turquoise);
    margin-bottom: 1rem;
    opacity: 0.7;
}

/* --- Hero Section --- */
#hero {
    position: relative;
    width: 100%;
    height: 120vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow: hidden;
    background: linear-gradient(180deg, #0B1D2C 0%, #122A3A 40%, #1A3A4A 70%, #0B1D2C 100%);
    opacity: 0;
    animation: heroFadeIn 1.5s ease-out 0.3s forwards;
}

@keyframes heroFadeIn {
    to { opacity: 1; }
}

/* Caustic light layer */
#caustic-layer {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.caustic-blob {
    position: absolute;
    border-radius: 50%;
    will-change: transform;
    pointer-events: none;
}

.caustic-blob-1 {
    width: 600px;
    height: 600px;
    top: 10%;
    left: 20%;
    background: radial-gradient(circle, rgba(79, 195, 199, 0.045) 0%, transparent 70%);
    animation: caustic1 18s ease-in-out infinite;
}

.caustic-blob-2 {
    width: 500px;
    height: 500px;
    top: 40%;
    right: 15%;
    background: radial-gradient(circle, rgba(79, 195, 199, 0.04) 0%, transparent 65%);
    animation: caustic2 22s ease-in-out infinite;
}

.caustic-blob-3 {
    width: 450px;
    height: 450px;
    top: 55%;
    left: 40%;
    background: radial-gradient(circle, rgba(128, 222, 234, 0.03) 0%, transparent 60%);
    animation: caustic3 20s ease-in-out infinite;
}

.caustic-blob-4 {
    width: 350px;
    height: 350px;
    top: 20%;
    right: 35%;
    background: radial-gradient(circle, rgba(168, 230, 207, 0.02) 0%, transparent 55%);
    animation: caustic4 25s ease-in-out infinite;
}

@keyframes caustic1 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(60px, -40px) scale(1.15); }
    50% { transform: translate(-30px, 50px) scale(0.9); }
    75% { transform: translate(40px, 20px) scale(1.1); }
}

@keyframes caustic2 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(-50px, 30px) scale(1.12); }
    66% { transform: translate(40px, -60px) scale(0.92); }
}

@keyframes caustic3 {
    0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.6; }
    50% { transform: translate(35px, -25px) scale(1.18); opacity: 1; }
}

@keyframes caustic4 {
    0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.4; }
    40% { transform: translate(-25px, 40px) scale(1.1); opacity: 0.8; }
    70% { transform: translate(20px, -15px) scale(0.95); opacity: 0.6; }
}

/* Hero content */
#hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
    margin-top: 40vh;
}

#site-title {
    opacity: 0;
    transform: translateY(20px);
    animation: titleReveal 1.8s ease-out 1.2s forwards;
}

@keyframes titleReveal {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#site-subtitle {
    font-family: 'Quicksand', sans-serif;
    font-weight: 300;
    font-size: clamp(0.95rem, 2vw, 1.2rem);
    letter-spacing: 0.08em;
    color: var(--sea-foam-white);
    opacity: 0;
    transform: translateY(10px);
    animation: subtitleReveal 1.5s ease-out 2.5s forwards;
    margin-top: 1.2rem;
}

@keyframes subtitleReveal {
    to {
        opacity: 0.7;
        transform: translateY(0);
    }
}

/* --- Bubbles --- */
#bubble-field {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}

.bubble-cluster {
    position: absolute;
    width: 100%;
    height: 100%;
}

.bubble {
    position: absolute;
    bottom: -20px;
    border-radius: 50%;
    background: rgba(128, 222, 234, 0.08);
    border: 1px solid rgba(128, 222, 234, 0.15);
    border-top-color: rgba(128, 222, 234, 0.25);
    border-left-color: rgba(128, 222, 234, 0.2);
    animation: bubbleRise linear infinite;
    will-change: transform, opacity;
    opacity: 0;
}

@keyframes bubbleRise {
    0% {
        transform: translateY(0) translateX(0);
        opacity: 0;
    }
    5% {
        opacity: 0.6;
    }
    10% {
        opacity: 1;
    }
    50% {
        transform: translateY(-60vh) translateX(15px);
    }
    90% {
        opacity: 0.8;
    }
    100% {
        transform: translateY(-125vh) translateX(25px);
        opacity: 0;
    }
}

/* --- Seaweed --- */
.seaweed {
    position: absolute;
    bottom: 0;
    width: 40px;
    height: 200px;
    z-index: 1;
    opacity: 0.6;
    will-change: transform;
    transform-origin: bottom center;
}

.seaweed-left {
    left: 5%;
    animation: seaweedSway 7s ease-in-out infinite;
}

.seaweed-left-2 {
    position: absolute;
    bottom: 0;
    left: 8%;
    width: 30px;
    height: 160px;
    z-index: 1;
    opacity: 0.35;
    will-change: transform;
    transform-origin: bottom center;
    animation: seaweedSway 9s ease-in-out infinite 1s;
}

.seaweed-right {
    right: 5%;
    animation: seaweedSway 8s ease-in-out infinite reverse;
}

.seaweed-right-2 {
    position: absolute;
    bottom: 0;
    right: 8%;
    width: 30px;
    height: 160px;
    z-index: 1;
    opacity: 0.35;
    will-change: transform;
    transform-origin: bottom center;
    animation: seaweedSway 6.5s ease-in-out infinite reverse 0.5s;
}

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

/* --- Content Area --- */
#content-area {
    position: relative;
    padding: 10vh 24px 15vh;
}

/* Wave separators */
.wave-separator {
    display: block;
    width: 100%;
    height: 30px;
    margin: 8vh auto;
    max-width: 800px;
}

.wave-path {
    stroke-dasharray: 8 4;
    animation: waveDash 4s linear infinite;
}

@keyframes waveDash {
    to { stroke-dashoffset: -48; }
}

/* Content islands */
.content-island {
    position: relative;
    max-width: 640px;
    margin: 0 auto 15vh;
    padding: 3rem 2.5rem;
    border: 1px solid rgba(130, 200, 220, 0.15);
    border-radius: 48% 52% 45% 55% / 52% 48% 55% 45%;
    background: rgba(18, 42, 58, 0.4);
    transition: border-color 600ms ease, box-shadow 600ms ease;
    animation: morphBorder 12s ease-in-out infinite;
}

@keyframes morphBorder {
    0%, 100% { border-radius: 48% 52% 45% 55% / 52% 48% 55% 45%; }
    33% { border-radius: 52% 48% 50% 50% / 45% 55% 48% 52%; }
    66% { border-radius: 45% 55% 52% 48% / 55% 45% 50% 50%; }
}

.content-island:hover {
    border-color: rgba(79, 195, 199, 0.35);
    box-shadow: 0 0 40px rgba(79, 195, 199, 0.06), inset 0 0 30px rgba(79, 195, 199, 0.02);
}

.content-island p {
    margin-bottom: 1.2rem;
}

.content-island p:last-child {
    margin-bottom: 0;
}

/* Bioluminescent glow halo behind islands */
.content-island::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 110%;
    height: 110%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: radial-gradient(ellipse, rgba(79, 195, 199, 0.02) 0%, transparent 70%);
    z-index: -1;
    pointer-events: none;
    transition: opacity 600ms ease;
    opacity: 0;
}

.content-island:hover::before {
    opacity: 1;
}

/* Seaweed fronds on content islands */
.seaweed-frond {
    position: absolute;
    width: 20px;
    height: 120px;
    bottom: -10px;
    opacity: 0.5;
    will-change: transform;
    transform-origin: bottom center;
}

.frond-left {
    left: -30px;
    animation: seaweedSway 6s ease-in-out infinite;
}

.frond-right {
    right: -30px;
    animation: seaweedSway 7.5s ease-in-out infinite reverse;
}

/* Radiolarian dividers */
.radiolarian-divider {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 5vh auto;
}

.radiolarian-divider svg {
    width: 48px;
    height: 48px;
    animation: radiolSpin 30s linear infinite;
}

@keyframes radiolSpin {
    to { transform: rotate(360deg); }
}

/* Accent text styles */
.accent-text {
    font-weight: 500;
}

.phosphor-flash {
    color: var(--phosphorescent-green);
    text-shadow: 0 0 8px rgba(168, 230, 207, 0.3);
    transition: text-shadow 2s ease-in-out;
}

.coral-accent {
    color: var(--coral-blush);
    text-shadow: 0 0 8px rgba(224, 169, 200, 0.25);
}

.teal-glow {
    color: var(--bioluminescent-teal);
    text-shadow: 0 0 8px rgba(79, 195, 199, 0.3);
}

/* --- Reveal Animation --- */
.reveal-element {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 1.2s ease-out, transform 1.2s ease-out;
}

.reveal-element.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* --- Scroll Indicator --- */
#scroll-indicator {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 100;
    opacity: 0.5;
    transition: opacity 600ms ease;
}

#scroll-indicator svg {
    width: 24px;
    height: 40px;
}

.indicator-bubble {
    animation: indicatorPulse 3s ease-in-out infinite;
}

.ib-1 { animation-delay: 0s; }
.ib-2 { animation-delay: 0.4s; }
.ib-3 { animation-delay: 0.8s; }

@keyframes indicatorPulse {
    0%, 100% { opacity: 0.2; transform: translateY(0); }
    50% { opacity: 0.6; transform: translateY(-3px); }
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    #hero {
        opacity: 1;
    }

    #site-title,
    #site-subtitle {
        opacity: 1;
        transform: none;
    }

    .reveal-element {
        opacity: 1;
        transform: none;
    }

    .bubble {
        display: none;
    }
}

/* --- Mobile Adaptation --- */
@media (max-width: 768px) {
    #hero {
        height: 100vh;
    }

    #hero-content {
        margin-top: 35vh;
    }

    .content-island {
        border-radius: 24px;
        padding: 2rem 1.5rem;
        margin-bottom: 10vh;
        animation: none;
    }

    .seaweed-frond {
        display: none;
    }

    .seaweed,
    .seaweed-left-2,
    .seaweed-right-2 {
        display: none;
    }

    #scroll-indicator {
        transform: scale(0.8);
        bottom: 16px;
        right: 16px;
    }

    #content-area {
        padding: 5vh 24px 10vh;
    }

    .wave-separator {
        margin: 5vh auto;
    }

    .radiolarian-divider {
        margin: 3vh auto;
    }

    .caustic-blob {
        transform: scale(0.6);
    }
}

/* --- Hero bottom fade --- */
#hero::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 200px;
    background: linear-gradient(to top, var(--abyssal-ink), transparent);
    pointer-events: none;
    z-index: 3;
}

/* --- Additional hero caustic pseudo-layer --- */
#hero::before {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    top: 60%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(79, 195, 199, 0.03) 0%, transparent 60%);
    animation: causticPseudo 15s ease-in-out infinite;
    pointer-events: none;
}

@keyframes causticPseudo {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.5; }
    50% { transform: translate(-45%, -55%) scale(1.2); opacity: 1; }
}

/* Additional scattered bubbles for content area */
#content-area::before {
    content: '';
    position: absolute;
    top: 20%;
    left: 10%;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(128, 222, 234, 0.06);
    border: 1px solid rgba(128, 222, 234, 0.1);
    animation: bubbleRise 16s linear infinite 3s;
    pointer-events: none;
}

#content-area::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 15%;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(128, 222, 234, 0.05);
    border: 1px solid rgba(128, 222, 234, 0.08);
    animation: bubbleRise 20s linear infinite 7s;
    pointer-events: none;
}

/* --- Link styles with wave underline --- */
a {
    color: var(--bioluminescent-teal);
    text-decoration: none;
    position: relative;
    display: inline;
}

a::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -2px;
    width: 100%;
    height: 2px;
    background: repeating-linear-gradient(
        90deg,
        transparent 0px,
        var(--bioluminescent-teal) 2px,
        transparent 4px
    );
    background-size: 8px 2px;
    opacity: 0.4;
    transition: opacity 600ms ease;
}

a:hover::after {
    opacity: 0.8;
    animation: linkWaveFlow 1s linear infinite;
}

@keyframes linkWaveFlow {
    to { background-position: 8px 0; }
}
