/* ==================== MINIMALIST BLACK & WHITE DESIGN ==================== */
/* Elegant • Refined • Timeless + Birthday Cake */

:root {
    /* Minimalist Monochrome Palette */
    --black: hsl(0, 0%, 5%);
    --charcoal: hsl(0, 0%, 15%);
    --gray-dark: hsl(0, 0%, 35%);
    --gray: hsl(0, 0%, 55%);
    --gray-light: hsl(0, 0%, 75%);
    --silver: hsl(0, 0%, 90%);
    --white: hsl(0, 0%, 98%);
    
    /* Cake Colors */
    --vanilla: #f0e4d0;
    --chocolate: #553c13;
    --candle-red: #7b020b;
    --flame-orange: orange;
    
    /* Spacing - Generous */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 2rem;
    --spacing-lg: 3rem;
    --spacing-xl: 5rem;
    --spacing-xxl: 8rem;
    
    /* Border */
    --border-thin: 1px;
    --border-medium: 2px;
    --border-thick: 3px;
    
    /* Shadows - Subtle */
    --shadow-sm: 0 1px 3px hsla(0, 0%, 0%, 0.06);
    --shadow-md: 0 2px 8px hsla(0, 0%, 0%, 0.08);
    --shadow-lg: 0 4px 16px hsla(0, 0%, 0%, 0.1);
    
    /* Transitions - Smooth */
    --transition-fast: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 350ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==================== RESET & BASE ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Cormorant Garamond', 'Georgia', 'Times New Roman', serif;
    background: var(--charcoal);
    color: var(--white);
    min-height: 100vh;
    line-height: 1.8;
    font-size: 18px;
    font-weight: 400;
    letter-spacing: 0.01em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* ==================== TYPOGRAPHY ==================== */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 400;
    letter-spacing: 0.02em;
    line-height: 1.2;
}

/* ==================== CONTAINER & LAYOUT ==================== */
html, body {
    overflow: hidden;
    height: 100vh;
}

.container {
    max-width: 100%;
    width: 100%;
    height: 100vh;
    margin: 0;
    padding: 0;
    position: relative;
    overflow: hidden;
}

.page {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100vh;
    padding: var(--spacing-lg) var(--spacing-md);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    overflow-y: auto;
    transition: opacity var(--transition-slow), visibility var(--transition-slow);
}

.page.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    z-index: 10;
    animation: fadeInMinimal var(--transition-slow);
}

@keyframes fadeInMinimal {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==================== CARDS ==================== */
.card {
    background: var(--white);
    border: var(--border-thin) solid var(--silver);
    padding: var(--spacing-xl);
    box-shadow: var(--shadow-sm);
    transition: var(--transition-base);
    max-width: 800px;
    width: 100%;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.glass-card {
    background: hsla(0, 0%, 100%, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.card-header {
    text-align: center;
    margin-bottom: var(--spacing-xl);
    padding-bottom: var(--spacing-lg);
    border-bottom: var(--border-thin) solid var(--silver);
}

.title {
    font-size: clamp(2.5rem, 6vw, 4rem);
    font-weight: 300;
    margin-bottom: var(--spacing-md);
    letter-spacing: 0.05em;
    color: var(--black);
    line-height: 1.1;
}

.subtitle {
    color: var(--gray);
    font-size: 1rem;
    font-weight: 300;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ==================== CAMERA SECTION ==================== */
.camera-section {
    margin-bottom: var(--spacing-lg);
}

.video-wrapper {
    position: relative;
    width: 100%;
    max-width: 640px;
    margin: 0 auto var(--spacing-lg);
    border: var(--border-medium) solid var(--black);
    overflow: hidden;
    background: var(--black);
    aspect-ratio: 4 / 3;
    transition: var(--transition-base);
}

.video-wrapper:hover {
    box-shadow: var(--shadow-lg);
}

#video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    filter: grayscale(0);
    transition: var(--transition-base);
}

.camera-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60%;
    height: 60%;
    border: var(--border-medium) solid var(--white);
    opacity: 0.3;
    pointer-events: none;
    transition: var(--transition-base);
}

.camera-overlay.active {
    opacity: 1;
    animation: pulseMinimal 3s ease-in-out infinite;
}

@keyframes pulseMinimal {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.6;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.02);
        opacity: 1;
    }
}

.camera-controls {
    display: flex;
    gap: var(--spacing-md);
    justify-content: center;
    flex-wrap: wrap;
    margin-top: var(--spacing-lg);
}

/* ==================== BUTTONS ==================== */
.btn {
    padding: 1.2rem 3rem;
    border: var(--border-medium) solid var(--white);
    background: transparent;
    font-size: 0.9rem;
    font-weight: 400;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    cursor: pointer;
    transition: var(--transition-base);
    position: relative;
    overflow: hidden;
    color: var(--white);
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: var(--white);
    transition: var(--transition-base);
    z-index: -1;
}

.btn:hover::before {
    left: 0;
}

.btn:hover {
    color: var(--black);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-icon {
    font-size: 1rem;
    margin-right: var(--spacing-xs);
}

.btn-primary {
    background: var(--white);
    color: var(--black);
    border-color: var(--white);
}

.btn-primary::before {
    background: var(--black);
}

.btn-primary:hover {
    color: var(--white);
    border-color: var(--black);
}

.btn-success {
    background: var(--charcoal);
    color: var(--white);
    border-color: var(--white);
}

.btn-success::before {
    background: var(--white);
}

.btn-success:hover {
    color: var(--black);
    border-color: var(--white);
}

.btn-secondary {
    background: transparent;
    color: var(--gray-light);
    border-color: var(--gray);
}

.btn-secondary:hover {
    border-color: var(--white);
    color: var(--black);
}

.btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none !important;
}

.btn:disabled:hover::before {
    left: -100%;
}

.btn:disabled:hover {
    color: inherit;
    box-shadow: none;
}

/* ==================== STATUS MESSAGES ==================== */
.status-message {
    padding: var(--spacing-md);
    border: var(--border-thin) solid var(--gray);
    text-align: center;
    font-weight: 400;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 0.9rem;
    letter-spacing: 0.05em;
    margin-top: var(--spacing-lg);
    display: none;
    animation: slideInMinimal var(--transition-base);
    color: var(--black);
}

.status-message.show {
    display: block;
}

@keyframes slideInMinimal {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.status-processing {
    background: var(--silver);
    color: var(--gray-dark);
    border-color: var(--gray);
}

.status-success {
    background: var(--black);
    color: var(--white);
    border-color: var(--black);
}

.status-error {
    background: var(--white);
    color: var(--charcoal);
    border-color: var(--charcoal);
}

/* ==================== CAKE SECTION ==================== */
/* Cake page specific styles only when active */
#cake-page.active {
    position: relative;
}

.cake-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 5;
}

