/*
 * Erbil Server – Mobile Layer
 * Nur für öffentliche Seiten, Desktop bleibt unangetastet.
 * Ziel: saubere Header-/Tab-Struktur, kein horizontaler Overflow,
 * kompaktere Typografie und korrekt versteckter Skip-Link.
 */

@media (max-width: 760px) {
  html,
  body {
    max-width: 100%;
    overflow-x: clip;
  }

  /* Skip-Link: unsichtbar, bis echte Tastatur-Fokussierung erfolgt. */
  .skip-link:not(:focus-visible) {
    position: fixed !important;
    left: -10000px !important;
    top: 0 !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
  }

  .skip-link:focus-visible {
    position: fixed !important;
    left: 16px !important;
    top: max(12px, env(safe-area-inset-top)) !important;
    width: auto !important;
    height: auto !important;
    clip-path: none !important;
    z-index: 10000 !important;
  }

  /* Einheitliche Seitenbreite auf dem Handy. */
  .dashboard-page .page-shell,
  .history-page .page-shell,
  .portfolio-page > .container,
  .friends-page > .container,
  main.container {
    width: calc(100% - 32px) !important;
    max-width: none !important;
    margin-inline: auto !important;
  }

  /* Brand bleibt einzeilig; die Unterzeile ist mobil entbehrlich. */
  .brand {
    min-width: 0 !important;
    max-width: calc(100vw - 100px) !important;
  }

  .brand-copy {
    min-width: 0 !important;
  }

  .brand-copy strong {
    display: block !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    font-size: 16px !important;
    line-height: 1.15 !important;
  }

  .brand-copy small {
    display: none !important;
  }

  .brand-mark,
  .brand-logo,
  .brand img {
    flex: 0 0 auto !important;
  }

  /* Status kompakt halten, damit der Markenname nicht umbrechen muss. */
  .top-status {
    min-width: 42px !important;
    width: 42px !important;
    height: 42px !important;
    padding: 0 !important;
    display: grid !important;
    place-items: center !important;
    border-radius: 13px !important;
  }

  .top-status b,
  .top-status strong,
  .top-status .label {
    display: none !important;
  }

  .header-actions {
    min-width: 0 !important;
    gap: 7px !important;
  }

  .admin-entry {
    min-width: 42px !important;
    width: 42px !important;
    height: 42px !important;
    padding: 0 !important;
  }

  .admin-entry-label {
    display: none !important;
  }

  /*
   * DASHBOARD / AUSLASTUNG
   * Erste Zeile: Brand + Status.
   * Zweite Zeile: Dashboard / Portfolio / Friends.
   */
  .dashboard-page .topbar,
  .history-page .topbar {
    height: auto !important;
    min-height: 0 !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    align-items: center !important;
    gap: 12px 10px !important;
    padding: 18px 0 12px !important;
  }

  .dashboard-page .topbar > .brand,
  .history-page .topbar > .brand {
    grid-column: 1 !important;
    grid-row: 1 !important;
  }

  .dashboard-page .topbar > .top-status,
  .history-page .topbar > .top-status,
  .dashboard-page .topbar > .header-actions,
  .history-page .topbar > .header-actions {
    grid-column: 2 !important;
    grid-row: 1 !important;
    justify-self: end !important;
  }

  .dashboard-page .main-nav,
  .history-page .main-nav {
    grid-column: 1 / -1 !important;
    grid-row: 2 !important;
    width: 100% !important;
    min-width: 0 !important;
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 4px !important;
    padding: 4px !important;
    margin: 0 !important;
    overflow: visible !important;
    border-radius: 14px !important;
  }

  .dashboard-page .main-nav a,
  .history-page .main-nav a {
    min-width: 0 !important;
    text-align: center !important;
    justify-content: center !important;
    white-space: nowrap !important;
    font-size: 13px !important;
    padding: 9px 5px !important;
  }

  /*
   * Die zweite Dashboard-Zeile (Übersicht / Auslastung / Admin)
   * wird anhand des Auslastungs-Links erkannt. Dadurch bleibt der Fix
   * unabhängig vom aktuell verwendeten Klassennamen.
   */
  .dashboard-page :is(nav, div):has(> a[href="/history.html"]),
  .history-page :is(nav, div):has(> a[href="/history.html"]) {
    width: 100% !important;
    min-width: 0 !important;
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 4px !important;
    position: static !important;
    inset: auto !important;
    transform: none !important;
    overflow: visible !important;
  }

  .dashboard-page :is(nav, div):has(> a[href="/history.html"]) > a,
  .history-page :is(nav, div):has(> a[href="/history.html"]) > a {
    min-width: 0 !important;
    text-align: center !important;
    justify-content: center !important;
    white-space: nowrap !important;
    font-size: 13px !important;
    padding: 9px 5px !important;
  }

  /*
   * PORTFOLIO / FRIENDS
   * Erste Zeile: Brand + Status.
   * Zweite Zeile: Haupttabs.
   * Dritte Zeile: horizontal scrollbar Subtabs.
   */
  .portfolio-page .site-nav,
  .friends-page .site-nav,
  .legal-public-page .site-nav {
    width: 100% !important;
    margin-bottom: 34px !important;
      display: block !important;
      height: auto !important;
      min-height: 0 !important;
      overflow: visible !important;
      padding-bottom: 0 !important;
  }

  .portfolio-page .nav-row,
  .friends-page .nav-row,
  .legal-public-page .nav-row {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    grid-template-areas:
      "brand actions"
      "tabs  tabs" !important;
    gap: 12px 10px !important;
    align-items: center !important;
    width: 100% !important;
      height: auto !important;
      min-height: 0 !important;
      overflow: visible !important;
  }

  .portfolio-page .nav-row > .brand,
  .friends-page .nav-row > .brand,
  .legal-public-page .nav-row > .brand {
    grid-area: brand !important;
    min-width: 0 !important;
  }

  .portfolio-page .nav-row > .header-actions,
  .friends-page .nav-row > .header-actions,
  .legal-public-page .nav-row > .header-actions {
    grid-area: actions !important;
    justify-self: end !important;
  }

  .portfolio-page .top-tabs,
  .friends-page .top-tabs,
  .legal-public-page .top-tabs {
    grid-area: tabs !important;
    width: 100% !important;
    min-width: 0 !important;
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 4px !important;
    margin: 0 !important;
    padding: 4px !important;
    overflow: visible !important;
    border-radius: 14px !important;
  }

  .portfolio-page .top-tabs a,
  .friends-page .top-tabs a,
  .legal-public-page .top-tabs a {
    min-width: 0 !important;
    text-align: center !important;
    justify-content: center !important;
    white-space: nowrap !important;
    font-size: 13px !important;
    padding: 9px 5px !important;
  }

  .portfolio-page .sub-tabs,
  .friends-page .sub-tabs,
  .legal-public-page .sub-tabs {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 5px !important;
    margin: 8px 0 0 !important;
    padding: 4px 2px 8px !important;
    position: static !important;
    inset: auto !important;
    transform: none !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    scroll-snap-type: x proximity !important;
    scrollbar-width: none !important;
    white-space: nowrap !important;
  }

  .portfolio-page .sub-tabs::-webkit-scrollbar,
  .friends-page .sub-tabs::-webkit-scrollbar,
  .legal-public-page .sub-tabs::-webkit-scrollbar {
    display: none !important;
  }

  .portfolio-page .sub-tabs a,
  .friends-page .sub-tabs a,
  .legal-public-page .sub-tabs a {
    flex: 0 0 auto !important;
    min-width: max-content !important;
    scroll-snap-align: start !important;
    white-space: nowrap !important;
    font-size: 13px !important;
    line-height: 1.2 !important;
    padding: 9px 11px !important;
    border-radius: 10px !important;
  }

  /* Typografie: auf 390–430 px nicht mehr unnötig vier Zeilen hoch. */
  .dashboard-page h1,
  .history-page h1,
  .portfolio-page h1,
  .friends-page h1 {
    max-width: 100% !important;
    font-size: clamp(38px, 10.5vw, 44px) !important;
    line-height: 1.03 !important;
    letter-spacing: -0.045em !important;
    overflow-wrap: normal !important;
    word-break: normal !important;
    hyphens: none !important;
  }

  .dashboard-page .hero,
  .history-page .hero,
  .portfolio-page .hero,
  .friends-page .hero {
    padding-top: 30px !important;
  }

  .portfolio-page .hero,
  .friends-page .hero {
    grid-template-columns: 1fr !important;
    gap: 24px !important;
  }

  .dashboard-page .lead,
  .history-page .lead,
  .portfolio-page .lead,
  .friends-page .lead,
  .portfolio-page .hero p,
  .friends-page .hero p {
    font-size: 17px !important;
    line-height: 1.55 !important;
  }

  .hero-actions {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  .hero-actions .button,
  .hero-actions a {
    min-width: 0 !important;
    width: 100% !important;
    justify-content: center !important;
    text-align: center !important;
    white-space: normal !important;
  }

  /* Karten / Sektionen bekommen auf Mobile konsistente Abstände. */
  .section {
    margin-top: 56px !important;
  }

  .section-header {
    gap: 14px !important;
  }

  .profile-card,
  .box,
  .card,
  .qualification-card,
  .setup-card,
  .game-card,
  .voice-card {
    max-width: 100% !important;
  }

  /* Dashboard-Karten bleiben einspaltig und ohne seitlichen Überstand. */
  .stats-grid,
  .container-grid,
  .link-grid {
    grid-template-columns: 1fr !important;
  }

  .container-card,
  .stat-card,
  .link-card {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  /* Footer auf schmalen Displays nicht gegeneinander drücken. */
  footer {
    gap: 12px !important;
  }

  footer nav {
    flex-wrap: wrap !important;
  }
}

@media (max-width: 410px) {
  .dashboard-page .page-shell,
  .history-page .page-shell,
  .portfolio-page > .container,
  .friends-page > .container,
  main.container {
    width: calc(100% - 28px) !important;
  }

  .dashboard-page h1,
  .history-page h1,
  .portfolio-page h1,
  .friends-page h1 {
    font-size: 38px !important;
  }

  .hero-actions {
    grid-template-columns: 1fr !important;
  }
}


/* ==========================================================
   PORTFOLIO / FRIENDS – konsolidiert aus mobile-portfolio-friends.css
   Verhalten unverändert übernommen; separate Patch-Datei
   entfällt ab diesem Stand.
   ========================================================== */
/*
 * Mobile polish: Portfolio + Friends
 * Ergänzt mobile.css und überschreibt ausschließlich schmale Displays.
 */

@media (max-width: 760px) {

  /* ---------------------------------------------------------
     1. HORIZONTALEN OVERFLOW HART VERHINDERN
     --------------------------------------------------------- */

  html,
  body.portfolio-page,
  body.friends-page {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
  }

  body.portfolio-page *,
  body.friends-page * {
    box-sizing: border-box;
  }

  body.portfolio-page main,
  body.friends-page main,
  body.portfolio-page main > *,
  body.friends-page main > *,
  body.portfolio-page section,
  body.friends-page section,
  body.portfolio-page .hero,
  body.friends-page .hero,
  body.portfolio-page .hero-grid,
  body.friends-page .hero-grid,
  body.portfolio-page .hero-copy,
  body.friends-page .hero-copy,
  body.portfolio-page .hero-content,
  body.friends-page .hero-content,
  body.portfolio-page .section,
  body.friends-page .section,
  body.portfolio-page .section-inner,
  body.friends-page .section-inner,
  body.portfolio-page .content,
  body.friends-page .content {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  body.portfolio-page > .container,
  body.friends-page > .container,
  body.portfolio-page main.container,
  body.friends-page main.container,
  body.portfolio-page .site-nav.container,
  body.friends-page .site-nav.container {
    width: calc(100% - 32px) !important;
    max-width: calc(100% - 32px) !important;
    min-width: 0 !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }

  /* Grid-/Flex-Kinder dürfen wirklich schrumpfen. */
  body.portfolio-page .hero > *,
  body.friends-page .hero > *,
  body.portfolio-page .hero-grid > *,
  body.friends-page .hero-grid > *,
  body.portfolio-page .section > *,
  body.friends-page .section > *,
  body.portfolio-page .grid > *,
  body.friends-page .grid > * {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  /* ---------------------------------------------------------
     2. SUBNAV – eigener sauberer Balken statt Überlappung
     --------------------------------------------------------- */

  body.portfolio-page .sub-tabs,
  body.friends-page .sub-tabs {
    position: relative !important;
    inset: auto !important;
    transform: none !important;

    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center !important;

    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;

    margin: 9px 0 0 !important;
    padding: 4px !important;

    overflow-x: auto !important;
    overflow-y: hidden !important;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;

    border: 1px solid rgba(145, 165, 185, .18) !important;
    border-radius: 14px !important;
    background: rgba(14, 20, 26, .68) !important;
  }

  body.portfolio-page .sub-tabs::-webkit-scrollbar,
  body.friends-page .sub-tabs::-webkit-scrollbar {
    display: none !important;
  }

  body.portfolio-page .sub-tabs a,
  body.friends-page .sub-tabs a {
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: max-content !important;

    margin: 0 !important;
    padding: 9px 12px !important;

    white-space: nowrap !important;
    line-height: 1.15 !important;
    font-size: 13px !important;
    text-decoration: none !important;

    border-radius: 10px !important;
  }

  body.portfolio-page .sub-tabs a.active,
  body.friends-page .sub-tabs a.active,
  body.portfolio-page .sub-tabs a[aria-current="page"],
  body.friends-page .sub-tabs a[aria-current="page"] {
    background: rgba(255, 255, 255, .075) !important;
  }

  /* Etwas Abstand zwischen Navigation und Hero. */
  body.portfolio-page .site-nav,
  body.friends-page .site-nav {
    margin-bottom: 0 !important;
  }

  body.portfolio-page main,
  body.friends-page main {
    padding-top: 34px !important;
  }

  /* ---------------------------------------------------------
     3. HERO – kein Abschneiden rechts
     --------------------------------------------------------- */

  body.portfolio-page .hero,
  body.friends-page .hero {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 24px !important;
    padding-top: 28px !important;
    overflow: visible !important;
  }

  body.portfolio-page .eyebrow,
  body.friends-page .eyebrow,
  body.portfolio-page .hero-eyebrow,
  body.friends-page .hero-eyebrow,
  body.portfolio-page .section-kicker,
  body.friends-page .section-kicker {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;

    white-space: normal !important;
    overflow-wrap: anywhere !important;
    word-break: normal !important;

    font-size: 12px !important;
    line-height: 1.5 !important;
    letter-spacing: .12em !important;
  }

  body.portfolio-page h1,
  body.friends-page h1,
  body.portfolio-page .hero h1,
  body.friends-page .hero h1 {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;

    margin-right: 0 !important;

    white-space: normal !important;
    overflow: visible !important;
    overflow-wrap: break-word !important;
    word-break: normal !important;
    hyphens: auto !important;

    font-size: clamp(38px, 10vw, 44px) !important;
    line-height: 1.02 !important;
    letter-spacing: -.045em !important;
  }

  body.portfolio-page .hero p,
  body.friends-page .hero p,
  body.portfolio-page .lead,
  body.friends-page .lead {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;

    white-space: normal !important;
    overflow-wrap: break-word !important;
    word-break: normal !important;

    font-size: 17px !important;
    line-height: 1.55 !important;
  }

  /* ---------------------------------------------------------
     4. BUTTONS – beide sauber innerhalb der Viewportbreite
     --------------------------------------------------------- */

  body.portfolio-page .hero-actions,
  body.friends-page .hero-actions {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;

    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  body.portfolio-page .hero-actions > *,
  body.friends-page .hero-actions > *,
  body.portfolio-page .hero-actions a,
  body.friends-page .hero-actions a,
  body.portfolio-page .hero-actions button,
  body.friends-page .hero-actions button {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;

    margin: 0 !important;
    justify-content: center !important;
    text-align: center !important;
    white-space: normal !important;
  }

  /* ---------------------------------------------------------
     5. KARTEN / BILDER – nichts darf breiter als das Handy werden
     --------------------------------------------------------- */

  body.portfolio-page img,
  body.friends-page img,
  body.portfolio-page video,
  body.friends-page video,
  body.portfolio-page picture,
  body.friends-page picture,
  body.portfolio-page iframe,
  body.friends-page iframe {
    max-width: 100% !important;
  }

  body.portfolio-page .card,
  body.friends-page .card,
  body.portfolio-page .profile-card,
  body.friends-page .profile-card,
  body.portfolio-page .project-card,
  body.friends-page .project-card,
  body.portfolio-page .setup-card,
  body.friends-page .setup-card,
  body.portfolio-page .game-card,
  body.friends-page .game-card,
  body.portfolio-page .voice-card,
  body.friends-page .voice-card,
  body.portfolio-page .media-card,
  body.friends-page .media-card {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  body.portfolio-page .grid,
  body.friends-page .grid,
  body.portfolio-page .cards,
  body.friends-page .cards,
  body.portfolio-page .profile-grid,
  body.friends-page .profile-grid,
  body.portfolio-page .project-grid,
  body.friends-page .project-grid,
  body.portfolio-page .setup-grid,
  body.friends-page .setup-grid,
  body.portfolio-page .game-grid,
  body.friends-page .game-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }
}

@media (max-width: 410px) {
  body.portfolio-page > .container,
  body.friends-page > .container,
  body.portfolio-page main.container,
  body.friends-page main.container,
  body.portfolio-page .site-nav.container,
  body.friends-page .site-nav.container {
    width: calc(100% - 28px) !important;
    max-width: calc(100% - 28px) !important;
  }

  body.portfolio-page h1,
  body.friends-page h1,
  body.portfolio-page .hero h1,
  body.friends-page .hero h1 {
    font-size: 38px !important;
  }
}

/* ==========================================================
   MOBILE VISUAL AUDIT – PORTFOLIO / FRIENDS
   - natürliche H1-Umbrüche im Portfolio
   - mehr Abstand zwischen Haupt- und Sekundärnavigation
   - sauberes horizontales Touch-Scrolling
   Desktop bleibt unverändert.
   ========================================================== */

@media (max-width: 760px) {

  body.portfolio-page h1,
  body.portfolio-page .hero h1 {
    font-size: clamp(36px, 9.4vw, 42px) !important;
    line-height: 1.03 !important;
    letter-spacing: -.045em !important;

    overflow-wrap: normal !important;
    word-break: normal !important;
    hyphens: none !important;
  }

  body.portfolio-page .sub-tabs,
  body.friends-page .sub-tabs {
    margin-top: 12px !important;

    scroll-behavior: smooth;
    scroll-snap-type: x proximity;
    scroll-padding-inline: 10px;

    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;

    scrollbar-width: none;
  }

  body.portfolio-page .sub-tabs::-webkit-scrollbar,
  body.friends-page .sub-tabs::-webkit-scrollbar {
    display: none;
  }

  body.portfolio-page .sub-tabs > a,
  body.friends-page .sub-tabs > a {
    scroll-snap-align: start;
  }
}
