/* ============================================
   lugubrious.dev — Candy Palace of Sadness
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --deep-plum: #2d1b4e;
    --candy-pink: #ff6fb7;
    --electric-violet: #7c4dff;
    --lemon-sherbet: #ffe566;
    --mint-cream: #e8fff0;
    --cotton-candy-blue: #7fdbff;
    --marshmallow: #fdf4ff;
    --teardrop-gray: #8b7da8;
    --lavender-light: #f0e4ff;
    --lavender-bg: #f5eaff;
    --mid-plum: #3d2c5e;
}

/* --- Isometric Cube Background Pattern (inline SVG) --- */
body {
    margin: 0;
    padding: 0;
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-size: 1.05rem;
    line-height: 1.65;
    letter-spacing: 0.01em;
    color: var(--deep-plum);
    background-color: var(--marshmallow);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='49' viewBox='0 0 28 49'%3E%3Cg fill-rule='evenodd'%3E%3Cg fill='%23f5eaff' fill-opacity='0.4'%3E%3Cpath d='M13.99 9.25l13 7.5v15l-13 7.5L1 31.75v-15l12.99-7.5zM3 17.9v12.7l10.99 6.34 11-6.35V17.9l-11-6.34L3 17.9z'/%3E%3Cpath d='M0 15l12.98-7.5V0h-2v6.35L0 12.69v2.3zm0 18.5L12.98 41v8h-2v-6.85L0 35.81v-2.3zM15 0v7.5L27.99 15H28v-2.31h-.01L17 6.35V0h-2zm0 49v-8l12.99-7.5H28v2.31h-.01L17 42.15V49h-2z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    overflow-x: hidden;
}

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

/* --- Typography --- */
h1, h2, h3 {
    font-family: 'Caveat', cursive;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.01em;
}

h1 {
    font-size: clamp(2.8rem, 7vw, 5.2rem);
    color: var(--deep-plum);
    text-shadow: 2px 2px 0 var(--candy-pink);
}

h2 {
    font-size: clamp(2rem, 5vw, 3.8rem);
    color: var(--deep-plum);
    text-shadow: 2px 2px 0 var(--candy-pink);
}

h3 {
    font-size: clamp(1.4rem, 3.5vw, 2.2rem);
    font-family: 'Indie Flower', cursive;
    font-weight: 400;
    line-height: 1.25;
}

/* --- Bubble Navigation --- */
#bubble-nav {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
}

.nav-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 16px;
    border-radius: 50px;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    text-decoration: none;
    color: var(--deep-plum);
    background: rgba(240, 228, 255, 0.85);
    backdrop-filter: blur(8px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.3s ease;
    cursor: pointer;
    position: relative;
}

.nav-pill:nth-child(1) { background: rgba(255, 111, 183, 0.25); }
.nav-pill:nth-child(2) { background: rgba(124, 77, 255, 0.2); }
.nav-pill:nth-child(3) { background: rgba(127, 219, 255, 0.25); }
.nav-pill:nth-child(4) { background: rgba(255, 229, 102, 0.3); }
.nav-pill:nth-child(5) { background: rgba(232, 255, 240, 0.5); }
.nav-pill:nth-child(6) { background: rgba(240, 228, 255, 0.5); }

.nav-pill:hover {
    transform: scale(1.08);
    animation: wobble 0.4s ease-in-out;
}

.nav-pill.active {
    background: var(--electric-violet);
    color: var(--marshmallow);
    box-shadow: 0 4px 15px rgba(124, 77, 255, 0.4);
}

.crown-icon {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    display: none;
}

.nav-pill.active .crown-icon {
    display: block;
}

@keyframes wobble {
    0% { transform: rotate(0deg) scale(1.08); }
    25% { transform: rotate(-3deg) scale(1.08); }
    75% { transform: rotate(3deg) scale(1.08); }
    100% { transform: rotate(0deg) scale(1.08); }
}

/* --- Confetti of Sorrows --- */
#confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.confetti-piece {
    position: absolute;
    bottom: -20px;
    width: 6px;
    height: 6px;
    opacity: 0;
    animation: float-up var(--duration) linear infinite;
    animation-delay: var(--delay);
}

