/* Modern CSS Reset */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* CSS Variables */
:root {
    --primary-color: #ff6b6b;
    --primary-dark: #ee5a52;
    --secondary-color: #4ecdc4;
    --accent-color: #45b7d1;
    --background-primary: #0a0a0a;
    --background-secondary: #1a1a1a;
    --background-card: rgba(30, 30, 30, 0.9);
    --text-primary: #ffffff;
    --text-secondary: #a0aec0;
    --text-muted: #718096;
    --border-color: rgba(255, 255, 255, 0.1);
    --success-color: #48bb78;
    --warning-color: #ed8936;
    --error-color: #f56565;
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 20px 40px -10px rgba(0, 0, 0, 0.6);
    --border-radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    --meta-blue: #0095f6;
    --theme-gradient: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    
    /* --- NEW: Font Stack --- */
    --font-mono: 'Consolas', 'Menlo', 'Monaco', 'Courier New', monospace;
}

/* Base Styles (FOR SCROLLING) */
body {
    font-family: var(--font-mono);
    line-height: 1.6;
    background: var(--background-primary); 
    color: var(--text-primary);
    font-size: 16px;
    position: relative;
    overflow-x: hidden; /* Prevent horizontal scroll */
}

/* Container (FOR SCROLLING) */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    /* This flex setup is required for scrolling */
    min-height: 100vh;
    display: flex;
    flex-direction: column; 
    position: relative;
    z-index: 1; 
}

/* Header */
.header {
    padding: 48px 0;
    text-align: center;
    border-bottom: 2px solid var(--border-color); 
    margin-bottom: 48px;
    backdrop-filter: blur(10px);
}

.header-content {
    max-width: 600px;
    margin: 0 auto;
}

.title {
    font-size: 3.5rem; 
    font-weight: 800;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

#header-canvas {
    width: 100%;
    max-width: 600px; 
    height: 90px;   
    cursor: pointer;
}

.subtitle {
    font-size: 1.25rem;
    color: var(--text-secondary);
    font-weight: 400;
}


/* Main Content (FOR SCROLLING) */
.main-content {
    flex: 1; /* This makes the main content push the footer down */
    padding-bottom: 48px;
}

.app-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 48px;
    align-items: start;
}

/* Card Base */
.upload-card,
.results-card {
    background: var(--background-card);
    backdrop-filter: blur(20px);
    border-radius:
    var(--border-radius);
    box-shadow: var(--shadow);
    padding: 32px;
    border: 2px solid var(--border-color);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

/* Card hover glow */
.upload-card::before,
.results-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
        transparent,
        rgba(255, 107, 107, 0.1), /* Red glow */
        transparent);
    transition: left 0.5s;
}

.upload-card:hover,
.results-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
    border-color: var(--secondary-color);
}

.upload-card:hover::before,
.results-card:hover::before {
    left: 100%;
}

/* Upload Section */
.upload-header,
.results-header {
    margin-bottom: 32px;
    text-align: center;
}

.upload-header h2,
.results-header h2 {
    font-size: 1.875rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.upload-header h2 span,
.results-header h2 span {
    color: var(--secondary-color); /* Teal */
}

.upload-header p,
.results-header p {
    color: var(--text-secondary);
    font-size: 1rem;
}

.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: 48px 24px;
    text-align: center;
    transition: var(--transition);
    cursor: pointer;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: rgba(255, 107, 107, 0.05);
    backdrop-filter: blur(10px);
}

