/* -------------------------------------------------------------
   Apology Website Stylesheet
   ------------------------------------------------------------- */

/* Reset & Variable Setup */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-start: #fdfbfb;
    --bg-end: #ebedee;
    --color-primary: #ff5e7e;
    --color-primary-dark: #e04a69;
    --color-text-dark: #2d2d2d;
    --color-text-muted: #5e6e7a;
    --color-card-bg: rgba(255, 255, 255, 0.95);
    --font-ui: 'Fredoka', 'Quicksand', sans-serif;
    --font-handwritten: 'Caveat', 'Playpen Sans', cursive;
}

body {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: var(--font-ui);
    background: linear-gradient(180deg, var(--bg-start) 0%, var(--bg-end) 100%);
    color: var(--color-text-dark);
    position: relative;
}

/* Floating Hearts Background */
.heart-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.floating-heart {
    position: absolute;
    bottom: -50px;
    font-size: 20px;
    color: rgba(255, 94, 126, 0.25);
    animation: floatUp 6s linear infinite;
    user-select: none;
}

@keyframes floatUp {
    0% {
        transform: translateY(0) rotate(0deg) scale(0.8);
        opacity: 0;
    }
    10% {
        opacity: 0.8;
    }
    90% {
        opacity: 0.8;
    }
    100% {
        transform: translateY(-110vh) rotate(360deg) scale(1.2);
        opacity: 0;
    }
}

.main-container {
    width: 100%;
    max-width: 440px;
    height: 100vh;
    height: 100dvh;
    padding: clamp(10px, 3vh, 20px);
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
    perspective: 1000px;
    overflow: hidden;
}

/* Premium Card Styles */
.card {
    background: var(--color-card-bg);
    border-radius: 24px;
    padding: clamp(20px, 3.5vh, 35px) clamp(20px, 5vw, 30px);
    width: 100%;
    max-height: 95vh;
    max-height: 95dvh;
    overflow: hidden;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.05), 0 5px 15px rgba(0, 0, 0, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    text-align: center;
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.intro-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(15px, 3vh, 25px);
}

.intro-title {
    font-size: clamp(1.4rem, 3.5vh, 1.8rem);
    font-weight: 700;
    color: var(--color-text-dark);
    line-height: 1.3;
}

.gif-container {
    width: 100%;
    max-width: clamp(150px, 28vh, 220px);
    border-radius: 16px;
    overflow: hidden;
    margin: clamp(5px, 1.5vh, 10px) 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.apology-gif {
    width: 100%;
    height: auto;
    object-fit: cover;
}

.intro-subtitle {
    font-size: clamp(1.05rem, 2.5vh, 1.3rem);
    color: var(--color-text-dark);
    font-weight: 600;
}

.highlight-red {
    color: #ff3366;
    font-weight: 700;
}

/* Custom Buttons */
.btn {
    font-family: var(--font-ui);
    border: none;
    border-radius: 50px;
    padding: clamp(10px, 2vh, 14px) clamp(24px, 4vw, 36px);
    font-size: clamp(0.95rem, 2.2vh, 1.1rem);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary) 0%, #ff2a5f 100%);
    color: #fff;
    box-shadow: 0 6px 20px rgba(255, 94, 126, 0.3);
}

.btn-primary:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 25px rgba(255, 94, 126, 0.4);
}

.btn-primary:active {
    transform: translateY(-1px) scale(1.02);
}

.pulse-btn {
    animation: pulseGlow 2s infinite;
}

@keyframes pulseGlow {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 94, 126, 0.4);
    }
    70% {
        box-shadow: 0 0 0 15px rgba(255, 94, 126, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 94, 126, 0);
    }
}

/* -------------------------------------------------------------
   3D Envelope Animations
   ------------------------------------------------------------- */
.envelope-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 100%;
}

.envelope-wrapper {
    position: relative;
    width: 280px;
    height: 180px;
    cursor: pointer;
    background: transparent;
}

