/* Gemeinsame mobile Darstellung: ausklappbare Navigation, Touch-Flächen und schmale Seitenraster.
   Bei mehrfach definierten Selektoren gilt die CSS-Kaskade: spätere bzw. spezifischere Regeln können frühere überschreiben. */
/* Shared mobile layout, loaded after the page-specific styles. */
.menu-toggle {
  display: none;
}

/* Mobiles Navigationspanel: JavaScript steuert den geöffneten Zustand. */
.mobile-nav-panel {
  display: contents;
}

/* Bildschirmabhängige Anpassungen: gelten nur bei der folgenden Breite bzw. Systemeinstellung. */
@media (max-width: 900px) {
  html {
    scroll-padding-top: 6rem;
  }

  .site-header {
    position: sticky;
    top: 0;
    padding: 0.6rem 0;
    background: transparent;
    border-bottom: 0;
  }

  .header-bar {
    gap: 0 0.5rem;
    padding: 0.65rem;
    border: 1px solid rgba(167, 139, 250, 0.28);
    border-radius: 18px;
    background: rgba(12, 10, 19, 0.97);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.25);
  }

  .mobile-nav-ready {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  .brand-logo-box {
    width: min(200px, 100%);
  }

  .home-hero .hero-visual {
    border-top: 0;
  }

  .menu-toggle {
    grid-row: 1;
    grid-column: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 64px;
    min-height: 44px;
    gap: 0.45rem;
    padding: 0.5rem 0.65rem;
    border: 1px solid rgba(167, 139, 250, 0.22);
    border-radius: 12px;
    background: rgba(167, 139, 250, 0.07);
    color: #ede6ff;
    font-size: 0.8rem;
    font-weight: 600;
    transition: background 180ms ease, border-color 180ms ease;
  }

  .menu-toggle[aria-expanded="true"] {
    background: rgba(167, 139, 250, 0.18);
    border-color: rgba(167, 139, 250, 0.5);
  }

  .menu-toggle-icon {
    position: relative;
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
  }

  .menu-toggle-icon::before,
  .menu-toggle-icon::after {
    content: "";
    position: absolute;
    left: 0;
    top: 7px;
    width: 16px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
    transition: transform 220ms ease;
  }

  .menu-toggle-icon::before {
    transform: translateY(-3px);
  }

  .menu-toggle-icon::after {
    transform: translateY(3px);
  }

  .menu-toggle[aria-expanded="true"] .menu-toggle-icon::before {
    transform: rotate(45deg);
  }

  .menu-toggle[aria-expanded="true"] .menu-toggle-icon::after {
    transform: rotate(-45deg);
  }

  .lang-switch {
    grid-row: 1;
    grid-column: -2 / -1;
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
    padding: 10px;
    border: 1px solid rgba(167, 139, 250, 0.22);
    border-radius: 12px;
    background: rgba(167, 139, 250, 0.07);
    transition: background 180ms ease, border-color 180ms ease;
  }

  .lang-switch .lang-flag {
    width: 24px;
    height: 16px;
    border-radius: 3px;
    object-fit: cover;
  }

  .menu-toggle:focus-visible,
  .lang-switch:focus-visible {
    outline: 2px solid #c4b5fd;
    outline-offset: 3px;
  }

  @media (hover: hover) {
    .menu-toggle:hover,
    .lang-switch:hover {
      background: rgba(167, 139, 250, 0.16);
      border-color: rgba(167, 139, 250, 0.5);
    }
  }

  .mobile-nav-panel {
    display: grid;
    grid-column: 1 / -1;
    grid-row: 2;
    grid-template-rows: 0fr;
    overflow: hidden;
    visibility: hidden;
    opacity: 0;
    margin-top: 0;
    transition: grid-template-rows 280ms ease, margin-top 280ms ease,
      opacity 200ms ease, visibility 280ms;
  }

  .menu-open .mobile-nav-panel {
    grid-template-rows: 1fr;
    visibility: visible;
    opacity: 1;
    margin-top: 0.75rem;
  }

  .mobile-nav-ready .main-nav {
    display: grid;
    grid-row: 1;
    grid-column: 1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
    min-height: 0;
    max-height: 60vh;
    max-height: 60dvh;
    overflow-y: auto;
    padding: 0;
  }

  .main-nav .nav-btn {
    min-height: 44px;
    padding: 0.65rem;
    font-size: 0.9rem;
    box-shadow: none;
    white-space: normal;
    text-align: center;
  }

  :where(a, button, summary, input):focus-visible {
    outline: 2px solid #c4b5fd;
    outline-offset: 3px;
  }

  input[type="search"],
  input[type="text"],
  select,
  textarea {
    min-height: 44px;
    font-size: 16px;
  }
}

