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

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

:root {
    --bg-start: #fff5f7;
    --bg-end: #ffe3e8;
    --color-primary: #ff4d6d;
    --color-primary-dark: #c9184a;
    --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
   ------------------------------------------------------------- */
/* -------------------------------------------------------------
   Anniversary Screen Styling
   ------------------------------------------------------------- */
.anniversary-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(15px, 3vh, 25px);
    border: 1px solid rgba(255, 255, 255, 0.9);
}

.anniversary-title {
    font-size: clamp(1.8rem, 4vh, 2.5rem);
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1.3;
    animation: heartBeat 1.5s infinite ease-in-out;
    text-shadow: 0 2px 10px rgba(255, 77, 109, 0.15);
}

.anniversary-subtitle {
    font-size: clamp(1.1rem, 2.5vh, 1.35rem);
    color: var(--color-text-dark);
    font-weight: 600;
    line-height: 1.5;
    margin: 5px 0;
}

/* -------------------------------------------------------------
   Gallery Screen Styling
   ------------------------------------------------------------- */
.gallery-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(15px, 2.5vh, 25px);
    border: 1px solid rgba(255, 255, 255, 0.9);
}

.gallery-title {
    font-size: clamp(1.8rem, 4vh, 2.5rem);
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1.3;
}

.gallery-subtitle {
    font-size: clamp(1.05rem, 2.5vh, 1.2rem);
    color: var(--color-text-muted);
    font-weight: 600;
    margin-bottom: -5px;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    width: 100%;
}

.flip-card {
    background-color: transparent;
    width: 100%;
    aspect-ratio: 1 / 1;
    perspective: 1000px;
    cursor: pointer;
}

.flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s cubic-bezier(0.4, 0.2, 0.2, 1);
    transform-style: preserve-3d;
}

.flip-card.flipped .flip-card-inner {
    transform: rotateY(180deg);
}

.flip-card-front, .flip-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 12px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    overflow: hidden;
}

.flip-card-front {
    background-color: #fff;
}

.flip-card-front img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.flip-card-back {
    background-color: var(--color-primary-dark);
    color: white;
    transform: rotateY(180deg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    font-family: var(--font-handwritten);
    font-size: 1.2rem;
}

/* -------------------------------------------------------------
   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;
    }
}

/* Road Timeline Styling */
.road-card {
    max-height: 92vh;
    max-height: 92dvh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: clamp(15px, 2.5vh, 25px);
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 77, 109, 0.3) transparent;
}

.road-card::-webkit-scrollbar {
    width: 6px;
}

.road-card::-webkit-scrollbar-thumb {
    background-color: rgba(255, 77, 109, 0.3);
    border-radius: 10px;
}

.road-container {
    position: relative;
    padding-left: 10px;
    display: flex;
    flex-direction: column;
    gap: clamp(20px, 3vh, 35px);
    margin-bottom: 10px;
}

.road-track {
    position: absolute;
    left: 34px; /* aligns centered with the signs */
    top: 10px;
    bottom: 10px;
    width: 4px;
    z-index: 1;
}

.road-dashed-line {
    width: 100%;
    height: 100%;
    background-color: #ff8fa3;
    border-radius: 2px;
    opacity: 0.8;
}

.road-avatar {
    position: absolute;
    left: -18px; /* centered over the track (4px track width, avatar size 40px) */
    width: 40px;
    height: auto;
    z-index: 5;
    transition: top 0.8s cubic-bezier(0.25, 1, 0.5, 1);
    top: 0;
}

.road-milestone {
    display: flex;
    position: relative;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease;
    z-index: 2;
}

.road-milestone.reveal {
    opacity: 1;
    transform: translateY(0);
}

.milestone-sign {
    position: absolute;
    left: 21px; /* Center aligns on the 16px track width + padding offset */
    top: 5px;
    width: 30px;
    height: 30px;
    background: #fff;
    border: 2px solid var(--color-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    box-shadow: 0 4px 8px rgba(255, 77, 109, 0.2);
    z-index: 3;
    cursor: default;
}

.milestone-card {
    margin-left: 60px;
    background: #fff;
    border-radius: 16px;
    padding: 16px;
    width: calc(100% - 60px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(255, 77, 109, 0.1);
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
}

.milestone-date {
    font-family: var(--font-ui);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-primary-dark);
}

.milestone-title {
    font-family: var(--font-ui);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-text-dark);
}

.milestone-desc {
    font-family: var(--font-handwritten);
    font-size: 1.15rem;
    color: var(--color-text-dark);
    line-height: 1.3;
}

.milestone-photo-holder {
    width: 100%;
    margin-top: 5px;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.milestone-photo {
    width: 100%;
    height: auto;
    object-fit: cover;
    max-height: 180px;
}

/* 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;
    }
}
