/* =============================================
   KarmaBadge.com - Coastal Blend Design
   ============================================= */

/* --- CSS Custom Properties --- */
:root {
    --primary-warm: #D4A574;
    --primary-cool: #1B3A4B;
    --secondary-warm: #E8D5B5;
    --secondary-cool: #2C5F6E;
    --accent-copper: #8B7355;
    --mist: #F0EBE3;
    --night: #0D1B2A;
    --glow: #E6C89C;
    --font-display: 'Cormorant Garamond', Georgia, serif;
    --font-body: 'Lora', Georgia, serif;
    --font-accent: 'DM Sans', Arial, sans-serif;
}

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

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--mist);
    color: var(--accent-copper);
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 18px;
    line-height: 1.6;
    overflow-x: hidden;
    position: relative;
}

/* --- Grain Overlay --- */
.grain-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='256' height='256' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
    mix-blend-mode: multiply;
}

/* --- Particle Field --- */
.particle-field {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.particle {
    position: absolute;
    opacity: 0.2;
    background-color: var(--primary-warm);
    transition: opacity 1.5s ease, box-shadow 1.5s ease;
}

.particle.hex {
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
}

.particle.circle {
    border-radius: 50%;
}

.particle.diamond {
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}

.particle-field.constellation-mode .particle {
    opacity: 0.6;
    box-shadow: 0 0 12px var(--glow);
}

@keyframes particle-drift-1 {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(40px, -20px); }
    50% { transform: translate(-20px, 30px); }
    75% { transform: translate(30px, 10px); }
}

@keyframes particle-drift-2 {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(-30px, 25px); }
    50% { transform: translate(35px, -15px); }
    75% { transform: translate(-15px, -30px); }
}

@keyframes particle-drift-3 {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(20px, 35px); }
    50% { transform: translate(-40px, -10px); }
    75% { transform: translate(10px, -25px); }
}

/* --- Sections Common --- */
.section {
    position: relative;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.8s ease;
}

.section.visible {
    opacity: 1;
}

/* --- Section 1: The Threshold --- */
.section-threshold {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--mist);
    padding: 8vh 8%;
    opacity: 1;
}

.threshold-content {
    display: flex;
    align-items: baseline;
    gap: 0.1em;
    position: relative;
}

.hero-word {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(42px, 7vw, 128px);
    letter-spacing: 0.04em;
    color: var(--primary-cool);
    overflow: hidden;
}

.hero-karma {
    transform: translateX(-15%);
}

.hero-badge {
    opacity: 0;
    transform: translateX(15%);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.hero-badge.revealed {
    opacity: 1;
    transform: translateX(0);
}

.char-wrap {
    display: inline-block;
    overflow: hidden;
}

.char {
    display: inline-block;
    transform: translateY(110%);
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.char.animate-in {
    transform: translateY(0);
}

/* --- Section 2: The Shore --- */
.section-shore {
    min-height: 120vh;
    position: relative;
    overflow: hidden;
    padding: 8vh 8% 10vh;
}

.shore-diagonal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    background: linear-gradient(135deg, var(--primary-warm) 0%, var(--secondary-warm) 40%, var(--secondary-cool) 40.5%, var(--primary-cool) 100%);
}

.shore-badges {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    min-height: 100vh;
}

.badge-shape {
    position: absolute;
    left: var(--x);
    top: var(--y);
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse-badge 3s ease-in-out infinite;
    animation-delay: var(--delay);
    cursor: default;
}

.badge-shape.hex {
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: rgba(44, 95, 110, 0.15);
    border: 2px solid var(--secondary-cool);
}

.badge-shape.hex::before {
    content: '';
    position: absolute;
    top: 10%;
    left: 10%;
    width: 80%;
    height: 80%;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    border: 1px solid rgba(44, 95, 110, 0.4);
}

.badge-shape.shield {
    clip-path: polygon(50% 0%, 100% 35%, 85% 100%, 15% 100%, 0% 35%);
    background: rgba(44, 95, 110, 0.1);
}

.badge-shape.circle-badge {
    border-radius: 50%;
    background: rgba(212, 165, 116, 0.1);
    border: 1px solid var(--primary-warm);
    clip-path: none;
}

.badge-shape.circle-badge::before {
    content: '';
    position: absolute;
    top: 15%;
    left: 15%;
    width: 70%;
    height: 70%;
    border-radius: 50%;
    border: 1px solid rgba(212, 165, 116, 0.5);
}

.badge-shape.circle-badge::after {
    content: '';
    position: absolute;
    top: 30%;
    left: 30%;
    width: 40%;
    height: 40%;
    border-radius: 50%;
    border: 1px solid rgba(212, 165, 116, 0.3);
}

.badge-label {
    font-family: var(--font-accent);
    font-weight: 500;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--secondary-warm);
    position: relative;
    z-index: 2;
}

@keyframes pulse-badge {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 rgba(212, 165, 116, 0); }
    50% { transform: scale(1.03); box-shadow: 0 0 20px rgba(212, 165, 116, 0.25); }
}

/* --- Section 3: The Tide Pool --- */
.section-tidepool {
    min-height: 80vh;
    background-color: var(--mist);
    padding: 8vh 8% 10vh;
    display: flex;
    align-items: center;
}

.tidepool-content {
    max-width: 900px;
    margin-left: 12%;
}

.section-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(28px, 4vw, 64px);
    letter-spacing: 0.04em;
    color: var(--primary-cool);
    margin-bottom: 1.5em;
}

