/* Responsive styles for the community garden website */

/* Narrower desktop - slightly smaller nav type */
@media (max-width: 1000px) {
    nav a {
        font-size: 1.05rem;
    }

    .language-switcher .current-lang {
        font-size: 0.97rem;
    }
}

@media (max-width: 900px) {
    /* Expanded header: follows 65vw from the desktop width (matches at 900px), then holds a minimum that fits the nav and language picker */
    header.logo-expanded nav {
        width: min(calc(100% - 2rem), max(65vw, 36rem));
    }

    nav a {
        font-size: 0.95rem;
    }

    .language-switcher .current-lang {
        font-size: 0.87rem;
    }
}

/* Tablet portrait and below - 4rem side margins */
@media (max-width: 800px) {
    header {
        width: 100%;
    }

    header:not(.logo-expanded) .nav-logo-img {
        display: none;
    }

    header:not(.logo-expanded) nav {
        width: calc(100% - 2rem);
        max-width: none;
    }

    header:not(.logo-expanded)::after {
        width: calc(100% - 2rem);
    }

    nav a {
        padding: 0.4rem 0.5rem;
    }

    .projects-tab {
        font-size: 1rem;
        padding: 0.4rem 0.7rem;
    }

    .projects-tabs {
        width: calc(100vw - 8rem);
    }

    .language-switcher {
        position: relative;
        right: auto;
        top: auto;
        transform: none;
        margin-left: 2rem;
    }

    main {
        width: auto;
        max-width: none;
        margin: 5rem 4rem;
    }

    main #content {
        max-width: 100%;
    }

    h1 {
        font-size: 2em;
    }

    h2 {
        font-size: 1.75em;
    }

    h3 {
        font-size: 1.3em;
    }

    p {
        font-size: 1rem;
    }

    article,
    section ul li {
        padding: 1rem;
    }

    /* About page: wide-page margins on tablet */
    body.about-page main,
    body.calendar-page main,
    body.projects-page main,
    body.gallery-view main,
    body.materials-view main {
        margin-left: var(--about-gutter);
        margin-right: var(--about-gutter);
    }

    .collaborator-logos {
        justify-content: center;
    }

    /* Projects grid — 2 columns on tablet */
    .project-grid {
        grid-template-columns: repeat(2, 1fr);
        width: auto;
        max-width: none;
        margin: 0;
    }

    .project-modal-dialog {
        width: calc(100vw - 4rem);
        max-width: none;
    }

    .project-modal-content {
        padding: 0 2rem 2rem;
    }

    .modal-hero-img {
        width: calc(100% + 4rem);
        margin: 0 -2rem 1.5rem;
    }

    .modal-close {
        top: -3rem;
        left: auto;
        right: 0;
    }

    .modal-description .project-content-split {
        grid-template-columns: 1fr;
    }

    .footer-container {
        width: calc(100vw - 8rem);
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 3.5rem;
    }

    .footer-map {
        grid-column: 1 / -1;
        grid-row: 1;
    }

    .footer-stats {
        grid-column: 1;
        grid-row: 2;
    }

    .footer-contact {
        grid-column: 2;
        grid-row: 2;
    }

    .footer-privacy {
        grid-row: 3;
    }

    .footer-contact h3,
    .footer-stats h3 {
        font-size: 1rem;
    }
}

/* About page stacks into one column */
@media (max-width: 680px) {
    .about-intro,
    .about-governance {
        grid-template-columns: 1fr;
    }

    .about-intro .about-photo,
    .about-intro .about-projects,
    .about-governance .about-photo:first-child,
    .about-governance p,
    .about-governance .about-photo:last-child {
        grid-column: 1;
    }

    .about-intro .about-photo {
        order: -1;
    }
}

@media (max-width: 666px) {
    nav a {
        font-size: 0.9rem;
        padding: 0.4rem 0.5rem;
    }

    .language-switcher .current-lang {
        font-size: 0.83rem;
    }

    .footer-contact h3,
    .footer-stats h3 {
        font-size: 0.95rem;
    }
}

