/* rational.group - Goblincore Coastal Collective */

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

:root {
    --sea-fog: #E8ECE6;
    --driftwood-cream: #F0E8D8;
    --wet-stone: #3D4A4F;
    --kelp-dark: #2A3530;
    --foam-white: #F4F1EB;
    --tide-teal: #5A8C82;
    --barnacle-rust: #A67B5B;
    --lichen-sage: #8BA888;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Source Sans 3', sans-serif;
    font-weight: 400;
    font-size: 0.95rem;
    line-height: 1.7;
    background-color: var(--sea-fog);
    color: var(--kelp-dark);
    overflow-x: hidden;
    position: relative;
}

/* === Tidal Watermarks === */
#tidal-watermarks {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.02;
    background-image:
        repeating-linear-gradient(0deg, transparent, transparent 40px, var(--tide-teal) 40px, var(--tide-teal) 41px),
        repeating-linear-gradient(0deg, transparent, transparent 43px, var(--tide-teal) 43px, var(--tide-teal) 44px);
    background-size: 100% 82px, 100% 87px;
    will-change: transform;
    transition: opacity 2s ease;
}

#tidal-watermarks.deeper {
    opacity: 0.03;
}

/* === Flowing Curves === */
#flowing-curves {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

.flow-curve {
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
    opacity: 0.15;
    transition: stroke-dashoffset 0.5s ease, opacity 0.5s ease;
}

.flow-curve.drawn {
    stroke-dashoffset: 0;
}

/* === Hero: The Fog === */
.section-fog {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
}

.fog-content {
    text-align: center;
}

.fog-rational {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 300;
    font-size: clamp(3rem, 8vw, 6rem);
    color: var(--kelp-dark);
    display: block;
    opacity: 0;
    transition: opacity 0.8s ease;
}

.fog-rational.visible {
    opacity: 1;
}

.fog-group {
    font-family: 'Caveat', cursive;
    font-size: clamp(1.5rem, 4vw, 3rem);
    color: var(--barnacle-rust);
    display: block;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.fog-group.visible {
    opacity: 1;
}

/* === Ma Sections === */
.ma-section {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 8rem 2rem;
    z-index: 2;
    gap: 6rem;
}

/* === Content Islands === */
.content-island {
    max-width: 480px;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.content-island.visible {
    opacity: 1;
    transform: translateY(0) rotate(var(--island-rotation, 0deg));
}

.island-1 { --island-rotation: -2deg; }
.island-2 { --island-rotation: 1.5deg; }
.island-3 { --island-rotation: -1deg; }
.island-4 { --island-rotation: 2deg; }
.island-5 { --island-rotation: -1.5deg; }

.island-revealed {
    max-width: 640px;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.island-revealed.visible {
    opacity: 1;
    transform: translateY(0);
}

/* === Flip Cards === */
.flip-card {
    perspective: 800px;
    width: 100%;
    min-height: 320px;
    cursor: pointer;
}

.card-large {
    min-height: 380px;
}

.card-xlarge {
    min-height: 400px;
}

.card-small {
    min-height: 260px;
}

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

.flip-card:hover .flip-card-inner,
.flip-card.touched .flip-card-inner {
    transform: rotateY(180deg);
}

.flip-card-inner.flipped {
    transform: rotateY(180deg);
}

.flip-card-front,
.flip-card-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    min-height: inherit;
    backface-visibility: hidden;
    border-radius: 4px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.flip-card-front {
    background-color: var(--driftwood-cream);
    border: 1px solid rgba(42, 53, 48, 0.08);
}

.flip-card-back {
    background-color: var(--wet-stone);
    color: var(--foam-white);
    transform: rotateY(180deg);
    align-items: flex-start;
    justify-content: flex-start;
    overflow-y: auto;
}

/* Edge flash on flip midpoint */
.flip-card:hover .flip-card-inner::after,
.flip-card.touched .flip-card-inner::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    width: 2px;
    height: 100%;
    background-color: var(--barnacle-rust);
    transform: translateX(-50%);
    animation: edgeFlash 0.6s ease forwards;
    pointer-events: none;
}

@keyframes edgeFlash {
    0% { opacity: 0; }
    45% { opacity: 1; }
    55% { opacity: 1; }
    100% { opacity: 0; }
}

/* === Specimen Illustrations === */
.specimen-illustration {
    margin-bottom: 1rem;
}

.specimen-label {
    font-family: 'Caveat', cursive;
    font-size: 0.85rem;
    color: var(--barnacle-rust);
    text-align: center;
}

/* === Card Back Content === */
.card-back-title {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 600;
    font-size: clamp(1.1rem, 2.5vw, 1.75rem);
    color: var(--foam-white);
    margin-bottom: 1rem;
}

.card-back-text {
    font-family: 'Source Sans 3', sans-serif;
    font-weight: 400;
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--foam-white);
    margin-bottom: 1rem;
}

/* === Revealed Card === */
.revealed-card {
    cursor: default;
}

.revealed-card .flip-card-inner {
    position: relative;
    min-height: 400px;
}

.revealed-card .flip-card-front {
    display: none;
}

.revealed-card .flip-card-back {
    position: relative;
    transform: none;
}

.revealed-card:hover .flip-card-inner {
    transform: none;
}

/* === Finale === */
.finale-title {
    text-align: center;
    margin-top: 8rem;
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0;
}

.final-rational {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 700;
    font-size: clamp(2rem, 5vw, 4rem);
    color: var(--kelp-dark);
}

.final-dot {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 700;
    font-size: clamp(2rem, 5vw, 4rem);
    color: var(--tide-teal);
}

.final-group {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 700;
    font-size: clamp(2rem, 5vw, 4rem);
    color: var(--kelp-dark);
}

/* === Compass Navigation === */
#compass-nav {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 999;
}

.compass-rose {
    position: relative;
    width: 24px;
    height: 24px;
    opacity: 0.4;
    transition: opacity 0.3s, width 0.4s, height 0.4s;
    cursor: pointer;
}

.compass-rose:hover {
    width: 120px;
    height: 120px;
    opacity: 1;
}

.compass-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.compass-labels {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120px;
    height: 120px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.compass-rose:hover .compass-labels {
    opacity: 1;
    pointer-events: auto;
}

.compass-dir {
    position: absolute;
    font-family: 'Caveat', cursive;
    font-size: 0.85rem;
    color: var(--tide-teal);
    background: none;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.3s;
}

.compass-dir:hover {
    color: var(--barnacle-rust);
}

.dir-n { top: -8px; left: 50%; transform: translateX(-50%); }
.dir-e { right: -10px; top: 50%; transform: translateY(-50%); }
.dir-s { bottom: -8px; left: 50%; transform: translateX(-50%); }
.dir-w { left: -10px; top: 50%; transform: translateY(-50%); }
.dir-se { bottom: 5px; right: 5px; }

/* === Responsive === */
@media (max-width: 768px) {
    .content-island {
        max-width: 90%;
        margin-left: 5% !important;
    }

    .island-revealed {
        max-width: 95%;
    }

    .ma-section {
        padding: 4rem 1rem;
        gap: 4rem;
    }

    .flip-card {
        min-height: 280px;
    }

    .compass-rose {
        display: none;
    }
}