.upload-area:hover,
.upload-area.drag-over {
    border-color: var(--primary-color);
    background: rgba(255, 107, 107, 0.1);
    box-shadow: 0 0 20px rgba(255, 107, 107, 0.3);
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.upload-icon {
    color: var(--primary-color);
    opacity: 0.7;
}

.upload-text {
    text-align: center;
}

.upload-main-text {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.upload-sub-text {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.preview-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--border-radius);
    object-fit: cover;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

/* Buttons */
.upload-actions,
.results-actions {
    margin-top: 32px;
    display: flex;
    gap: 16px;
    justify-content: center;
}

.btn {
    padding: 12px 24px;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    min-width: 120px;
    justify-content: center;
    font-family: var(--font-mono);
}

.btn-primary {
    background: var(--primary-color); /* Solid Red */
    color: white;
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.4);
    position: relative;
    overflow: hidden;
}

.btn-primary:hover {
    transform: translateY(-2px);
    background: var(--secondary-color); /* Hover to Teal */
    box-shadow: 0 6px 16px rgba(78, 205, 196, 0.6);
}

#cameraBtn {
    background: var(--secondary-color); /* Solid Teal */
    box-shadow: 0 4px 12px rgba(78, 205, 196, 0.4);
}

#cameraBtn:hover {
    background: var(--primary-color); /* Hover to Red */
    box-shadow: 0 6px 16px rgba(255, 107, 107, 0.6);
}

.btn-secondary {
    background: var(--border-color);
    color: var(--text-primary);
}

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

