/* ==========================================================================
   Ruhr-Inspekt: Mobile Optimierung (Stand 30.09.2026)
   Wird nach styles.css geladen. Alle Layout-Aenderungen greifen nur auf
   Tablets und Smartphones (max. 1024px). Desktop bleibt unveraendert.
   Neue Klassen beginnen mit "m-" und werden teils von mobile.js erzeugt.
   ========================================================================== */

/* Neue Bausteine sind auf dem Desktop grundsaetzlich ausgeblendet */
.m-actionbar,
.m-nav-extras,
.m-toc,
.m-hero-contact,
.m-readmore {
  display: none;
}

/* ---------- Tablets und Smartphones (<= 1024px) ---------- */
@media (max-width: 1024px) {

  /* Hell/Dunkel-Schalter in der Kopfzeile, kleiner Abstand zum Menue-Knopf */
  .site-header .header-tools {
    margin-right: 0.35rem;
  }

  /* ---- Feste Aktionsleiste unten ---- */
  .m-actionbar {
    position: fixed;
    z-index: 85;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    gap: 0.6rem;
    align-items: center;
    padding: 0.6rem max(0.9rem, env(safe-area-inset-right)) max(0.6rem, env(safe-area-inset-bottom)) max(0.9rem, env(safe-area-inset-left));
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    -webkit-backdrop-filter: saturate(1.4) blur(12px);
    backdrop-filter: saturate(1.4) blur(12px);
    border-top: 1px solid color-mix(in srgb, var(--line-strong) 70%, transparent);
    box-shadow: 0 -10px 24px -18px rgba(8, 43, 71, 0.45);
    transition: transform 0.25s ease;
  }

  .m-actionbar .btn {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 48px;
    margin: 0;
    justify-content: center;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .m-actionbar .m-wa {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-width: 48px;
    height: 48px;
    padding: 0 0.95rem;
    border-radius: var(--radius-pill);
    background: #1f9e55;
    color: #fff;
    font-weight: 800;
    font-size: 0.95rem;
    text-decoration: none;
  }

  .m-actionbar .m-wa svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
  }

  body.m-has-actionbar {
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
  }

  /* Leiste weg, solange Menue offen ist oder die Tastatur genutzt wird */
  body.is-menu-open .m-actionbar,
  body.m-typing .m-actionbar {
    transform: translateY(110%);
  }

  /* Kein schwebender DachCheck-Knopf mehr, feste Buttons sind abgeschaltet */
  .mobile-sticky-cta {
    display: none !important;
  }

  body[data-page="dachcheck"] .site-footer {
    padding-bottom: 0;
  }

  /* ---- Zusatzbereich im Menue ---- */
  .m-nav-extras {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.75rem;
    margin-top: 1.1rem;
    padding: 1rem 0 max(1rem, env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
  }

  .m-nav-search {
    display: flex;
    gap: 0.5rem;
  }

  .m-nav-search input {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    height: 46px;
    padding: 0 0.9rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-strong);
    font: inherit;
    font-size: 16px;
  }

  .m-nav-search button {
    flex: 0 0 auto;
    height: 46px;
    padding: 0 1rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-alt);
    color: var(--text-strong);
    font: inherit;
    font-weight: 700;
  }

  .m-nav-extras .btn {
    width: 100%;
    min-height: 48px;
    justify-content: center;
    margin: 0;
  }

  .m-nav-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
  }

  .m-nav-row a,
  .m-theme-row {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-height: 46px;
    padding: 0 0.8rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-pill);
    background: var(--surface);
    color: var(--text-strong);
    font: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    text-decoration: none;
    min-width: 0;
  }

  .m-nav-row svg,
  .m-theme-row svg {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .m-nav-row .m-nav-wa svg {
    fill: #1f9e55;
    stroke: none;
  }

  .m-theme-row {
    width: 100%;
    justify-content: space-between;
    cursor: pointer;
  }

  .m-theme-row .m-theme-state {
    color: var(--text-muted);
    font-weight: 600;
  }

  .m-nav-note {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: center;
  }

  /* ---- Groessere Tippflaechen (Ziel mindestens 44px) ---- */
  .case-link,
  .case-study-link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
  }

  .footer-links {
    row-gap: 0.1rem;
  }

  .footer-links a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
  }

  .breadcrumb a {
    display: inline-block;
    padding-block: 0.55rem;
  }

  .brand {
    padding-block: 0.3rem;
  }

  .site-footer .btn,
  .callout .btn,
  .btn-ghost,
  .btn-secondary {
    min-height: 44px;
  }

  /* ---- Mindestschriftgroessen fuer Lesetext ---- */
  p.small,
  div.small,
  .small {
    font-size: max(0.9rem, 14px);
  }

  .service-offer-chips li,
  .contact-submit-note,
  .dcx-review-trust,
  .dcx-offer-note {
    font-size: max(0.9rem, 14px);
  }

  .news-meta,
  .news-meta time,
  .news-meta span,
  .news-overview-topline time,
  .news-overview-footer-meta span,
  figcaption {
    font-size: max(0.82rem, 13px);
  }

  .case-study-badge,
  .news-category-badge,
  .news-source-chip,
  .decision-fit-kicker,
  .service-offer-meta,
  .case-group-label-text {
    font-size: max(0.75rem, 12px);
  }

  /* ---- Formulare: kein automatisches Hineinzoomen auf dem iPhone ---- */
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
  select,
  textarea {
    font-size: 16px !important;
  }

  button,
  .btn {
    font-family: inherit;
  }

  .contact-submit {
    font-size: 1rem;
    font-weight: 800;
    min-height: 50px;
    width: 100%;
    justify-content: center;
  }

  input[type="checkbox"],
  input[type="radio"] {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
  }

  /* Sprungziele nicht unter der festen Kopfzeile verstecken */
  main h2[id],
  main section[id] {
    scroll-margin-top: 96px;
  }
}

