/*
 * 마음우체통 - 디자인 시스템
 * 따뜻한 파스텔 톤 + 편지/우체통 메타포
 * Mobile-First Design
 */

/* ============ 변수 ============ */
:root {
    /* 컬러 팔레트 - 따뜻한 파스텔 */
    --primary: #FFB5A7;       /* 코랄 핑크 */
    --primary-dark: #F08B7A;
    --secondary: #FCD5CE;     /* 연한 피치 */
    --accent: #B5838D;        /* 모브 */
    --accent-light: #E5989B;

    --bg-main: #FFF8F5;       /* 크림 화이트 */
    --bg-card: #FFFFFF;
    --bg-hover: #FFF0EB;

    --text-primary: #5D4037;   /* 브라운 */
    --text-secondary: #8D7B74;
    --text-muted: #A89F9B;

    --border: #F0E6E3;
    --shadow: rgba(93, 64, 55, 0.08);

    /* 카테고리 색상 */
    --cat-love: #FFB5B5;
    --cat-work: #B5D8FF;
    --cat-family: #C5E8B7;
    --cat-friend: #FFE5B5;
    --cat-health: #D5B5FF;
    --cat-general: #E0E0E0;
    --cat-money: #B5F0D5;

    /* 간격 */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* 터치 타겟 */
    --touch-min: 44px;

    /* 반응형 */
    --bp-sm: 480px;
    --bp-md: 768px;
    --bp-lg: 1024px;

    /* 애니메이션 */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --duration: 0.3s;
}

/* ============ 리셋 & 기본 ============ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.6;
    word-break: keep-all;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    padding-bottom: 80px; /* 하단 네비 공간 */
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

input, textarea {
    font-family: inherit;
    font-size: 16px; /* iOS zoom 방지 */
}

/* ============ 레이아웃 ============ */
.container {
    max-width: 640px;
    margin: 0 auto;
    padding: 0 var(--space-md);
}

@media (min-width: 768px) {
    .container {
        max-width: 800px;
    }
    body {
        padding-bottom: 0;
        padding-top: 70px;
    }
}

/* ============ 헤더 ============ */
.header {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    z-index: 100;
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 var(--space-md);
}

.logo {
    font-size: 1.2rem;
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.nav-desktop {
    display: none;
}

.header .btn {
    display: none;
}

@media (min-width: 768px) {
    .header {
        position: fixed;
        height: 70px;
        background: var(--bg-card);
        border-bottom: 1px solid var(--border);
    }

    .header-inner {
        justify-content: space-between;
        padding: 0 var(--space-lg);
    }

    .logo {
        font-size: 1.25rem;
        color: var(--primary-dark);
    }

    .nav-desktop {
        display: flex;
        gap: var(--space-lg);
    }

    .nav-desktop a {
        padding: var(--space-sm) var(--space-md);
        border-radius: 8px;
        transition: background var(--duration);
        color: var(--text-secondary);
    }

    .nav-desktop a:hover,
    .nav-desktop a.active {
        background: var(--bg-hover);
        color: var(--primary-dark);
    }

    .header .btn {
        display: inline-flex;
    }
}

/* ============ 하단 네비게이션 (모바일) ============ */
.nav-bottom {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom, 0);
    z-index: 100;
}

.nav-bottom a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: var(--space-sm);
    min-width: var(--touch-min);
    min-height: var(--touch-min);
    color: var(--text-muted);
    transition: color var(--duration);
}

.nav-bottom a.active {
    color: var(--primary-dark);
}

.nav-bottom .nav-icon {
    font-size: 1.5rem;
}

.nav-bottom .nav-label {
    font-size: 0.7rem;
    font-weight: 500;
}

@media (min-width: 768px) {
    .nav-bottom {
        display: none;
    }
}

/* ============ 페이지 타이틀 ============ */
.page-title {
    padding: var(--space-xl) 0 var(--space-lg);
    text-align: center;
}

.page-title h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: var(--space-xs);
}

.page-title p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ============ 카드 ============ */
.card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: var(--space-lg);
    margin-bottom: var(--space-md);
    box-shadow: 0 2px 8px var(--shadow);
    transition: transform var(--duration) var(--ease-out),
                box-shadow var(--duration);
    animation: fadeSlideUp 0.4s var(--ease-out) both;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px var(--shadow);
}