.btn-outline {
    background: transparent;
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-outline:hover {
    border-color: var(--primary-color);
    background: rgba(255, 107, 107, 0.1);
}

.upload-info {
    margin-top: 24px;
    text-align: center;
}

.upload-info p {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Results Section */
.results-content {
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column; 
}

.results-placeholder {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.results-icon {
    color: var(--text-muted);
    opacity: 0.5;
}

.results-main-text {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.results-sub-text {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Match Display */
.results-display {
    width: 100%;
}

.match-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    text-align: center;
}

/* Image Container */
.matched-image-container {
    position: relative;
    width: 200px; 
    height: 200px; 
    margin-bottom: 24px;
}

.matched-image {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--primary-color);
    box-shadow: var(--shadow);
}

.match-details {
    width: 100%;
}

.matched-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.matched-movie {
    font-size: 1rem;
    color: var(--text-secondary);
}

/* Verified Badge Styles */
.verified-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--meta-blue); 
    color: white;
    font-weight: 700;
    font-size: 0.9rem; 
    border-radius: 50%; 
    border: 3px solid var(--background-card); 
    box-shadow: 0 0 10px var(--meta-blue); 
    transform: scale(0);
    animation: popIn 0.5s 1s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

#verifiedPercent {
    display: block !important; 
}

.verified-icon {
    display: none;
}

@keyframes popIn {
    from {
        transform: scale(0);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* AI Roast Container Styles */
.roast-container {
    background: var(--background-secondary);
    border: 1px solid var(--border-color);
    padding: 20px;
    border-radius: var(--border-radius);
    text-align: center;
}

.roast-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.roast-message {
    font-size: 1rem;
    font-style: italic;
    color: var(--secondary-color); /* Themed */
    line-height: 1.5;
}

/* Loading State */
.loading-state {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.loading-text {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.loading-subtext {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

/* Footer */
.footer {
    padding: 24px 0;
    text-align: center;
    border-top: 2px solid rgba(78, 205, 196, 0.2); /* Themed */
    color: var(--text-muted);
    font-size: 0.875rem;
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
}

.footer p {
  margin: 0;
  font-size: 0.95rem;
  opacity: 0.8;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .app-grid {
        grid-template-columns: 1fr;
        gap: 32px;
    }
    .title {
        font-size: 2.5rem;
        flex-direction: column;
        gap: 8px;
    }
    #header-canvas {
        height: 100px;
    }
}
@media (max-width: 768px) {
    .container { padding: 0 16px; }
    .header { padding: 32px 0; margin-bottom: 32px; }
    .title { font-size: 2rem; }
    .upload-card, .results-card { padding: 24px; }
    .upload-area { padding: 32px 16px; min-height: 400px; } 
    .upload-actions, .results-actions { flex-direction: column; align-items: stretch; }
    .upload-actions { flex-direction: row; gap: 8px; }
    .btn { width: 100%; font-size: 0.9rem; padding: 12px 8px; }
    .match-info { gap: 16px; }
    .matched-image-container { width: 150px; height: 150px; margin-bottom: 16px; }
    /* .matched-image is handled by the animation rule now */
    .verified-badge { width: 50px; height: 50px; font-size: 0.8rem; bottom: 0; right: 0;}
}
@media (max-width: 480px) {
    .title { font-size: 1.75rem; }
    .subtitle { font-size: 1rem; }
    .upload-header h2, .results-header h2 { font-size: 1.5rem; }
    .upload-actions { flex-direction: column; }
}

/* Animations */
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.fade-in-up { animation: fadeInUp 0.6s ease-out; }

/* Camera Modal Styles */
.camera-modal {
  display: none; align-items: center; justify-content: center;
  position: fixed; z-index: 1000; left: 0; top: 0;
  width: 100%; height: 100%; background-color: rgba(0,0,0,0.8);
}
.camera-content {
  background: var(--background-card); backdrop-filter: blur(20px);
  padding: 20px; border-radius: var(--border-radius); text-align: center;
  box-shadow: var(--shadow-lg); max-width: 90vw; border: 2px solid var(--border-color);
}
#webcamVideo {
  width: 100%; max-width: 640px; height: auto; border-radius: var(--border-radius);
  background: #000; margin-bottom: 20px; transform: scaleX(-1); 
}
.camera-actions { display: flex; justify-content: center; gap: 15px; }


/* Share Modal Styles */
.share-modal {
  display: none; align-items: center; justify-content: center;
  position: fixed; z-index: 1001; left: 0; top: 0;
  width: 100%; height: 100%; background-color: rgba(0,0,0,0.85);
  backdrop-filter: blur(5px);
}
.share-content {
  background: var(--background-card); padding: 24px; border-radius: var(--border-radius);
  text-align: center; box-shadow: var(--shadow-lg); max-width: 90vw;
  width: 450px; border: 2px solid var(--border-color);
}
.share-content h3 { font-size: 1.5rem; color: var(--text-primary); margin-bottom: 20px; }
#sharePreviewContent { display: none; }
#collageCanvas {
  margin-bottom: 20px; 
  border-radius: 8px;
  max-width: 100%; 
  height: auto;
}
.share-actions { display: flex; flex-direction: column; gap: 12px; }
.share-actions .btn { width: 100%; }


/* --- 1. The Generic Loader (Throbbing Circle) --- */
.match-finder-animation {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    position: relative;
    border: 4px solid var(--primary-color);
    box-shadow: 0 0 30px rgba(255, 107, 107, 0.5); /* Outer glow */
    
    /* Center the inner circle */
    display: flex; 
    align-items: center;
    justify-content: center;
}

/* This is the inner throbbing white circle */
.match-finder-animation::before {
    content: '';
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: white; /* White inner circle */
    
    /* Apply the throbbing animation */
    animation: pulse-loader 1.5s infinite cubic-bezier(0.66, 0, 0, 1);
}

/* Keyframes for the inner circle */
@keyframes pulse-loader {
    0% {
        transform: scale(0.9);
        opacity: 0.7;
    }
    50% {
        transform: scale(1.1);
        opacity: 1;
    }
    100% {
        transform: scale(0.9);
        opacity: 0.7;
    }
}

/* --- 2. The "Grain Progress" Reveal Animation --- */
/* This is the default, "grained" state of the matched image */
.matched-image {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--primary-color);
    box-shadow: var(--shadow);
    
    /* Default "grained" state */
    filter: blur(12px) grayscale(80%);
    transform: scale(1.1); /* Slightly zoomed in */
    opacity: 0.5;
    
    /* The animation! */
    transition: all 1.2s cubic-bezier(0.25, 1, 0.5, 1);
}

/* This class is added by JS to trigger the animation */
.matched-image.reveal {
    /* The final, clear state */
    filter: blur(0) grayscale(0%);
    transform: scale(1);
    opacity: 1;
}



.preview-link {
    display: inline-block;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.preview-link:hover {
    transform: scale(1.03);
}

#collageCanvas {
    border-radius: 12px;
    box-shadow: 0 0 20px rgba(0, 230, 118, 0.3);
    background: #000;
}



#bgVideo {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    object-fit: cover; /* Important */
    z-index: -1;       /* Hide behind everything */
    filter: brightness(0.35) blur(2px); /* OPTIONAL: Make text readable */
}

.footer-version {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.footer-version {
    font-size: 1rem;
    opacity: 0.9;
}

#coffeeTag {
    position: fixed;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    background: #ffdd00;
    border-radius: 50%;
    height: 60px;
    width: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 99999;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    user-select: none;
    transition: transform 0.15s ease;
}

#coffeeTag:active {
    transform: translateY(-50%) scale(1.12); /* subtle press-grow */
}

