/* ===== 커스텀 폰트 설정 (KirangHaerang) ===== */
@font-face {
    font-family: "KirangHaerang";
    src: url("KirangHaerang-Regular.ttf") format("truetype");
    font-weight: normal;
    font-style: normal;
}

/* ===== 공통 기본 스타일 ===== */
:root {
    --bg-color: #02091a;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
        sans-serif;
    background: var(--bg-color);
    color: #fff;
    min-height: 100vh;
    overflow: hidden;
}

/* ===== 메인 제목 (크리스마스 땡땡이 텍스트) ===== */
.page-title {
    font-family: "KirangHaerang", system-ui, sans-serif;
    font-size: 46px;
    margin: 16px 0;
    text-align: center;
    letter-spacing: 2px;

    /* 🔴 글자 기본 색 (빨강) + 🟢 초록 땡땡이 패턴 */
    background-color: #ff3b3b;
    background-image:
        radial-gradient(circle, #2ecc71 20%, transparent 21%),
        radial-gradient(circle, #2ecc71 20%, transparent 21%);
    background-size: 18px 18px;
    background-position: 0 0, 9px 9px;

    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;

    display: inline-block;
    position: relative;
    padding: 0 10px;
}

/* ❄ 좌우 눈송이 */
.page-title::before,
.page-title::after {
    content: "❄";
    position: relative;
    top: -2px;
    font-size: 28px;
    color: white;
    text-shadow:
        0 0 6px rgba(255, 255, 255, 0.6),
        0 0 14px rgba(200, 240, 255, 0.8);
}

.page-title::before {
    margin-right: 10px;
}
.page-title::after {
    margin-left: 10px;
}

/* 작은 화면에서 글씨 조금 줄이기 */
@media (max-width: 380px) {
    .page-title {
        font-size: 28px;
    }
}

/* ===== 중앙 정렬 레이아웃 ===== */
.center-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    text-align: center;
    position: relative;
    padding: 20px;
}

/* view.html에서만 위 여백 줄이기 */
.view-layout {
    justify-content: flex-start;
    padding-top: 16px;
    gap: 12px;
}

/* 일반 텍스트 */
.center-wrapper > p {
    opacity: 0.9;
    margin-bottom: 16px;
}

/* ===== 공통 버튼 ===== */
.btn {
    margin-top: 16px;
    padding: 10px 22px;
    border-radius: 999px;
    border: none;
    background: #ff4d6a;
    color: white;
    font-size: 15px;
    cursor: pointer;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.25);
    transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
    font-family: "KirangHaerang", system-ui, sans-serif;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35);
    background: #ff6f86;
}

.btn-small {
    margin-top: 0;
    padding: 7px 14px;
    font-size: 13px;
}

/* ===== 눈 내리는 배경 ===== */
.snow-layer {
    pointer-events: none;
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    z-index: -1;
    background-image:
        radial-gradient(2px 2px at 10px 10px, rgba(255, 255, 255, 0.8) 50%, transparent 50%),
        radial-gradient(3px 3px at 50px 80px, rgba(255, 255, 255, 0.8) 50%, transparent 50%),
        radial-gradient(2px 2px at 120px 40px, rgba(255, 255, 255, 0.8) 50%, transparent 50%),
        radial-gradient(3px 3px at 200px 150px, rgba(255, 255, 255, 0.8) 50%, transparent 50%);
    background-repeat: repeat;
    background-size: 200px 200px;
    opacity: 0.7;
    animation: snowfall 18s linear infinite;
}

.snow-layer.slow {
    animation-duration: 26s;
    opacity: 0.4;
}
.snow-layer.fast {
    animation-duration: 12s;
    opacity: 0.9;
}

@keyframes snowfall {
    0%   { transform: translate3d(0, 0, 0); }
    100% { transform: translate3d(0, 50%, 0); }
}

/* ===== index.html : 선물 상자 ===== */

.gift-box {
    width: 220px;
    height: auto;
    cursor: pointer;
    animation: gift-shake 1.3s ease-in-out infinite;
    filter: invert(1) brightness(1000%);
    transition: transform 0.4s ease, opacity 0.4s ease;
}

.gift-box.opening {
    animation: none;
    transform: scale(1.1) translateY(-10px);
    opacity: 0;
}

/* 흔들리는 애니메이션 */
@keyframes gift-shake {
    0%   { transform: translateX(0) rotate(0deg); }
    20%  { transform: translateX(-4px) rotate(-2deg); }
    40%  { transform: translateX(4px) rotate(2deg); }
    60%  { transform: translateX(-3px) rotate(-1.5deg); }
    80%  { transform: translateX(3px) rotate(1.5deg); }
    100% { transform: translateX(0) rotate(0deg); }
}

.gift-caption {
    margin-top: 16px;
    font-size: 18px;
}

/* ===== write.html : 편지 작성 폼 ===== */

.letter-container {
    max-width: 800px;
    width: 100%;
    background: rgba(0, 0, 0, 0.35);
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    text-align: left;
}

.letter-container label {
    font-size: 14px;
    display: block;
    margin-bottom: 4px;
}

.form-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.form-row input {
    width: 100%;
    padding: 8px 10px;
    border-radius: 999px;
    border: none;
    outline: none;
    font-size: 14px;
}