.card:active {
    transform: scale(0.98);
}

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

/* 카드 스태거 애니메이션 */
.card:nth-child(1) { animation-delay: 0.05s; }
.card:nth-child(2) { animation-delay: 0.1s; }
.card:nth-child(3) { animation-delay: 0.15s; }
.card:nth-child(4) { animation-delay: 0.2s; }
.card:nth-child(5) { animation-delay: 0.25s; }

/* ============ 고민 카드 ============ */
.confession-card {
    cursor: pointer;
}

.confession-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.confession-emoji {
    font-size: 1.5rem;
}

.confession-category {
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 20px;
    background: var(--cat-general);
    color: var(--text-primary);
}

.confession-category.love { background: var(--cat-love); }
.confession-category.work { background: var(--cat-work); }
.confession-category.family { background: var(--cat-family); }
.confession-category.friend { background: var(--cat-friend); }
.confession-category.health { background: var(--cat-health); }
.confession-category.money { background: var(--cat-money); }

.confession-time {
    margin-left: auto;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.confession-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 var(--space-sm) 0;
    line-height: 1.4;
}

.confession-content {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-secondary);
    margin-bottom: var(--space-md);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.confession-footer {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    color: var(--text-muted);
    font-size: 0.85rem;
}

.confession-stat {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ============ 버튼 ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    min-height: var(--touch-min);
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    transition: all var(--duration) var(--ease-out);
    touch-action: manipulation;
}

.btn:active {
    transform: scale(0.96);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--secondary);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--bg-hover);
}

.btn-block {
    width: 100%;
}

.btn-lg {
    padding: var(--space-lg) var(--space-xl);
    font-size: 1.1rem;
    border-radius: 16px;
}

/* 플로팅 액션 버튼 */
.fab {
    position: fixed;
    bottom: 90px;
    right: var(--space-md);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-size: 1.5rem;
    box-shadow: 0 4px 16px rgba(240, 139, 122, 0.4);
    z-index: 50;
}

.fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(240, 139, 122, 0.5);
}

@media (min-width: 768px) {
    .fab {
        bottom: var(--space-xl);
        right: var(--space-xl);
    }
}

/* ============ 폼 ============ */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    font-weight: 600;
    margin-bottom: var(--space-sm);
    color: var(--text-primary);
}

.form-input,
.form-textarea {
    width: 100%;
    padding: var(--space-md);
    border: 2px solid var(--border);
    border-radius: 12px;
    background: var(--bg-card);
    transition: border-color var(--duration);
    min-height: var(--touch-min);
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-textarea {
    min-height: 150px;
    resize: vertical;
    line-height: 1.6;
}

.char-count {
    text-align: right;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: var(--space-xs);
}

/* ============ 이모지 선택 ============ */
.emoji-picker {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
    margin-bottom: var(--space-md);
}

.emoji-btn {
    width: var(--touch-min);
    height: var(--touch-min);
    font-size: 1.5rem;
    border-radius: 12px;
    background: var(--bg-hover);
    transition: all var(--duration);
}

.emoji-btn.active,
.emoji-btn:hover {
    background: var(--secondary);
    transform: scale(1.1);
}

/* ============ 카테고리 선택 ============ */
.category-tabs {
    display: flex;
    gap: var(--space-sm);
    overflow-x: auto;
    padding-bottom: var(--space-sm);
    margin-bottom: var(--space-md);
    -webkit-overflow-scrolling: touch;
}

.category-tabs::-webkit-scrollbar {
    display: none;
}

.category-tab {
    flex-shrink: 0;
    padding: var(--space-sm) var(--space-md);
    border-radius: 20px;
    font-size: 0.9rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    transition: all var(--duration);
    min-height: 36px;
}

.category-tab.active,
.category-tab:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ============ 답장 ============ */
.reply-item {
    padding: var(--space-md);
    background: var(--bg-hover);
    border-radius: 12px;
    margin-top: var(--space-md);
}

.reply-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-sm);
}

.reply-number {
    font-size: 0.8rem;
    color: var(--accent);
    font-weight: 600;
}

