/* ==========================================================================
   IYASHIKKO (癒やしっ子) - Design System & Styles
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Theme Custom Properties & Design Tokens
   -------------------------------------------------------------------------- */
:root {
    /* Font Families */
    --font-primary: 'M PLUS Rounded 1c', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-heading: 'Outfit', 'M PLUS Rounded 1c', sans-serif;

    /* Theme: Midnight Aurora (Default) */
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #31103f 100%);
    --card-bg: rgba(255, 255, 255, 0.08);
    --card-border: rgba(255, 255, 255, 0.15);
    --card-shadow: 0 12px 32px 0 rgba(0, 0, 0, 0.37);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent-primary: #a855f7;
    --accent-glow: #c084fc;
    --accent-secondary: #38bdf8;
    --accent-heart: #f43f5e;
    --speech-bg: rgba(255, 255, 255, 0.95);
    --speech-text: #1e1b4b;
}

[data-theme="sakura"] {
    --bg-gradient: linear-gradient(135deg, #2d1b2e 0%, #4a1e35 50%, #5c2438 100%);
    --card-bg: rgba(255, 255, 255, 0.1);
    --card-border: rgba(255, 182, 193, 0.25);
    --card-shadow: 0 12px 32px 0 rgba(74, 30, 53, 0.4);
    --text-main: #fff5f7;
    --text-muted: #f4b8c9;
    --accent-primary: #fb7185;
    --accent-glow: #f472b6;
    --accent-secondary: #f43f5e;
    --accent-heart: #ff4d6d;
    --speech-bg: rgba(255, 240, 245, 0.95);
    --speech-text: #4a1e35;
}

[data-theme="matcha"] {
    --bg-gradient: linear-gradient(135deg, #12241b 0%, #1c3628 50%, #264734 100%);
    --card-bg: rgba(255, 255, 255, 0.08);
    --card-border: rgba(167, 243, 208, 0.2);
    --card-shadow: 0 12px 32px 0 rgba(18, 36, 27, 0.5);
    --text-main: #f0fdf4;
    --text-muted: #86efac;
    --accent-primary: #34d399;
    --accent-glow: #6ee7b7;
    --accent-secondary: #a7f3d0;
    --accent-heart: #fb7185;
    --speech-bg: rgba(240, 253, 244, 0.95);
    --speech-text: #166534;
}

[data-theme="cafe"] {
    --bg-gradient: linear-gradient(135deg, #281a14 0%, #3e261c 50%, #4f3223 100%);
    --card-bg: rgba(255, 255, 255, 0.09);
    --card-border: rgba(253, 186, 116, 0.2);
    --card-shadow: 0 12px 32px 0 rgba(40, 26, 20, 0.5);
    --text-main: #fff7ed;
    --text-muted: #fdba74;
    --accent-primary: #fb923c;
    --accent-glow: #fdba74;
    --accent-secondary: #fef08a;
    --accent-heart: #f43f5e;
    --speech-bg: rgba(255, 247, 237, 0.95);
    --speech-text: #431407;
}

/* --------------------------------------------------------------------------
   2. Reset & Global Base
   -------------------------------------------------------------------------- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

body {
    font-family: var(--font-primary);
    background: var(--bg-gradient);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background 0.8s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* Ambient Animated Star Particles Background */
.ambient-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.ambient-particle {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,0.8) 0%, rgba(255,255,255,0) 70%);
    animation: floatParticle linear infinite;
}

@keyframes floatParticle {
    0% {
        transform: translateY(100vh) scale(0.3);
        opacity: 0;
    }
    50% {
        opacity: 0.7;
    }
    100% {
        transform: translateY(-10vh) scale(1);
        opacity: 0;
    }
}

/* --------------------------------------------------------------------------
   3. Main Layout & Glassmorphism Cards
   -------------------------------------------------------------------------- */
.app-container {
    width: 100%;
    max-width: 1200px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: relative;
    z-index: 10;
}

.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    box-shadow: var(--card-shadow);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.4s ease;
}

/* Header Styles */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 28px;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 1.8rem;
    animation: pulseGlow 2.5s ease-in-out infinite alternate;
}

@keyframes pulseGlow {
    0% { transform: scale(1) rotate(-5deg); filter: drop-shadow(0 0 4px var(--accent-glow)); }
    100% { transform: scale(1.15) rotate(5deg); filter: drop-shadow(0 0 12px var(--accent-glow)); }
}