.cake-instruction {
    text-align: center;
    margin-bottom: var(--spacing-lg);
    animation: floatInstruction 2s ease-in-out infinite;
}

.cake-instruction p {
    font-size: 1.8rem;
    color: var(--white);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    font-weight: 500;
}

@keyframes floatInstruction {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.cake {
    position: relative;
    width: 250px;
    height: 200px;
    margin: 0 auto;
}

.cake > * {
    position: absolute;
}

.plate {
    width: 270px;
    height: 110px;
    position: absolute;
    bottom: -10px;
    left: -10px;
    background-color: #ccc;
    border-radius: 50%;
    box-shadow:
        0 2px 0 #b3b3b3,
        0 4px 0 #b3b3b3,
        0 5px 40px rgba(0, 0, 0, 0.5);
}

.layer {
    position: absolute;
    display: block;
    width: 250px;
    height: 100px;
    border-radius: 50%;
    background-color: var(--chocolate);
    box-shadow:
        0 2px 0px #5f4318,
        0 4px 0px #4a340f,
        0 6px 0px #493310,
        0 8px 0px #483210,
        0 10px 0px #473111,
        0 12px 0px #463011,
        0 14px 0px #452f12,
        0 16px 0px #442e12,
        0 18px 0px #432d13,
        0 20px 0px #422c13,
        0 22px 0px #412b14,
        0 24px 0px #402a14,
        0 26px 0px #3f2915,
        0 28px 0px #3e2815,
        0 30px 0px #3d2716;
}

.layer-top {
    top: 0px;
}

.layer-middle {
    top: 33px;
}

.layer-bottom {
    top: 66px;
}

.icing {
    top: 2px;
    left: 5px;
    background-color: var(--vanilla);
    width: 240px;
    height: 90px;
    border-radius: 50%;
}

.icing::before {
    content: "";
    position: absolute;
    top: 4px;
    right: 5px;
    bottom: 6px;
    left: 5px;
    background-color: #f5ead8;
    box-shadow:
        0 0 4px #f9f0e2,
        0 0 4px #f9f0e2,
        0 0 4px #f9f0e2;
    border-radius: 50%;
    z-index: 1;
}

.drip {
    display: block;
    width: 50px;
    height: 60px;
    border-bottom-left-radius: 25px;
    border-bottom-right-radius: 25px;
    background-color: var(--vanilla);
}

.drip1 {
    top: 53px;
    left: 5px;
    transform: skewY(15deg);
    height: 48px;
    width: 40px;
}

.drip2 {
    top: 69px;
    left: 181px;
    transform: skewY(-15deg);
}

.drip3 {
    top: 54px;
    left: 90px;
    width: 80px;
    border-bottom-left-radius: 40px;
    border-bottom-right-radius: 40px;
}

.candle {
    background-color: var(--candle-red);
    width: 16px;
    height: 50px;
    border-radius: 8px / 4px;
    top: -20px;
    left: 50%;
    margin-left: -8px;
    z-index: 10;
}

.candle::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 16px;
    height: 8px;
    border-radius: 50%;
    background-color: #8f1016;
}