.envelope {
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: #ffdde2;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
    transition: transform 0.5s ease;
}

.envelope::before {
    content: '';
    position: absolute;
    z-index: 4;
    border-left: 140px solid transparent;
    border-right: 140px solid transparent;
    border-bottom: 90px solid #ffccd4;
    bottom: 0;
    left: 0;
    border-radius: 0 0 8px 8px;
}

.envelope::after {
    content: '';
    position: absolute;
    z-index: 4;
    border-top: 90px solid transparent;
    border-bottom: 90px solid transparent;
    border-left: 140px solid #ffb3c1;
    top: 0;
    left: 0;
}

/* Envelope Flap */
.flap {
    position: absolute;
    width: 0;
    height: 0;
    border-left: 140px solid transparent;
    border-right: 140px solid transparent;
    border-top: 90px solid #ffa3b1;
    top: 0;
    left: 0;
    z-index: 5;
    transform-origin: top;
    transition: transform 0.4s ease 0.2s, z-index 0.2s ease 0.2s;
}

/* Letter Preview Inside Envelope */
.letter-preview {
    position: absolute;
    left: 20px;
    bottom: 10px;
    width: 240px;
    height: 140px;
    background-color: #fffefc;
    border-radius: 4px;
    z-index: 2;
    padding: 15px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.02);
    transition: transform 0.6s ease;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.letter-line {
    height: 8px;
    background-color: #f1f3f5;
    border-radius: 4px;
}

.line-1 { width: 60%; background-color: #ffccd4; }
.line-2 { width: 90%; }
.line-3 { width: 75%; }

/* Open State Animations */
.envelope-wrapper:hover .envelope {
    transform: translateY(-5px);
}

.envelope-wrapper.open .flap {
    transform: rotateX(180deg);
    z-index: 1;
    transition: transform 0.4s ease, z-index 0.2s ease 0.2s;
}

.envelope-wrapper.open .letter-preview {
    transform: translateY(-80px);
    z-index: 3;
    transition: transform 0.6s ease 0.3s;
}

.envelope-instruction {
    font-size: 1.1rem;
    color: var(--color-text-muted);
    font-weight: 600;
    margin-top: 10px;
    animation: breathe 2s infinite ease-in-out;
}

@keyframes breathe {
    0%, 100% { opacity: 0.7; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.03); }
}

/* -------------------------------------------------------------
   Apology Letter Styling
   ------------------------------------------------------------- */
.letter-container {
    width: 100%;
    max-width: 440px;
    max-height: 96vh;
    max-height: 96dvh;
    perspective: 1200px;
    display: flex;
    justify-content: center;
    overflow: hidden;
}