/* Narrow phones: the nav becomes a carousel with chevrons instead of shrinking further */
@media (max-width: 580px) {
    .footer-container {
        grid-template-columns: 1fr;
    }

    .footer-map {
        grid-row: 1;
    }

    .footer-contact {
        grid-column: 1;
        grid-row: 2;
    }

    .footer-stats {
        grid-column: 1;
        grid-row: 3;
    }

    .footer-privacy {
        grid-column: 1;
        grid-row: 4;
    }

    .footer-contact h3,
    .footer-stats h3 {
        font-size: 0.88rem;
    }

    nav::before {
        display: none;
    }

    nav ul {
        position: relative;
        flex: 1 1 0;
        min-width: 0;
        justify-content: flex-start;
        overflow-x: auto;
        scrollbar-width: none;
        scroll-snap-type: x proximity;
    }

    nav ul::-webkit-scrollbar {
        display: none;
    }

    nav li {
        flex: none;
        scroll-snap-align: center;
    }

    nav a {
        font-size: 0.9rem;
        padding: 0.4rem 0.6rem;
        white-space: nowrap;
    }

    nav a.active {
        background-color: var(--color-primary);
    }

    .nav-chevron {
        display: block;
        flex: none;
        position: relative;
        width: 1.5rem;
        height: 1.8rem;
        padding: 0;
        border: 0;
        background: none;
        cursor: pointer;
        z-index: 1;
    }

    .nav-chevron::before {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 0.5rem;
        height: 0.5rem;
        border-top: 2px solid var(--color-primary);
        border-right: 2px solid var(--color-primary);
    }

    .nav-prev::before {
        transform: translate(-30%, -50%) rotate(-135deg);
    }

    .nav-next::before {
        transform: translate(-70%, -50%) rotate(45deg);
    }

    .nav-chevron:disabled {
        opacity: 0.25;
        cursor: default;
    }
}

/* Mobile - smaller margins */
@media (max-width: 480px) {
    .language-switcher {
        margin-left: 1rem;
    }

    header:not(.logo-expanded) nav,
    header:not(.logo-expanded)::after {
        width: calc(100% - 1rem);
    }

    .projects-tab {
        font-size: 0.85rem;
        padding: 0.3rem 0.4rem;
    }

    .projects-tabs {
        width: 100%;
    }

    main {
        width: auto;
        margin: 5rem 2rem;
    }

    h1 {
        font-size: 1.75em;
    }

    h2 {
        font-size: 1.5em;
    }

    h3 {
        font-size: 1.2em;
    }

    p {
        font-size: 0.95rem;
    }

    article,
    section ul li {
        padding: 1rem;
    }

    section ul li strong {
        font-size: 1.1rem;
    }

    form button {
        width: 100%;
        padding: 0.875rem;
    }

    /* Projects grid — 1 column on mobile */
    .project-grid {
        grid-template-columns: 1fr;
        width: auto;
        max-width: none;
        margin: 0;
    }

    .project-modal-dialog {
        width: calc(100vw - 2rem);
    }

    .project-modal-content {
        padding: 0 1.5rem 1.5rem;
        max-height: 85vh;
    }

    .modal-hero-img {
        width: calc(100% + 3rem);
        margin: 0 -1.5rem 1.25rem;
    }

    .modal-project-title {
        font-size: 1.4em;
    }

    .modal-gallery {
        grid-template-columns: 1fr;
    }

    .footer-container {
        width: calc(100vw - 4rem);
        gap: 1.5rem;
    }

    .footer-privacy-dialog {
        width: calc(100vw - 1.5rem);
        max-height: calc(100vh - 1.5rem);
    }

    .footer-privacy-heading {
        padding: 1.5rem 3rem 0.75rem 1.25rem;
    }

    .footer-privacy-content {
        max-height: calc(100vh - 6rem);
        padding: 0.75rem 1.25rem 1.5rem;
    }
}