.flame {
    position: absolute;
    background-color: var(--flame-orange);
    width: 15px;
    height: 35px;
    border-radius: 10px 10px 10px 10px / 25px 25px 10px 10px;
    top: -34px;
    left: 50%;
    margin-left: -7.5px;
    z-index: 10;
    box-shadow:
        0 0 10px rgba(255, 165, 0, 0.5),
        0 0 20px rgba(255, 165, 0, 0.5),
        0 0 60px rgba(255, 165, 0, 0.5),
        0 0 80px rgba(255, 165, 0, 0.5);
    transform-origin: 50% 90%;
    animation: flicker 1s ease-in-out alternate infinite;
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

.flame.out {
    opacity: 0;
    transform: scale(0) translateY(-20px);
}

@keyframes flicker {
    0% {
        transform: skewX(5deg);
        box-shadow:
            0 0 10px rgba(255, 165, 0, 0.2),
            0 0 20px rgba(255, 165, 0, 0.2),
            0 0 60px rgba(255, 165, 0, 0.2),
            0 0 80px rgba(255, 165, 0, 0.2);
    }
    25% {
        transform: skewX(-5deg);
        box-shadow:
            0 0 10px rgba(255, 165, 0, 0.5),
            0 0 20px rgba(255, 165, 0, 0.5),
            0 0 60px rgba(255, 165, 0, 0.5),
            0 0 80px rgba(255, 165, 0, 0.5);
    }
    50% {
        transform: skewX(10deg);
        box-shadow:
            0 0 10px rgba(255, 165, 0, 0.3),
            0 0 20px rgba(255, 165, 0, 0.3),
            0 0 60px rgba(255, 165, 0, 0.3),
            0 0 80px rgba(255, 165, 0, 0.3);
    }
    75% {
        transform: skewX(-10deg);
        box-shadow:
            0 0 10px rgba(255, 165, 0, 0.4),
            0 0 20px rgba(255, 165, 0, 0.4),
            0 0 60px rgba(255, 165, 0, 0.4),
            0 0 80px rgba(255, 165, 0, 0.4);
    }
    100% {
        transform: skewX(5deg);
        box-shadow:
            0 0 10px rgba(255, 165, 0, 0.5),
            0 0 20px rgba(255, 165, 0, 0.5),
            0 0 60px rgba(255, 165, 0, 0.5),
            0 0 80px rgba(255, 165, 0, 0.5);
    }
}

.cake-controls {
    margin-top: var(--spacing-xl);
    text-align: center;
}

/* Lottie Animation Containers - Only visible on cake page */
.lottie-hbd-container,
.lottie-confetti-container {
    display: none;
}

#cake-page.active .lottie-hbd-container {
    display: block;
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    pointer-events: none;
}

.lottie-hbd {
    width: 400px;
    max-width: 90vw;
}

#cake-page.active .lottie-confetti-container {
    display: block;
    position: absolute;
    top: 25%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 30;
    pointer-events: none;
}

.lottie-confetti {
    width: 400px;
    max-width: 90vw;
}

/* ==================== LETTER SLIDE EFFECT ==================== */
#letter-page {
    position: relative;
}

.letter-slide-container {
    perspective: 2000px;
    max-width: 800px;
    margin: 0 auto;
    /* overflow: hidden; Removed to prevent clipping long content */
}

.letter-slide {
    background: var(--white);
    border: var(--border-medium) solid var(--black);
    padding: var(--spacing-xl);
    box-shadow: var(--shadow-lg);
    transform: translateY(0);
    opacity: 1;
}

/* Animation only when letter-page becomes active */
#letter-page.active .letter-slide {
    animation: slideUpLetter 1.2s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