.app-title {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: 1px;
    background: linear-gradient(90deg, #ffffff, var(--accent-glow));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sub-title {
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--text-muted);
    margin-left: 6px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.theme-selector {
    display: flex;
    gap: 6px;
    background: rgba(0, 0, 0, 0.2);
    padding: 4px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.theme-btn {
    border: none;
    background: transparent;
    font-size: 1.1rem;
    padding: 6px 10px;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.25s ease;
}

.theme-btn:hover {
    transform: scale(1.15);
}

.theme-btn.active {
    background: rgba(255, 255, 255, 0.25);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.icon-btn {
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    padding: 8px 14px;
    border-radius: 16px;
    cursor: pointer;
    font-size: 1.1rem;
    border: 1px solid var(--card-border);
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

/* --------------------------------------------------------------------------
   4. Main Content: Grid & Mascot Section
   -------------------------------------------------------------------------- */
.app-main {
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 24px;
}

@media (max-width: 992px) {
    .app-main {
        grid-template-columns: 1fr;
    }
}

/* Mascot Section */
.mascot-section {
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

/* Speech Bubble */
.speech-bubble-container {
    width: 100%;
    min-height: 70px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 12px;
}

.speech-bubble {
    background: var(--speech-bg);
    color: var(--speech-text);
    padding: 14px 20px;
    border-radius: 20px;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.5;
    position: relative;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    text-align: center;
    animation: bubbleBounce 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 10px 10px 0;
    border-style: solid;
    border-color: var(--speech-bg) transparent;
    display: block;
    width: 0;
}

@keyframes bubbleBounce {
    0% { transform: scale(0.8) translateY(10px); opacity: 0; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

/* Canvas Wrapper */
.canvas-wrapper {
    position: relative;
    width: 100%;
    height: 320px;
    display: flex;
    justify-content: center;
    align-items: center;
}

#mascotCanvas {
    width: 100%;
    height: 100%;
    cursor: grab;
}

#mascotCanvas:active {
    cursor: grabbing;
}

.mascot-hint {
    position: absolute;
    bottom: 8px;
    font-size: 0.78rem;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.3);
    padding: 4px 12px;
    border-radius: 12px;
    backdrop-filter: blur(4px);
    pointer-events: none;
    transition: opacity 0.5s ease;
}

/* Status Bars */
.status-bar-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 16px 0;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    width: 80px;
}

.progress-bar {
    flex: 1;
    height: 10px;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-glow));
    border-radius: 10px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-fill.relax {
    background: linear-gradient(90deg, var(--accent-secondary), #38bdf8);
}

/* Mascot Action Buttons */
.mascot-actions {
    display: flex;
    gap: 10px;
    width: 100%;

}

.action-btn {
    flex: 1;
    padding: 10px 12px;
    border-radius: 16px;
    border: 1px solid var(--card-border);
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-main);
    font-family: var(--font-primary);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* --------------------------------------------------------------------------
   5. Tools & Tab Panels
   -------------------------------------------------------------------------- */
.tools-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.tabs-header {
    display: flex;
    padding: 8px;
    gap: 8px;
    overflow-x: auto;
}

.tab-btn {
    flex: 1;
    padding: 12px 16px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-primary);
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 16px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.3s ease;
}

.tab-btn.active {
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-main);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.tab-body {
    padding: 28px;
    min-height: 440px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.panel-title {
    margin-bottom: 24px;
}

.panel-title h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.panel-title .subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Sound Grid */
.sound-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.sound-card {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: all 0.25s ease;
}

.sound-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

.sound-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sound-icon {
    font-size: 1.4rem;
}

.sound-name {
    font-size: 0.9rem;
    font-weight: 600;
}

/* Custom Range Sliders */
input[type="range"].sound-slider,
#masterVol {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.15);
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-glow);
    cursor: pointer;
    box-shadow: 0 0 8px var(--accent-glow);
    transition: transform 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.25);
}

.master-sound-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    background: rgba(0, 0, 0, 0.3);
    padding: 14px 20px;
    border-radius: 16px;
    font-size: 0.9rem;
}

/* Buttons */
.primary-btn {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-glow));
    color: #ffffff;
    border: none;
    padding: 12px 24px;
    border-radius: 16px;
    font-family: var(--font-primary);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.primary-btn.small {
    padding: 8px 14px;
    font-size: 0.8rem;
}

.primary-btn.glow {
    animation: glowPulse 2s infinite alternate;
}

@keyframes glowPulse {
    0% { box-shadow: 0 0 10px var(--accent-primary); }
    100% { box-shadow: 0 0 24px var(--accent-glow); }
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    border: 1px solid var(--card-border);
    padding: 12px 24px;
    border-radius: 16px;
    font-family: var(--font-primary);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
}

.secondary-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
}

