/*
 * ============================================
 * A Letter For You
 * © 2026 Soufiane Amabraa. All rights reserved.
 * ============================================
 */

/* ============================================
   VICTORIAN LOVE LETTER - STYLES
   Modern Romantic Scrollytelling Experience
   ============================================ */

/* ============================================
   CSS VARIABLES (Design System)
   ============================================ */
:root {
    /* Colors */
    --paper: #F5E5E1;
    --paper-dark: #E8D5D0;
    --ink: #174143;
    --ink-light: #1f5558;
    --decor: #427A76;
    --decor-light: #5a9a96;
    --accent: #F9B487;
    --accent-dark: #e89b6a;
    
    /* Typography */
    --font-heading: 'Pinyon Script', cursive;
    --font-body: 'Cormorant Garamond', serif;
    
    /* Spacing */
    --space-xs: clamp(0.5rem, 2vw, 1rem);
    --space-sm: clamp(1rem, 3vw, 2rem);
    --space-md: clamp(2rem, 5vw, 4rem);
    --space-lg: clamp(4rem, 10vw, 8rem);
    --space-xl: clamp(6rem, 15vw, 12rem);
    --space-dramatic: clamp(8rem, 20vw, 16rem);
    
    /* Layout */
    --content-width: min(700px, 90vw);
    --wide-content-width: min(900px, 95vw);
    
    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-medium: 0.4s ease;
    --transition-slow: 0.8s ease;
    --transition-glacial: 1.2s ease;
}

/* ============================================
   RESET & BASE
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: var(--font-body);
    font-size: clamp(1.1rem, 2.5vw, 1.35rem);
    font-weight: 400;
    line-height: 1.8;
    color: var(--ink);
    background-color: var(--paper);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Hide scrollbar during preloader */
body.loading {
    overflow: hidden;
}

/* ============================================
   GRAIN TEXTURE OVERLAY
   ============================================ */
.grain-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 10000;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    background-repeat: repeat;
}

/* ============================================
   FIXED BACKGROUND LAYER
   ============================================ */
.bg-layer {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
}

.bg-image {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0;
    transition: opacity var(--transition-glacial);
    
    /* Paper-tear mask effect */
    mask-image: 
        radial-gradient(ellipse 120% 100% at 50% 50%, black 70%, transparent 100%);
    -webkit-mask-image: 
        radial-gradient(ellipse 120% 100% at 50% 50%, black 70%, transparent 100%);
}

.bg-image::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to bottom,
        rgba(245, 229, 225, 0.7) 0%,
        rgba(245, 229, 225, 0.5) 50%,
        rgba(245, 229, 225, 0.7) 100%
    );
}

/* ============================================
   PRELOADER
   ============================================ */
#preloader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--paper);
    transition: opacity var(--transition-slow), visibility var(--transition-slow);
}

#preloader.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.preloader-content {
    text-align: center;
    padding: var(--space-md);
}

.preloader-title {
    font-family: var(--font-heading);
    font-size: clamp(2.5rem, 8vw, 5rem);
    color: var(--ink);
    margin-bottom: var(--space-sm);
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 1s ease 0.3s forwards;
}

.open-letter-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 1rem 2.5rem;
    font-family: var(--font-body);
    font-size: 1.1rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    color: var(--ink);
    background: transparent;
    border: 2px solid var(--decor);
    border-radius: 0;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all var(--transition-medium);
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 1s ease 0.6s forwards;
}

.open-letter-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--decor);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--transition-medium);
    z-index: -1;
}

.open-letter-btn:hover {
    color: var(--paper);
    border-color: var(--decor);
}

.open-letter-btn:hover::before {
    transform: scaleX(1);
}

.open-letter-btn:active {
    transform: scale(0.98);
}

/* ============================================
   AUDIO TOGGLE
   ============================================ */
.audio-toggle {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1000;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--paper);
    border: 2px solid var(--decor);
    border-radius: 50%;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-medium);
    box-shadow: 0 4px 15px rgba(23, 65, 67, 0.1);
}

.audio-toggle.visible {
    opacity: 1;
    visibility: visible;
}

.audio-toggle:hover {
    background: var(--decor);
    transform: scale(1.05);
}

.audio-toggle:hover .audio-icon {
    color: var(--paper);
}

.audio-icon {
    width: 24px;
    height: 24px;
    color: var(--ink);
    transition: color var(--transition-fast);
}

.audio-icon.audio-off {
    display: none;
}

.audio-toggle.muted .audio-icon.audio-on {
    display: none;
}

