/* --- CSS VARIABLES (THEME BASE) --- */
:root {
    /* Main Colors */
    --primary-color: #ff4d6d;
    --secondary-color: #ffb3c1;
    --bg-gradient: radial-gradient(circle at center, #2b1029 0%, #1a0b18 60%, #000000 100%);
    --card-bg: rgba(20, 20, 35, 0.65);
    
    /* Text Colors */
    --text-color: #eaeaea;        
    --heading-color: #ff8fa3;     
    --h2-shadow-color: #ff4d6d; 
    
    /* Effects */
    /* [UPDATED] Trail Gradient (Fixed dark tail issue) */
    --trail-gradient: linear-gradient(to right, rgba(162, 210, 255, 0.01), rgba(162, 210, 255, 0.8));
    --glow-shadow: 0 0 15px rgba(255, 77, 109, 0.6);
    --heart-bg-fill: rgba(255, 77, 109, 0.15);
    
    /* Filter */
    --heart-filter: none; 

    /* Sizes */
    --main-heart-size: 120px; 
    --mini-heart-size: 20px;

    /* Image Ratio Config (Width / Height) */
    --img-ratio: 9/11; 
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    /* [UPDATED] ป้องกันการกดค้างแล้วขึ้นเมนู Copy/Select บนมือถือ */
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none; /* iOS Safari */
    -webkit-user-select: none; /* Safari */
    -khtml-user-select: none; /* Konqueror HTML */
    -moz-user-select: none; /* Old Firefox */
    -ms-user-select: none; /* Internet Explorer/Edge */
    user-select: none; /* Non-prefixed version, currently supported by Chrome, Opera and Firefox */
}

body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100dvh;
    overflow: hidden;
    font-family: 'Prompt', sans-serif;
    background: var(--bg-gradient); 
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-color);
    /* [UPDATED] ป้องกันการ Scroll เด้งๆ (Rubber banding) บน Chrome/Safari Mobile */
    overscroll-behavior: none;
    touch-action: none; /* ปิด Default touch action (เช่นการเลื่อน) */
}

/* --- Screens --- */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: opacity 0.8s ease;
}

#unlock-screen { z-index: 10; }

.unlock-instruction {
    color: var(--text-color);
    font-size: 1.2rem;
    margin-bottom: 2rem;
    text-shadow: 0 0 10px var(--primary-color); 
    opacity: 1;
    pointer-events: none; 
    transition: opacity 0.5s ease;
    animation: pulse-text 1s infinite alternate; 
}

/* [NEW] Sound Instruction Styles */
.sound-instruction {
    position: absolute;
    bottom: 40px; /* อยู่ด้านล่าง */
    left: 50%;
    transform: translateX(-50%);
    
    display: flex;
    align-items: center;
    gap: 8px;
    
    color: var(--text-color);
    font-size: 1rem;
    opacity: 0.8;
    pointer-events: none;
    transition: opacity 0.5s ease;
}
.sound-instruction svg {
    color: var(--primary-color);
    filter: drop-shadow(0 0 5px var(--primary-color));
    animation: pulse-icon 1.5s infinite;
}

/* Common fade-out class */
.unlock-instruction.fade-out,
.sound-instruction.fade-out {
    opacity: 0;
}

/* --- Big Heart --- */
.big-heart-wrapper {
    width: var(--main-heart-size);
    height: var(--main-heart-size);
    position: relative;
    cursor: pointer;
    z-index: 10;
}

.big-heart-wrapper:active { transform: scale(0.95); }

.heart-svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(var(--glow-shadow));
}

.heart-outline {
    stroke: var(--text-color); 
    stroke-width: 3px;
    filter: drop-shadow(0 0 2px rgba(0,0,0,0.3));
    fill: var(--heart-bg-fill); 
}

.heart-fill {
    fill: var(--primary-color); 
    transition: clip-path 0.1s linear;
}

/* --- Flying Hearts & Particles --- */
.flying-heart, 
.explosion-particle {
    position: fixed;
    top: 0; left: 0;
    pointer-events: none;
    z-index: 20;
    display: flex; 
    justify-content: center; 
    align-items: center;
    opacity: 0;
    /* [UPDATED] ลบ fontSize ออก เพราะจะใช้ width/height แทน */
    /* font-size: var(--mini-heart-size); */ 
    
    /* [UPDATED] ใช้รูปภาพแทน Text Color */
    /* color: var(--primary-color); */
    
    background-image: url('./assets/miniheart.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    
    /* ถ้าจะให้เงายังทำงานกับรูป PNG ต้องใช้ drop-shadow filter */
    filter: drop-shadow(0 0 5px var(--primary-color));
    
    will-change: transform, opacity;
}
.explosion-particle { z-index: 40; }

.flying-heart::after,
.explosion-particle::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 10%;
    width: 60px; 
    height: 4px; 
    background: var(--trail-gradient);
    box-shadow: var(--glow-shadow);
    transform-origin: right center;
    transform: translate(-100%, -50%);
    border-radius: 10px;
    z-index: -1;
    pointer-events: none;
    
    /* Mask Image for smooth trail fade */
    -webkit-mask-image: linear-gradient(to right, transparent 0%, #333333 40%, black 100%);
    mask-image: linear-gradient(to right, transparent 0%, #333333 80%, black 100%);
}

/* --- Content Screen --- */
#content-screen {
    z-index: 50;
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
    transition: opacity 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#content-screen.active {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.content-card {
    width: 380px;  
    height: auto;  
    min-height: 600px; 
    max-width: none;
    max-height: none;
    
    background: var(--card-bg); 
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border-radius: 30px;
    padding: 25px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
    
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    
    position: absolute;
    top: 50%;
    left: 50%;
    transform-origin: center center; 
    transform: translate(-50%, -50%) scale(1); 
    
    overflow: visible; 
    will-change: transform;
}

.photo-area { width: 100%; margin-bottom: 20px; }
.img-wrapper {
    width: 100%;
    aspect-ratio: var(--img-ratio);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
    position: relative; 
}

.img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    transition: opacity 1s ease;
    will-change: opacity;
}