.secondary-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* --------------------------------------------------------------------------
   6. Breathing Coach Styles
   -------------------------------------------------------------------------- */
.breathing-modes {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.mode-chip {
    padding: 8px 16px;
    border-radius: 20px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    font-family: var(--font-primary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mode-chip.active {
    background: rgba(255, 255, 255, 0.25);
    color: var(--text-main);
    border-color: var(--accent-glow);
}

.breathing-circle-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 220px;
    margin: 20px 0;
}

.breathing-ring-outer {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.02) 70%);
    border: 3px solid var(--accent-glow);
    box-shadow: 0 0 30px var(--accent-glow);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 1s ease-in-out, box-shadow 1s ease-in-out;
}

.breathing-ring-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.breathing-instruction {
    font-size: 1.25rem;
    font-weight: 700;
}

.breathing-timer {
    font-size: 1.5rem;
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--accent-glow);
}

.breathing-controls {
    display: flex;
    justify-content: center;
    gap: 16px;
}

/* --------------------------------------------------------------------------
   7. Worry Bubble Releasing Styles
   -------------------------------------------------------------------------- */
.worry-input-area {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

#worryInput {
    width: 100%;
    height: 90px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 14px;
    color: var(--text-main);
    font-family: var(--font-primary);
    font-size: 0.95rem;
    resize: none;
    outline: none;
    transition: border-color 0.3s ease;
}

#worryInput:focus {
    border-color: var(--accent-glow);
}

.worry-actions {
    display: flex;
    justify-content: flex-end;
}

.bubbles-stage {
    min-height: 140px;
    border-radius: 18px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px dashed rgba(255, 255, 255, 0.15);
    padding: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.bubble-placeholder {
    font-size: 0.88rem;
    color: var(--text-muted);
    text-align: center;
}

.worry-bubble {
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.4), rgba(168, 85, 247, 0.2));
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 4px 20px rgba(168, 85, 247, 0.3), inset 0 0 15px rgba(255, 255, 255, 0.5);
    border-radius: 50px;
    padding: 12px 20px;
    max-width: 280px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    backdrop-filter: blur(6px);
    animation: floatBubble 4s ease-in-out infinite alternate;
}

.worry-bubble-text {
    font-size: 0.88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.release-btn {
    border: none;
    background: rgba(255, 255, 255, 0.3);
    color: #fff;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.release-btn:hover {
    transform: scale(1.2) rotate(90deg);
}

@keyframes floatBubble {
    0% { transform: translateY(0px) rotate(-1deg); }
    100% { transform: translateY(-8px) rotate(1deg); }
}

/* Bubble Popping & Sky Float Animation */
.worry-bubble.floating-away {
    animation: floatToSky 2s forwards cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes floatToSky {
    0% { transform: scale(1) translateY(0); opacity: 1; }
    50% { transform: scale(1.2) translateY(-100px); opacity: 0.8; filter: brightness(1.5); }
    100% { transform: scale(0.2) translateY(-250px); opacity: 0; }
}

/* --------------------------------------------------------------------------
   8. Affirmation Cards Styles
   -------------------------------------------------------------------------- */
.card-draw-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.flip-card {
    background-color: transparent;
    width: 300px;
    height: 180px;
    perspective: 1000px;
    cursor: pointer;
}

.flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-style: preserve-3d;
}

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

.flip-card-front, .flip-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 20px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--card-border);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.flip-card-front {
    background: linear-gradient(135deg, rgba(255,255,255,0.15), rgba(255,255,255,0.05));
}

.card-pattern {
    font-size: 2.5rem;
    margin-bottom: 8px;
}

.flip-card-back {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.25), rgba(56, 189, 248, 0.25));
    transform: rotateY(180deg);
}

.card-tag {
    font-size: 0.75rem;
    color: var(--accent-glow);
    font-weight: 700;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.card-quote {
    font-size: 0.92rem;
    line-height: 1.5;
    font-weight: 600;
    margin-bottom: 8px;
}

.card-author {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   9. Modal Styles
   -------------------------------------------------------------------------- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    width: 90%;
    max-width: 440px;
    padding: 28px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 16px;
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.active .modal-card {
    transform: translateY(0);
}

.modal-subtitle {
    font-size: 0.88rem;
    color: var(--text-muted);
}

.snack-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;

}

.snack-item {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 14px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.snack-item:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-4px);
}

.snack-emoji {
    font-size: 2rem;
}

.snack-name {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-main);
}

.snack-desc {
    font-size: 0.7rem;
    color: var(--accent-glow);
}

/* --------------------------------------------------------------------------
   10. Footer
   -------------------------------------------------------------------------- */
.app-footer {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 12px 0;
}