/* ---------- Smartphones (<= 760px) ---------- */
@media (max-width: 760px) {

  /* ---- Startseite: Hero kompakter, mit Bild und Vertrauenszeile ---- */
  body[data-page="home"] .hero {
    padding-block: 0.7rem 1.1rem;
  }

  body[data-page="home"] .hero-grid {
    gap: 0;
  }

  body[data-page="home"] .hero-media {
    display: block !important;
    order: -1;
    position: relative;
    z-index: 1;
    min-height: 0;
    width: 100%;
    max-width: none;
    justify-self: stretch;
    margin: 0 0 -16px;
    height: clamp(120px, 34vw, 200px);
    border-radius: 16px 16px 0 0;
    border-bottom: 0;
    box-shadow: none;
  }

  body[data-page="home"] .hero-media::after {
    height: 55%;
    background: linear-gradient(180deg, transparent, rgba(9, 40, 62, 0.35));
  }

  body[data-page="home"] .hero-media picture,
  body[data-page="home"] .hero-media img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 50% 55%;
  }

  body[data-page="home"] .hero-copy {
    position: relative;
    z-index: 2;
    border-radius: 16px;
  }

  body[data-page="home"] .hero-copy .kicker {
    margin-bottom: 0.7rem;
  }

  body[data-page="home"] .hero-copy h1 {
    margin-bottom: 0.8rem;
    font-size: clamp(1.5rem, 6.9vw, 2rem);
    line-height: 1.12;
  }

  /* Die Aufzaehlung wiederholt die Leistungsliste direkt darunter,
     daher auf dem Smartphone ausgeblendet (bleibt im HTML fuer Google) */
  body[data-page="home"] .hero-copy .hero-subline,
  body[data-page="home"] .hero-points {
    display: none;
  }

  body[data-page="home"] .hero-actions {
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
    margin-top: 1rem;
  }

  body[data-page="home"] .hero-actions .btn {
    min-height: 48px;
    padding-inline: 0.6rem;
    font-size: 0.97rem;
    text-align: center;
    line-height: 1.2;
  }

  /* ---- Startseite: Schnellkontakt unter den Buttons ----
     Als zusammenhaengende, leicht getoente Leiste, damit sie sich von
     den Navigations-Buttons darueber abhebt */
  .m-hero-contact {
    display: block;
    margin: 1rem 0 0;
  }

  .m-hero-contact-links {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0;
    padding: 0.3rem;
    border-radius: 16px;
    background: color-mix(in srgb, var(--accent-soft) 65%, var(--surface));
  }

  .m-hero-contact-links a {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 44px;
    padding: 0 0.5rem;
    border-radius: 12px;
    color: var(--text-strong);
    font-size: 0.9rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
  }

  .m-hero-contact-links a + a::before {
    content: "";
    position: absolute;
    left: 0;
    top: 25%;
    bottom: 25%;
    width: 1px;
    background: color-mix(in srgb, var(--accent) 30%, transparent);
  }

  .m-hero-contact-links a:active {
    background: var(--surface);
  }

  .m-hero-contact-links svg {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    fill: none;
    stroke: var(--accent);
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .m-hero-contact-links svg.is-fill {
    fill: #1f9e55;
    stroke: none;
  }

  @media (max-width: 399px) {
    .m-hero-contact-links a {
      padding: 0 0.3rem;
      font-size: 0.86rem;
      gap: 0.3rem;
    }
    .m-hero-contact-links svg {
      width: 16px;
      height: 16px;
    }
  }

  @media (max-width: 340px) {
    .m-hero-contact-links svg {
      display: none;
    }
  }

  /* ---- Startseite: Buttons unter den Praxisbeispielen ----
     Punkte zentriert darueber, Buttons untereinander in voller Breite,
     damit nichts rechts aus der Karte ragt */
  .strip-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.65rem;
    width: 100%;
  }

  .strip-actions .strip-progress {
    justify-self: center;
    margin-bottom: 0.1rem;
  }

  .strip-actions .btn {
    width: 100%;
    min-width: 0;
    min-height: 48px;
    margin: 0;
    justify-content: center;
    text-align: center;
    white-space: normal;
  }

  /* ---- DachCheck: Beispielbild im Bericht nie breiter als die Karte ----
     Mindesthoehe 220px plus 16:10 erzwang sonst 352px Breite */
  body[data-page="dachcheck"] .dcx-report-image {
    width: 100%;
    min-height: 0;
  }

  /* ---- Startseite: Leistungen als kompakte Liste statt grosser Karten ---- */
  body[data-page="home"] #leistungen .service-grid {
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }

  body[data-page="home"] #leistungen .service-card {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr) 20px;
    grid-template-rows: auto auto;
    column-gap: 0.85rem;
    align-items: center;
    padding: 0.6rem 0.75rem 0.6rem 0.6rem;
    min-height: 0;
  }

  body[data-page="home"] #leistungen .service-card::after {
    content: "";
    grid-column: 3;
    grid-row: 1 / span 2;
    width: 9px;
    height: 9px;
    border-top: 2px solid var(--brand);
    border-right: 2px solid var(--brand);
    transform: rotate(45deg);
    justify-self: center;
  }

  body[data-page="home"] #leistungen .service-card > img {
    grid-column: 1;
    grid-row: 1 / span 2;
    width: 96px;
    height: 76px;
    min-height: 0;
    margin: 0;
    border-radius: 10px;
    object-fit: cover;
    aspect-ratio: auto;
  }

  body[data-page="home"] #leistungen .service-card-title-badge {
    grid-column: 2;
    grid-row: 1;
    align-self: end;
    position: static;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    box-shadow: none;
    transform: none;
  }

  body[data-page="home"] #leistungen .service-card-title-badge h3 {
    margin: 0;
    font-size: 1.05rem;
    line-height: 1.25;
  }

  body[data-page="home"] #leistungen .service-card-body {
    grid-column: 2;
    grid-row: 2;
    align-self: start;
    margin: 0;
    padding: 0.2rem 0 0;
    border: 0;
  }

  body[data-page="home"] #leistungen .service-card-body p {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  body[data-page="home"] #leistungen .service-mini-list,
  body[data-page="home"] #leistungen .service-card-cta {
    display: none;
  }

  /* ---- "Weiterlesen" fuer lange Textbloecke (von mobile.js gesetzt) ---- */
  .m-clamp {
    max-height: 13.5em;
    overflow: hidden;
    -webkit-mask-image: linear-gradient(180deg, #000 55%, transparent 100%);
    mask-image: linear-gradient(180deg, #000 55%, transparent 100%);
  }

  .m-clamp.is-expanded {
    max-height: none;
    overflow: visible;
    -webkit-mask-image: none;
    mask-image: none;
  }

  .m-readmore {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 44px;
    margin-top: 0.3rem;
    padding: 0 1rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-pill);
    background: var(--surface);
    color: var(--brand-strong);
    font: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
  }

  .m-readmore::after {
    content: "";
    width: 7px;
    height: 7px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
  }

  .m-readmore[aria-expanded="true"]::after {
    transform: translateY(2px) rotate(-135deg);
  }

  /* ---- Inhaltsverzeichnis auf Leistungs- und Standortseiten ---- */
  .m-toc {
    display: block;
    margin: 1rem 0 0.2rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-2);
  }

  .m-toc > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 50px;
    padding: 0 1rem;
    color: var(--text-strong);
    font-weight: 800;
    cursor: pointer;
    list-style: none;
  }

  .m-toc > summary::-webkit-details-marker {
    display: none;
  }

  .m-toc > summary span {
    color: var(--text-muted);
    font-size: 0.88rem;
    font-weight: 600;
  }

  .m-toc > summary::after {
    content: "";
    width: 8px;
    height: 8px;
    margin-left: 0.6rem;
    border-right: 2px solid var(--brand);
    border-bottom: 2px solid var(--brand);
    transform: translateY(-2px) rotate(45deg);
  }

  .m-toc[open] > summary::after {
    transform: translateY(2px) rotate(-135deg);
  }

  .m-toc ol {
    margin: 0;
    padding: 0 0.5rem 0.6rem;
    list-style: none;
    border-top: 1px solid var(--line);
  }

  .m-toc li a {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 0 0.5rem;
    border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
    color: var(--text-body);
    font-weight: 600;
    text-decoration: none;
  }

  .m-toc li:last-child a {
    border-bottom: 0;
  }

  /* ---- Kurze Linklisten (z. B. Staedte, Stadtteile) als Chips ---- */
  ul.m-chips {
    display: flex !important;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0;
    list-style: none;
  }

  ul.m-chips > li {
    margin: 0;
    padding: 0;
    border: 0;
  }

  ul.m-chips > li::before,
  ul.m-chips > li::marker {
    display: none;
    content: none;
  }

  ul.m-chips > li > a,
  ul.m-chips > li.m-chip-text {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0 0.9rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-pill);
    background: var(--surface);
    color: var(--text-strong);
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
  }

  main ul.m-chips > li > a {
    min-height: 44px;
    text-decoration: none;
    color: var(--brand-strong);
  }

  /* ---- Standortseiten: Wappen-Bild nimmt weniger Platz ein ---- */
  .company-slideshow--crest {
    height: 132px;
    min-height: 0;
    aspect-ratio: auto;
  }

  .company-slideshow--crest .company-slide {
    padding: 0.9rem;
  }
}

