/* Font Face Declarations with fallbacks */
@font-face {
    font-family: 'SF Pro Display';
    src: url('fonts/SF-Pro-Display-Regular.otf') format('opentype'),
         local('SF Pro Display'),
         local('SFProDisplay-Regular');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'SF Pro Display';
    src: url('fonts/SF-Pro-Display-Bold.otf') format('opentype'),
         local('SF Pro Display Bold'),
         local('SFProDisplay-Bold');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'SF Pro Display';
    src: url('fonts/SF-Pro-Display-Medium.otf') format('opentype'),
         local('SF Pro Display Medium'),
         local('SFProDisplay-Medium');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

/* Apple Design System Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', system-ui, sans-serif;
}

body {
    background: #fff;
    color: #1d1d1f;
    line-height: 1.47059;
    font-weight: 400;
    letter-spacing: -0.022em;
    overflow-x: hidden;
}

/* Apple Navigation */
.apple-nav {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.nav-content {
    max-width: 1024px;
    margin: 0 auto;
    padding: 0 22px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-brand {
    font-size: 21px;
    font-weight: 600;
    color: #1d1d1f;
    letter-spacing: -0.022em;
}

/* Hero Section */
.hero-section {
    padding: 80px 0 60px;
    background: #fff;
    text-align: center;
}

.hero-content {
    max-width: 1024px;
    margin: 0 auto;
    padding: 0 22px;
}

.hero-title {
    font-size: 56px;
    line-height: 1.07143;
    font-weight: 600;
    letter-spacing: -0.005em;
    color: #1d1d1f;
    margin-bottom: 16px;
}

.hero-subtitle {
    font-size: 28px;
    line-height: 1.14286;
    font-weight: 400;
    letter-spacing: 0.004em;
    color: #86868b;
    max-width: 800px;
    margin: 0 auto;
}

/* Canvas Section */
.canvas-section {
    padding: 40px 0 20px 0; /* Reduced bottom padding */
    background: #f5f5f7;
}

.canvas-container {
    max-width: 1024px;
    margin: 0 auto;
    padding: 0 22px;
    text-align: center;
}

.canvas-showcase {
    position: relative;
    background: #fff;
    border-radius: 18px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    display: inline-block;
    max-width: 100%;
    overflow: hidden; /* Prevent canvas from extending outside */
}

/* Editor Section */
.editor-section {
    padding: 20px 0 60px 0; /* Reduced top padding to bring closer to canvas */
    background: #fff;
}

.editor-container {
    max-width: 980px;
    margin: 0 auto;
    padding: 0 22px;
}

.editor-header {
    text-align: center;
    margin-bottom: 40px; /* Reduced from 60px for more compact layout */
}

.section-title {
    font-size: 48px;
    line-height: 1.08349;
    font-weight: 600;
    letter-spacing: -0.003em;
    color: #1d1d1f;
    margin-bottom: 16px;
}

.section-subtitle {
    font-size: 21px;
    line-height: 1.381;
    font-weight: 400;
    letter-spacing: 0.011em;
    color: #86868b;
}

.editor-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    max-width: 800px;
    margin: 0 auto;
}

#memeCanvas {
    display: block;
    border-radius: 12px;
    background: #f5f5f7;
    /* Size controlled by JavaScript for proper responsiveness */
    max-width: 100%;
    height: auto;
}

.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 16px 32px;
    border-radius: 16px;
    font-weight: 500;
    color: #1d1d1f;
    font-size: 17px;
    letter-spacing: -0.022em;
}

.loading.hidden {
    display: none;
}

.input-card {
    background: #f5f5f7;
    border-radius: 18px;
    padding: 32px;
    transition: all 0.3s ease;
}

.input-card:hover {
    background: #f0f0f3;
}

.input-label {
    display: block;
    font-size: 17px;
    line-height: 1.29412;
    font-weight: 600;
    color: #1d1d1f;
    margin-bottom: 12px;
    letter-spacing: -0.022em;
}

