/* 全局樣式 */
body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    font-family: 'JasonHandwriting1', 'Poppins', sans-serif;
    overflow: hidden;
    background-image: url('HappyBirthday.svg');
    background-size: cover;
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-position: center;
    position: relative;
}

/* 動態背景粒子效果 */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 80%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(255, 255, 255, 0.05) 0%, transparent 50%);
    animation: floatingParticles 20s ease-in-out infinite;
    pointer-events: none;
    z-index: 1;
}

@keyframes floatingParticles {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    33% { transform: translateY(-20px) rotate(120deg); }
    66% { transform: translateY(10px) rotate(240deg); }
}

.container {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    perspective: 1000px;
}

/* 信封樣式 */
.envelope {
    position: relative;
    width: min(80vw, calc(100vh * 1.2));
    height: min(55vw, calc(100vh * 0.8));
    background: linear-gradient(145deg, #f7d97c 0%, #e6b33e 100%);
    border: 3px solid #b8860b;
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 
      0 15px 30px rgba(0, 0, 0, 0.2),
      0 6px 12px rgba(0, 0, 0, 0.15),
      inset 0 0 50px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    z-index: 10;
    transform: perspective(1000px) rotateX(3deg);
}

.envelope:hover {
    transform: perspective(1000px) rotateX(0deg) scale(1.01);
    box-shadow: 
      0 25px 50px rgba(0, 0, 0, 0.2),
      0 12px 24px rgba(0, 0, 0, 0.15),
      inset 0 0 60px rgba(0, 0, 0, 0.15);
}

/* 信封翻蓋樣式 */
.flap {
    width: 100%;
    height: 0;
    padding-bottom: 68%;
    background: linear-gradient(145deg, #ffeb99 0%, #f7d97c 100%);
    clip-path: polygon(50% 58%, 0 0, 100% 0);
    transform-origin: top;
    transition: transform 0.6s ease-in-out;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 3;
    box-shadow: 
      0 4px 8px rgba(0, 0, 0, 0.1),
      inset 0 -2px 4px rgba(0, 0, 0, 0.1);
}

.flap-border {
    width: 100%;
    height: 0;
    padding-bottom: 68%;
    background: linear-gradient(145deg, #e6b33e 0%, #b8860b 100%);
    clip-path: polygon(50% 59%, -1% 0%, 101% 0%);
    transform-origin: top;
    transition: transform 0.6s ease-in-out;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    box-shadow: 
      0 2px 4px rgba(0, 0, 0, 0.1),
      inset 0 -1px 2px rgba(0, 0, 0, 0.1);
}

.flaplow {
    width: 100%;
    height: 0;
    padding-bottom: 68%;
    background: linear-gradient(145deg, #ffeb99 0%, #f7d97c 100%);
    clip-path: polygon(50% 58%, 0 0, 100% 0);
    transform-origin: top;
    transition: transform 0.6s ease-in-out;
    transform: scaleY(-1);
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1;
    box-shadow: 
      0 -4px 8px rgba(0, 0, 0, 0.1),
      inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.flaplow-border {
    width: 100%;
    height: 0;
    padding-bottom: 68%;
    background: linear-gradient(145deg, #e6b33e 0%, #b8860b 100%);
    clip-path: polygon(50% 59%, -1% 0%, 101% 0%);
    transform-origin: top;
    transition: transform 0.6s ease-in-out;
    transform: scaleY(-1);
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 0;
    box-shadow: 
      0 -2px 4px rgba(0, 0, 0, 0.1),
      inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* 卡片樣式 */
.card {
    position: absolute;
    width: min(85%, 860px);
    height: min(64%, 600px);
    background: linear-gradient(to bottom, #fff 0%, #f8f8f8 100%);
    border-radius: 15px;
    box-shadow: 
        0 8px 20px rgba(0, 0, 0, 0.15),
        0 2px 8px rgba(0, 0, 0, 0.1);
    
    top: 46%;
    left: 50%;
    transform: translate(-50%, -50%) translateY(150%);
    opacity: 0;
    
    transition: 
        transform 0.8s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.6s ease-in-out;

    text-align: center;
    padding: 5vw;
    display: flex;
    flex-direction: column;
    justify-content: center;
    z-index: 120;
}


.card p {
    font-size: min(4vw, 5vh);
    margin: 0;
    opacity: 0;
    font-family: 'ChenYuluoyan', 'JasonHandwriting1', sans-serif;
    color: #2a2a2a;
    background: linear-gradient(to bottom, #333 0%, #1a1a1a 100%);
    -webkit-background-clip: text;
    background-clip: text;
    text-shadow: 
        1px 1px 1px rgba(255, 255, 255, 0.3),
        -1px -1px 1px rgba(0, 0, 0, 0.7),
        2px 2px 2px rgba(206, 189, 189, 0.1),
        -2px -2px 2px rgba(0, 0, 0, 0.1),
        0 1px 3px rgba(0, 0, 0, 0.2);
    position: relative;
    letter-spacing: 0.03em;
    font-weight: 500;
}


.card p::before {
    content: attr(data-text);
    position: absolute;
    left: 0;
    top: 0;
    z-index: -1;
    background: linear-gradient(45deg, 
        rgba(255,255,255,0.1) 0%,
        rgba(255,255,255,0.05) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    text-shadow: none;
    filter: blur(0.3px);
}

/* 底部訊息樣式 */
.bottom-message {
    position: absolute;
    bottom: 20px;
    width: 100%;
    text-align: center;
    font-size: min(1.5vw, 2vh);
    color: #666;
    text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.5);
    top: 92%;
}

/* 動畫狀態 */
.envelope.open .flap {
    transform: rotateX(180deg);
}

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

.envelope.open .flaplow {
    transform: rotateY(-180deg);
}

.envelope.open .flaplow-border {
    transform: rotateY(-180deg);
}

.envelope.open .card {
    transform: translate(-50%, -50%) translateY(0) rotateY(0deg);
    opacity: 1;
}

.envelope.closed .flap {
    transform: rotateX(0);
}

.envelope.closed .card {
    transform: translate(-50%, -50%) translateY(150%);
    opacity: 0;
}

/* 開啟提示文字 */
.envelope .open-text {
    position: absolute;
    top: 60%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: min(2vw, 3vh);
    font-weight: bold;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 
      2px 2px 4px rgba(0, 0, 0, 0.3),
      0 0 10px rgba(255, 255, 255, 0.5);
    animation: gentlePulse 2s ease-in-out infinite;
    z-index: 100;
}

@keyframes gentlePulse {
    0% { 
        opacity: 1; 
        transform: translate(-50%, -50%) scale(1);
    }
    50% { 
        opacity: 0.7; 
        transform: translate(-50%, -50%) scale(0.98);
    }
    100% { 
        opacity: 1; 
        transform: translate(-50%, -50%) scale(1);
    }
}

/* 響應式設計 */
@media (max-width: 600px) {
    body {
        background-image: url('HappyBirthday-phone.svg');
        background-size: cover;
        background-repeat: no-repeat;
        background-attachment: fixed;
        background-position: center;
    }

    .envelope {
        width: 90vw;
        height: 60vw;
        transform: perspective(1000px) rotateX(2deg);
    }
    
    .envelope:hover {
        transform: perspective(1000px) rotateX(0deg) scale(1.01);
    }
    
    .card {
        padding: 6vw;
        width: min(90%, 400px);
        height: min(70%, 500px);
    }
    
    .card p {
        font-size: min(5vw, 4vh);
        line-height: 1.3;
    }
    
    .open-text {
        font-size: min(6vw, 5vh);
        top: 65%;
    }

    .bottom-message {
        top: 88%;
        font-size: min(3vw, 2vh);
    }
    
    footer {
        font-size: min(3vw, 2vh);
        padding: 3px 10px;
    }
    
    .marquee-content {
        font-size: 14px;
        padding: 6px 0;
    }
    
    /* 移動端粒子效果調整 */
    .particle {
        width: 3px;
        height: 3px;
    }
    
    .heart-particle {
        width: 8px;
        height: 8px;
    }
    
    .heart-particle:before,
    .heart-particle:after {
        width: 8px;
        height: 8px;
    }
}

/* 平板設計 */
@media (min-width: 601px) and (max-width: 1024px) {
    .envelope {
        width: 75vw;
        height: 50vw;
    }
    
    .card {
        padding: 4vw;
        width: min(80%, 600px);
        height: min(60%, 450px);
    }
    
    .card p {
        font-size: min(3.5vw, 4vh);
    }
    
    .open-text {
        font-size: min(3vw, 4vh);
    }
}

/* 署名樣式 */
#name {
    display: block;
    text-align: left;
}

#last {
    display: block;
    text-align: right;
}

/* 字體設定 */
@font-face {
    font-family: 'ChenYuluoyan';
    src: url('ChenYuluoyan.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: JasonHandwriting1;
    src: url('JasonHandwriting1.ttf') format('truetype');
    font-display: swap;
}

footer {
    position: absolute;
    bottom: 0px;
    width: 100%;
    text-align: center;
    font-size: min(1.5vw, 2vh);
    text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.5);
}

.envelope .text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: min(4vw, 5vh);
    font-weight: bold;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    z-index: 100;
}

.marquee-container {
    position: fixed;
    width: 100vw;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 16px;
    padding: 5px 0;
    top: 0;
    z-index: 1000;
}

.marquee-content {
    display: inline-block;
    white-space: nowrap;
    padding-left: 100%;
    animation: marquee 10s linear infinite;
}

@keyframes marquee {
    0% { 
        transform: translateX(0);
    }
    100% { 
        transform: translateX(-100%);
    }
}

/* 浮動粒子效果 */
.floating-particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.8) 0%, transparent 70%);
    border-radius: 50%;
    animation: floatUp 8s linear infinite;
}

.particle:nth-child(odd) {
    background: radial-gradient(circle, rgba(255, 182, 193, 0.6) 0%, transparent 70%);
    animation-duration: 10s;
}

.particle:nth-child(3n) {
    background: radial-gradient(circle, rgba(173, 216, 230, 0.6) 0%, transparent 70%);
    animation-duration: 12s;
}

@keyframes floatUp {
    0% {
        transform: translateY(100vh) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-100px) rotate(360deg);
        opacity: 0;
    }
}

/* 心形粒子效果 */
.heart-particle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #ff6b6b;
    transform: rotate(-45deg);
    animation: heartFloat 6s ease-in-out infinite;
}

.heart-particle:before,
.heart-particle:after {
    content: '';
    width: 10px;
    height: 10px;
    position: absolute;
    left: 5px;
    top: 0;
    background: #ff6b6b;
    border-radius: 50%;
    transform: rotate(-45deg);
    transform-origin: 0 50%;
}

.heart-particle:after {
    left: 0;
    top: -5px;
    transform-origin: 50% 50%;
}

@keyframes heartFloat {
    0% {
        transform: translateY(100vh) rotate(-45deg) scale(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
        transform: translateY(90vh) rotate(-45deg) scale(1);
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-50px) rotate(-45deg) scale(0);
        opacity: 0;
    }
}