.audio-toggle.muted .audio-icon.audio-off {
    display: block;
}

/* ============================================
   MAIN CONTENT LAYOUT
   ============================================ */
#letter-container {
    position: relative;
    z-index: 1;
    opacity: 0;
    transition: opacity var(--transition-slow);
}

#letter-container.visible {
    opacity: 1;
}

.letter-section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg) var(--space-sm);
}

.section-content {
    width: 100%;
    max-width: var(--content-width);
    margin: 0 auto;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */
.letter-content {
    color: var(--ink);
    mix-blend-mode: multiply;
}

.letter-content h1 {
    font-family: var(--font-heading);
    font-size: clamp(2.5rem, 7vw, 4.5rem);
    font-weight: 400;
    line-height: 1.2;
    margin-bottom: var(--space-md);
    text-align: center;
}

.letter-content h2 {
    font-family: var(--font-heading);
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 400;
    line-height: 1.3;
    margin-bottom: var(--space-sm);
    color: var(--ink);
}

.letter-content p {
    margin-bottom: var(--space-sm);
    text-align: justify;
    text-justify: inter-word;
    hyphens: auto;
}

.letter-content p:first-of-type {
    font-size: 1.15em;
}

/* Special styling for "My love," salutation */
.letter-content .salutation {
    font-family: var(--font-heading);
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    text-align: left;
    margin-bottom: var(--space-sm);
    display: block;
}

/* "We are different" emphasis */
.different-text p {
    font-size: clamp(1.3rem, 3vw, 1.6rem);
    font-weight: 500;
    text-align: center;
    font-style: italic;
}

.different-text .emphasis {
    display: block;
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: 600;
    margin-top: var(--space-xs);
    color: var(--ink-light);
}

/* Crescendo "I love you more than..." styling */
.crescendo-content .love-line {
    font-size: clamp(1.4rem, 3.5vw, 1.8rem);
    text-align: center;
    margin-bottom: var(--space-md);
    font-style: italic;
    opacity: 0;
    transform: translateY(30px);
}

.crescendo-content .love-line:last-of-type {
    font-size: clamp(1.6rem, 4vw, 2.2rem);
    font-weight: 600;
    font-style: normal;
    color: var(--ink);
}

/* Farewell styling */
.farewell-content {
    text-align: center;
}

.farewell-content p {
    text-align: center;
    font-size: clamp(1.2rem, 3vw, 1.5rem);
    line-height: 2;
}

/* ============================================
   LOTTIE CONTAINERS
   ============================================ */
.lottie-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: var(--space-md) auto;
}

.opening-lottie {
    opacity: 0;
    transform: scale(0.9);
}

.opening-lottie.visible {
    opacity: 1;
    transform: scale(1);
    transition: all var(--transition-slow);
}

.birds-lottie {
    width: 100%;
    overflow: visible;
    opacity: 0;
    transform: translateX(-100%);
}

.birds-lottie.flying {
    opacity: 1;
    transform: translateX(0);
    transition: all 2s ease-out;
}

.bunnies-lottie {
    position: absolute;
    top: 0;
    right: -100px;
    opacity: 0.7;
}

@media (max-width: 768px) {
    .bunnies-lottie {
        position: relative;
        right: auto;
        margin: var(--space-sm) auto;
    }
}

/* ============================================
   DIVIDERS
   ============================================ */
.divider {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: var(--space-lg) auto;
    width: 100%;
    max-width: 400px;
    opacity: 0;
    transform: scaleX(0.5);
}

.divider img {
    width: 100%;
    height: auto;
    max-height: 60px;
    object-fit: contain;
    filter: sepia(20%) hue-rotate(140deg) saturate(60%);
    opacity: 0.7;
}

.divider-hearts img {
    max-height: 80px;
}

.divider-leaves img {
    max-height: 50px;
}

/* ============================================
   GARDEN SECTION
   ============================================ */
.garden-header {
    position: relative;
    text-align: center;
    margin-bottom: var(--space-md);
}

.garden-title {
    font-family: var(--font-heading);
    font-size: clamp(2.5rem, 6vw, 4rem);
    color: var(--ink);
    margin-bottom: var(--space-sm);
}

/* ============================================
   FAVORITES GRID
   ============================================ */
#section-grid {
    padding: var(--space-xl) var(--space-sm);
}

#section-grid .section-content {
    max-width: var(--wide-content-width);
}

.grid-header,
.grid-footer {
    position: relative;
    height: 60px;
    margin: var(--space-md) 0;
}