.apple-textarea {
    width: 100%;
    min-height: 120px;
    border: none;
    background: #fff;
    border-radius: 12px;
    padding: 16px 20px;
    font-size: 17px;
    line-height: 1.29412;
    font-weight: 400;
    color: #1d1d1f;
    letter-spacing: -0.022em;
    resize: vertical;
    transition: all 0.2s ease;
    font-family: inherit;
}

.apple-textarea:focus {
    outline: none;
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.3);
}

.apple-textarea::placeholder {
    color: #86868b;
}

.input-description {
    display: block;
    font-size: 14px;
    line-height: 1.28577;
    font-weight: 400;
    color: #86868b;
    margin-top: 8px;
    letter-spacing: -0.016em;
}

/* Action Section */
.action-section {
    padding: 60px 0 80px;
    background: #f5f5f7;
}

.action-container {
    max-width: 1024px;
    margin: 0 auto;
    padding: 0 22px;
    text-align: center;
}

.action-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Apple Buttons */
.apple-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 140px;
    height: 48px;
    padding: 0 24px;
    border-radius: 24px;
    font-size: 17px;
    line-height: 1.29412;
    font-weight: 400;
    letter-spacing: -0.022em;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    white-space: nowrap;
}

.apple-btn-primary {
    background: #007aff;
    color: #fff;
}

.apple-btn-primary:hover {
    background: #0051d5;
    transform: translateY(-1px);
}

.apple-btn-secondary {
    background: #1d1d1f;
    color: #f5f5f7;
}

.apple-btn-secondary:hover {
    background: #424245;
    transform: translateY(-1px);
}

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

.apple-btn.success {
    background: #30d158;
    color: #fff;
}

/* Apple Footer */
.apple-footer {
    background: #f5f5f7;
    border-top: 1px solid #d6d6d6;
    padding: 40px 0;
}

.footer-content {
    max-width: 1024px;
    margin: 0 auto;
    padding: 0 22px;
    text-align: center;
}


.footer-legal {
    font-size: 12px;
    line-height: 1.33337;
    font-weight: 400;
    color: #86868b;
    letter-spacing: -0.01em;
}

.footer-legal p {
    margin-bottom: 4px;
}

/* Responsive Design */
@media (max-width: 834px) {
    .hero-title {
        font-size: 40px;
        line-height: 1.1;
    }
    
    .hero-subtitle {
        font-size: 21px;
        line-height: 1.381;
    }
    
    .section-title {
        font-size: 32px;
        line-height: 1.125;
    }
    
    .editor-grid {
        grid-template-columns: 1fr;
        gap: 30px;
    }
    
    .action-buttons {
        flex-direction: column;
        align-items: center;
        gap: 16px;
    }
    
    .apple-btn {
        width: 100%;
        max-width: 280px;
    }
    
    .canvas-showcase {
        padding: 16px;
    }
    
    /* Optimize for mobile viewing */
    .canvas-section {
        padding: 30px 0 15px 0; /* Maintain close spacing on tablet */
    }
    
    .editor-section {
        padding: 15px 0 50px 0; /* Maintain close spacing on tablet */
    }
}

@media (max-width: 428px) {
    .hero-title {
        font-size: 32px;
    }
    
    .hero-subtitle {
        font-size: 19px;
    }
    
    .section-title {
        font-size: 28px;
    }
    
    .input-card {
        padding: 20px;
    }
    
    .canvas-showcase {
        padding: 12px;
        margin: 0 12px;
    }
    
    .hero-section {
        padding: 60px 0 40px;
    }
    
    .canvas-section {
        padding: 20px 0 10px 0; /* Very compact on mobile */
    }
    
    .editor-section {
        padding: 10px 0 30px 0; /* Very compact on mobile */
    }
    
    .action-section {
        padding: 30px 0;
    }
    
    /* Mobile-optimized text inputs */
    .apple-textarea {
        font-size: 16px; /* Prevent zoom on iOS */
        min-height: 100px;
    }
    
    .editor-header {
        margin-bottom: 25px; /* Even more compact on mobile */
    }
}

/* Loading Animation */
.loading::after {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-left: 8px;
    border: 2px solid #86868b;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .apple-btn-primary {
        background: #0000ff;
    }
    
    .hero-subtitle, .section-subtitle {
        color: #424245;
    }
}