/**
 * Responsive fixes — sikrer at ALLE sider fungerer på alle bredder.
 * Loades sidst i CSS-kæden så den overrider tidligere regler.
 *
 * Målsætning:
 *  - 320px (min viewport iPhone SE) → 1920px (desktop)
 *  - Ingen horisontal scroll
 *  - Ingen indhold der klemmes i smal bjælke (Elementor særligt)
 *  - Læselige font-størrelser overalt
 *  - Klikbare knapper med min 44×44px target-area
 */

/* ═══════════════════════════════════════════════════════════════
   GLOBAL — no horizontal overflow
   VIGTIGT: brug overflow-x:clip fremfor overflow-x:hidden.
   `hidden` skaber en scroll-container der bryder position:sticky
   (sidebar-CTA'en i single.php scroller ikke med længere).
   `clip` gør samme visuelt uden at bryde sticky.
   Fallback til hidden på ældre browsere (Safari < 16, Firefox < 111).
   ═══════════════════════════════════════════════════════════════ */
html, body {
    max-width: 100%;
    overflow-x: clip;
}
@supports not (overflow-x: clip) {
    html, body { overflow-x: hidden; }
}
img, video, iframe, table, pre {
    max-width: 100%;
    height: auto;
}
img { height: auto; }
video, iframe { aspect-ratio: 16 / 9; }
table { display: block; overflow-x: auto; }

/* ═══════════════════════════════════════════════════════════════
   ASTRA CONTAINER — bliv altid fuld bredde på forced pages
   ═══════════════════════════════════════════════════════════════ */