.confetti-piece.circle { border-radius: 50%; }
.confetti-piece.triangle {
    width: 0; height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-bottom: 7px solid var(--color);
    background: transparent !important;
}
.confetti-piece.star {
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
    width: 8px;
    height: 8px;
}

@keyframes float-up {
    0% { transform: translateY(100vh) rotate(0deg); opacity: 0; }
    10% { opacity: 0.7; }
    90% { opacity: 0.7; }
    100% { transform: translateY(-20vh) rotate(360deg); opacity: 0; }
}

/* --- Sad Bubbles --- */
#bubbles-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
    overflow: hidden;
}

.sad-bubble {
    position: absolute;
    bottom: -60px;
    border-radius: 50%;
    opacity: 0.6;
    animation: bubble-float var(--duration) linear infinite;
    animation-delay: var(--delay);
}

.sad-bubble::before {
    content: '';
    position: absolute;
    top: 20%;
    left: 20%;
    width: 30%;
    height: 30%;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
}

.sad-bubble .bubble-face {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

@keyframes bubble-float {
    0% { transform: translateY(0) scale(1); opacity: 0.6; }
    50% { transform: translateY(-40vh) scale(1.05); opacity: 0.4; }
    100% { transform: translateY(-80vh) scale(0.95); opacity: 0; }
}

/* --- Palace Sections --- */
.palace-section {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    z-index: 5;
}

/* --- Gates Section --- */
.gates-section {
    min-height: 100vh;
    text-align: center;
    padding-top: 100px;
}

.gates-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.gate-illustration {
    max-width: 400px;
    width: 100%;
}

.palace-gate {
    width: 100%;
    height: auto;
}

.site-title {
    margin: 0;
    padding: 0;
}

.site-subtitle {
    font-family: 'Indie Flower', cursive;
    font-size: clamp(1.2rem, 3vw, 1.8rem);
    color: var(--teardrop-gray);
    margin: 0;
}

/* Animated teardrop on gate */
.gate-teardrop {
    animation: teardrop-fall 4s ease-in infinite;
}

@keyframes teardrop-fall {
    0% { transform: translateY(0); opacity: 1; }
    60% { transform: translateY(20px); opacity: 1; }
    75% { transform: translateY(20px); opacity: 0; }
    100% { transform: translateY(0); opacity: 0; }
}

/* --- Room Dividers --- */
.room-divider {
    width: 100%;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 5;
    overflow: visible;
}

.divider-svg {
    width: 100%;
    height: 120px;
}

/* --- Room Sections --- */
.room-section {
    min-height: 100vh;
    padding: 40px 20px 80px;
}

.room-title {
    text-align: center;
    margin-bottom: 50px;
}

/* --- Tears Ticker --- */
.tears-ticker {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    margin-bottom: 40px;
    font-family: 'Caveat', cursive;
    font-size: 1.5rem;
    color: var(--electric-violet);
}

.tears-ticker .counter-value {
    font-weight: 700;
    font-size: 2rem;
}

.ticker-label {
    font-family: 'Nunito', sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--teardrop-gray);
}

/* --- Isometric Grid --- */
.isometric-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 40px 30px;
    max-width: 1100px;
    margin: 0 auto;
    perspective: 1200px;
}

.grid-2x2 {
    grid-template-columns: repeat(2, 1fr);
    max-width: 900px;
}

.grid-3x2 {
    grid-template-columns: repeat(3, 1fr);
    max-width: 1000px;
}

.grid-throne {
    grid-template-columns: 1fr;
    max-width: 700px;
}

/* --- Isometric Cards --- */
.iso-card {
    position: relative;
    transform-style: preserve-3d;
    transform: scale(0.85) translateY(20px);
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.6s ease;
    opacity: 0;
}