/* ---------- Sehr schmale Bildschirme (<= 400px) ----------
   Kleine Handys, Klapphandy-Aussendisplays, grosse Schrift oder Zoom.
   Raster duerfen nie breiter werden als der Bildschirm, lange Woerter
   werden getrennt. */
@media (max-width: 400px) {
  main h1,
  main h2,
  main h3 {
    overflow-wrap: break-word;
  }

  .section-head,
  .news-article,
  .news-overview-content,
  .news-source-block,
  .current-projects-report,
  .callout-grid,
  .service-offer-card,
  .services-cards-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .section-head > *,
  .news-article > *,
  .news-overview-content > *,
  .news-source-block > *,
  .current-projects-report > *,
  .callout > *,
  .callout-grid > *,
  .service-offer-card > *,
  .services-cards-grid > *,
  .dcam-comparison-pair > *,
  .dcam-comparison-pair > * > * {
    min-width: 0;
  }

  .dcam-comparison-pair > * {
    grid-template-columns: minmax(0, 1fr);
  }

  .service-offer-image,
  .dcam-comparison-pair img {
    width: 100%;
    max-width: 100%;
  }

  .kicker {
    flex-wrap: wrap;
    white-space: normal;
  }

  .news-link,
  .news-source-block a {
    overflow-wrap: anywhere;
  }
}

@media (max-width: 340px) {
  main h1,
  main h2,
  main h3 {
    -webkit-hyphens: auto;
    hyphens: auto;
  }
}

/* ---------- Startseite: Hero-Buttons auf dem Smartphone (<= 560px) ----------
   Zeile 1: Leistungen ansehen (volle Breite, Haupt-Button)
   Zeile 2: Erklaervideos ansehen (volle Breite, langer Text bricht nicht um)
   Zeile 3: DachCheck | Projektberichte (zwei gleich breite Buttons) */
@media (max-width: 560px) {
  body[data-page="home"] .hero-actions {
    max-width: none;
  }

  body[data-page="home"] .hero-actions .btn-wide {
    grid-column: 1 / -1;
  }
}

@media (max-width: 380px) {
  body[data-page="home"] .hero-actions .btn {
    padding-inline: 0.35rem;
    font-size: 0.92rem;
  }
}

@media (max-width: 340px) {
  body[data-page="home"] .hero-actions .btn {
    padding-inline: 0.25rem;
    font-size: 0.84rem;
    letter-spacing: 0;
  }
}
