/* ================================
    Responsive Styles
================================ */

/* Tablet (max-width: 1024px) */
@media screen and (max-width: 64rem) {
    :root {
        --spacing-xl: 3rem; /* Reduce from 96px to 48px */
    }

    .header {
        padding: var(--spacing-lg) var(--spacing-lg);
    }

    .container {
        padding: 0 var(--spacing-lg);
    }

    .page {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }

    .sidebar {
        position: static;
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-sm);
    }

    .filter-tabs {
        flex-wrap: wrap;
    }

    .filter-tab {
        min-width: auto;
        flex: 1;
    }

    .footer__container {
        padding: 0 3rem; /* Reduce from 64px to 48px */
    }

    .footer__top {
        grid-template-columns: 1fr 1fr; /* 2 columns */
        gap: 2rem;
    }

    .footer__column--nav {
        grid-column: 1 / -1; /* Full width */
    }

    .footer__bottom {
        flex-wrap: wrap;
        gap: 2rem;
    }

    .footer__address {
        text-align: left;
        flex-basis: 100%;
    }

    .page > article {
        max-width: calc(100vw - var(--spacing-md) * 2);
        margin-left: auto;
        margin-right: auto;
    }
}

/* Mobile (max-width: 768px) */
@media screen and (max-width: 48rem) {
    :root {
        --spacing-xl: 1.5rem; /* Reduce to 24px */
        --font-size-large: 1.75rem; /* Reduce from 33px to 28px */
    }

    /* Prevent horizontal scroll */
    html, body {
        overflow-x: hidden;
        max-width: 100vw;
    }

    /* Ensure all containers respect viewport width */
    * {
        max-width: 100%;
    }

    .header {
        padding: var(--spacing-md); /* 20px vertical, 30px horizontal */
    }

    .header__container {
        /* Keep flex-direction: row (default) - DON'T change to column */
        justify-content: space-between;
        align-items: center;
        padding: var(--spacing-lg); /* Match Figma padding */
        max-width: 100%; /* Remove desktop max-width constraint */
    }

    .header__logo-group {
        width: auto; /* Remove width: 100% */
        justify-content: flex-start; /* Align logo to left */
    }

    .header__logo {
        height: 2rem; /* 32px as per Figma */
    }

    /* Mobile nav is hidden by mobile-menu.css */

    .container {
        padding: 0 var(--spacing-md);
    }

    .sidebar {
        grid-template-columns: 1fr;
    }

    .filter-tabs,
    .filter-subtabs {
        flex-direction: column;
    }

    .filter-tab,
    .filter-subtab {
        width: 100%;
    }

    .results__section-title {
        font-size: 1.5rem;
        line-height: 1.3;
    }

    .card {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-md);
    }

    .footer {
        padding: var(--spacing-lg); /* 30px matches mobile container padding */
        margin: var(--spacing-md);
        margin-bottom: 0;
        padding-bottom: 3rem;
        border-radius: 20px 20px 0 0; /* Match Figma mobile design */
    }

    .footer__container {
        padding: 0;
        gap: 43px; /* Match Figma spacing between sections */
    }

    .footer__top {
        grid-template-columns: 1fr; /* Single column */
        gap: 43px; /* Gap between footer columns on mobile per Figma */
    }

    .footer__column--nav,
    .footer__column--legal-social,
    .footer__column--extra {
        grid-column: 1;
    }

    .footer__bottom {
        display: flex; /* Change from grid to flex */
        flex-direction: column;
        align-items: flex-start;
        gap: 43px;
    }

    .footer__logo-container {
        order: 2; /* Logo comes after divider per Figma */
        padding-bottom: 43px;
        border-bottom: 1px solid var(--color-gray-light);
    }

    .footer__organization-container {
        margin-left: 0;
        order: 3;
    }

    .footer__address {
        order: 3;
    }

    .footer__logo {
        height: auto; /* Match Figma height */
        width: 100%;
    }

    .footer__divider {
        margin: 0; /* Remove extra margin, gap handles spacing */
    }

    .scrollable-list {
        flex-direction: column;
    }

    .scrollable-list__scrollbar {
        display: none;
    }

    /* ================================
         Projects Page Mobile Styles
         ================================ */

    /* Projects Page Container */
    .projects-container {
        padding: 0 var(--spacing-md); /* Match Figma mobile padding */
    }

    /* Projects Header */
    .projects-header {
        flex-direction: column;
        gap: 2.25rem; /* Reduce from 3.5rem */
        align-items: stretch;
    }

    .projects-title {
        font-size: 28px; /* Match Figma */
        line-height: 32px;
        margin-bottom: 0;
        transform: none;
    }

    .projects-tabs {
        flex-direction: column;
        gap: 0;
    }

    .projects-tab {
        padding: var(--spacing-lg);
        text-align: left;
        font-size: 18px;
        font-style: normal;
        font-weight: 450;
        line-height: 20px;
        display: block;
        height: unset;
        border-radius: var(--spacing-lg);
        margin: 0 var(--spacing-lg);
        width: calc(100% - var(--spacing-lg) * 2);

        display: none;
    }

    .projects-tab span {
        display: block;
    }

    .projects-tab--active {
        display: block;
        margin: 0;
        width: 100%;
        order: -1;
        background: var(--color-black) url('data:image/svg+xml,<svg width="30" height="16" viewBox="0 0 30 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0.707031 0.707032L14.707 14.707L28.707 0.70703" stroke="white" stroke-width="2" stroke-linejoin="bevel"/></svg>') no-repeat center right var(--spacing-lg);
    }

    .projects-tab:not(.projects-tab--disabled):hover {
        transform: none;
    }

    /* Search Input */
    .projects-search {
        width: 100%;
        margin: 0;
        padding-left: 0;
        margin-bottom: 1.5rem;
    }

    .projects-search-input {
        width: 100%;
        max-width: 100%;
        height: 64px; /* Match Figma */
        font-size: 18px;
        line-height: 24px;
        padding: 16px 24px;
        border-radius: 20px;
        margin-top: 1.5rem;
    }

    /* Mobile Filter Toggle Button */
    .mobile-filter-toggle {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        height: 64px; /* Match Figma */
        background-color: var(--color-primary); /* #ff412c */
        color: var(--color-white);
        border: none;
        border-radius: 16px;
        padding: 16px 24px;
        font-family: var(--font-family);
        font-size: 20px;
        font-weight: var(--font-weight-medium);
        line-height: 24px;
        cursor: pointer;
        transition: background-color var(--transition-fast);
    }

    .mobile-filter-toggle:hover {
        background-color: rgba(255, 65, 44, 0.9);
    }

    .mobile-filter-toggle__icon {
        font-size: 24px;
        line-height: 1;
        transition: transform 0.3s ease;
    }

    .mobile-filter-toggle[aria-expanded="true"] .mobile-filter-toggle__icon {
        transform: rotate(45deg); /* Plus becomes X */
    }

    /* Projects Layout - Single Column */
    .projects-layout {
        grid-template-columns: 1fr; /* Remove sidebar column */
        gap: 0;
    }

    /* Mobile Filter Drawer (Sidebar) */
    .mobile-filter-drawer {
        scroll-margin-top: 12rem;
        display: none; /* Hidden by default */
        gap: 24px; /* Gap between filter boxes */
        order: -1; /* Show before projects grid */
        padding-top: 1.5rem;
    }

    .mobile-filter-drawer[aria-hidden="false"] {
        display: flex;
    }

    /* Filter Boxes on Mobile */
    .filter-box {
        background-color: var(--color-white);
        padding: 24px; /* Match Figma */
        border-radius: 20px; /* Match Figma */
        gap: 40px; /* Internal gap between header and content */
    }

    .filter-header {
        font-size: 18px;
        line-height: 24px;
        color: var(--color-primary);
    }

    .filter-content {
        gap: 24px; /* Gap between checkbox rows */
    }

    /* Checkboxes on Mobile */
    .filter-checkbox {
        gap: 10px; /* Match Figma */
    }

    .checkbox__box {
        width: 28px;
        height: 28px;
        border-width: 2px;
        border-radius: 2px;
    }

    .checkbox__label {
        font-size: 18px;
        line-height: 24px;
    }

    /* Projects Grid - Single Column */
    .projects-grid {
        grid-template-columns: 1fr; /* Single column */
        gap: 24px; /* Match Figma */
    }

    /* Project Cards on Mobile */
    .project-card {
        padding: 24px; /* Match Figma */
        border-radius: 20px; /* Match Figma */
        gap: 30px; /* Internal gap */
    }

    .project-card-title {
        font-size: 24px; /* Match Figma */
        line-height: 28px;
        min-height: auto; /* Remove desktop constraint */
    }

    .project-tag {
        font-size: 15px;
        line-height: 17px;
        padding: 8px;
    }

    /* ================================
         Single Project Page Mobile Styles
         ================================ */

    /* Single Project Container */
    .single-project-container {
        margin-top: 0;
        padding: 0 var(--spacing-md); /* Match Figma mobile padding */
    }

    /* Single Project Layout - Single Column */
    .single-project-layout {
        grid-template-columns: 1fr; /* Remove sidebar column */
        gap: var(--spacing-lg);
    }

    /* Main Project Info Box */
    .project-info-box {
        flex: initial;
        padding: 24px; /* Match Figma */
        border-radius: 20px; /* Match Figma */
        gap: 24px; /* Reduce from 56px */
    }

    /* Project Hero - Column Layout on Mobile */
    .project-hero {
        flex-direction: column;
        gap: 24px;
    }

    .project-hero-image {
        flex: initial;
        width: 100%;
        height: auto;
        aspect-ratio: 1; /* Square image on mobile */
        border-radius: 4px; /* Match Figma */
    }

    .project-hero-content {
        max-width: 100%;
    }

    .project-hero-title {
        font-size: 32px; /* Match Figma */
        line-height: 36px;
        letter-spacing: -0.32px; /* Match Figma */
        word-break: break-word;
    }

    /* Project Meta Row - Single Column */
    .project-meta-row {
        grid-template-columns: 1fr; /* Single column */
        gap: 24px;
        padding-top: 24px;
    }

    .project-meta-icon {
        grid-column: initial;
        width: 64px; /* Match Figma */
        height: 64px;
    }

    .project-meta-icon img {
        width: 100%;
        height: auto;
    }

    .project-meta-item {
        grid-column: initial;
    }

    .project-meta-item--download .project-jury-button {
        width: fit-content;
    }

    .project-meta-label,
    .project-meta-value {
        font-size: 15px;
        line-height: 17px;
    }

    /* Project Details Rows - Single Column */
    .project-details-row {
        grid-template-columns: 1fr; /* Single column */
        gap: 24px;
        padding-top: 24px;
    }

    .project-oembed-wrapper {
        padding-right: 0;
    }

    .project-details-row--links {
        gap: 0.625rem;
    }

    .project-detail-item {
        grid-column: initial !important; /* Override desktop grid-column spans */
    }

    .project-detail-item--awards,
    .project-detail-item--coord,
    .project-detail-item--team,
    .project-detail-item--events,
    .project-detail-item--tiraj {
        grid-column: initial !important;
    }

    .project-detail-label,
    .project-detail-value {
        font-size: 15px;
        line-height: 17px;
    }

    /* Jury Report Button */
    .button-container {
        width: 100%;
    }

    .project-jury-button {
        width: fit-content;
        padding: 10px;
        border-radius: 10px;
        font-size: 15px;
        line-height: 17px;
    }

    /* Project Sidebar - Full Width on Mobile */
    .project-sidebar {
        flex: initial;
        gap: 24px;
    }

    .project-sidebar-box {
        padding: 24px; /* Match Figma */
        border-radius: 20px; /* Match Figma */
        gap: 40px; /* Match Figma */
    }

    .project-sidebar-title {
        font-size: 18px; /* Match Figma */
        line-height: 24px;
    }

    /* Recurring Project Dropdown */
    .project-recurring-dropdown .dropdown-button,
    select.filter-select {
        padding: 16px; /* Match Figma */
        border-radius: 10px; /* Match Figma */
        font-size: 18px;
        line-height: 24px;
        background-color: #f6f6f6; /* Match Figma */
    }

    /* Keywords List - Wrap on Mobile */
    .project-keywords-list {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 16px; /* Match Figma */
    }

    .project-keyword-tag {
        padding: 10px 12px;
        border-radius: 12px;
        font-size: 15px;
        line-height: 17px;
    }

    /* Description Section - Full Width */
    .project-description-section {
        margin-right: 0;
        margin-top: 1.5rem;
        margin-bottom: 0;
        grid-template-columns: 1fr; /* Single column */
        gap: 1.5rem;
    }

    .project-section-label {
        font-size: 15px;
        line-height: 17px;
        margin-bottom: 24px;
        padding-bottom: 24px;
    }

    .project-section-label.title {
        margin: 0;
        padding: 0;
        border: 0;
        float: none;
    }

    .project-description-content {
        grid-column: initial;
    }

    .project-description-content p {
        font-size: 18px; /* Match Figma */
        line-height: 24px;
    }

    /* Links Section */
    .project-links-section {
        margin-right: 0;
        padding-top: 24px;
        padding-bottom: 24px;
    }

    .project-links-list {
        margin-left: 0; /* Remove desktop offset */
        gap: 15px; /* Match line-height */
    }

    .project-links-list a {
        font-size: 15px;
        line-height: 30px; /* Match Figma */
    }

    /* Gallery Section */
    .project-gallery-wrapper {
        margin-right: 0;
        grid-template-columns: 1fr 1fr; /* Single column */
        gap: 24px;
        margin-bottom: 1.5rem;
    }

    .project-gallery-slider {
        width: 100%;
        margin: 0;
        grid-column: 1/3;
    }

    .project-gallery-slider img {
        border-radius: 24px; /* Match Figma */
    }

    .project-gallery-slider figcaption {
        margin: 8px 0 0 0;
    }

    .project-gallery-nav-btn {
        grid-row: 2;
        margin-right: 0;
        margin-left: auto;
    }

    .project-gallery-nav-btn--next {
        transform: none; /* Remove desktop offset */
        margin-left: 0;
    }

    /* Related Projects Section */
    .project-related-section {
        padding-top: 24px;
    }

    .project-related-section .project-section-label {
        margin-bottom: 3rem;
    }

    .project-related-grid {
        grid-template-columns: 1fr; /* Single column */
        gap: 24px; /* Match Figma */
    }
}

