/* --- Global Reset & Anti-Highlight --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none !important;
    -webkit-user-select: none !important;
    -webkit-user-drag: none;
    cursor: none !important;
}

/* --- Mood scenes (Fruitiger-ish dark): swap via html[data-mood] --- */
html {
    --mood-bg-base: #030810;
    --mood-bg-glow: rgba(20, 70, 120, 0.22);
    --mood-text: #e4eef8;
    --mood-muted: #8aa4bc;
    --mood-accent: #5eb8ff;
    --mood-accent-soft: rgba(94, 184, 255, 0.35);
    --mood-card-bg: rgba(12, 28, 48, 0.48);
    --mood-card-border: rgba(140, 200, 255, 0.22);
    --mood-card-inset: rgba(255, 255, 255, 0.12);
    --mood-vig-top: rgba(15, 55, 95, 0.45);
    --mood-vig-bottom: rgba(0, 0, 0, 0.9);
    --mood-vig-mid: rgba(0, 0, 0, 0.32);
    --mood-grain: 0.055;
    --mood-cursor-border: rgba(160, 210, 255, 0.45);
    --mood-btn-top: rgba(255, 255, 255, 0.14);
    --mood-btn-bot: rgba(255, 255, 255, 0.04);
    --mood-btn-border: rgba(160, 210, 255, 0.22);
    --mood-btn-glow: rgba(80, 160, 255, 0.15);
    --mood-dock-bg: rgba(8, 20, 36, 0.72);
}

html[data-mood='forest'] {
    --mood-bg-base: #050f0a;
    --mood-bg-glow: rgba(30, 120, 70, 0.2);
    --mood-text: #e2f4ea;
    --mood-muted: #8cba9e;
    --mood-accent: #5ee8a8;
    --mood-accent-soft: rgba(94, 232, 168, 0.32);
    --mood-card-bg: rgba(12, 36, 28, 0.5);
    --mood-card-border: rgba(120, 220, 170, 0.2);
    --mood-card-inset: rgba(255, 255, 255, 0.1);
    --mood-vig-top: rgba(20, 80, 50, 0.42);
    --mood-vig-bottom: rgba(0, 0, 0, 0.92);
    --mood-vig-mid: rgba(0, 0, 0, 0.34);
    --mood-grain: 0.048;
    --mood-cursor-border: rgba(150, 255, 200, 0.4);
    --mood-btn-top: rgba(255, 255, 255, 0.13);
    --mood-btn-bot: rgba(255, 255, 255, 0.035);
    --mood-btn-border: rgba(130, 220, 170, 0.22);
    --mood-btn-glow: rgba(60, 200, 140, 0.14);
    --mood-dock-bg: rgba(8, 28, 20, 0.75);
}

html[data-mood='frost'] {
    --mood-bg-base: #0a0c10;
    --mood-bg-glow: rgba(200, 220, 255, 0.12);
    --mood-text: #f2f6fc;
    --mood-muted: #a8b4c8;
    --mood-accent: #e8f0ff;
    --mood-accent-soft: rgba(255, 255, 255, 0.28);
    --mood-card-bg: rgba(36, 40, 52, 0.42);
    --mood-card-border: rgba(255, 255, 255, 0.2);
    --mood-card-inset: rgba(255, 255, 255, 0.16);
    --mood-vig-top: rgba(80, 90, 110, 0.35);
    --mood-vig-bottom: rgba(0, 0, 0, 0.88);
    --mood-vig-mid: rgba(0, 0, 0, 0.28);
    --mood-grain: 0.04;
    --mood-cursor-border: rgba(255, 255, 255, 0.5);
    --mood-btn-top: rgba(255, 255, 255, 0.2);
    --mood-btn-bot: rgba(255, 255, 255, 0.06);
    --mood-btn-border: rgba(255, 255, 255, 0.26);
    --mood-btn-glow: rgba(255, 255, 255, 0.12);
    --mood-dock-bg: rgba(20, 24, 32, 0.78);
}

