:root {
    --primary-color: #2563eb;
    --primary-dark: #1e40af;
    --secondary-color: #4f46e5;
    --accent-color: #06b6d4;
    --bg-color: #f8fafc;
    --surface-color: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-full: 9999px;

    --font-heading: 'Montserrat', sans-serif;
    --font-body: 'Inter', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

img {
    max-width: 100%;
    display: block;
}

/* Layout */
.container {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Header */
.site-header {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 3rem 0;
    margin-bottom: 3rem;
    text-align: center;
    box-shadow: var(--shadow-md);
}

.festival-title {
    font-family: var(--font-heading);
    font-size: clamp(1.2rem, 3.5vw, 2.2rem);
    /* Slightly smaller to fit uppercase */
    font-weight: 800;
    /* Extra bold for impact */
    line-height: 1.4;
    text-wrap: balance;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    /* Elegance */
    max-width: 900px;
    margin: 0 auto;
    /* Center it */
}

/* Footer */
.site-footer {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--secondary-color) 100%);
    /* Match Header */
    padding: 1rem 0;
    /* Reduced height (from 3rem) */
    margin-top: auto;
    /* Push to bottom if content is short */
    /* Remove border-top as it might clash with the gradient look */
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 -4px 6px -1px rgb(0 0 0 / 0.1);
    /* Subtle shadow top */
}

.site-footer .container {
    display: flex;
    justify-content: center;
    width: 100%;
    text-align: center;
}

.footer-logo {
    height: 60px;
    /* Reasonable height */
    width: auto;
    object-fit: contain;
    opacity: 0.9;
    transition: opacity 0.3s;
}

.footer-logo:hover {
    opacity: 1;
}

/* Grid */
.grid {
    display: grid;
    /* Reduced min-width to 250px to fit iPhone SE / narrow Androids safely */
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
    /* Slightly smaller gap for mobile efficiency */
    padding-bottom: 4rem;
}

