/* ============================================
   DRIFT — Calm Thought Release App
   Headspace-inspired visual design
   ============================================ */

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

:root {
    /* Headspace-inspired night mode - calming, AAA compliant */
    --color-bg-start: #1a1d2e;
    --color-bg-end: #16182a;
    --color-text-primary: #d4d7e0; /* AAA compliant on dark bg (9:1 ratio) */
    --color-text-subtle: #9095a3; /* Subtle but still readable (5.5:1) */
    --color-accent: #7c8db5; /* Muted blue-purple accent */
    --color-blob-1: rgba(88, 101, 142, 0.15); /* Deep blue-purple */
    --color-blob-2: rgba(75, 85, 122, 0.12); /* Navy blue */
    --color-blob-3: rgba(95, 80, 115, 0.14); /* Muted purple */
    --color-blob-4: rgba(70, 90, 130, 0.13); /* Indigo */

    /* Easing curves */
    --ease-smooth: cubic-bezier(0.33, 1, 0.68, 1);
    --ease-gentle: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

body {
    font-family: 'Nunito', 'Comfortaa', 'Quicksand', -apple-system, BlinkMacSystemFont,
                 'SF Pro Rounded', 'Segoe UI', 'Rounded Mplus 1c', Arial, sans-serif;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, var(--color-bg-start) 0%, var(--color-bg-end) 100%);
    color: var(--color-text-primary);
    position: relative;
    font-weight: 300;
    letter-spacing: 0.02em;
}

/* Grain texture overlay */
.grain {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.03;
    pointer-events: none;
    z-index: 1;
    background-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"><filter id="noiseFilter"><feTurbulence type="fractalNoise" baseFrequency="4" numOctaves="3" stitchTiles="stitch"/></filter><rect width="100%" height="100%" filter="url(%23noiseFilter)"/></svg>');
    background-repeat: repeat;
}

/* Floating background blobs */
.blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 0;
    pointer-events: none;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 1;
}

.blob-1 {
    width: 400px;
    height: 400px;
    background: var(--color-blob-1);
    top: -100px;
    left: -100px;
    animation: float-1 45s ease-in-out infinite;
}

.blob-2 {
    width: 350px;
    height: 350px;
    background: var(--color-blob-2);
    bottom: -80px;
    right: -80px;
    animation: float-2 38s ease-in-out infinite;
}

.blob-3 {
    width: 300px;
    height: 300px;
    background: var(--color-blob-3);
    top: 50%;
    right: 10%;
    animation: float-3 50s ease-in-out infinite;
}

.blob-4 {
    width: 320px;
    height: 320px;
    background: var(--color-blob-4);
    bottom: 20%;
    left: 15%;
    animation: float-4 42s ease-in-out infinite;
}

@keyframes float-1 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, 50px) scale(1.05); }
    66% { transform: translate(-20px, 30px) scale(0.95); }
}

@keyframes float-2 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    40% { transform: translate(-40px, -30px) scale(1.08); }
    70% { transform: translate(20px, -50px) scale(0.92); }
}

@keyframes float-3 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(-50px, 40px) scale(1.1); }
}

@keyframes float-4 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    35% { transform: translate(40px, -20px) scale(0.9); }
    65% { transform: translate(-30px, 20px) scale(1.05); }
}

/* Main container */
.container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

/* Center input wrapper */
.input-wrapper {
    position: relative;
    z-index: 10;
}

.thought-input {
    font-size: clamp(24px, 4vw, 48px);
    font-weight: 300;
    color: var(--color-text-primary);
    background: transparent;
    border: none;
    outline: none;
    text-align: center;
    width: 80vw;
    max-width: 600px;
    padding: 16px;
    transition: color 0.3s var(--ease-gentle);
    caret-color: var(--color-accent);
    letter-spacing: 0.03em;
}

.thought-input::placeholder {
    color: var(--color-text-subtle);
    opacity: 0.6;
}

.thought-input:focus::placeholder {
    opacity: 0.3;
}

/* Response shown in placeholder - typewriter effect */
.thought-input.response-visible::placeholder {
    color: var(--color-text-primary);
    opacity: 0.95;
    font-style: italic;
    font-weight: 400;
}

/* Floating thoughts container */
.thoughts-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

/* Individual thought bubble */
.thought-bubble {
    position: absolute;
    font-size: clamp(18px, 3vw, 36px);
    color: var(--color-text-primary);
    opacity: 0.85;
    pointer-events: none;
    white-space: nowrap;
    max-width: 80vw;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 300;
    letter-spacing: 0.02em;
}

/* Audio start overlay */
.audio-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(22, 24, 42, 0.95);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: opacity 0.8s var(--ease-smooth),
                visibility 0.8s var(--ease-smooth);
}

.audio-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.start-audio-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 32px;
    background: rgba(124, 141, 181, 0.15);
    border: 1px solid rgba(124, 141, 181, 0.3);
    border-radius: 40px;
    color: var(--color-text-primary);
    font-size: 18px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s var(--ease-gentle);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.start-audio-btn:hover {
    background: rgba(124, 141, 181, 0.25);
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
}

.start-audio-btn:active {
    transform: translateY(0);
}

.start-audio-btn svg {
    flex-shrink: 0;
}

/* Mute button */
.mute-btn {
    position: fixed;
    top: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(124, 141, 181, 0.12);
    border: 1px solid rgba(124, 141, 181, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s var(--ease-gentle);
    z-index: 50;
    color: var(--color-text-primary);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.mute-btn:hover {
    background: rgba(124, 141, 181, 0.2);
    transform: scale(1.05);
}

.mute-btn:focus {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .thought-input {
        width: 90vw;
    }

    .blob {
        filter: blur(40px);
    }

    .start-audio-btn {
        font-size: 16px;
        padding: 14px 28px;
    }

    .mute-btn {
        width: 44px;
        height: 44px;
        top: 16px;
        right: 16px;
    }
}

/* Accessibility: respect reduced motion */
@media (prefers-reduced-motion: reduce) {
    .blob {
        animation: none;
    }

    .thought-bubble {
        animation-duration: 2s !important;
    }

    * {
        transition-duration: 0.1s !important;
    }
}