html[data-mood='aurora'] {
    --mood-bg-base: #080612;
    --mood-bg-glow: rgba(120, 60, 200, 0.18);
    --mood-text: #eee8ff;
    --mood-muted: #b0a0d8;
    --mood-accent: #c49cff;
    --mood-accent-soft: rgba(196, 156, 255, 0.35);
    --mood-card-bg: rgba(28, 18, 48, 0.48);
    --mood-card-border: rgba(180, 140, 255, 0.24);
    --mood-card-inset: rgba(255, 255, 255, 0.11);
    --mood-vig-top: rgba(60, 40, 100, 0.48);
    --mood-vig-bottom: rgba(0, 0, 0, 0.92);
    --mood-vig-mid: rgba(0, 0, 0, 0.36);
    --mood-grain: 0.06;
    --mood-cursor-border: rgba(200, 170, 255, 0.45);
    --mood-btn-top: rgba(255, 255, 255, 0.14);
    --mood-btn-bot: rgba(255, 255, 255, 0.04);
    --mood-btn-border: rgba(190, 150, 255, 0.26);
    --mood-btn-glow: rgba(160, 100, 255, 0.18);
    --mood-dock-bg: rgba(16, 10, 32, 0.78);
}

body,
html {
    width: 100%;
    height: 100%;
    min-height: 100dvh;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    background-color: var(--mood-bg-base);
    background-image: radial-gradient(ellipse 130% 85% at 50% -15%, var(--mood-bg-glow), transparent 55%);
    color: var(--mood-text);
    font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    overflow: hidden;
    position: relative;
    transition:
        background-color 1.15s cubic-bezier(0.4, 0, 0.2, 1),
        color 0.85s ease;
}

/* --- Aero Cursor --- */
#custom-cursor {
    width: 22px;
    height: 22px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid var(--mood-cursor-border);
    border-radius: 50%;
    position: fixed;
    pointer-events: none;
    z-index: 10000;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transform: translate(-50%, -50%);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.1);
}

/* --- Background: procedural flow (canvas) + vignette --- */
.background-waves,
.background-streams {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
    background: #000000;
}

.background-streams .stream {
    display: none;
}

#flow-field {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    z-index: 1;
    pointer-events: none;
    /* Avoid extra blur pass on the full canvas (GPU-heavy on low-end machines) */
    filter: saturate(0);
}

.bg-vignette {
    position: absolute;
    inset: 0;
    z-index: 2;
    background:
        radial-gradient(ellipse 125% 90% at 50% -8%, var(--mood-vig-top) 0%, transparent 58%),
        radial-gradient(ellipse 95% 80% at 50% 108%, var(--mood-vig-bottom) 0%, transparent 55%),
        radial-gradient(ellipse 65% 55% at 50% 45%, transparent 0%, var(--mood-vig-mid) 100%);
    pointer-events: none;
    transition: background 1.1s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Subtle film texture — reads “camera / glass” not “noise plugin” */
.film-grain {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    opacity: var(--mood-grain, 0.045);
    transition: opacity 0.9s ease;
    mix-blend-mode: overlay;
    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='100%25' height='100%25' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 180px 180px;
}

/* --- Bubbles: always soft / optical; fade in; never “teleport” on --- */
#bubble-layer {
    position: fixed;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    overflow: hidden;
}

.bubble {
    position: absolute;
    border-radius: 50%;
    pointer-events: auto;
    cursor: none;
    opacity: 0;
    /* Glossy sphere read through haze — no hard edge */
    background: radial-gradient(
        circle at 34% 32%,
        rgba(255, 255, 255, 0.45) 0%,
        rgba(210, 210, 210, 0.08) 38%,
        rgba(60, 60, 60, 0.06) 62%,
        rgba(0, 0, 0, 0.15) 100%
    );
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow:
        inset 0 0 20px rgba(255, 255, 255, 0.12),
        0 8px 32px rgba(0, 0, 0, 0.45),
        0 0 24px rgba(255, 255, 255, 0.04);
    will-change: transform, opacity, filter;
}

.bubble.is-live {
    animation:
        bubbleReveal 1.45s cubic-bezier(0.22, 1, 0.36, 1) forwards,
        bubbleFloat var(--float-dur, 18s) ease-in-out var(--float-delay, 1.45s) infinite;
}

.bubble.popping {
    pointer-events: none;
    animation: bubblePopSoft 0.55s cubic-bezier(0.4, 0, 0.2, 1) forwards !important;
}

