/* Letter Container */
.letter-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    position: relative;
}

/* Landing Page */
.landing-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
}

.landing-content h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.landing-content p {
    font-size: 1.25rem;
    color: var(--text-secondary);
}

@media (max-width: 768px) {
    .landing-content h1 {
        font-size: 2.5rem;
    }
    
    .landing-content p {
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    .landing-content h1 {
        font-size: 2rem;
    }
    
    .landing-content p {
        font-size: 1rem;
    }
}

/* Loading Container */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--accent-soft);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-container p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Error Container */
.error-container {
    text-align: center;
    padding: 2rem;
    max-width: 500px;
}

.error-container h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.error-container p {
    color: var(--text-secondary);
}

/* Letter Content */
.letter-content {
    width: 100%;
    max-width: 600px;
    position: relative;
}

/* Envelope Wrapper */
.envelope-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 3rem 0;
    cursor: pointer;
    transition: transform 0.3s ease;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.envelope-wrapper:hover {
    transform: translateY(-5px);
}

@media (hover: none) {
    .envelope-wrapper:hover {
        transform: none;
    }
    
    .envelope-wrapper:active {
        transform: scale(0.98);
    }
}

/* Envelope */
.envelope {
    position: relative;
    width: 300px;
    height: 200px;
    max-width: 90vw;
}

.envelope-body {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 140px;
    background: linear-gradient(135deg, var(--bg-envelope) 0%, #d4c4b0 100%);
    border-radius: 5px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 1;
}

.envelope-flap {
    position: absolute;
    bottom: 20%;
    left: 0;
    width: 100%;
    height: 100px;
    background: linear-gradient(135deg, #d4c4b0 0%, var(--bg-envelope) 100%);
    clip-path: polygon(0 0, 50% 100%, 100% 0);
    z-index: 2;
    transform-origin: top center;
    transition: transform 0.6s ease;
}

.envelope.opened .envelope-flap {
    transform: rotateX(-180deg);
}

/* Letter Paper */
.letter-paper {
    max-width: 600px;
    margin: 0 auto;
    background: var(--paper-color);
    padding: 3rem;
    border-radius: 8px;
    box-shadow: 0 8px 30px var(--paper-shadow);
    position: relative;
    z-index: 0;
}

.letter-paper.fade-in {
    animation: slideUpFadeIn 0.8s ease-out forwards;
}

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

.letter-inner {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Letter Title */
.letter-title {
    font-size: 1.75rem;
    text-align: center;
    color: var(--text-primary);
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-weight: 200;
}

/* Character Section */
.character-section {
    text-align: center;
    padding: 2rem 0;
}

.character-text {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
    line-height: 1.4;
    word-break: keep-all;
    margin-bottom: 0.2rem; /* character와 fixed-message 사이 간격 */
}

/* 일본어가 포함된 경우 폰트 적용 */
.character-text.has-japanese {
    font-family: 'JapaneseFont', sans-serif;
    word-break: break-word; /* 일본어 텍스트 줄바꿈 처리 */
    overflow-wrap: break-word; /* 긴 단어 강제 줄바꿈 */
    word-wrap: break-word; /* 구형 브라우저 호환 */
}

/* Fixed Message Text (character 바로 아래 고정 메시지) */
.fixed-message-text {
    font-size: 1.1rem;
    color: var(--text-primary);
    white-space: pre-line;
    word-break: keep-all;
    margin-top: 0;
    line-height: 1.6;
}

/* Message Section */
.message-section {
    line-height: 2;
    padding: 1.5rem 0;
}

.message-text {
    font-size: 1.1rem;
    color: var(--text-primary);
    white-space: pre-line;
    word-break: keep-all;
}

/* 일본어가 포함된 경우 폰트 적용 */
.message-text.has-japanese {
    font-family: 'JapaneseFont', sans-serif;
    word-break: break-word; /* 일본어 텍스트 줄바꿈 처리 */
    overflow-wrap: break-word; /* 긴 단어 강제 줄바꿈 */
    word-wrap: break-word; /* 구형 브라우저 호환 */
}

/* From Section */
.from-section {
    text-align: right;
    padding-top: 2rem;
    margin-top: 2rem;
    border-top: 1px solid var(--accent-soft);
}

.from-text {
    font-size: 1rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Responsive Design */
@media (max-width: 768px) {
    .letter-paper {
        padding: 2rem 1.5rem;
        margin: 0 1rem;
    }
    
    .letter-title {
        font-size: 1.5rem;
    }
    
    .character-text {
        font-size: 1.75rem;
    }
    
    .message-text {
        font-size: 1rem;
    }
    
    .envelope {
        width: 250px;
        height: 170px;
    }
}

@media (max-width: 480px) {
    .letter-container,
    .landing-container {
        padding: 1rem;
    }
    
    .letter-paper {
        padding: 1.5rem 1rem;
    }
    
    .letter-title {
        font-size: 1.25rem;
    }
    
    .character-text {
        font-size: 1.5rem;
    }
    
    .message-text {
        font-size: 0.95rem;
        line-height: 1.8;
    }
    
    .envelope {
        width: 200px;
        height: 140px;
    }
    
    .envelope-body {
        height: 100px;
    }
    
    .envelope-flap {
        height: 70px;
    }
    
    .envelope-wrapper {
        padding: 2rem 0;
    }
}

/* 추가 반응형: 작은 화면 (320px 이하) */
@media (max-width: 320px) {
    .letter-paper {
        padding: 1rem 0.75rem;
    }
    
    .letter-title {
        font-size: 1.1rem;
    }
    
    .character-text {
        font-size: 1.25rem;
    }
    
    .message-text {
        font-size: 0.9rem;
    }
}