.iso-card.visible {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* Stagger offsets for isometric feel */
.card-stagger-1 { margin-top: 0; }
.card-stagger-2 { margin-top: 60px; }
.card-stagger-3 { margin-top: 120px; }
.card-stagger-4 { margin-top: 40px; }
.card-stagger-5 { margin-top: 80px; }
.card-stagger-6 { margin-top: 20px; }

/* Card Shadow */
.card-shadow {
    position: absolute;
    top: 12px;
    left: -8px;
    width: 100%;
    height: 100%;
    background: var(--candy-pink);
    border-radius: 16px;
    filter: blur(12px);
    opacity: 0.3;
    z-index: -1;
    transition: filter 0.3s ease;
}

.card-shadow-large {
    filter: blur(20px);
    opacity: 0.4;
}

/* Card Base */
.card-base {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    padding: 28px;
    min-height: 220px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border: 2px solid rgba(45, 27, 78, 0.1);
}

.card-bg-plum {
    background: var(--deep-plum);
    color: var(--lavender-light);
}

.card-bg-plum .card-title { color: var(--candy-pink); }
.card-bg-plum .card-text { color: var(--lavender-light); }

.card-bg-mint {
    background: var(--mint-cream);
    color: var(--deep-plum);
}

.card-bg-mint .card-title { color: var(--electric-violet); }

.card-bg-lavender {
    background: var(--lavender-light);
    color: var(--deep-plum);
}

.card-bg-lavender .card-title { color: var(--candy-pink); }

.card-bg-pink {
    background: linear-gradient(135deg, rgba(255, 111, 183, 0.15), rgba(253, 244, 255, 0.9));
    color: var(--deep-plum);
}

.card-bg-pink .card-title { color: var(--electric-violet); }

/* Card Pattern Layer */
.card-pattern {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.08;
    pointer-events: none;
}

.pattern-bubbles {
    background-image: radial-gradient(circle, var(--candy-pink) 2px, transparent 2px),
                      radial-gradient(circle, var(--candy-pink) 3px, transparent 3px),
                      radial-gradient(circle, var(--candy-pink) 5px, transparent 5px);
    background-size: 40px 40px, 60px 60px, 80px 80px;
    background-position: 0 0, 20px 20px, 10px 40px;
}

.pattern-teardrops {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='30' viewBox='0 0 20 30'%3E%3Cpath d='M10 0 Q6 10 6 15 Q6 20 10 20 Q14 20 14 15 Q14 10 10 0Z' fill='%237c4dff'/%3E%3C/svg%3E");
    background-size: 30px 40px;
}

/* Card Content */
.card-content {
    position: relative;
    z-index: 2;
}

.card-title {
    margin: 0 0 12px 0;
}

.card-text {
    margin: 0 0 16px 0;
    font-size: 1rem;
    line-height: 1.6;
}

/* Card Gloss Layer */
.card-gloss {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, transparent 50%);
    pointer-events: none;
    z-index: 3;
    border-radius: 16px;
}

/* --- Counter --- */
.card-counter, .throne-counter {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-top: 12px;
}

.counter-value {
    font-family: 'Caveat', cursive;
    font-weight: 700;
    font-size: 2.2rem;
    color: var(--lemon-sherbet);
    line-height: 1;
}

.card-bg-mint .counter-value,
.card-bg-lavender .counter-value,
.card-bg-pink .counter-value {
    color: var(--electric-violet);
}

.counter-label {
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--teardrop-gray);
}

.card-bg-plum .counter-label {
    color: var(--teardrop-gray);
}

/* --- Card Illustrations --- */
.card-illustration {
    text-align: center;
    margin-bottom: 16px;
}

.weeping-illustration {
    width: 100px;
    height: 84px;
}

/* --- Drawer Cards (Room 3) --- */
.card-drawer .card-base {
    min-height: 140px;
    padding: 24px;
}

.letter-snippet {
    font-family: 'Caveat', cursive;
    font-style: italic;
    font-size: clamp(1.1rem, 2.5vw, 1.4rem);
    line-height: 1.4;
    color: var(--marshmallow);
    margin: 0;
}

.card-bg-mint .letter-snippet { color: var(--deep-plum); }
.card-bg-lavender .letter-snippet { color: var(--deep-plum); }
.card-bg-pink .letter-snippet { color: var(--deep-plum); }

/* --- Throne Card --- */
.card-throne .card-base {
    min-height: 400px;
    padding: 50px 40px;
}

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

.throne-illustration {
    margin-bottom: 30px;
}

.throne-svg {
    width: 160px;
    height: auto;
}