@keyframes bubbleReveal {
    0% {
        opacity: 0;
        filter: blur(16px);
    }
    100% {
        opacity: var(--b-op, 0.42);
        filter: blur(var(--blur, 5px));
    }
}

@keyframes bubbleFloat {
    0%,
    100% {
        transform: translate3d(0, 0, 0);
    }
    20% {
        transform: translate3d(var(--dx1, 10px), var(--dy1, -14px), 0);
    }
    45% {
        transform: translate3d(var(--dx2, -8px), var(--dy2, 8px), 0);
    }
    70% {
        transform: translate3d(var(--dx3, 6px), var(--dy3, 12px), 0);
    }
}

@keyframes bubblePopSoft {
    0% {
        opacity: var(--b-op, 0.45);
        filter: blur(var(--blur, 5px));
        transform: scale3d(1, 1, 1);
    }
    100% {
        opacity: 0;
        filter: blur(18px);
        transform: scale3d(1.12, 1.12, 1);
    }
}

.bubble-spark {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.35);
    pointer-events: none;
    filter: blur(2px);
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.35);
    animation: sparkFadeSoft 0.55s ease-out forwards;
}

@keyframes sparkFadeSoft {
    from {
        transform: translate3d(0, 0, 0) scale(1);
        opacity: 0.7;
    }
    to {
        transform: translate3d(var(--sx), var(--sy), 0) scale(0.2);
        opacity: 0;
    }
}

/* --- Layout --- */
.container {
    position: relative;
    z-index: 10;
    width: 100%;
    height: 100%;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

/* --- The Glass Card --- */
.glass-card {
    background: var(--mood-card-bg);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    border: 1px solid var(--mood-card-border);
    border-radius: 24px;
    padding: 30px;
    width: min(380px, calc(100vw - 40px));
    position: absolute;
    box-shadow:
        0 28px 56px rgba(0, 0, 0, 0.75),
        0 0 0 1px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 var(--mood-card-inset);
    transition:
        background 1s cubic-bezier(0.4, 0, 0.2, 1),
        border-color 0.9s ease,
        box-shadow 1s ease;
    z-index: 10;
    pointer-events: auto;
    isolation: isolate;
    touch-action: none;
}

/* Sharp fracture lines drawn at click; pointer-events none so UI stays usable */
.glass-crack-overlay {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    z-index: 20;
    overflow: hidden;
}

.glass-crack-overlay svg {
    display: block;
    width: 100%;
    height: 100%;
}

.glass-card.draggable {
    cursor: grab;
}

.glass-card.draggable:active {
    cursor: grabbing;
}

.glass-card h1,
.glass-card .subtitle,
.about-section h3 {
    transition: color 0.85s ease;
}

.card-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    opacity: 0.65;
    font-size: 0.8rem;
    font-family: ui-monospace, "Cascadia Code", monospace;
    color: var(--mood-muted);
}

.glass-card h1 {
    font-weight: 700;
    color: var(--mood-text);
    font-size: 1.45rem;
    line-height: 1.25;
}

.subtitle {
    opacity: 0.85;
    margin-top: 8px;
    font-size: 0.95rem;
}

.about-section {
    margin-top: 22px;
}

.about-section h3 {
    font-size: 0.95rem;
    margin-bottom: 8px;
    opacity: 0.9;
}

.about-section p {
    font-size: 0.88rem;
    line-height: 1.45;
    opacity: 0.75;
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 25px;
}

.mag-button {
    position: relative;
    overflow: hidden;
    padding: 14px 16px;
    background: linear-gradient(165deg, var(--mood-btn-top) 0%, var(--mood-btn-bot) 100%);
    border: 1px solid var(--mood-btn-border);
    color: var(--mood-text);
    text-decoration: none;
    text-align: center;
    border-radius: 14px;
    transition:
        background 0.55s cubic-bezier(0.4, 0, 0.2, 1),
        border-color 0.55s ease,
        box-shadow 0.45s ease,
        transform 0.2s cubic-bezier(0.22, 1, 0.36, 1),
        filter 0.35s ease;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.12),
        0 4px 20px rgba(0, 0, 0, 0.35),
        0 0 24px var(--mood-btn-glow);
    will-change: transform;
}