.letter-paper {
    background: #fffefb;
    background-image: radial-gradient(#eceae4 1px, transparent 1px);
    background-size: 20px 20px;
    border-radius: 12px;
    padding: clamp(10px, 2vh, 22px) clamp(15px, 4vw, 25px);
    width: 100%;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 15px 45px rgba(0, 0, 0, 0.08), 0 5px 15px rgba(0, 0, 0, 0.04);
    border: 1px solid #f2eedb;
    font-family: var(--font-handwritten);
    position: relative;
    transform-origin: top center;
    transition: transform 0.8s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.8s ease;
    overflow: hidden;
}

/* Lined Paper Lines */
.letter-paper::before {
    content: '';
    position: absolute;
    top: 0;
    left: clamp(25px, 7vw, 40px);
    width: 1.5px;
    height: 100%;
    background-color: rgba(255, 90, 143, 0.35);
}

.letter-header {
    margin-bottom: clamp(4px, 1.2vh, 12px);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.letter-title {
    font-family: var(--font-handwritten);
    font-size: clamp(1.6rem, 3.8vh, 2.4rem);
    font-weight: 700;
    color: #1e293b;
    margin-bottom: clamp(1px, 0.2vh, 4px);
    letter-spacing: 0.5px;
    line-height: 1.1;
}

/* SVG Hearts Drawing */
.hearts-svg-container {
    width: 100%;
    height: clamp(35px, 6.5vh, 60px);
    display: flex;
    justify-content: center;
    margin: 1px 0;
}

.hearts-svg {
    width: 100%;
    height: 100%;
}

.svg-annotation {
    font-family: var(--font-handwritten);
    font-size: 1.1rem;
    fill: #5e6e7a;
    font-weight: 600;
}

.italic-anno {
    font-style: italic;
    fill: #2d2d2d;
}

.arrow-path {
    stroke-dasharray: 6;
    animation: dash 30s linear infinite;
}

@keyframes dash {
    to {
        stroke-dashoffset: -1000;
    }
}

/* Poem Styling */
.poem-container {
    display: flex;
    flex-direction: column;
    gap: clamp(1px, 0.2vh, 3px);
    padding-left: clamp(12px, 5vw, 20px); /* Stay to the right of red margin line */
}

.poem-line {
    font-size: clamp(0.92rem, 1.95vh, 1.25rem);
    line-height: 1.3;
    color: #2d3748;
    min-height: clamp(1.05rem, 2.1vh, 1.35rem);
}

.poem-word {
    display: inline-block;
    opacity: 0;
    transform: translateY(3px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.poem-word.reveal {
    opacity: 1;
    transform: translateY(0);
}

.spacer-line {
    height: clamp(3px, 0.8vh, 8px);
}

/* Forgive Interaction Inside Letter */
.forgive-section {
    margin-top: clamp(6px, 1.4vh, 16px);
    padding-left: clamp(12px, 5vw, 20px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(5px, 1vh, 10px);
    width: 100%;
    transition: opacity 0.5s ease;
}

.forgive-question {
    font-size: clamp(1.15rem, 2.3vh, 1.4rem);
    font-weight: 700;
    color: #1a202c;
    text-align: center;
}

.btn-group {
    display: flex;
    gap: 20px;
    position: relative;
    width: 100%;
    justify-content: center;
    min-height: clamp(34px, 5.5vh, 46px);
}

.btn-yes {
    background: #ff5a8f;
    color: white;
    z-index: 10;
}

.btn-yes:hover {
    transform: scale(1.1);
    background: #e02868;
}

.btn-no {
    background: #e2e8f0;
    color: #4a5568;
    border: 1px solid #cbd5e0;
    transition: none; /* No transition for dodging to make it instantly jump */
}

/* -------------------------------------------------------------
   Success Screen Styling
   ------------------------------------------------------------- */
.success-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    border: 1px solid rgba(255, 255, 255, 0.9);
}

.success-title {
    font-size: 2.2rem;
    color: #ff2a5f;
    font-weight: 700;
    animation: heartBeat 1.2s infinite;
}

.success-subtitle {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--color-text-dark);
}

.success-footer {
    font-family: var(--font-handwritten);
    font-size: 1.5rem;
    color: var(--color-primary-dark);
    margin-top: 5px;
}

@keyframes heartBeat {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Hidden Element Helpers */
.hidden {
    display: none !important;
}

.hidden-element {
    opacity: 0;
    pointer-events: none;
}

.show-element {
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* -------------------------------------------------------------
   Music Controller
   ------------------------------------------------------------- */
.music-controller {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
}

.music-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--color-card-bg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.8);
}

.music-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

.music-btn.playing {
    background: var(--color-primary);
    color: white;
    animation: rotateMusic 4s linear infinite;
}

@keyframes rotateMusic {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Responsive Scaling adjustments */
@media (max-width: 480px) {
    .intro-title {
        font-size: 1.5rem;
    }
    
    .intro-subtitle {
        font-size: 1.1rem;
    }
    
    .letter-title {
        font-size: 2.2rem;
    }
    
    .poem-line {
        font-size: 1.2rem;
    }
    
    .forgive-question {
        font-size: 1.4rem;
    }
}
