/* ==========================================================================
   responsive.css - tablet (<=1024px) and phone (<=767px) layout fixes.
   Loaded last in every page. Desktop (>1024px) is intentionally untouched.
   Nothing is hidden; only spacing, sizing, wrapping and grid counts change.
   ========================================================================== */

/* ---- 1. Base safety: media never wider than the viewport ---------------- */
@media (max-width: 1024px) {
    img,
    video,
    embed,
    object,
    iframe,
    canvas {
        max-width: 100%;
    }
    img {
        height: auto;
    }
    /* Long words, URLs and e-mail addresses must wrap instead of pushing the page wide */
    p,
    li,
    td,
    th,
    dd,
    figcaption,
    h1,
    h2,
    h3,
    h4,
    h5,
    h6 {
        overflow-wrap: break-word;
    }
    a[href^="mailto:"],
    .gr-footer a,
    .gr-mobile-address {
        overflow-wrap: anywhere;
    }
}

/* ---- 2. Tablet (<=1024px): spacing and grids ----------------------------- */
@media (max-width: 1024px) {
    .gr-main-content {
        padding-left: 24px;
        padding-right: 24px;
    }
    .gr-footer {
        padding-left: 24px;
        padding-right: 24px;
    }
    .gr-services-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1.25rem;
    }
    /* News: two cards per row; the featured card spans the full row */
    .gr-news-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .gr-news-card.featured {
        grid-column: 1 / -1;
    }
    .cms-cols-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    /* Header: the full nav does not fit beside the logo and phone on tablets,
       so it moves into the hamburger menu (which already lists every link and the address). */
    .gr-nav,
    .gr-header-address {
        display: none;
    }
    .gr-mobile-toggle,
    .gr-mobile-menu {
        display: block;
    }
    .gr-header-contact {
        gap: 1rem;
    }
    .gr-header-inner {
        padding-left: 24px;
        padding-right: 24px;
    }
}

/* ---- 3. Typography (<=1024px) -------------------------------------------- */
@media (max-width: 1024px) {
    body {
        line-height: 1.6;
    }
    .gr-main-content p,
    .gr-main-content li,
    .gr-footer-text {
        font-size: 1rem;
        line-height: 1.65;
    }
    .gr-main-content h1,
    .gr-page-hero h1 {
        font-size: clamp(1.75rem, 4.5vw + 0.5rem, 2.25rem);
        line-height: 1.2;
    }
    .gr-main-content h2 {
        font-size: clamp(1.5rem, 3vw + 0.6rem, 1.9rem);
        line-height: 1.25;
    }
    .gr-main-content h3 {
        font-size: clamp(1.2rem, 2vw + 0.6rem, 1.4rem);
        line-height: 1.3;
    }
}

/* ---- 4. Phone (<=767px): layout, spacing and grids ----------------------- */
@media (max-width: 767px) {
    .gr-main-content {
        padding-left: 16px;
        padding-right: 16px;
    }
    .gr-footer {
        padding: 3rem 16px 2rem;
        margin-top: 3rem;
    }
    .gr-footer-inner {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    .gr-footer-links li {
        margin-bottom: 0;
    }
    .gr-services-grid,
    .gr-news-grid,
    .cms-cols,
    .cms-cols-3 {
        grid-template-columns: minmax(0, 1fr);
    }
    .gr-news-card.featured {
        grid-template-columns: minmax(0, 1fr);
    }
    /* Blog list cards: image and text stack at full width */
    .gr-main-content .post > * {
        width: 100% !important;
        max-width: 100%;
    }
    .gr-main-content .post-thumbnail-wrap img {
        width: 100%;
        height: auto;
    }
    .gr-hero-title {
        font-size: clamp(2rem, 8.5vw, 2.5rem);
        line-height: 1.15;
    }
    .gr-hero-subtitle,
    .gr-hero-description {
        font-size: 1rem;
        line-height: 1.6;
    }
    .gr-hero-content {
        padding-left: 16px;
        padding-right: 16px;
    }
}

/* ---- 5. Tap targets (<=1024px) ------------------------------------------- */
@media (max-width: 1024px) {
    .gr-footer-links a,
    .gr-footer-privacy a,
    .gr-footer-legal a,
    .gr-mobile-nav a,
    .gr-mobile-contact a {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
    }
    .gr-mobile-nav a {
        display: flex;
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
    }
    .gr-mobile-toggle,
    .gr-mobile-close,
    .gr-search-toggle,
    .gr-search-close {
        min-width: 44px;
        min-height: 44px;
    }
    .gr-header .gr-phone {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
    }
}

/* ---- 6. Buttons and forms (<=767px) -------------------------------------- */
@media (max-width: 767px) {
    .gr-btn-primary,
    .gr-btn-secondary,
    .cms-button,
    .gr-hero-buttons a {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 44px;
        max-width: 100%;
        box-sizing: border-box;
        text-align: center;
    }
    .gr-hero-buttons {
        width: 100%;
    }
    /* 16px inputs stop iOS from zooming the page on focus */
    input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]),
    select,
    textarea,
    button {
        font-size: 16px;
    }
    input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]),
    select,
    textarea {
        width: 100%;
        max-width: 100%;
        min-height: 44px;
        box-sizing: border-box;
    }
    .gr-search-overlay-form input,
    .gr-mobile-search input {
        width: 100%;
        max-width: 100%;
    }
}

/* ---- 7. Price tables (TablePress, <=767px) ------------------------------- */
@media (max-width: 767px) {
    .tablepress {
        width: 100%;
        max-width: 100%;
        table-layout: auto;
    }
    .tablepress th,
    .tablepress td {
        padding: 0.75rem 0.5rem;
        overflow-wrap: break-word;
    }
    /* Price column stays on one line and right-aligned */
    .tablepress th:last-child,
    .tablepress td:last-child {
        white-space: nowrap;
        text-align: right;
        padding-right: 0.75rem;
    }
}

/* ---- 8. Phone header and small phones (<=380px) -------------------------- */
@media (max-width: 380px) {
    .gr-header-inner {
        gap: 0.5rem;
        padding-left: 12px;
        padding-right: 12px;
    }
    .gr-phone {
        font-size: 0.875rem;
    }
    .gr-hero-title {
        font-size: 2rem;
    }
    .gr-page-hero h1,
    .gr-main-content h1 {
        font-size: 1.6rem;
    }
    .gr-main-content h2 {
        font-size: 1.35rem;
    }
    .gr-main-content {
        padding-left: 12px;
        padding-right: 12px;
    }
    .gr-footer {
        padding-left: 12px;
        padding-right: 12px;
    }
    .gr-hero-content {
        padding-left: 12px;
        padding-right: 12px;
    }
}

/* ---- 9. Reduced motion (all sizes) --------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
