/* ATM Projekt - Responsive Styles */

/* Scroll position of a mobile gallery (0 = first slide, 1 = last), animated by its scroll timeline */
@property --gallery-progress {
    syntax: '<number>';
    inherits: true;
    initial-value: 0;
}

@keyframes gallery-progress {
    from { --gallery-progress: 0; }
    to { --gallery-progress: 1; }
}

/* Tablet / smaller desktop */
@media only screen and (max-width: 1199px) {
    :root {
        --section-padding: 60px 0;
        --container-padding: 0 15px;
    }

    .container {
        padding: var(--container-padding);
    }

    h1 {
        font-size: 2.5rem;
    }

    h2 {
        font-size: 2rem;
    }

    .nav-list li {
        margin: 0 1rem;
    }

    .nav-list a {
        font-size: 1rem;
    }

    .services-content > .services-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .contact-content {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .team-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

/* Mobile */
@media only screen and (max-width: 767px),
       only screen and (hover: none) and (pointer: coarse) {
    :root {
        --section-padding: 40px 0;
        --container-padding: 0 10px;
    }

    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.8rem;
    }

    h3 {
        font-size: 1.4rem;
    }

    p {
        font-size: 1rem;
    }

    .hero-section {
        padding: 40px 0 0;
    }

    .hero-content {
        padding: 20px 0 40px;
    }

    .logo {
        max-height: 80px;
        margin-bottom: 15px;
    }

    .hero-subtitle {
        font-size: 1.1rem;
    }

    /* Navigation without JS: reveal on hover/focus. */
    .nav-list {
        flex-direction: column;
        background-color: var(--atm-green);
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        transform: translateY(-100%);
        visibility: hidden;
        z-index: 99;
        opacity: 0;
        transition: transform 0.3s ease, opacity 0.3s ease;
    }

    .main-nav:hover .nav-list,
    .main-nav:focus-within .nav-list {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }

    .main-nav::before {
        content: '☰ MENU';
        display: block;
        padding: 1rem;
        text-align: center;
        color: var(--on-green);
        font-family: main;
        background-color: var(--atm-green);
        cursor: pointer;
        z-index: 100;
        position: relative;
    }

    .nav-list li {
        margin: 0;
        border-bottom: 1px solid rgba(255,255,255,0.1);
    }

    .nav-list a {
        padding: 1rem;
        text-align: center;
        font-size: 1.1rem;
    }

    .cloud-link {
        margin: 0.5rem 1rem;
        text-align: center;
        border-radius: 4px;
    }

    .section-title {
        font-size: 1.8rem;
        margin-bottom: 2rem;
    }

    .projects-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .project-header {
        padding: 1.25rem 1.25rem 0.8rem;
    }

    .project-meta {
        flex-direction: column;
        gap: 0.35rem;
    }

    .project-meta span::before {
        display: none;
    }

    .project-description {
        padding: 0.9rem 1.25rem 1.1rem;
    }

    .gallery-dot {
        width: 10px;
        height: 10px;
    }

    .gallery-nav {
        gap: 6px;
    }

    /* Swipeable gallery: slides sit in a horizontal scroll-snap strip instead of radio switching */
    .gallery-container {
        display: flex;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-snap-type: x mandatory;
        overscroll-behavior-x: contain;
        scrollbar-width: none;
        scroll-timeline: --gallery x;
    }

    .gallery-container::-webkit-scrollbar {
        display: none;
    }

    .gallery-item {
        position: relative;
        inset: auto;
        flex: 0 0 100%;
        display: block;
        opacity: 1;
        scroll-snap-align: start;
        scroll-snap-stop: always;
    }

    /* Dots become a position indicator: --n (slides) and --i (dot index) come from index.php */
    .project-gallery {
        timeline-scope: --gallery;
    }

    @supports (animation-timeline: scroll()) {
        .project-gallery {
            animation: gallery-progress linear both;
            animation-timeline: --gallery;
        }
    }

    .gallery-dot {
        --gallery-dot-on: clamp(0, (0.5 - max(var(--gallery-progress, 0) * (var(--n) - 1) - var(--i), var(--i) - var(--gallery-progress, 0) * (var(--n) - 1))) * 100, 1);
        /* !important beats the desktop :checked radio highlight, which would pin the first dot */
        background-color: rgb(calc(255 * var(--gallery-dot-on)) calc(255 * var(--gallery-dot-on)) calc(255 * var(--gallery-dot-on)) / calc(0.18 + 0.77 * var(--gallery-dot-on))) !important;
        pointer-events: none;
    }

    .about-text p {
        font-size: 1rem;
        line-height: 1.6;
    }

    .team-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .team-member {
        padding: 1rem;
        text-align: center;
    }

    .services-content > .services-list {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .service-item {
        padding: 1.25rem;
    }

    .contact-content {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .contact-info {
        gap: 1rem;
    }

    .contact-item {
        padding: 1rem;
    }

    .contact-form {
        padding: 1.5rem;
    }

    .form-group {
        margin-bottom: 1rem;
    }

    .submit-btn {
        width: 100%;
        padding: 1rem;
    }

    .main-footer {
        padding: 1.5rem 0;
        font-size: 0.9rem;
    }

    .contact-toast-toggle {
        right: 1rem;
        bottom: 1rem;
        padding: 0.7rem 1.2rem;
        font-size: 1rem;
    }

    /* Toast becomes a bottom sheet */
    .contact-toast-panel {
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-height: 85vh;
        max-height: 85dvh;
        padding: 1.5rem 1rem 1rem;
        border-radius: 12px 12px 0 0;
    }

    .contact-toast .section-title {
        font-size: 1.6rem;
    }

    .go-up {
        right: 1rem;
        bottom: 4.5rem;
        width: 2.75rem;
        height: 2.75rem;
    }
}

/* Extra small mobile */
@media only screen and (max-width: 480px) {
    :root {
        --container-padding: 0 5px;
    }

    h1 {
        font-size: 1.8rem;
    }

    h2 {
        font-size: 1.6rem;
    }

    .hero-content {
        padding: 15px 0 30px;
    }

    .logo {
        max-height: 60px;
    }

    .project-header,
    .project-description {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .service-item,
    .contact-form {
        padding: 1rem;
    }

    .contact-item {
        padding: 0.8rem;
    }
}

/* Landscape on low-height screens */
@media only screen and (max-height: 500px) and (orientation: landscape) {
    .hero-section {
        padding: 20px 0 0;
    }

    .hero-content {
        padding: 10px 0 20px;
    }

    .logo {
        max-height: 50px;
        margin-bottom: 10px;
    }

    .section-title {
        margin-bottom: 1.5rem;
    }
}

/* High DPI */
@media only screen and (-webkit-min-device-pixel-ratio: 2),
       only screen and (min-resolution: 192dpi) {
    .logo {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Print */
@media print {
    * {
        background: transparent !important;
        color: black !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }

    .main-nav,
    .gallery-nav,
    .contact-toast,
    .go-up,
    .main-footer {
        display: none;
    }

    .hero-section,
    .portfolio-section,
    .about-section,
    .services-section,
    .contact-section {
        page-break-inside: avoid;
    }

    .projects-grid,
    .services-list {
        display: block;
    }

    .project-item,
    .service-item {
        page-break-inside: avoid;
        margin-bottom: 2rem;
    }

    .gallery-container {
        aspect-ratio: auto;
        height: auto;
    }

    .gallery-item {
        position: static;
        display: none;
        opacity: 1;
    }

    .gallery-item:first-child {
        display: block;
    }

    .project-image {
        width: 100%;
        height: auto;
        object-fit: contain;
    }
}

/* Keyboard focus */
@media (prefers-reduced-motion: no-preference) {
    .nav-list a:focus,
    .submit-btn:focus,
    .gallery-dot:focus,
    .contact-item a:focus {
        outline: 2px solid var(--atm-accent);
        outline-offset: 2px;
    }
}

/* Keep the existing automatic dark-mode behaviour. */
@media (prefers-color-scheme: dark) {
    :root {
        --white: #1a1a1a;
        --light-gray: #2d2d2d;
        --medium-gray: #404040;
        --text-color: #e0e0e0;
        /* Lighter logo green for text on dark backgrounds (backgrounds keep --atm-green) */
        --atm-green-text: #81a880;
        --atm-green-text-hover: #a3c2a2;
    }

    .project-item,
    .service-item,
    .process-section,
    .contact-form,
    .contact-item,
    .team-member {
        background-color: var(--light-gray);
        color: var(--text-color);
    }

    .go-up,
    .go-up::before {
        border-color: var(--atm-accent);
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        background-color: var(--medium-gray);
        color: var(--text-color);
        border-color: #555;
    }

    .form-group input:focus,
    .form-group select:focus,
    .form-group textarea:focus {
        border-color: var(--atm-accent);
    }
}