@keyframes slideUpLetter {
    0% {
        transform: translateY(50px);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

.letter-content {
    position: relative;
    color: var(--black);
    font-size: 1.2rem;
    line-height: 2;
    max-width: 600px;
    margin: 0 auto;
}

.letter-content h2 {
    color: var(--black);
    margin-bottom: var(--spacing-lg);
    font-size: 2.5rem;
    font-weight: 300;
    letter-spacing: 0.05em;
    text-align: center;
    opacity: 0;
    animation: fadeInTitle 1s ease-out 0.8s forwards;
}

@keyframes fadeInTitle {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.letter-content p {
    margin-bottom: var(--spacing-md);
    text-align: justify;
    hyphens: auto;
    opacity: 0;
}

.letter-content p:nth-child(2) { 
    animation: fadeInLine 0.8s ease-out 1.2s forwards;
}
.letter-content p:nth-child(3) { 
    animation: fadeInLine 0.8s ease-out 1.5s forwards;
}
.letter-content p:nth-child(4) { 
    animation: fadeInLine 0.8s ease-out 1.8s forwards;
}
.letter-content p:nth-child(5) { 
    animation: fadeInLine 0.8s ease-out 2.1s forwards;
}
.letter-content p:nth-child(6) { 
    animation: fadeInLine 0.8s ease-out 2.4s forwards;
}
.letter-content p:nth-child(n+7) { 
    animation: fadeInLine 0.8s ease-out 2.7s forwards;
}

@keyframes fadeInLine {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.back-btn {
    display: block;
    margin: var(--spacing-lg) auto 0;
}

/* ==================== CONFETTI CANVAS ==================== */
#confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

/* ==================== DECORATIVE ELEMENTS ==================== */
.card-header::after {
    content: '✦';
    display: block;
    font-size: 1.5rem;
    color: var(--gray-light);
    margin-top: var(--spacing-md);
    letter-spacing: 1rem;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
    .container {
        padding: var(--spacing-lg) var(--spacing-sm);
    }
    
    .card {
        padding: var(--spacing-lg);
    }
    
    .title {
        font-size: 2.5rem;
    }
    
    .subtitle {
        font-size: 0.85rem;
    }
    
    .camera-controls {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
        padding: 1rem 2rem;
    }
    
    .cake {
        transform: scale(0.8);
    }
    
    .cake-instruction p {
        font-size: 1.4rem;
    }
    
    .letter-slide {
        padding: var(--spacing-md);
    }
    
    .letter-content {
        font-size: 1rem;
        line-height: 1.8;
    }
    
    .letter-content h2 {
        font-size: 2rem;
    }
    
    .lottie-hbd,
    .lottie-confetti {
        width: 300px;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 16px;
    }
    
    .container {
        padding: 0;
    }

    .page {
        padding: var(--spacing-sm); /* Reduced padding for page container */
    }

    .card {
        padding: var(--spacing-sm);
        border: none;
        height: auto; /* Allow natural height */
        min-height: auto;
        display: block; /* Remove flex centering */
        border-radius: 0;
        box-shadow: none;
        overflow: visible; /* Ensure content flows */
    }

    .letter-slide {
        padding: var(--spacing-sm);
    }

    .card-header {
        margin-bottom: var(--spacing-sm);
        padding-bottom: var(--spacing-sm);
    }
    
    .video-wrapper {
        aspect-ratio: 1 / 1;
        border-width: 1px;
        margin-bottom: var(--spacing-sm);
        max-height: 40vh;
    }
    
    .camera-overlay {
        width: 70%;
        height: 70%;
    }
    
    .title {
        font-size: 1.75rem;
        margin-bottom: var(--spacing-xs);
    }
    
    .subtitle {
        font-size: 0.75rem;
    }

    .camera-controls {
        margin-top: var(--spacing-sm);
        gap: var(--spacing-sm);
    }

    .btn {
        padding: 0.8rem 1.5rem;
        font-size: 0.8rem;
    }
    
    .status-message {
        margin-top: var(--spacing-sm);
        padding: var(--spacing-sm);
        font-size: 0.8rem;
    }
    
    .cake {
        transform: scale(0.65);
    }
    
    .cake-instruction p {
        font-size: 1.2rem;
    }
}

/* ==================== PRINT STYLES ==================== */
@media print {
    body {
        background: white;
    }
    
    .btn, .camera-section, .cake-wrapper {
        display: none;
    }
    
    .letter-content {
        opacity: 1;
    }
}

/* ==================== ACCESSIBILITY ==================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.btn:focus-visible,
button:focus-visible {
    outline: var(--border-medium) solid var(--white);
    outline-offset: 4px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    body {
        background: black;
        color: white;
    }
    
    .btn {
        border-width: 3px;
    }
}

/* ==================== SELECTION ==================== */
::selection {
    background: var(--white);
    color: var(--black);
}

::-moz-selection {
    background: var(--white);
    color: var(--black);
}

/* ==================== CUSTOM CURSOR ==================== */
@media (hover: hover) and (pointer: fine) {
    .btn {
        cursor: pointer;
    }
    
    .btn:hover {
        cursor: pointer;
    }
}
