/* ===================================================
   CryBaby Mini App — Warm, cozy design
   Inspired by bedtime / lullaby app references
   =================================================== */

/* === Palette === */
:root {
    --cream:       #F5F0EB;
    --cream-dark:  #EDE6DE;
    --sand:        #D4C5B0;
    --sand-dark:   #A89580;
    --sky:         #C8D5E2;
    --sky-dark:    #8BA4BC;
    --sage:        #C2CFC2;
    --sage-dark:   #7A9A7A;
    --text-primary:   #2C2520;
    --text-secondary: #7A7067;
    --text-hint:      #A89D94;
    --accent:      #6B8EAE;
    --accent-light:#D8E4EE;
    --white:       #FFFFFF;
    --shadow:      0 2px 12px rgba(44,37,32,0.08);
    --shadow-lg:   0 8px 32px rgba(44,37,32,0.12);
    --radius:      16px;
    --radius-sm:   12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
    background: var(--cream);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
}

.hidden { display: none !important; }

.screen {
    animation: screenIn 0.3s ease;
}

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

/* ==========================================
   HOME SCREEN
   ========================================== */
.home-header {
    padding: 32px 24px 20px;
}

.home-title {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

.home-subtitle {
    font-size: 15px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* --- Category cards (3 circles) --- */
.categories {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 12px 24px 32px;
}

.category-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    background: none;
    border: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.category-card:active .category-icon {
    transform: scale(0.93);
}

.category-icon {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: var(--white);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease;
    overflow: hidden;
}

.category-icon svg {
    width: 56px;
    height: 56px;
}

.category-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

/* ==========================================
   LIST SCREEN
   ========================================== */
.list-header {
    padding: 24px 24px 16px;
}

.list-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}

.list-content {
    padding: 0 16px 120px;
}

/* --- Cards in list --- */
.card {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    margin-bottom: 10px;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.card:active {
    transform: scale(0.97);
    box-shadow: 0 1px 4px rgba(44,37,32,0.06);
}

.card-thumb {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-right: 14px;
    font-size: 24px;
}

.card-thumb.tales   { background: linear-gradient(135deg, #EDE6DE, #D4C5B0); }
.card-thumb.lullaby { background: linear-gradient(135deg, #D8E4EE, #C8D5E2); }
.card-thumb.noise   { background: linear-gradient(135deg, #D5E0D5, #C2CFC2); }

.card-body {
    flex: 1;
    min-width: 0;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-meta {
    font-size: 12px;
    color: var(--text-hint);
    margin-top: 2px;
}

.card-play {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--cream);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-left: 8px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
    pointer-events: none;
}

/* --- Noise grid --- */
.noise-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 0 16px 120px;
}

.noise-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 16px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.12s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.noise-card:active {
    transform: scale(0.96);
}

.noise-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #D5E0D5, #C2CFC2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.noise-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.noise-card-play {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--cream);
    border: none;
    font-size: 11px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

/* ==========================================
   DETAIL SCREEN
   ========================================== */
.detail-content {
    padding: 0 0 140px;
}

.detail-art {
    width: 100%;
    height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 80px;
    position: relative;
    overflow: hidden;
}

.detail-art.tales   { background: linear-gradient(135deg, #EDE6DE 0%, #D4C5B0 100%); }
.detail-art.lullaby { background: linear-gradient(135deg, #D8E4EE 0%, #B8CADC 100%); }
.detail-art.noise   { background: linear-gradient(135deg, #D5E0D5 0%, #AECAAE 100%); }

.detail-art svg {
    width: 120px;
    height: 120px;
    opacity: 0.7;
}

.detail-body {
    padding: 24px;
}

.detail-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.detail-meta {
    font-size: 13px;
    color: var(--text-hint);
    margin-bottom: 20px;
}

.detail-text {
    font-size: 16px;
    line-height: 1.7;
    color: var(--text-primary);
    white-space: pre-wrap;
    font-family: 'Georgia', 'Times New Roman', serif;
}

.detail-text::first-letter {
    font-size: 2.4em;
    float: left;
    line-height: 1;
    margin: 2px 8px 0 0;
    font-weight: 700;
    color: var(--sand-dark);
}

.detail-description {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
}

/* ==========================================
   PLAYER BAR (mini, bottom)
   ========================================== */
.player-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--white);
    box-shadow: 0 -2px 16px rgba(44,37,32,0.08);
    z-index: 30;
    border-radius: 16px 16px 0 0;
    overflow: hidden;
    cursor: pointer;
}

.player-bar-info {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
}

.player-bar-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    background: linear-gradient(135deg, #D8E4EE, #C8D5E2);
}

.player-bar-text {
    flex: 1;
    min-width: 0;
}

#player-bar-title {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#player-bar-time {
    font-size: 12px;
    color: var(--text-hint);
}

.bar-play-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    color: var(--white);
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: pointer;
}

.bar-play-btn:active { opacity: 0.8; }

.player-bar-progress {
    height: 3px;
    background: var(--cream-dark);
}

.player-bar-progress-fill {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 0.3s linear;
}

/* ==========================================
   PLAYER FULL SCREEN
   ========================================== */
.player-full {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--cream);
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 32px 48px;
    animation: slideUp 0.3s ease;
    overflow-y: auto;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

.player-full-art {
    width: 260px;
    height: 260px;
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 80px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 32px;
    background: linear-gradient(135deg, #D8E4EE 0%, #B8CADC 100%);
}

.player-full-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 4px;
}

.player-full-subtitle {
    font-size: 14px;
    color: var(--text-hint);
    margin-bottom: 32px;
}

/* --- Progress --- */
.player-full-progress {
    width: 100%;
    margin-bottom: 24px;
}

#progress {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    border-radius: 2px;
    background: var(--cream-dark);
    outline: none;
}

#progress::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 0 6px rgba(107,142,174,0.3);
}

.player-full-times {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-hint);
}

/* --- Controls --- */
.player-full-controls {
    display: flex;
    align-items: center;
    gap: 32px;
}

.ctrl-btn {
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
}

.ctrl-btn:active { opacity: 0.7; }

.ctrl-play {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--white);
    font-size: 28px;
    box-shadow: 0 4px 20px rgba(107,142,174,0.3);
}

.ctrl-small {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--cream-dark);
    color: var(--text-secondary);
    font-size: 18px;
}

.ctrl-small.active {
    background: var(--accent-light);
    color: var(--accent);
}

/* ==========================================
   LOADING
   ========================================== */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px;
    color: var(--text-hint);
    font-size: 15px;
}

.loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid var(--cream-dark);
    border-top-color: var(--accent);
    border-radius: 50%;
    margin-left: 10px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