.img-wrapper img.visible {
    opacity: 1;
    z-index: 10; 
}

.img-wrapper img.fade-in {
    opacity: 1;
    z-index: 20; 
}

.text-area h2 {
    margin: 0 0 10px 0;
    font-family: 'Mali', cursive;
    font-size: 1.8rem;
    color: var(--heading-color); 
    text-shadow: 0 0 10px var(--h2-shadow-color); 
    transition: opacity 0.5s ease;
    opacity: 1;
}
.text-area h2.hidden {
    opacity: 0;
}

.text-area p {
    margin: 0 0 20px 0;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text-color); 
}

/* --- Music Player --- */
.music-player {
    width: 100%;
    background: rgba(0, 0, 0, 0.2); 
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 20px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2); 
}
.progress-bar-bg {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    margin-bottom: 15px;
    cursor: default; 
    pointer-events: none; 
    overflow: hidden;
}
.progress-bar-fill {
    width: 0%;
    height: 100%;
    background: var(--primary-color); 
    border-radius: 3px;
    transition: width 0.1s linear;
    box-shadow: 0 0 10px var(--primary-color); 
}

.controls {
    display: flex;
    justify-content: space-between; 
    align-items: center;
    color: rgba(255, 255, 255, 0.8);
}

.play-container {
    display: flex;
    align-items: center;
    gap: 15px; 
    font-size: 0.8rem;
    font-weight: 300;
}

.time { min-width: 35px; text-align: center; }

.control-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    padding: 5px;
    transition: color 0.2s, transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.control-btn:hover {
    color: var(--primary-color);
    transform: scale(1.1);
}
.control-btn:active { transform: scale(0.9); }
.small-btn svg { width: 24px; height: 24px; }

.icon-play-btn {
    background: var(--primary-color); 
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    color: var(--btn-icon-color);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 0 15px var(--primary-color); 
    transition: transform 0.2s, background 0.2s, box-shadow 0.2s;
}
.icon-play-btn:hover {
    transform: scale(1.1);
    background: var(--secondary-color); 
    box-shadow: 0 0 25px var(--primary-color); 
}
.icon-play-btn svg { width: 24px; height: 24px; }
.icon-play-btn:active { transform: scale(0.9); }

.typing-cursor::after {
    content: '|';
    animation: blink 1s step-start infinite;
    color: var(--primary-color);
    margin-left: 2px;
}

#main-image, #sub-text {
    transition: opacity 1s ease, transform 1s ease;
    opacity: 1;
    transform: scale(1);
}

.content-hidden {
    opacity: 0;
    transform: scale(0.95);
}

#prev-btn, #next-btn {
    opacity: 0.5; 
    pointer-events: none; 
    cursor: default;
}

#sub-text {
    transition: opacity 0.5s ease;
    opacity: 1;
}
.content-hidden {
    opacity: 0;
}

/* --- Animations --- */
@keyframes pulse-text {
    0% { opacity: 0.6; transform: scale(0.95); }
    50% { opacity: 1; transform: scale(1); }
    100% { opacity: 0.6; transform: scale(0.95); }
}

@keyframes pulse-icon {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

@keyframes heartbeat {
    0% { transform: scale(1); }
    8% { transform: scale(1.15); }
    16% { transform: scale(1); }
    24% { transform: scale(1.15); }
    32% { transform: scale(1); }
    50% { transform: scale(1); }
    58% { transform: scale(1.15); }
    66% { transform: scale(1); }
    74% { transform: scale(1.15); }
    82% { transform: scale(1); }
    100% { transform: scale(1); }
}
.big-heart-wrapper.heartbeat { animation: heartbeat 2.4s infinite ease-in-out; }

@keyframes explode-final {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(8); opacity: 0; }
}
.big-heart-wrapper.exploded { animation: explode-final 1s forwards ease-out; }

@keyframes blink {
    50% { opacity: 0; }
}