.card {
    background: var(--surface-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    height: 100%;
    border: 1px solid var(--border-color);
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.card-image-wrapper {
    aspect-ratio: 2/3;
    /* Taller ratio to fit more poster content */
    overflow: hidden;
    background-color: #e2e8f0;
    position: relative;
}

.card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
    /* Ensure top logos are never cut off */
    transition: transform 0.3s ease;
}

.card:hover .card-img {
    transform: scale(1.05);
}

.project-id-badge {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
    backdrop-filter: blur(4px);
    z-index: 2;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.card-content {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    justify-content: space-between;
}

.card-title-stub {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--text-main);
    /* Ensure text truncate */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    /* Standard property */
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-teacher {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.read-more-btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    background-color: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    border-radius: var(--radius-full);
    font-weight: 500;
    font-size: 0.875rem;
    text-align: center;
    transition: all 0.2s;
}

.card:hover .read-more-btn {
    background-color: var(--primary-color);
    color: white;
}

/* Modal */
.modal {
    margin: auto;
    width: 95%;
    max-width: 1200px;
    height: 90vh;
    border: none;
    border-radius: 1.5rem;
    box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.5);
    background: transparent;
    /* Wrapper handles bg */
    padding: 0;
    overflow: hidden;
}

.modal::backdrop {
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
}

.modal-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    /* Dynamic Blue Background per reference image */
    background:
        radial-gradient(circle at top left, #2563eb, transparent 60%),
        radial-gradient(circle at bottom right, #4f46e5, transparent 60%),
        linear-gradient(135deg, #020617 0%, #1e3a8a 50%, #172554 100%);
    color: white;
}

.close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.3);
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

.modal-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    padding: 2rem;
    gap: 2rem;
}

/* Left Side (30% - The Info Stack) */
.modal-left {
    width: 300px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    /* Reduced gap */
    padding: 0;
    /* Remove top/bottom vertical padding */
    /* Remove scrollbar by default, only show if absolutely necessary */
    overflow-y: auto;
    scrollbar-width: thin;
    /* Firefox */
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

/* Custom Scrollbar for Webkit */
.modal-left::-webkit-scrollbar {
    width: 4px;
}

.modal-left::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

/* Avatar Styling */
.avatar-container {
    position: relative;
    margin-bottom: 0.25rem;
    /* Reduced margin */
    flex-shrink: 0;
    /* Don't shrink avatar */
}

.avatar-glow-ring {
    width: 160px;
    /* Reduced from 200px */
    height: 160px;
    border-radius: 50%;
    padding: 5px;
    background: linear-gradient(135deg, #ffffff 0%, #60a5fa 100%);
    box-shadow: 0 0 20px rgba(37, 99, 235, 0.5);
}

.profile-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #fff;
    background-color: #cbd5e1;
}

/* Info Boxes Common Style */
.info-stack {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    /* Tighter stack */
    /* Tighter stack */
    flex: 1;
    /* Allow stack to take available space */
    justify-content: flex-start;
    /* Start from top */
}

.info-box {
    width: 100%;
    padding: 0.75rem;
    /* Compact padding */
    border-radius: 0.75rem;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

/* Specific Box Styles */
.name-box {
    background: linear-gradient(90deg, #0f172a 0%, #1e3a8a 100%);
    border: 1px solid #3b82f6;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.school-box {
    background: linear-gradient(90deg, #0f172a 0%, #1e3a8a 100%);
    border: 1px solid #3b82f6;
    min-height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.title-box {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border: 1px solid #fca5a5;
    text-align: left;
    margin-top: 1rem;
    box-shadow: 0 10px 15px -3px rgba(220, 38, 38, 0.3);
    position: relative;
    overflow: hidden;
}

/* Sparkle decoration for red box */
.sparkle-icon {
    position: absolute;
    top: -5px;
    left: -5px;
    font-size: 1.5rem;
    color: #fef08a;
    text-shadow: 0 0 5px rgba(255, 255, 0, 0.5);
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.2);
        opacity: 0.8;
    }
}

/* Text Styles inside boxes */
.modal-id-badge {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
    display: inline-block;
    padding: 0.1rem 0.6rem;
    border-radius: 99px;
    color: #93c5fd;
}

.teacher-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
    margin: 0;
}

.school-name {
    font-size: 0.9rem;
    color: #bfdbfe;
    margin: 0;
    line-height: 1.4;
}

.project-label {
    font-size: 1.5rem;
    /* Much bigger */
    font-weight: 800;
    /* Extra bold */
    text-transform: uppercase;
    color: #fef08a;
    /* Gold color to match sparkle */
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    /* Lift it off the background */
    margin-bottom: 0.5rem;
    letter-spacing: 0.05em;
}

.project-title {
    font-size: 1rem;
    font-weight: 600;
    color: white;
    line-height: 1.4;
}

/* Right Side (Fill Remaining) */
.modal-right {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.poster-frame {
    position: relative;
    width: 100%;
    height: 100%;
    background: #0f172a;
    border-radius: 1.5rem;
    border: 8px solid #172554;
    box-shadow:
        0 0 0 2px #3b82f6,
        /* Thin outer electric blue line */
        inset 0 0 20px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.poster-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    cursor: zoom-in;
    /* Indicate clickable */
    transition: transform 0.2s;
}

.poster-img:hover {
    transform: scale(1.02);
}

/* Lightbox */
.lightbox {
    margin: auto;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    background: rgba(0, 0, 0, 0.95);
    border: none;
    padding: 0;
    z-index: 100;
}

.lightbox-content {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox img {
    max-width: 95vw;
    max-height: 95vh;
    object-fit: contain;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
}

.lightbox-close {
    top: 2rem;
    right: 2rem;
    width: 3rem;
    height: 3rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Corner Decorations */
.corner-decor {
    position: absolute;
    color: #60a5fa;
    /* Light blue sparkle */
    font-size: 2rem;
    line-height: 1;
    text-shadow: 0 0 10px #2563eb;
}

.top-left {
    top: 0.5rem;
    left: 0.5rem;
}

.top-right {
    top: 0.5rem;
    right: 0.5rem;
}

.bottom-left {
    bottom: 0.5rem;
    left: 0.5rem;
}

.bottom-right {
    bottom: 0.5rem;
    right: 0.5rem;
}

/* Footer */
.modal-footer {
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.6);
    /* Darker backdrop for contrast */
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: center;
    width: 100%;
}

.voting-links {
    display: flex;
    flex-wrap: wrap;
    /* Allow wrapping */
    gap: 0.75rem;
    justify-content: center;
    width: 100%;
    max-width: 900px;
    /* Allow wider spread */
}

.vote-btn {
    flex: 1 1 160px;
    /* Grow, shrink, basis 160px */
    max-width: 240px;
    /* Don't get too wide on large screens */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;

    padding: 0.75rem 1.25rem;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0.75rem;

    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
    text-decoration: none;
    text-transform: uppercase;

    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.vote-btn:hover {
    transform: translateY(-2px);
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border-color: #60a5fa;
    box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.4);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Add a pseudo-element for a "glow" effect */
.vote-btn::before {
    content: "🗳️";
    /* Optional icon context */
    font-size: 1.1em;
    filter: grayscale(1);
    transition: filter 0.3s;
}

.vote-btn:hover::before {
    filter: grayscale(0);
}

@media (max-width: 900px) {
    .modal {
        height: auto;
        max-height: 95vh;
        overflow-y: auto;
        /* Allow the dialog itself to scroll */
    }

    .modal-wrapper {
        height: auto;
        /* Let wrapper grow with content */
        display: block;
        /* Remove flex column constraint */
    }

    .modal-content {
        flex-direction: column;
        overflow-y: visible;
        /* Don't scroll internally */
        height: auto;
        padding-bottom: 0;
    }

    .modal-footer {
        position: relative;
        /* It will now just sit at the bottom of the wrapper */
    }

    .modal-left {
        width: 100%;
        flex-direction: column;
        /* Stack vertically */
        align-items: center;
        gap: 1rem;
    }

    .info-stack {
        width: 100%;
        flex-direction: column;
        /* Stack boxes vertically */
        gap: 0.75rem;
    }

    .info-box {
        width: 100%;
        /* Full width boxes */
        min-width: unset;
    }
}