.throne-heading {
    font-family: 'Caveat', cursive;
    font-weight: 700;
    font-size: clamp(1.8rem, 4vw, 3rem);
    color: var(--lemon-sherbet);
    margin: 0 0 24px 0;
    text-shadow: 2px 2px 0 rgba(0,0,0,0.2);
}

.throne-text {
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--lavender-light);
    max-width: 580px;
    margin: 0 auto 24px;
}

.throne-counter {
    justify-content: center;
}

.throne-counter .counter-value {
    font-size: 3rem;
}

/* --- Balcony Section --- */
.balcony-section {
    min-height: 80vh;
    position: relative;
    overflow: hidden;
    padding-top: 40px;
    padding-bottom: 80px;
}

.balcony-illustration {
    width: 100%;
    max-width: 900px;
    margin: 0 auto 60px;
}

.balcony-svg {
    width: 100%;
    height: auto;
}

/* --- Floating Text Fragments --- */
.floating-texts {
    position: relative;
    width: 100%;
    height: 200px;
    overflow: hidden;
}

.floating-fragment {
    position: absolute;
    bottom: -30px;
    left: var(--x);
    font-family: 'Indie Flower', cursive;
    font-size: clamp(0.9rem, 2vw, 1.2rem);
    color: var(--electric-violet);
    opacity: 0;
    animation: fragment-float 10s linear infinite;
    animation-delay: var(--delay);
}

@keyframes fragment-float {
    0% { transform: translateY(0); opacity: 0; }
    10% { opacity: 0.6; }
    80% { opacity: 0.5; }
    100% { transform: translateY(-220px); opacity: 0; }
}

/* --- Closing Line --- */
.closing-line {
    font-family: 'Indie Flower', cursive;
    font-size: clamp(1.4rem, 3.5vw, 2.2rem);
    color: var(--teardrop-gray);
    text-align: center;
    margin: 40px 0;
}

/* --- Footer --- */
.palace-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 30px 0;
}

.footer-domain {
    font-family: 'Caveat', cursive;
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--teardrop-gray);
}

.footer-crown {
    width: 24px;
    height: auto;
}

/* ===================================
   Responsive Design
   =================================== */

@media (max-width: 1024px) {
    .isometric-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 30px 20px;
    }

    .grid-3x2 {
        grid-template-columns: repeat(2, 1fr);
    }

    .card-stagger-1 { margin-top: 0; }
    .card-stagger-2 { margin-top: 40px; }
    .card-stagger-3 { margin-top: 80px; }
    .card-stagger-4 { margin-top: 20px; }
    .card-stagger-5 { margin-top: 60px; }
    .card-stagger-6 { margin-top: 10px; }
}

@media (max-width: 640px) {
    .isometric-grid,
    .grid-2x2,
    .grid-3x2 {
        grid-template-columns: 1fr;
        gap: 30px;
        max-width: 400px;
    }

    .iso-card {
        transform: scale(0.85) translateY(20px) rotate(-2deg);
    }

    .iso-card.visible {
        transform: scale(1) translateY(0) rotate(-2deg);
    }

    .card-stagger-1,
    .card-stagger-2,
    .card-stagger-3,
    .card-stagger-4,
    .card-stagger-5,
    .card-stagger-6 {
        margin-top: 0;
    }

    #bubble-nav {
        top: auto;
        bottom: 10px;
        right: 10px;
        left: 10px;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        background: rgba(253, 244, 255, 0.95);
        backdrop-filter: blur(10px);
        padding: 8px;
        border-radius: 20px;
        box-shadow: 0 4px 20px rgba(45, 27, 78, 0.15);
    }

    .nav-pill {
        font-size: 0.6rem;
        padding: 4px 10px;
    }

    .gates-section {
        padding-top: 60px;
    }

    .gate-illustration {
        max-width: 280px;
    }

    .card-throne .card-base {
        min-height: 300px;
        padding: 30px 20px;
    }

    .throne-svg {
        width: 120px;
    }

    .room-title {
        margin-bottom: 30px;
    }

    .palace-section {
        padding: 40px 16px;
    }
}

/* --- Smooth scroll --- */
html {
    scroll-behavior: smooth;
}
