/* ============================================================
   mobile.css — eigene Handy-Oberfläche
   Greift nur bei schmalem Bildschirm (≤ 700 px). Auf dem PC ändert sich
   nichts. Grundsätze:
     * Kompakte Kopfzeile: Zurück-Pfeil + aktuelle Ebene (darüber klein der
       übergeordnete Pfad), alles Weitere im Menü (mobile.js).
     * Tabellenzeilen werden zu Karten: Name + Leistung oben, die übrigen
       Angaben klein darunter — statt vieler zerquetschter Spalten.
     * Kacheln kleiner und zweispaltig, weniger Rand.
   Die Breakpoint-Zahl steht auch in mobile.js (matchMedia).
   ============================================================ */

/* Handy-Elemente der Kopfzeile sind auf dem PC unsichtbar. */
.mnav-zurueck, .mnav-ort, .mnav-menu-btn { display: none; }

@media (max-width: 700px) {

  /* ---------------------------------------------------------- Kopfzeile */
  .appheader {
    flex-wrap: wrap; gap: 10px; row-gap: 8px;
    padding: 10px 14px;
  }
  .appheader .breadcrumb,
  .appheader .design-btn { display: none !important; }
  .appheader img.logo { height: 34px; }
  /* In einer Unterebene ersetzt der Zurück-Pfeil das Logo. */
  :root.mnav-tief .appheader img.logo { display: none; }

  .mnav-zurueck:not([hidden]),
  .mnav-menu-btn {
    display: flex; align-items: center; justify-content: center;
    flex: 0 0 auto; width: 40px; height: 40px; padding: 0;
    border: 1px solid var(--card-border); border-radius: 12px;
    background: var(--field-bg-solid); color: var(--navy); cursor: pointer;
  }
  .mnav-zurueck::before {
    content: ""; width: 10px; height: 10px; margin-left: 4px;
    border-left: 2.5px solid currentColor; border-bottom: 2.5px solid currentColor;
    transform: rotate(45deg);
  }
  .mnav-menu-btn { flex-direction: column; gap: 4px; margin-left: auto; }
  .mnav-menu-btn span { display: block; width: 18px; height: 2px; border-radius: 2px; background: currentColor; }
  .mnav-menu-btn[aria-expanded="true"] { background: var(--navy); color: #fff; border-color: var(--navy); }

  .mnav-ort:not([hidden]) {
    display: flex; flex-direction: column; justify-content: center;
    flex: 1 1 0; min-width: 0; line-height: 1.2;
  }
  .mnav-pfad, .mnav-titel { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mnav-pfad { font-size: 12px; color: var(--muted); }
  .mnav-pfad:empty { display: none; }
  .mnav-titel { font-size: 17px; font-weight: 800; color: var(--navy); }
  /* Ohne Ort (Startseite) schiebt die Lücke das Menü nach rechts. */
  .appheader .spacer { display: none; }

  .appheader .sperre-leiste { order: 10; }
  /* Warteschlange: Knöpfe bleiben auf dem Handy sichtbar. */
  .appheader .sperre-leiste .design-btn { display: inline-flex !important; }
  .sperre-panel { max-width: calc(100vw - 28px); }

  /* Menü: Pfad als eingerückter Baum + Aktionen. Bewusst deckend, OHNE
     backdrop-filter (fixierte Glasflächen erzeugen Paint-Fehler beim Scrollen). */
  .mnav-overlay {
    position: fixed; inset: 0; z-index: 90;
    background: rgba(20, 30, 74, 0.30);
    animation: lvlFadeIn 0.15s var(--ease) both;
  }
  .mnav-panel {
    position: absolute; top: 62px; right: 10px; left: 10px;
    max-height: calc(100vh - 80px); overflow: auto;
    background: var(--panel-bg); border: 1px solid var(--card-border);
    border-radius: 16px; box-shadow: var(--shadow-lg); padding: 6px;
    animation: lvlPop 0.18s var(--ease) both;
  }
  .mnav-baum, .mnav-aktionen { display: flex; flex-direction: column; }
  .mnav-aktionen { border-top: 1px solid var(--card-border); margin-top: 6px; padding-top: 6px; }
  .mnav-eintrag {
    text-align: left; border: none; background: none; border-radius: 10px;
    padding: 12px 14px; font: inherit; font-size: 15px; color: var(--text-dark); cursor: pointer;
  }
  .mnav-baum .mnav-eintrag { position: relative; font-weight: 600; color: var(--navy); }
  .mnav-baum .mnav-eintrag + .mnav-eintrag::before {
    content: "›"; position: absolute; margin-left: -12px; color: var(--muted); font-weight: 400;
  }
  .mnav-eintrag.aktuell { background: var(--placeholder-bg); font-weight: 800; }
  .mnav-eintrag:active { background: var(--placeholder-bg); }

  /* ---------------------------------------------------------- Grundgerüst */
  .main { padding: 16px 14px 32px; }
  .db-kopf { gap: 10px; margin-bottom: 12px; }
  .view-title, .jb-kachel-titel { font-size: 20px; }
  /* Kein Zoomen beim Antippen von Feldern (iOS zoomt unter 16 px). */
  input, select, textarea { font-size: 16px !important; }

  .tabbar, .saison-reiter { flex-wrap: wrap; }
  .lb-toolbar, .lb-buttons, .jb-werkzeug, .jb-filter { flex-wrap: wrap; gap: 8px; }
  .jb-filter .such { max-width: none; flex: 1 1 100%; }

  /* Kacheln: zweispaltig und flacher; Startseite (3 Bereiche) einspaltig. */
  .tiles, .tiles.tiles-2 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .tiles.tiles-3, .tiles.tiles-4 { grid-template-columns: 1fr; gap: 10px; }
  .tile { min-height: 88px; padding: 14px 12px 14px 20px; }
  .tile::before { width: 6px; }
  .tile .tile-name { font-size: 15px; line-height: 1.25; hyphens: auto; overflow-wrap: anywhere; }
  .tiles.tiles-3 .tile, .tiles.tiles-4 .tile { min-height: 72px; }
  .tiles.tiles-3 .tile .tile-name, .tiles.tiles-4 .tile .tile-name { font-size: 18px; }

  /* Dialoge fast bildschirmbreit. */
  .modal-overlay { padding: 10px; }
  .modal-box { padding: 18px 16px; max-height: 92vh; }
  .modal-actions { flex-wrap: wrap; }
  /* Anmeldefenster als Vollbild. */
  .modal-overlay:has(.anm-modal) { padding: 0; }
  .modal-box:has(.anm-modal) { max-width: none; height: 100dvh; max-height: none; border: 0; border-radius: 0; }
  .anm-modal { height: 100%; max-height: none; }
  .anm-modal .anm-editor { min-height: 100%; display: flex; flex-direction: column; }
  .anm-modal .anm-editor > .anm-aktionen:last-child { margin-top: auto; }

  /* ---------------------------------------------------------- Limitenbulletin
     Lesemodus-Zeile als Karte:
       Haydn Brotschi                          2004
       400m   LIMITE 45.25   SB 2026 45.20                          */
  .lb-kachel-body { padding: 2px 12px 8px; }
  /* Band bündig zum schmaleren Innenabstand (sonst ragt es 6px heraus) */
  .lb-subhead { margin: 8px -12px 0; padding: 8px 12px; }
  .lb-row:has(> .lb-val) {
    display: flex; flex-wrap: wrap; align-items: baseline;
    column-gap: 14px; row-gap: 2px; padding: 8px 0;
  }
  .lb-row:has(> .lb-val)::before { content: ""; order: 2; flex-basis: 100%; height: 0; }
  .lb-row > .lb-val { padding: 0; order: 3; }
  .lb-row > .lb-val:empty { display: none; }
  .lb-row > .lb-val.name { order: 1; flex: 1 1 0; font-size: 15px; }
  .lb-row > .lb-val.jg { order: 1; color: var(--muted); }
  .lb-row > .lb-val.disz { font-weight: 600; }
  .lb-row > .lb-val[data-label]:not(.name):not(.jg):not(.disz)::before {
    content: attr(data-label) " "; font-size: 11px; font-weight: 600;
    letter-spacing: 0.3px; text-transform: uppercase; color: var(--muted);
  }

  /* Bearbeitungszeile (Admin): Name über die ganze Breite, übrige Felder
     zweispaltig, Werkzeuge rechts. Überschreibt die Inline-Spaltenbreiten. */
  .lb-row:has(> .lb-inp) { grid-template-columns: 1fr 1fr !important; padding: 8px 0; }
  .lb-row > .lb-inp.name { grid-column: 1 / -1; }
  .lb-row:has(> .lb-inp) > .zeilen-tools { grid-column: 1 / -1; justify-self: end; }

  /* ---------------------------------------------------------- Jahresbulletin
     Lesemodus-Zeile als Karte: Rang links, Name + Leistung oben, alle
     übrigen Angaben klein darunter (nur Abstand, keine Trennzeichen —
     so beginnt eine umbrochene Zeile nie mit einem Punkt). */
  .jb-thead { display: none; }
  .jb-row:has(> .jb-val) {
    display: flex; flex-wrap: wrap; align-items: baseline;
    column-gap: 12px; row-gap: 2px;
    position: relative; padding: 8px 10px 8px 2.8em;
  }
  .jb-row:has(> .jb-val):not(:has(> .rang)) { padding-left: 10px; }
  .jb-row:has(> .jb-val)::before { content: ""; order: 2; flex-basis: 100%; height: 0; }
  .jb-row > .jb-val { padding: 0; order: 3; font-size: 12px; color: var(--muted); }
  .jb-row > .jb-val:empty { display: none; }
  .jb-row > .jb-val.rang {
    position: absolute; left: 0; top: 8px; width: 2.6em;
    font-size: 14px; font-weight: 800; color: var(--navy);
  }
  .jb-row > .jb-val.name { order: 0; flex: 1 1 0; font-size: 14px; color: var(--text-dark); }
  .jb-row > .jb-val.wert { order: 1; font-size: 14px; color: var(--navy); }
  :root[data-theme="dark"] .jb-row > .jb-val.wert { color: var(--text-dark); }

  /* SM (Alle Platzierungen): Zeile ohne Namen — Disziplin wird zur Hauptzeile. */
  .jb-sma-egrid > .jb-val:nth-child(2) { order: 1; flex: 1 1 0; font-size: 14px; font-weight: 600; color: var(--text-dark); }
  /* Vereinsrekorde: Disziplin als kleine Überschrift über dem Namen. */
  .jb-rek-egrid > .jb-val:first-child {
    order: -1; flex-basis: 100%; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.3px; font-size: 11px;
  }

  .jb-disc { padding: 6px 8px; }
}