body.ug-fullwidth #primary,
body.ug-fullwidth .site-content > .ast-container,
body.ug-elementor-full .ast-container,
body.page-template-page-service .ast-container,
body.page-template-page-istandsaettelse .ast-container,
body.page-template-page-forside .ast-container,
body.page-template-page-priser .ast-container,
body.page-template-page-faq .ast-container,
body.page-template-page-om-os .ast-container,
body.page-template-page-kontakt .ast-container {
    max-width: 100% !important;
    width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

/* Elementor sektioner — force full-width når de er i vores forced-container */
body.ug-elementor-full .elementor-section-full_width > .elementor-container,
body.ug-elementor-full .elementor-section-boxed > .elementor-container {
    max-width: min(1200px, 100%) !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding-left: 20px;
    padding-right: 20px;
}

/* Elementor col-50 og col-33 skal stå ved siden af hinanden på desktop */
@media (min-width: 1025px) {
    body.ug-elementor-full .elementor-container > .elementor-column {
        flex: 1 1 auto;
    }
}

/* Mobile: Elementor-columns stables */
@media (max-width: 767px) {
    .elementor-container > .elementor-column {
        width: 100% !important;
        flex-basis: 100% !important;
    }
    .elementor-container {
        flex-direction: column;
    }
    .elementor-column-gap-default > .elementor-container > .elementor-column {
        padding: 8px 0;
    }
}

/* ═══════════════════════════════════════════════════════════════
   TYPOGRAPHY — læsbar på alle skærme
   ═══════════════════════════════════════════════════════════════ */
h1 { font-size: clamp(1.75rem, 4vw + 0.5rem, 2.8rem); line-height: 1.15; word-wrap: break-word; }
h2 { font-size: clamp(1.4rem, 2.5vw + 0.5rem, 2.1rem); line-height: 1.25; }
h3 { font-size: clamp(1.15rem, 1.5vw + 0.5rem, 1.55rem); line-height: 1.35; }
p, li { font-size: clamp(0.95rem, 1vw + 0.3rem, 1.05rem); line-height: 1.65; }

/* Brekk lange ord (URLs, e-mails) i stedet for horizontal scroll */
h1, h2, h3, h4, h5, h6, p, li, td, th, a, span, div {
    overflow-wrap: break-word;
    word-wrap: break-word;
    hyphens: auto;
}

/* ═══════════════════════════════════════════════════════════════
   BUTTONS — 44×44px minimum target
   ═══════════════════════════════════════════════════════════════ */
.ug-btn, button, a.button, input[type="submit"], input[type="button"] {
    min-height: 44px;
    min-width: 44px;
    padding: 12px 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    touch-action: manipulation;
}

/* Mobile: knapper flex-wrap */
@media (max-width: 480px) {
    .ug-btn, button, a.button {
        width: 100%;
        max-width: 320px;
    }
    .ug-hero__actions,
    .ug-cta__actions {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
}

/* ═══════════════════════════════════════════════════════════════
   HERO — undgå vertical overflow på små skærme
   ═══════════════════════════════════════════════════════════════ */
.ug-hero {
    min-height: auto;
    padding: 48px 20px;
}
.ug-hero__title {
    max-width: 100%;
}
@media (max-width: 767px) {
    .ug-hero {
        padding: 32px 16px;
    }
    .ug-hero__grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }
    .ug-hero__card {
        margin-top: 16px;
    }
    .ug-hero__badges {
        justify-content: center;
        flex-wrap: wrap;
        gap: 8px;
    }
    .ug-hero__badge {
        font-size: 0.8rem;
        padding: 6px 12px;
    }
}

/* ═══════════════════════════════════════════════════════════════
   TABELLER — scroll-container på mobile
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 767px) {
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        font-size: 0.88rem;
    }
    table th, table td {
        padding: 8px 10px !important;
        white-space: nowrap;
    }
}

/* ═══════════════════════════════════════════════════════════════
   GRIDS — tilpas kolonner efter viewport
   ═══════════════════════════════════════════════════════════════ */
.ug-services,
.ug-work-columns,
.ug-admin-grid,
.ug-related-links-grid,
.ug-org-grid,
.ug-cities-list ul {
    display: grid;
    gap: 16px;
}

/* 4-col → 3 → 2 → 1 */
@media (min-width: 1200px) {
    .ug-services, .ug-work-columns { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
}
@media (max-width: 1199px) and (min-width: 768px) {
    .ug-services, .ug-work-columns, .ug-admin-grid, .ug-org-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .ug-cities-list ul { column-count: 2; }
}
@media (max-width: 767px) {
    .ug-services, .ug-work-columns, .ug-admin-grid, .ug-org-grid,
    .ug-related-links-grid {
        grid-template-columns: 1fr !important;
    }
    .ug-cities-list ul { column-count: 1 !important; }
    .ug-admin-col ul { column-count: 1 !important; }
    .ug-stats { grid-template-columns: 1fr !important; gap: 12px !important; }
}

/* ═══════════════════════════════════════════════════════════════
   FORMS — mobile-optimal
   ═══════════════════════════════════════════════════════════════ */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="number"],
textarea,
select {
    max-width: 100%;
    min-height: 44px;
    padding: 12px 14px;
    font-size: 16px !important; /* Undgå iOS auto-zoom */
    box-sizing: border-box;
}
textarea {
    min-height: 88px;
}

/* TEXTAREA-only: lys-grå, subtil placeholder (efter brugerønske) */
textarea::placeholder,
textarea::-webkit-input-placeholder,
textarea::-moz-placeholder,
textarea:-ms-input-placeholder {
    color: #a8b2bc !important;
    opacity: 0.65 !important;
    font-weight: 400 !important;
    font-style: italic;
}
textarea:focus::placeholder {
    opacity: 0.4 !important;
    transition: opacity 0.15s ease;
}
/* Inputs behouder deres normale synlige placeholder-farve */

.ug-form,
.ug-contactcard,
.ug-header-form,
.form-flat {
    max-width: 100%;
    padding: 20px;
    box-sizing: border-box;
}
@media (max-width: 480px) {
    .ug-form, .ug-contactcard, .ug-header-form, .form-flat {
        padding: 16px;
    }
}

/* ═══════════════════════════════════════════════════════════════
   NAVIGATION — mobile menu button
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 921px) {
    .ast-mobile-header-wrap {
        padding: 8px 12px;
    }
    .site-branding img {
        max-height: 44px;
        width: auto;
    }
}

/* ═══════════════════════════════════════════════════════════════
   FOOTER — stack pænt på mobile
   ═══════════════════════════════════════════════════════════════ */
.ug-footer__grid {
    display: grid;
    gap: 24px;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
@media (max-width: 767px) {
    .ug-footer__grid { grid-template-columns: 1fr !important; }
    .ug-footer__bar {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }
    .ug-footer-cta__grid {
        grid-template-columns: 1fr !important;
        text-align: center;
    }
    .ug-footer-cta__actions {
        justify-content: center;
    }
}

/* ═══════════════════════════════════════════════════════════════
   STICKY BAR — mobile only
   ═══════════════════════════════════════════════════════════════ */
.ug-stickybar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 999;
    background: #fff;
    box-shadow: 0 -4px 16px rgba(0,0,0,.1);
    padding: 8px;
    gap: 8px;
}
.ug-stickybar__btn {
    flex: 1;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
}
@media (min-width: 768px) {
    .ug-stickybar { display: none !important; }
    body { padding-bottom: 0 !important; }
}
@media (max-width: 767px) {
    body { padding-bottom: 68px; }
}

/* ═══════════════════════════════════════════════════════════════
   FIX: Sticky article-sidebar
   Sikrer at parent-elementerne ikke bryder position:sticky.
   Parent må IKKE have overflow:hidden/auto/scroll — kun visible/clip.
   ═══════════════════════════════════════════════════════════════ */
.ug-article__body-wrap,
.ug-article__layout,
.ug-article__sidebar {
    overflow: visible !important;
}
@media (min-width: 1024px) {
    .ug-article__sidebar {
        align-self: start;    /* undgår at grid-cellen stretcher = sticky bryder */
        position: relative;
    }
    .ug-article__sticky {
        position: sticky;
        top: 100px;
        max-height: calc(100vh - 120px);
        overflow-y: auto;     /* hvis CTA-card bliver højere end viewport */
    }
    /* Justér top hvis WP admin-bar er til stede */
    body.admin-bar .ug-article__sticky {
        top: 132px;
    }
}
.ug-article__cta-legal a {
    color: var(--ug-primary, #d12c3e) !important;
    text-decoration: underline;
    font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════════
   FIX: Elementor-content i thin bar
   ═══════════════════════════════════════════════════════════════ */
.elementor-widget-container,
.elementor-widget-wrap {
    max-width: 100%;
}
/* Force column widths reset når Elementor er i vores fullwidth-container */
body.ug-elementor-full .elementor-col-50 {
    width: 100% !important;
    max-width: 50%;
}
@media (max-width: 767px) {
    body.ug-elementor-full .elementor-col-50,
    body.ug-elementor-full .elementor-col-33,
    body.ug-elementor-full .elementor-col-66 {
        max-width: 100% !important;
    }
}

/* ═══════════════════════════════════════════════════════════════
   FIX: Select-elementer med by-liste (istandsaettelse-siden)
   ═══════════════════════════════════════════════════════════════ */
select[onchange*="document.location"] {
    max-width: 100%;
    padding: 12px 16px;
    font-size: 16px !important;
    border: 1px solid var(--ug-border, #d8dfe4);
    border-radius: 8px;
}

/* ═══════════════════════════════════════════════════════════════
   CLS PREVENTION — reserver plads til dynamisk indhold
   ═══════════════════════════════════════════════════════════════ */
.ug-hero { min-height: 400px; }
.ug-hero__video { aspect-ratio: 16 / 9; }
.ug-hero-img img,
.ug-hero__video { min-height: 240px; background: #ecf1f4; }

/* Images uden explicit dimensions får placeholder */
img:not([width]):not([height]) {
    aspect-ratio: 4 / 3;
    background: linear-gradient(135deg, #f5f5f5, #e0e0e0);
}

/* ═══════════════════════════════════════════════════════════════
   ACCESSIBILITY — focus-styles
   ═══════════════════════════════════════════════════════════════ */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 3px solid var(--ug-primary, #d12c3e);
    outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════════════════
   PRINT
   ═══════════════════════════════════════════════════════════════ */
@media print {
    .ug-stickybar, .ug-cta, .ug-hero__video,
    .ug-cookie-banner, header, footer { display: none !important; }
    body { color: #000; background: #fff; }
    a { color: #000; text-decoration: underline; }
}

/* ═══════════════════════════════════════════════════════════════
   DARK-MODE AWARENESS (light-only site — bevar hvid baggrund)
   ═══════════════════════════════════════════════════════════════ */
@media (prefers-color-scheme: dark) {
    /* Vi bevarer light-mode uanset — men gør fokus mere tydelig */
    a:focus-visible { outline-color: #ff5566; }
}
