/* =============================================
   감정 2단계 UI 전용 CSS
   ============================================= */

/* === 대분류 카테고리 탭 (1열 가로) === */
.emotion-category-tabs {
    display: flex;
    gap: 6px;
    padding: 0 16px;
    margin-bottom: 12px;
}

.emotion-category-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 8px 6px;
    border-radius: 12px;
    border: 1.5px solid transparent;
    background: #f9fafb;
    cursor: pointer;
    transition: all 0.25s ease;
    -webkit-tap-highlight-color: transparent;
}

.emotion-category-tab:active {
    transform: scale(0.96);
}

.emotion-category-tab .category-svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    transition: transform 0.25s ease;
}

.emotion-category-tab .category-name {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    white-space: nowrap;
}

/* 선택된 카테고리 */
.emotion-category-tab.selected {
    border-color: currentColor;
}

.emotion-category-tab.selected .category-svg {
    transform: scale(1.1);
}

.emotion-category-tab.selected .category-name {
    font-weight: 700;
}

/* 카테고리별 선택 색상 */
.emotion-category-tab[data-category="sunny"].selected {
    background: linear-gradient(135deg, #FFF3E0 0%, #FFFDE7 100%);
    border-color: #FF8A65;
    color: #FF8A65;
}
.emotion-category-tab[data-category="sunny"].selected .category-name {
    color: #E65100;
}

.emotion-category-tab[data-category="calm"].selected {
    background: linear-gradient(135deg, #F3E5F5 0%, #E3F2FD 100%);
    border-color: #B39DDB;
    color: #B39DDB;
}
.emotion-category-tab[data-category="calm"].selected .category-name {
    color: #4527A0;
}

.emotion-category-tab[data-category="cloudy"].selected {
    background: linear-gradient(135deg, #ECEFF1 0%, #E8EAF6 100%);
    border-color: #78909C;
    color: #78909C;
}
.emotion-category-tab[data-category="cloudy"].selected .category-name {
    color: #37474F;
}

/* === 감정 카드 그리드 (4열) === */
.emotion-cards-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    padding: 0 16px;
    margin-bottom: 16px;
}

.emotion-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    padding: 0;
    border-radius: 16px;
    border: 2px solid transparent;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    overflow: hidden;
}

.emotion-card:active {
    transform: scale(0.95);
}

.emotion-card .emotion-card-img {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    object-fit: contain;
    transition: transform 0.2s ease;
}

.emotion-card .emotion-card-icon {
    font-size: 36px;
    line-height: 52px;
    height: auto;
    width: 100%;
    transition: transform 0.2s ease;
}

.emotion-card .emotion-card-name {
    font-size: 11px;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
    padding: 4px 0 6px;
}

/* 선택된 감정 카드 */
.emotion-card.selected {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.emotion-card.selected .emotion-card-img,
.emotion-card.selected .emotion-card-icon {
    transform: scale(1.1);
}

/* 모달 내 영상 */
.emotion-modal-video {
    border-radius: 20px;
    object-fit: cover;
}

/* === 마음보내기 모달 === */
.emotion-send-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0,0,0,0);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    transition: background 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

.emotion-send-modal-overlay.active {
    background: rgba(0,0,0,0.4);
}

.emotion-send-modal {
    position: relative;
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 24px 24px 0 0;
    padding: 28px 20px calc(20px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -4px 30px rgba(0,0,0,0.12);
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    max-height: 85vh;
    overflow-y: auto;
}

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

.emotion-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #f3f4f6;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    cursor: pointer;
    transition: all 0.2s;
}

.emotion-modal-close:active {
    transform: scale(0.9);
    background: #e5e7eb;
}

/* 모달 내 감정 카드 */
.emotion-modal-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 20px 16px 16px;
    border-radius: 20px;
    margin-bottom: 16px;
}

.emotion-modal-image {
    width: 80px;
    height: 80px;
}

.emotion-modal-image .emotion-img {
    width: 80px !important;
    height: 80px !important;
    border-radius: 16px;
}

.emotion-modal-name {
    font-size: 18px;
    font-weight: 700;
}

.emotion-modal-definition {
    font-size: 13px;
    color: #6b7280;
    text-align: center;
    line-height: 1.5;
}

/* 편지지 영역 */
.emotion-letter-area {
    background: #FFFDF7;
    border: 1.5px solid #E8E0D0;
    border-radius: 16px;
    padding: 14px 16px 8px;
    margin-bottom: 16px;
    position: relative;
}

.emotion-letter-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #9ca3af;
    margin-bottom: 8px;
}

.emotion-letter-textarea {
    width: 100%;
    border: none;
    background: transparent;
    resize: none;
    font-size: 14px;
    line-height: 1.8;
    color: #374151;
    outline: none;
    font-family: inherit;
    background-image: repeating-linear-gradient(
        transparent,
        transparent 27px,
        #E8E0D0 27px,
        #E8E0D0 28px
    );
    background-position: 0 4px;
    padding: 0;
}

.emotion-letter-textarea::placeholder {
    color: #c4b9a8;
}

/* 기존 인라인 상세 (하위호환) */
.emotion-detail-area {
    padding: 0 16px;
    animation: emotionDetailSlideIn 0.3s ease-out;
}

.emotion-detail-card {
    background: #fff;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.emotion-definition {
    font-size: 13px;
    color: #6b7280;
    text-align: center;
    padding: 8px 0 16px;
    line-height: 1.5;
}

/* === 감정 카드 그리드 등장 애니메이션 === */
@keyframes emotionCardFadeIn {
    from { opacity: 0; transform: translateY(8px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

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

.emotion-cards-grid .emotion-card {
    animation: emotionCardFadeIn 0.3s ease-out backwards;
}
.emotion-cards-grid .emotion-card:nth-child(1) { animation-delay: 0s; }
.emotion-cards-grid .emotion-card:nth-child(2) { animation-delay: 0.05s; }
.emotion-cards-grid .emotion-card:nth-child(3) { animation-delay: 0.1s; }
.emotion-cards-grid .emotion-card:nth-child(4) { animation-delay: 0.15s; }

/* === 교사 대시보드 감정 분포 (12종 2줄) === */
.emotion-distribution-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
}

.emotion-dist-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 4px 2px;
}

.emotion-dist-item .emotion-dist-img {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.emotion-dist-item .emotion-dist-icon {
    font-size: 18px;
    line-height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.emotion-dist-item .emotion-dist-icon img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    border-radius: 50%;
}

.emotion-dist-item .emotion-dist-name {
    font-size: 9px;
    color: #888;
    line-height: 1;
}

.emotion-dist-item .emotion-dist-count {
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
}

/* === 카테고리 색상 점 (교사 뷰 감정 태그) === */
.emotion-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 9999px;
    background: rgba(255,255,255,0.9);
    border: 1px solid;
}

/* === 감정 이미지 공통 === */
.emotion-img {
    display: inline-block;
    border-radius: 12px;
}

/* === 감정 카드 내 이미지 (정사각 꽉 채움) === */
.emotion-card .emotion-img {
    border-radius: 14px 14px 0 0;
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
}

/* === 마음 보내기 날아가는 애니메이션 === */
.emotion-fly-element {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    transition: none;
}

@keyframes emotionFlyToTarget {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    60% {
        opacity: 1;
        transform: scale(0.6);
    }
    100% {
        opacity: 0;
        transform: scale(0.3);
    }
}

@keyframes petReceiveEmotion {
    0% { transform: scale(1); }
    30% { transform: scale(1.15); }
    60% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

.pet-receive-bounce {
    animation: petReceiveEmotion 0.5s ease-out;
}