.tidepool-content p {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 18px;
    line-height: 1.85;
    color: var(--accent-copper);
    margin-bottom: 2.5em;
}

.tidepool-accent {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 2em;
    opacity: 0.7;
}

/* --- Section 4: The Constellation --- */
.section-constellation {
    min-height: 100vh;
    background-color: var(--night);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8vh 8% 10vh;
}

.constellation-badges {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.constellation-badge {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 1s ease;
}

.constellation-badge.visible {
    opacity: 1;
}

.constellation-badge.hex-type {
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: rgba(212, 165, 116, 0.15);
    box-shadow: 0 0 12px var(--glow);
}

.constellation-badge.circle-type {
    border-radius: 50%;
    background: rgba(212, 165, 116, 0.1);
    box-shadow: 0 0 16px var(--glow);
}

.constellation-badge.pentagon-type {
    clip-path: polygon(50% 0%, 100% 38%, 82% 100%, 18% 100%, 0% 38%);
    background: rgba(212, 165, 116, 0.12);
    box-shadow: 0 0 10px var(--glow);
}

@keyframes constellation-float {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(5px, -8px) rotate(3deg); }
    66% { transform: translate(-5px, 5px) rotate(-2deg); }
}

.constellation-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(28px, 4vw, 64px);
    letter-spacing: 0.04em;
    color: var(--secondary-warm);
    position: relative;
    z-index: 3;
    text-align: center;
}

/* --- Section 5: The Return --- */
.section-return {
    min-height: 60vh;
    background-color: var(--mist);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 8vh 8% 10vh;
    position: relative;
}

.section-return::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    height: 80%;
    background: radial-gradient(ellipse at center, rgba(230, 200, 156, 0.05) 0%, transparent 70%);
    pointer-events: none;
}

.return-content {
    position: relative;
    z-index: 2;
}

.return-word {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(36px, 5vw, 96px);
    letter-spacing: 0.04em;
    color: var(--primary-cool);
    margin-bottom: 0.5em;
}

.return-tagline {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 20px;
    color: var(--accent-copper);
    margin-bottom: 2em;
    font-style: italic;
}

.return-link {
    display: inline-block;
    position: relative;
    text-decoration: none;
    color: var(--accent-copper);
    font-family: var(--font-body);
    font-size: 16px;
}

.link-text {
    position: relative;
    z-index: 1;
}

.link-underline {
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 1px;
    background-color: var(--primary-warm);
    transition: width 0.4s ease;
}

.return-link:hover .link-underline {
    width: 100%;
}

/* --- Compass Navigation --- */
.compass-nav {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999;
}

.compass-rose {
    width: 32px;
    height: 32px;
    color: var(--accent-copper);
    opacity: 0.4;
    cursor: pointer;
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
    display: flex;
    align-items: center;
    justify-content: center;
}

.compass-nav:hover .compass-rose {
    opacity: 0.8;
    transform: scale(1.5);
}

.compass-svg {
    display: block;
}

.compass-menu {
    position: absolute;
    bottom: 50%;
    right: 50%;
    width: 0;
    height: 0;
    pointer-events: none;
}

.compass-link {
    position: absolute;
    font-family: var(--font-accent);
    font-weight: 500;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-decoration: none;
    color: var(--accent-copper);
    white-space: nowrap;
    opacity: 0;
    transform: scale(0);
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
}

.compass-nav:hover .compass-link {
    opacity: 1;
    transform: scale(1) translate(var(--tx, 0), var(--ty, 0));
    pointer-events: all;
}

.compass-link:nth-child(1) { --tx: -60px; --ty: -50px; transition-delay: 0s; }
.compass-link:nth-child(2) { --tx: 15px; --ty: -45px; transition-delay: 0.05s; }
.compass-link:nth-child(3) { --tx: 25px; --ty: 5px; transition-delay: 0.1s; }
.compass-link:nth-child(4) { --tx: -70px; --ty: 15px; transition-delay: 0.15s; }
.compass-link:nth-child(5) { --tx: -85px; --ty: -15px; transition-delay: 0.2s; }

.compass-link:hover {
    color: var(--primary-warm);
}

.compass-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 1px;
    background-color: var(--primary-warm);
    transition: width 0.3s ease;
}

.compass-link:hover::after {
    width: 100%;
}

/* --- Scroll Reveal Animation --- */
.fade-up {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.fade-up.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    body {
        font-size: 16px;
    }

    .tidepool-content {
        margin-left: 5%;
        max-width: 100%;
    }

    .section-threshold {
        padding: 8vh 5%;
    }

    .threshold-content {
        flex-direction: column;
        align-items: center;
        gap: 0;
    }

    .hero-karma {
        transform: translateX(0);
    }

    .hero-badge {
        transform: translateX(0);
    }

    .hero-badge.revealed {
        transform: translateX(0);
    }

    .badge-shape {
        width: 75px;
        height: 75px;
    }

    .compass-nav {
        bottom: 16px;
        right: 16px;
    }
}

@media (min-width: 769px) {
    .section-threshold {
        padding: 8vh 15%;
    }

    .section-shore {
        padding: 8vh 15% 10vh;
    }

    .section-tidepool {
        padding: 8vh 15% 10vh;
    }

    .section-constellation {
        padding: 8vh 15% 10vh;
    }

    .section-return {
        padding: 8vh 15% 10vh;
    }
}