/* Bildschirmabhängige Anpassungen: gelten nur bei der folgenden Breite bzw. Systemeinstellung. */
@media (max-width: 640px) {
  .container {
    width: calc(100% - 2rem);
  }

  .page {
    padding-top: 0.75rem;
  }

  .hero,
  .home-hero,
  .programme-hero,
  .faq-hero,
  .contact-hero {
    padding-top: 1.25rem;
  }

  .page-title,
  .programme-heading .page-title {
    font-size: clamp(2rem, 10vw, 3rem);
    line-height: 1.08;
    overflow-wrap: anywhere;
  }

  main :where(p, h2, h3, a, summary) {
    overflow-wrap: anywhere;
  }

  .eyebrow {
    max-width: 100%;
    font-size: 0.68rem;
    letter-spacing: 0.07em;
  }

  .home-hero-card {
    min-height: 0;
    gap: 1rem;
  }

  .home-hero-content {
    padding: 0;
  }

  .hero-actions {
    width: 100%;
  }

  .hero-visual {
    min-height: 0;
    padding: 1rem;
  }

  .programme-tab,
  .programme-tools .filter-chip,
  .label-filter-row .filter-chip,
  .label-filter-row .faculty-filter summary,
  .label-filter-row .faculty-filter-options .filter-chip,
  .campus-filter,
  .organisation-filters .filter-chip {
    min-height: 44px;
    font-size: 0.8rem;
    letter-spacing: normal;
  }

  .label-filter-row .clear-filters-button {
    width: 44px;
    height: 44px;
  }

  .label-filter-row .filter-label {
    min-height: 44px;
  }

  .label-filter-row .faculty-filter {
    grid-column: 1 / -1;
  }

  .label-filter-row .faculty-filter-options {
    position: static;
    width: 100%;
    margin-top: 0.5rem;
    box-sizing: border-box;
  }

  .programme-tools .filter-chip.active:hover {
    background: #ffffff;
    color: #6c35d3;
  }

  .programme-event-meta,
  .info-organizer {
    font-size: 0.75rem;
    flex-wrap: wrap;
  }

  .programme-event-actions {
    flex-wrap: wrap;
    margin-right: 1rem;
    max-width: none;
  }

  .calendar-button-group {
    flex: 1 1 100%;
  }

  .calendar-button,
  .calendar-button-group .calendar-button,
  .ticket-button,
  .event-link-button,
  .organisation-links a,
  .guide-button,
  .schedule-notice-button,
  .faq-answer-button,
  .faq-contact-button,
  .contact-button,
  .save-date-link {
    min-height: 44px;
    font-size: 0.875rem;
    white-space: normal;
    text-align: center;
  }

  .schedule-links a {
    min-height: 44px;
    font-size: 0.95rem;
  }

  .guide-card {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .guide-content p,
  .schedule-notice p,
  .faq-answer,
  .faq-question summary {
    font-size: 0.95rem;
    line-height: 1.6;
  }

  .campus-map-pdf {
    height: 300px;
    height: clamp(220px, 45svh, 340px);
  }

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

  .campus-result p,
  .campus-map-hint {
    font-size: 0.85rem;
  }

  .campus-results {
    max-height: 320px;
  }

  .footer-bar {
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }
}