textarea {
    width: 100%;
    min-height: 220px;
    margin-top: 6px;
    padding: 12px 14px;
    border-radius: 18px;
    border: none;
    resize: vertical;
    outline: none;
    font-size: 15px;
    line-height: 1.6;
    font-family: inherit;
}

.helper-text {
    margin-top: 10px;
    font-size: 13px;
    opacity: 0.85;
}

/* ===== view.html : 링크 표시 박스 ===== */

.link-box {
    display: flex;
    gap: 8px;
    align-items: center;
    margin: 8px 0 16px;
    width: min(600px, 100%);
}

.link-box input {
    flex: 1;
    padding: 8px 10px;
    border-radius: 999px;
    border: none;
    outline: none;
    font-size: 12px;
    color: #333;
}

/* 선물 받는 손 아이콘 */
.gift-hand {
    width: 140px;
    margin-top: 4px;
    margin-bottom: 10px;
    filter: invert(1) brightness(1000%);
    opacity: 0.9;
}

/* ===== view.html : 봉투 + 편지지 ===== */

.envelope-wrapper {
    position: relative;
    width: 320px;
    height: 220px;
    margin-bottom: 10px;
    perspective: 1000px;
    cursor: pointer;
}

/* 봉투 바디 */
.envelope-base {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #ff4d6a, #ffaf4d);
    border-radius: 16px;
    box-shadow: 0 16px 30px rgba(0, 0, 0, 0.6);
}

/* 봉투 덮개 (처음엔 닫힘) */
.envelope-flap {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 60%;
    background: linear-gradient(135deg, #ff6f86, #ffd09b);
    border-radius: 16px 16px 60px 60px;
    transform-origin: top center;
    transform: rotateX(0deg);
}

/* 편지지(안에 들어가는 종이) */
.letter-paper {
    position: absolute;
    left: 10%;
    top: 40%;
    width: 80%;
    height: 70%;
    background: #fffdf5;
    border-radius: 14px;
    padding: 16px 18px;
    color: #333;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: translateY(40%);
    /* 줄 있는 메모지 느낌 */
    background-image:
        repeating-linear-gradient(
            to bottom,
            rgba(0, 0, 0, 0.04) 0,
            rgba(0, 0, 0, 0.04) 1px,
            transparent 1px,
            transparent 22px
        );
}

.letter-to {
    font-size: 14px;
    margin-bottom: 8px;
    color: #666;
    font-weight: 600;
}

.letter-message {
    font-size: 14px;
    line-height: 1.7;
    margin-bottom: 6px;
    white-space: normal;
}

.letter-from {
    font-size: 14px;
    text-align: right;
    margin-top: 10px;
    color: #666;
}

/* 봉투 열릴 때 애니메이션 적용 */
.envelope-wrapper.open .envelope-flap {
    animation: flap-open 0.8s ease-out forwards;
}

.envelope-wrapper.open .letter-paper {
    animation: paper-rise 0.7s 0.25s ease-out forwards;
}

/* 덮개가 탁! 열리는 모션 */
@keyframes flap-open {
    0%   { transform: rotateX(0deg); }
    60%  { transform: rotateX(-115deg); }
    80%  { transform: rotateX(-95deg); }
    100% { transform: rotateX(-120deg); }
}

/* 편지지가 봉투 안에서 위로 쑥 올라오는 모션 */
@keyframes paper-rise {
    0%   { opacity: 0; transform: translateY(40%); }
    100% { opacity: 1; transform: translateY(-10%); }
}

/* 봉투 아래 안내 문구 */
.envelope-hint {
    font-size: 13px;
    opacity: 0.85;
    margin-bottom: 24px;
}

/* ===========================
   모바일 반응형 튜닝
   =========================== */

/* 태블릿 & 작은 화면 공통 */
@media (max-width: 900px) {
    .center-wrapper {
        padding: 24px 16px;
    }

    .page-title {
        font-size: 32px;
        margin-top: 16px;
        text-align: center;
    }

    .center-wrapper > p {
        font-size: 14px;
    }

    .letter-container {
        margin-top: 16px;
        padding: 18px 16px;
        border-radius: 20px;
    }

    textarea {
        min-height: 180px;
        font-size: 14px;
    }

    .gift-box {
        width: 180px;
    }
}

/* 진짜 모바일(폰) 기준 */
@media (max-width: 600px) {
    /* 링크박스를 세로로 쌓기 */
    .link-box {
        flex-direction: column;
        align-items: stretch;
        margin-top: 10px;
    }

    .link-box input {
        font-size: 11px;
    }

    .btn.btn-small {
        align-self: flex-end;
        padding: 7px 16px;
        font-size: 12px;
    }

    .envelope-wrapper {
        transform: scale(0.9);
        margin-bottom: 20px;
    }

    .letter-paper {
        padding: 12px 14px;
        font-size: 13px;
    }

    .letter-message {
        font-size: 13px;
        line-height: 1.6;
    }

    .gift-hand {
        width: 100px;
        margin-bottom: 8px;
    }
}

/* 아주 작은 화면 (아이폰 SE 등) */
@media (max-width: 380px) {
    .center-wrapper > p {
        font-size: 13px;
    }

    .envelope-wrapper {
        transform: scale(0.8);
    }
}