.reply-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.reply-content {
    font-size: 0.95rem;
    line-height: 1.6;
}

.reply-actions {
    display: flex;
    gap: var(--space-md);
    margin-top: var(--space-sm);
}

.like-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: var(--space-xs) var(--space-sm);
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: all var(--duration);
    min-height: 32px;
}

.like-btn:hover,
.like-btn.liked {
    color: var(--accent);
    background: rgba(181, 131, 141, 0.1);
}

/* ============ 빈 상태 ============ */
.empty-state {
    text-align: center;
    padding: var(--space-2xl);
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 4rem;
    margin-bottom: var(--space-md);
}

.empty-state h3 {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}

.empty-state p {
    font-size: 0.9rem;
}

/* ============ 로딩 ============ */
.loading {
    display: flex;
    justify-content: center;
    padding: var(--space-xl);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ============ 토스트 메시지 ============ */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-primary);
    color: white;
    padding: var(--space-md) var(--space-lg);
    border-radius: 12px;
    font-size: 0.9rem;
    opacity: 0;
    transition: all 0.3s var(--ease-out);
    z-index: 200;
    max-width: calc(100% - 32px);
    text-align: center;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

@media (min-width: 768px) {
    .toast {
        bottom: var(--space-xl);
    }
}

/* ============ 탭 ============ */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    margin-bottom: var(--space-lg);
}

.tab {
    flex: 1;
    padding: var(--space-md);
    text-align: center;
    font-weight: 500;
    color: var(--text-muted);
    transition: all var(--duration);
    position: relative;
}

.tab.active {
    color: var(--primary-dark);
}

.tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary);
}

/* ============ 심심풀이 (운명의거울) ============ */
.play-section {
    margin-top: var(--space-xl);
}

.play-section h2 {
    font-size: 1.2rem;
    margin-bottom: var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.play-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
}

.play-card {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 16px;
    padding: var(--space-lg);
    color: white;
    text-align: center;
    transition: transform var(--duration) var(--ease-out);
}

.play-card:hover {
    transform: scale(1.02);
}

.play-card .play-icon {
    font-size: 2rem;
    margin-bottom: var(--space-sm);
}

.play-card h3 {
    font-size: 1rem;
    margin-bottom: var(--space-xs);
}

.play-card p {
    font-size: 0.8rem;
    opacity: 0.9;
}

/* ============ 통계 배너 ============ */
.stats-banner {
    display: flex;
    justify-content: space-around;
    background: linear-gradient(135deg, var(--secondary), var(--bg-card));
    border-radius: 16px;
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-dark);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ============ 정렬/필터 ============ */
.filter-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
}

.sort-select {
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-card);
    font-size: 0.9rem;
    min-height: 36px;
}

/* ============ 광고 영역 ============ */
.ad-container {
    width: 100%;
    max-width: 728px;
    margin: 0 auto;
    padding: var(--space-md);
    text-align: center;
}

.ad-top {
    margin-bottom: var(--space-md);
}

.ad-bottom {
    margin-top: var(--space-lg);
    margin-bottom: var(--space-lg);
}

.ad-slot {
    background: var(--bg-hover);
    border-radius: 8px;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.ad-slot ins {
    display: block !important;
}

/* ============ 푸터 ============ */
.footer {
    background: var(--text-primary);
    color: rgba(255, 255, 255, 0.8);
    padding: var(--space-xl) var(--space-md);
    margin-top: var(--space-2xl);
    text-align: center;
}

.footer-inner {
    max-width: 640px;
    margin: 0 auto;
}

.footer-logo {
    font-size: 1.2rem;
    font-weight: 700;
    color: white;
    margin-bottom: var(--space-md);
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: var(--space-lg);
    margin-bottom: var(--space-md);
    flex-wrap: wrap;
}

.footer-links a {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
    transition: color var(--duration);
}

.footer-links a:hover {
    color: white;
}

.footer-business {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: var(--space-sm);
}

.footer-business a {
    color: var(--primary);
}

.footer-copyright {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
}

@media (min-width: 768px) {
    .footer {
        margin-bottom: 0;
    }
}

/* ============ 모션 감소 ============ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