#coffeeImg {
    width: 65%;
    height: auto;
    object-fit: contain;
    pointer-events: none;
    transition: transform 0.2s ease;
}

.vibrospin {
    animation: vibrospin 0.9s cubic-bezier(.68,-0.55,.27,1.55) forwards;
}

@keyframes vibrospin {
    0%   { transform: rotate(0deg); }
    10%  { transform: rotate(80deg); }
    20%  { transform: rotate(160deg) scale(1.05); }
    30%  { transform: rotate(240deg); }
    40%  { transform: rotate(320deg) scale(0.97); }
    50%  { transform: rotate(360deg); }
    60%  { transform: rotate(420deg) scale(1.03); }
    70%  { transform: rotate(480deg); }
    80%  { transform: rotate(540deg) scale(0.95); }
    90%  { transform: rotate(600deg); }
    100% { transform: rotate(650deg) scale(1); }
}


body.midnight-mode-active {
    filter: sepia(0.35) contrast(1.1) brightness(0.95) saturate(0.9);
    background-color: #0b0b0b !important;
}

.midnight-mode-active .upload-card,
.midnight-mode-active .results-card {
    background: rgba(25, 25, 25, 0.9) !important;
    border-color: rgba(255, 255, 255, 0.15) !important;
}

.midnight-mode-active #header-canvas {
    opacity: 0.85;
}

.midnight-mode-active .roast-message {
    color: #b7a77e !important;
}
body.secret-mode #bgVideo {
    filter: hue-rotate(180deg) brightness(1.4) saturate(1.5);
    transition: filter 0.6s ease;
}

.secret-popup {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) scale(0.85);
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(12px);
    padding: 14px 28px;
    border-radius: 16px;
    font-size: 1.1rem;
    font-weight: 700;
    color: #00ffd5;
    border: 1px solid rgba(0, 255, 213, 0.4);
    box-shadow: 0 4px 20px rgba(0,255,213,0.25);
    opacity: 0;
    transition: all 0.35s cubic-bezier(.34,.79,.38,1.24);
    z-index: 999999;
    letter-spacing: 0.5px;
}

.secret-popup.show {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

#bgVideo {
    transition: opacity 0.6s ease-in-out;
}

.video-fade-out {
    opacity: 0;
}

.video-fade-in {
    opacity: 1;
}

#secretOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    background: rgba(255,255,255,0);
    backdrop-filter: blur(0px);
    opacity: 0;
    z-index: 99998;
    transition: opacity 0.6s ease, backdrop-filter 0.6s ease;
}

/* Shine sweep effect */
#secretOverlay.shine::before {
    content: "";
    position: absolute;
    top: 0;
    left: -150%;
    width: 50%;
    height: 100%;
    background: linear-gradient(
        120deg,
        rgba(255,255,255,0) 0%,
        rgba(255,255,255,0.7) 50%,
        rgba(255,255,255,0) 100%
    );
    transform: skewX(-20deg);
    animation: sweep 1.2s ease forwards;
}

@keyframes sweep {
    0% { left: -150%; }
    100% { left: 150%; }
}

#secretOverlay.active {
    opacity: 1;
    backdrop-filter: blur(10px) brightness(1.2);
}
#subTitle {
    transition: opacity 0.5s ease, transform 0.4s ease;
}

#subTitle.fade-out {
    opacity: 0;
    transform: translateY(-6px);
}

#subTitle.fade-in {
    opacity: 1;
    transform: translateY(0);
}