.corner-ornament {
    position: absolute;
    width: 60px;
    height: 60px;
    object-fit: contain;
    filter: sepia(20%) hue-rotate(140deg) saturate(60%);
    opacity: 0.6;
}

.corner-tl {
    top: 0;
    left: 0;
}

.corner-tr {
    top: 0;
    right: 0;
    transform: scaleX(-1);
}

.corner-bl {
    bottom: 0;
    left: 0;
    transform: scaleY(-1);
}

.corner-br {
    bottom: 0;
    right: 0;
    transform: scale(-1, -1);
}

.grid-intro {
    font-family: var(--font-heading);
    font-size: clamp(1.5rem, 4vw, 2rem);
    text-align: center;
    color: var(--ink);
    margin: var(--space-sm) 0;
}

.favorites-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--space-sm);
    padding: var(--space-sm);
}

@media (min-width: 768px) {
    .favorites-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Flip Card Styles */
.flip-card {
    perspective: 1000px;
    height: 280px;
    cursor: pointer;
}

.flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s cubic-bezier(0.4, 0, 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%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(23, 65, 67, 0.15);
}

.flip-card-front {
    background: linear-gradient(135deg, var(--paper) 0%, var(--paper-dark) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--decor-light);
}

.flip-card-front::before {
    content: '';
    position: absolute;
    inset: 8px;
    border: 1px solid var(--decor);
    opacity: 0.3;
    border-radius: 4px;
}

.card-title {
    font-family: var(--font-heading);
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    color: var(--ink);
    text-align: center;
}

.card-hint {
    font-family: var(--font-body);
    font-size: 0.85rem;
    color: var(--decor);
    margin-top: var(--space-xs);
    opacity: 0.8;
}

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

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

/* Hover effect */
@media (hover: hover) {
    .flip-card:hover .flip-card-inner {
        transform: scale(1.02);
    }
    
    .flip-card.flipped:hover .flip-card-inner {
        transform: rotateY(180deg) scale(1.02);
    }
}

/* ============================================
   CRESCENDO SECTION
   ============================================ */
.crescendo-wrapper {
    position: relative;
    padding: var(--space-md) 0;
}

.vine-decoration {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 80px;
    opacity: 0.15;
    pointer-events: none;
}

.vine-decoration img {
    width: 100%;
    height: auto;
    filter: sepia(20%) hue-rotate(140deg) saturate(60%);
}

.vine-left {
    left: -100px;
}

.vine-right {
    right: -100px;
    transform: translateY(-50%) scaleX(-1);
}

@media (max-width: 1100px) {
    .vine-decoration {
        display: none;
    }
}

/* ============================================
   WAX SEAL
   ============================================ */
.wax-seal {
    display: flex;
    justify-content: center;
    margin-top: var(--space-xl);
    opacity: 0;
    transform: scale(0.8) rotate(-10deg);
}

.seal-image {
    width: 120px;
    height: 120px;
    object-fit: contain;
    filter: sepia(30%) hue-rotate(340deg) saturate(120%) brightness(95%);
    transition: transform var(--transition-medium);
}

.wax-seal:hover .seal-image {
    transform: scale(1.05) rotate(5deg);
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.6;
    }
    50% {
        opacity: 1;
    }
}

/* Animation utility classes */
.animate-in {
    opacity: 0;
    transform: translateY(50px);
}

.animate-in.visible {
    opacity: 1;
    transform: translateY(0);
    transition: all var(--transition-slow);
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */
@media (max-width: 768px) {
    html {
        font-size: 15px;
    }
    
    .letter-section {
        padding: var(--space-md) var(--space-sm);
        min-height: auto;
    }
    
    .corner-ornament {
        width: 40px;
        height: 40px;
    }
    
    .flip-card {
        height: 240px;
    }
    
    .audio-toggle {
        bottom: 1rem;
        right: 1rem;
        width: 44px;
        height: 44px;
    }
    
    .divider {
        max-width: 280px;
    }
}

@media (max-width: 480px) {
    .favorites-grid {
        grid-template-columns: 1fr;
    }
    
    .flip-card {
        height: 200px;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .grain-overlay,
    .bg-layer,
    #preloader,
    .audio-toggle,
    .lottie-container,
    .divider {
        display: none !important;
    }
    
    body {
        background: white;
        color: black;
    }
    
    .letter-content {
        mix-blend-mode: normal;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    html {
        scroll-behavior: auto;
    }
}

/* Focus styles */
button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--decor);
    outline-offset: 2px;
}