/* Desktop - Hide Mobile Elements */
@media screen and (min-width: 48.0625rem) {
    .mobile-filter-toggle {
        display: none;
    }

    .mobile-filter-drawer {
        display: flex; /* Always visible on desktop */
    }
}

/* Small Mobile (max-width: 480px) */
@media screen and (max-width: 30rem) {
    :root {
        --font-size-base: 0.875rem; /* 14px */
        --font-size-medium: 1rem; /* 16px */
        --font-size-large: 1.5rem; /* 24px */
    }

    .header__logo {
        height: 2rem;
    }

    .btn {
        font-size: 0.875rem;
        padding: 0.5rem 0.625rem;
    }

    .card {
        padding: var(--spacing-md);
    }

    .card__title {
        font-size: 1rem;
    }

    .filter-box:not(:last-child) {
        margin-bottom: var(--spacing-lg);
    }
}

/* Print Styles */
@media print {
    .header,
    .sidebar,
    .filter-bar,
    .footer__divider {
        display: none;
    }

    .page {
        grid-template-columns: 1fr;
    }

    .card {
        break-inside: avoid;
    }

    body {
        background-color: var(--color-white);
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .btn,
    .filter-tab,
    .card {
        border: 2px solid currentColor;
    }

    .checkbox__box {
        border-width: 2px;
    }
}