.mag-button__label {
    position: relative;
    z-index: 2;
    display: inline-block;
}

.mag-button .gloss {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    background: linear-gradient(
        118deg,
        transparent 0%,
        rgba(255, 255, 255, 0.22) 38%,
        transparent 55%
    );
    opacity: 0.55;
    mix-blend-mode: soft-light;
}

.mag-button::before {
    content: '';
    position: absolute;
    inset: -40% -30%;
    pointer-events: none;
    z-index: 0;
    background: linear-gradient(
        105deg,
        transparent 35%,
        var(--mood-accent-soft) 48%,
        transparent 62%
    );
    opacity: 0;
    transform: translateX(-18%) rotate(6deg);
    transition: opacity 0.5s ease, transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.mag-button:hover::before {
    opacity: 0.55;
    transform: translateX(12%) rotate(6deg);
}

.mag-button:hover {
    border-color: var(--mood-accent);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.18),
        0 6px 28px rgba(0, 0, 0, 0.4),
        0 0 36px var(--mood-accent-soft);
    filter: brightness(1.06);
}

.mag-button:active {
    transform: scale(0.985);
    filter: brightness(0.96);
}

/* Mood scene picker */
#mood-dock {
    position: fixed;
    left: 50%;
    bottom: max(16px, env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    z-index: 9000;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    background: var(--mood-dock-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--mood-btn-border);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
    pointer-events: auto;
    transition:
        background 0.9s ease,
        border-color 0.9s ease,
        box-shadow 0.6s ease;
}

#mood-dock[hidden] {
    display: none !important;
}

.mood-dock__label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--mood-muted);
    margin-right: 4px;
    white-space: nowrap;
    transition: color 0.8s ease;
}

.mood-dot {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
    transition:
        border-color 0.45s ease,
        box-shadow 0.45s ease,
        transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform;
}

.mood-dot:focus-visible {
    outline: 2px solid var(--mood-accent);
    outline-offset: 2px;
}

.mood-dot[aria-pressed='true'] {
    border-color: var(--mood-accent);
    box-shadow: 0 0 0 3px var(--mood-accent-soft), 0 0 20px var(--mood-btn-glow);
}

.mood-dot--ocean {
    background: radial-gradient(circle at 32% 28%, #6ec8ff, #0a2848 72%);
}

.mood-dot--forest {
    background: radial-gradient(circle at 32% 28%, #7af0b8, #0a3020 72%);
}

.mood-dot--frost {
    background: radial-gradient(circle at 32% 28%, #ffffff, #6a7088 65%);
}

.mood-dot--aurora {
    background: radial-gradient(circle at 30% 30%, #e8a8ff, #402080 65%, #103050 100%);
}

/* --- Shatter Mechanics --- */
#card-outline {
    position: fixed;
    border: 2px dashed var(--mood-accent-soft);
    border-radius: 24px;
    pointer-events: none;
    display: none;
    z-index: 4;
}

#shatter-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

.shard {
    position: absolute;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    pointer-events: auto;
    z-index: 20;
    touch-action: none;
    transition:
        border 0.2s,
        box-shadow 0.2s,
        opacity 0.6s ease-in-out;
}

.shard-content-inner {
    position: absolute;
    pointer-events: none;
    /* Width set in JS from the live card width so shards match Music / Socials layouts */
    width: 380px;
    max-width: none;
}

.shard.snapped {
    border-color: var(--mood-accent);
    box-shadow: 0 0 22px var(--mood-accent-soft);
}

.shard.healing {
    border-color: transparent !important;
    box-shadow: none !important;
    opacity: 0;
    transition: opacity 0.45s ease;
}

@media (prefers-reduced-motion: reduce) {
    .film-grain {
        animation: none !important;
    }

    html,
    body,
    .glass-card,
    .bg-vignette,
    .mag-button,
    #mood-dock {
        transition-duration: 0.01ms !important;
    }

    .mag-button::before {
        transition: none !important;
    }

    .bubble.is-live {
        animation: none !important;
        opacity: var(--b-op, 0.42);
        filter: blur(var(--blur, 5px));
    }
}
