/* ===================================================================
   Handy-App

   Bis 820 px Breite wird aus der Website eine App: Tab-Leiste unten,
   Wappen in der Mitte, schlanke Kopfleiste, eigener Startbildschirm
   statt Drohnenflug. Darüber bleibt alles, wie es ist.

   Wird als letzte Datei geladen (system/vorlage.php) und benutzt nur
   die vorhandenen Farben aus style.css und kopf.css.
   Markup: system/app.php, Verhalten: app.js.
   =================================================================== */

/* Auf dem großen Bildschirm gibt es keine App-Teile */
.app-heute, .app-leiste, .app-mehr, .app-startbild { display: none; }

/* ---------- Startbild beim Öffnen der installierten App ----------
   Einmal je Sitzung, gut eine Sekunde: Wappen springt herein, Name
   blendet auf, dann gibt das Bild die Seite frei. Kein Video, kein
   Warten — die Seite lädt darunter schon fertig. */

html.zeige-startbild .app-startbild {
  display: flex;
  position: fixed; inset: 0; z-index: 200;
  flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(120% 70% at 50% 30%, #00602f, #003b1d 72%);
  color: #fff;
  text-align: center;
  animation: sb-weg .45s ease 1.25s forwards;
}
.app-startbild img {
  width: 104px; height: auto;
  filter: drop-shadow(0 14px 30px rgba(0, 0, 0, .4));
  animation: sb-wappen .85s cubic-bezier(.2, .9, .25, 1.15) both;
}
.app-startbild b {
  margin-top: 22px;
  font-size: 1.5rem; letter-spacing: -.01em;
  animation: sb-text .55s ease .3s both;
}
.app-startbild span {
  margin-top: 6px;
  font-size: .66rem; font-weight: 600; letter-spacing: .24em; text-transform: uppercase;
  color: var(--akzent, #8ee0ad);
  animation: sb-text .55s ease .45s both;
}
@keyframes sb-wappen { from { opacity: 0; transform: scale(.55) translateY(14px); } }
@keyframes sb-text   { from { opacity: 0; transform: translateY(8px); } }
@keyframes sb-weg    { to   { opacity: 0; visibility: hidden; } }

/* ---------- In der installierten App ---------- */

html.app-modus { overscroll-behavior-y: none; }
html.app-modus body { overscroll-behavior-y: none; }

@media (max-width: 820px) {

  :root {
    --leiste: 62px;
    --unten: env(safe-area-inset-bottom, 0px);
    --oben: env(safe-area-inset-top, 0px);
    --kopf-hoehe: 56px;
  }

  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

  body {
    padding-bottom: calc(var(--leiste) + var(--unten));
    -webkit-tap-highlight-color: transparent;
  }

  /* Kein Doppeltipp-Zoom: Tippen reagiert sofort, wie in einer App */
  a, button, input, select, textarea, label, summary { touch-action: manipulation; }

  /* iPhone zoomt in Eingabefelder unter 16 px hinein — das verhindert es */
  input, select, textarea { font-size: max(16px, 1em); }

  /* Bedienelemente nicht markieren und kein Kontextmenü beim Halten */
  .app-leiste, .app-mehr, .ah-schnell, .ah-punkte {
    -webkit-user-select: none; user-select: none;
    -webkit-touch-callout: none;
  }

  /* ================================================================
     Kopfleiste: schlank und immer grün. Burger und Schublade
     entfallen — dafür gibt es unten „Mehr".
     ================================================================ */

  .kopfleiste,
  .kopfleiste.fest {
    background: linear-gradient(to bottom, var(--leiste-oben), var(--leiste-unten));
    padding-top: var(--oben);
    box-shadow: 0 6px 20px rgba(0, 0, 0, .12);
  }
  .kopfleiste::before { opacity: 0; }
  .kopfleiste .innen { height: var(--kopf-hoehe); }
  .kopfleiste .burger,
  .kopfleiste .hauptnav,
  .menue-schatten { display: none !important; }
  .marke-link img { width: 34px; }
  .marke-wort { font-size: .54rem; line-height: 1.55; letter-spacing: .22em; }
  /* Suche: Lupe rechts im App-Kopf (suche.js) */
  .kopfleiste .suche { margin-left: auto; width: 40px; height: 40px; }

  body:not(.hat-hero) { padding-top: calc(var(--kopf-hoehe) + var(--oben)); }
  section[id], h2[id] { scroll-margin-top: calc(var(--kopf-hoehe) + var(--oben) + 12px); }

  /* ================================================================
     Startseite: eigener Startbildschirm statt Drohnenflug
     ================================================================ */

  .hat-hero .kopfleiste,
  .hat-hero .hero,
  .hat-hero .uebergang { display: none; }
  .hat-hero h2[id] { scroll-margin-top: calc(var(--oben) + 16px); }

  .app-heute {
    display: block;
    position: relative;
    margin: 0;
    padding: calc(var(--oben) + 22px) 0 24px;
    background:
      radial-gradient(90% 60% at 100% 0%, rgba(142, 224, 173, .16), transparent 60%),
      linear-gradient(170deg, #00602f 0%, var(--gruen) 45%, #003318 100%);
    border-radius: 0 0 28px 28px;
    color: #fff;
    overflow: hidden;
  }

  .ah-kopf {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 0 20px;
  }
  .ah-gruss {
    margin: 0;
    font-size: .82rem; font-weight: 600; letter-spacing: .02em;
    color: var(--akzent);
  }
  .ah-kopf h1 {
    margin: 2px 0 3px;
    color: #fff;
    font-size: 1.85rem; line-height: 1.1; letter-spacing: -.025em;
  }
  .ah-unter { margin: 0; font-size: .84rem; color: rgba(255, 255, 255, .72); }
  .ah-kopf img {
    width: 54px; height: auto; flex: none;
    filter: drop-shadow(0 8px 18px rgba(0, 0, 0, .35));
  }

  /* Spielkarten zum Wischen: nächstes Spiel vorn, letztes dahinter */
  .ah-karten {
    display: flex; gap: 12px;
    margin-top: 20px;
    padding: 0 20px 4px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding: 0 20px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .ah-karten::-webkit-scrollbar { display: none; }
  .ah-karten .spielband-karte {
    flex: 0 0 calc(100% - 26px);
    scroll-snap-align: start;
    margin: 0;
    box-shadow: 0 14px 34px rgba(0, 20, 8, .28);
  }
  .ah-karten .spielband-karte:only-child { flex-basis: 100%; }
  .ah-karten .spielband-karte:hover { transform: none; }

  .ah-punkte { display: flex; justify-content: center; gap: 6px; margin-top: 12px; }
  .ah-punkte i {
    width: 6px; height: 6px; border-radius: 3px;
    background: rgba(255, 255, 255, .32);
    transition: width .25s ease, background .25s ease;
  }
  .ah-punkte i.an { width: 18px; background: #fff; }

  /* Schnellzugriff: vier runde Kacheln */
  .ah-schnell {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
    margin-top: 20px; padding: 0 14px;
  }
  .ah-schnell a {
    display: flex; flex-direction: column; align-items: center; gap: 7px;
    color: #fff; text-decoration: none;
    font-size: .72rem; font-weight: 600; line-height: 1.2; text-align: center;
  }
  .ah-sinnbild {
    display: grid; place-items: center;
    width: 54px; height: 54px; border-radius: 18px;
    background: rgba(255, 255, 255, .11);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14);
    transition: transform .15s ease, background .15s ease;
  }
  .ah-sinnbild svg { width: 24px; height: 24px; }
  .ah-schnell a:active .ah-sinnbild { transform: scale(.92); background: rgba(255, 255, 255, .2); }

  /* Abschnitte darunter etwas dichter — auf dem Handy zählt jeder Daumenweg */
  .hat-hero main { padding-top: 6px; }
  .hat-hero .abschnitt { padding: 30px 0; }
  .kopfzeile h2 { font-size: 1.35rem; }

  /* Neuigkeiten auf der Startseite: zum Wischen statt untereinander */
  .beitragsreihe {
    display: flex; gap: 14px;
    margin: 0 -20px; padding: 2px 20px 8px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding: 0 20px;
    scrollbar-width: none;
  }
  .beitragsreihe::-webkit-scrollbar { display: none; }
  .beitragsreihe > .kachel { flex: 0 0 82%; scroll-snap-align: start; }
  .beitragsreihe > .kachel:only-child { flex-basis: 100%; }

  /* Seitenkopf der Unterseiten: kompakt, damit der Inhalt schon im
     ersten Bildschirm beginnt. Das Wappen steht ja oben in der Leiste. */
  .seitenkopf,
  .seitenkopf.klein { padding-top: 22px; padding-bottom: 28px; }
  .seitenkopf.mit-karte,
  .seitenkopf.klein.mit-karte { padding-bottom: 84px; }
  .seitenkopf .sk-wappen { display: none; }
  .seitenkopf h1,
  .seitenkopf.klein h1 { font-size: 1.85rem; margin-bottom: 8px; }
  .seitenkopf .eyebrow { margin-bottom: 8px; }
  .sk-text { font-size: .95rem; line-height: 1.55; }
  .seitenkopf .sk-zahlen {
    grid-auto-flow: column; grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    margin-top: 18px; padding-top: 16px; row-gap: 0;
  }
  .seitenkopf .sk-zahlen div { padding: 0 4px; }
  .seitenkopf .sk-zahlen div + div { border-left: 1px solid rgba(255, 255, 255, .18); }
  .seitenkopf .sk-zahlen b { font-size: 1.25rem; }
  .seitenkopf .sk-zahlen span { font-size: .6rem; letter-spacing: .08em; }

  /* Fußzeile: die Links stehen alle unter „Mehr" */
  footer { padding: 22px 0 18px; margin-top: 0; }
  footer .fuss-spalten { display: none; }
  footer .fuss-unten { margin-top: 0; padding-top: 0; border-top: 0; justify-content: center; text-align: center; font-size: .78rem; }

  /* ================================================================
     Tab-Leiste
     ================================================================ */

  .app-leiste {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
    height: calc(var(--leiste) + var(--unten));
    padding-bottom: var(--unten);
    background: rgba(255, 255, 255, .9);
    -webkit-backdrop-filter: blur(20px) saturate(1.6);
    backdrop-filter: blur(20px) saturate(1.6);
    box-shadow: 0 -1px 0 rgba(0, 0, 0, .06), 0 -8px 28px rgba(0, 0, 0, .07);
    view-transition-name: app-leiste;
  }

  .al-punkt {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-width: 0; padding: 0;
    border: 0; background: none;
    color: #76766f;
    font-family: inherit; font-size: 10.5px; font-weight: 600; line-height: 1.2;
    letter-spacing: .01em;
    text-decoration: none;
    cursor: pointer;
  }
  .al-punkt svg {
    width: 23px; height: 23px;
    padding: 3px 16px; box-sizing: content-box;
    border-radius: 14px;
    transition: background .2s ease, transform .15s ease;
  }
  .al-punkt span { white-space: nowrap; }
  .al-punkt.aktiv, .al-mehr.offen { color: var(--gruen); }
  .al-punkt.aktiv svg, .al-mehr.offen svg { background: #E1F1E7; stroke-width: 2.1; }
  .al-punkt:active svg { transform: scale(.9); }

  /* Das Wappen in der Mitte schaut oben aus der Leiste heraus */
  .al-mitte { position: relative; display: flex; justify-content: center; }
  .al-wappen {
    position: absolute; top: -20px;
    display: grid; place-items: center;
    width: 62px; height: 62px; border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(255, 255, 255, .9),
                0 8px 22px rgba(0, 50, 25, .28),
                inset 0 0 0 1.5px rgba(0, 72, 36, .14);
    transition: transform .18s ease, box-shadow .2s ease;
  }
  .al-wappen img { width: 36px; height: auto; }
  .al-mitte.aktiv .al-wappen {
    box-shadow: 0 0 0 4px rgba(255, 255, 255, .9),
                0 8px 22px rgba(0, 50, 25, .3),
                inset 0 0 0 2.5px var(--gruen);
  }
  .al-mitte:active .al-wappen { transform: scale(.92); }

  /* ================================================================
     Blatt „Mehr"
     ================================================================ */

  .app-mehr { display: block; position: fixed; inset: 0; z-index: 65; }
  .app-mehr[hidden] { display: none; }

  .am-schatten {
    position: absolute; inset: 0;
    background: rgba(0, 22, 10, .42);
    opacity: 0; transition: opacity .28s ease;
  }
  .am-blatt {
    position: absolute; left: 0; right: 0; bottom: 0;
    max-height: calc(100% - var(--oben) - 40px);
    overflow-y: auto; overscroll-behavior: contain;
    padding: 8px 16px calc(var(--leiste) + var(--unten) + 18px);
    background: #fff;
    border-radius: 26px 26px 0 0;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, .18);
    transform: translateY(100%);
    transition: transform .34s cubic-bezier(.2, .85, .25, 1);
  }
  .app-mehr.offen .am-schatten { opacity: 1; }
  .app-mehr.offen .am-blatt { transform: none; }

  .am-griff { width: 40px; height: 5px; margin: 4px auto 12px; border-radius: 3px; background: #D9D9D3; }

  .am-titel {
    margin: 14px 6px 6px;
    font-size: .7rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
    color: var(--grau);
  }
  .am-raster { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
  .am-raster a {
    display: flex; flex-direction: column; align-items: center; gap: 7px;
    padding: 9px 2px 8px; border-radius: 16px;
    color: var(--text); text-decoration: none;
    font-size: .72rem; font-weight: 600; line-height: 1.2; text-align: center;
  }
  .am-raster a:active { background: var(--sand); }
  .am-sinnbild {
    display: grid; place-items: center;
    width: 50px; height: 50px; border-radius: 16px;
    background: #EDF6F0; color: var(--gruen);
  }
  .am-sinnbild svg { width: 23px; height: 23px; }

  /* Installieren-Karte */
  .am-installieren {
    display: flex; align-items: center; gap: 12px;
    margin: 4px 0 6px; padding: 12px 12px 12px 12px;
    border-radius: 18px;
    background: linear-gradient(140deg, #00602f, #003b1d);
    color: #fff;
  }
  .am-installieren[hidden] { display: none; }
  .am-installieren img { width: 46px; height: 46px; border-radius: 12px; flex: none; }
  .am-installieren div { flex: 1; min-width: 0; }
  .am-installieren b { display: block; font-size: .92rem; }
  .am-installieren span { display: block; font-size: .76rem; line-height: 1.35; color: rgba(255, 255, 255, .78); }
  .am-installieren em { font-style: normal; font-weight: 700; color: #fff; }
  .am-knopf {
    flex: none;
    padding: 9px 15px; border: 0; border-radius: 999px;
    background: #fff; color: var(--gruen);
    font: inherit; font-size: .8rem; font-weight: 700;
    cursor: pointer;
  }
  .am-installieren.ios .am-text-android,
  .am-installieren.ios .am-knopf,
  .am-installieren:not(.ios) .am-text-ios { display: none; }

  /* ================================================================
     Seitenwechsel ohne weißes Aufblitzen (Chrome, Safari 18+)
     ================================================================ */

  @view-transition { navigation: auto; }
  ::view-transition-old(root),
  ::view-transition-new(root) { animation-duration: .16s; }
}

@media (max-width: 820px) and (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  .am-blatt, .am-schatten { transition: none; }
}
@media (prefers-reduced-motion: reduce) {
  html.zeige-startbild .app-startbild { animation-delay: .4s; }
  .app-startbild img, .app-startbild b, .app-startbild span { animation: none; }
}

/* ===================================================================
   Startbildschirm, Fassung 2 (07.10.2026): beide Mannschaften,
   Umschalter, Tabelle bzw. Spielplan darunter. Markup: system/app-start.php
   =================================================================== */

.app-start { display: none; }

@media (max-width: 820px) {

  .app-start { display: block; }

  /* Kopf: größeres Wappen, Zeile ohne Fußballbezug */
  .ah-kopf img { width: 76px; margin-top: -4px; }
  .ah-kopf h1 { font-size: 2rem; }
  .ah-unter { letter-spacing: .02em; }

  /* Umschalter Alle · I. Männer · Alte Herren */
  .ah-wahl {
    display: flex; gap: 4px;
    margin: 20px 20px 0; padding: 4px;
    border-radius: 999px;
    background: rgba(0, 0, 0, .18);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08);
  }
  .ah-wahl button {
    flex: 1;
    padding: 8px 6px; border: 0; border-radius: 999px;
    background: transparent; color: rgba(255, 255, 255, .78);
    font: inherit; font-size: .82rem; font-weight: 700;
    cursor: pointer;
    transition: background .2s ease, color .2s ease;
  }
  .ah-wahl button[aria-selected="true"] {
    background: #fff; color: var(--gruen);
    box-shadow: 0 4px 12px rgba(0, 0, 0, .15);
  }
  .ah-team[hidden], .ah-block[hidden] { display: none; }
  .ah-team .ah-karten { margin-top: 14px; }

  /* Mannschaftsmarke oben auf jeder Spielkarte */
  .ah-karten .spielband-karte { position: relative; padding-top: 34px; }
  .ah-marke {
    position: absolute; left: 50%; top: 10px; transform: translateX(-50%);
    padding: 2px 10px; border-radius: 999px;
    background: #EDF6F0; color: var(--gruen);
    font-size: .64rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
    white-space: nowrap;
  }

  /* Unter dem grünen Bereich: Tabelle oder Spielplan */
  .ah-detail { padding: 20px 20px 0; }
  .ah-block {
    padding: 16px 16px 8px;
    border-radius: 20px;
    background: #fff;
    box-shadow: 0 10px 30px rgba(0, 40, 20, .08), 0 0 0 1px rgba(0, 72, 36, .06);
  }
  .ah-block-kopf { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
  .ah-block-kopf h2 { margin: 0; font-size: 1.05rem; }
  .ah-block-kopf a { font-size: .82rem; font-weight: 700; text-decoration: none; white-space: nowrap; }

  .ah-tabelle { width: 100%; border-collapse: collapse; font-size: .88rem; font-variant-numeric: tabular-nums; }
  .ah-tabelle th {
    padding: 4px 4px 6px; text-align: right;
    font-size: .64rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--grau);
  }
  .ah-tabelle td { padding: 8px 4px; text-align: right; border-top: 1px solid #EEEEEA; }
  .ah-tabelle th:nth-child(-n+2), .ah-tabelle td:nth-child(-n+2) { text-align: left; }
  .ah-tabelle td:first-child { width: 26px; color: var(--grau); font-weight: 700; }
  .ah-tabelle tr.ist-wir td { background: #EAF5EE; color: var(--gruen); font-weight: 700; }
  .ah-tabelle tr.ist-wir td:first-child { box-shadow: inset 3px 0 0 var(--gruen); }
  .ah-verein { display: flex; align-items: center; gap: 8px; min-width: 0; }
  .ah-verein img { width: 20px; height: 20px; object-fit: contain; flex: none; }

  .ah-plan { list-style: none; margin: 0; padding: 0; }
  .ah-plan li { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid #EEEEEA; }
  .ah-plan li:first-child { border-top: 0; }
  .ah-tag {
    flex: none; width: 46px; padding: 5px 0;
    border-radius: 12px; background: #EDF6F0; color: var(--gruen);
    text-align: center; font-size: .66rem; font-weight: 700; text-transform: uppercase; line-height: 1.1;
  }
  .ah-tag b { display: block; font-size: 1.15rem; }
  .ah-paarung { min-width: 0; line-height: 1.3; }
  .ah-paarung b { display: block; font-size: .9rem; color: var(--text); }
  .ah-paarung small { font-size: .76rem; color: var(--grau); }
}

@media (max-width: 820px) {
  .app-zurueck {
    display: grid; place-items: center; flex: none;
    width: 36px; height: 36px; margin-left: -8px; padding: 0;
    border: 0; border-radius: 50%;
    background: rgba(255, 255, 255, .1); color: #fff;
    cursor: pointer;
  }
  .app-zurueck svg { width: 20px; height: 20px; }
  .app-zurueck:active { background: rgba(255, 255, 255, .22); }
}
