/* ============================================================
   SUTC-Designtokens -- Farbwelt "Sonnengelb", Kanten "Eckig".
   Identisch zu buchen.sutcgg.win, damit beide Apps gleich aussehen.
     prim #d9a300 · dark #8f6c02 · tint #fdf3d6
     bg #faf7ef · border #eee5cf · Text/Akzent #26202a

   Kontrast: --sun (#d9a300) traegt DUNKLE Schrift (--ink, 6,9:1) -> aktive
   Reiter, Primaerknopf, Symbol-Kacheln. --sun-deep (#8f6c02) traegt WEISSE
   Schrift (4,9:1) und ist die Textfarbe auf Weiss.
   ============================================================ */
:root {
  --sun: #d9a300;          /* Sonnengelb -- Akzentkanten, aktive Marker */
  --sun-deep: #8f6c02;     /* Tiefgold -- Flaechen + Text (lesbar) */
  --sun-deeper: #6f5301;   /* noch dunkler -- Hover, Text auf Tint */
  --sun-tint: #fdf3d6;     /* helle Flaeche */
  --ink: #26202a;          /* Schrift auf Sonnengelb (6,9:1) */

  /* Alias-Ebene: die bestehenden Regeln heissen historisch --court. */
  --court: var(--sun-deep);
  --court-dark: var(--sun-deeper);
  --swoosh: #b4532c;
  --accent: var(--sun);
  --accent-soft: var(--sun-tint);
  --tint: var(--sun-tint);
  --bg: #faf7ef;
  --card: #ffffff;
  --border: #eee5cf;
  --text: #26202a;
  --muted: #837c80;
  --danger: #b4532c;
  --ok: #2e7d4f;

  /* Eckige Kanten */
  --radius: 6px;
  --r-card: 6px;
  --r-btn: 6px;
  --r-input: 6px;
  --r-chip: 4px;

  --shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  /* Hoehe der mobilen Bottom-Nav (fixe Position). */
  --tabbar-h: calc(61px + env(safe-area-inset-bottom));
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: #fff;
  color: var(--text);
  border-bottom: 2px solid var(--sun);
  box-shadow: var(--shadow);
}
/* Marken-Lockup: Tennisball-Kachel + Klubbezeichnung zweizeilig (aus dem
   Design). Der Kreis bleibt rund -- im Design ist er auch in der Variante
   "Eckig" hart auf 50% gesetzt. */
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-badge {
  width: 30px; height: 30px; flex: 0 0 auto; border-radius: 50%;
  background: var(--ink); color: var(--sun);
  display: flex; align-items: center; justify-content: center;
}
.brand-badge svg { width: 18px; height: 18px; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name { font-weight: 800; font-size: 16px; color: var(--court); letter-spacing: .4px; }
.brand-sub {
  font-size: 8.5px; letter-spacing: 2.2px; color: var(--muted);
  font-weight: 600; text-transform: uppercase; white-space: nowrap;
}
.ball { font-size: 1.5rem; }

/* ---------- Konto-Knopf (mobil) ----------
   Loest den Hamburger ab: die Bereichs-Navigation sitzt jetzt unten in der
   Tabbar, hier drin bleiben nur Konto-Punkte. */
.topbar { position: relative; }
.nav-toggle {
  display: none; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0;
  background: var(--tint); color: var(--court-dark);
  border: 1px solid var(--border); border-radius: var(--r-btn);
  font-size: 14px; font-weight: 700; line-height: 1; cursor: pointer;
}
.nav-toggle svg { width: 18px; height: 18px; display: block; }
.nav-toggle.open { background: var(--sun); color: var(--ink); border-color: var(--sun); }

#mainNav { display: flex; align-items: center; gap: 14px; }
#mainNav a { color: var(--court-dark); text-decoration: none; font-weight: 600; font-size: .92rem; }
#mainNav a:hover { text-decoration: underline; }
#mainNav a.nav-cross { color: var(--court); }
#mainNav .who { font-size: .85rem; color: var(--muted); font-weight: 500; }

@media (max-width: 720px) {
  .nav-toggle { display: flex; }
  #mainNav {
    display: none; position: absolute; top: 100%; right: 0; left: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: #fff; padding: 6px 0; z-index: 40;
    border-bottom: 3px solid var(--court);
    box-shadow: var(--shadow);
  }
  #mainNav.open { display: flex; }
  #mainNav a, #mainNav .who {
    padding: 13px 22px; font-size: 1.02rem; display: block;
    border-top: 1px solid var(--border);
  }
  #mainNav a:first-child { border-top: none; }
  #mainNav .btn.ghost.sm { margin: 10px 22px; width: calc(100% - 44px); text-align: center; }
}

/* ---------- Layout ---------- */
main {
  max-width: 720px;
  margin: 0 auto;
  padding: 18px 16px 64px;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 8px 0 16px;
}
.section-head h2 { margin: 0; font-size: 1.25rem; }

/* ---------- Buttons ---------- */
.btn {
  border: none;
  text-decoration: none;   /* .btn wird teils auf <a> verwendet */
  border-radius: var(--r-btn);
  padding: 10px 18px;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform .05s ease, background .15s ease, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--sun); color: var(--ink); }
.btn.primary:hover { background: var(--sun-deep); color: #fff; }
.btn.court   { background: var(--court-dark); color: #fff; }
.btn.ball    { background: var(--accent); color: #3a2f00; }
.btn.ghost   { background: transparent; color: var(--court); border: 1px solid #e0d3b5; }
.btn.ghost.dark { border-color: #e0d3b5; color: var(--text); }
.btn.danger  { background: var(--danger); color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.sm { padding: 7px 14px; font-size: .85rem; }
.btn.block { width: 100%; }

/* ---------- Cards / Grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.card {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}
.card .photo {
  aspect-ratio: 4 / 3;
  background: #f6efe0 center/cover no-repeat;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.6rem; color: #c9b58a;
}
.card .body { padding: 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card .body h3 { margin: 0; font-size: 1.05rem; }
.card .desc { color: var(--muted); font-size: .9rem; margin: 0; flex: 1; }

.badge {
  align-self: flex-start;
  font-size: .78rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--r-chip);
}
.badge.free { background: #e3f4ea; color: var(--ok); }
.badge.out  { background: #fdeaea; color: var(--danger); }
.loan-info { font-size: .82rem; color: var(--muted); }
.loan-info b { color: var(--text); }
.card-actions { display: flex; gap: 8px; margin-top: 4px; }

/* ---------- Auth / Forms ---------- */
.auth-wrap { max-width: 380px; margin: 6vh auto 0; }
/* Marke auf dem Anmeldeschirm: Ball + Schriftzug statt Logo-Grafik. */
.auth-logo { text-align: center; margin: 0 auto 22px; }
.brandmark { display: inline-flex; flex-direction: column; align-items: center; gap: 12px; }
.brandmark-badge {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--ink); color: var(--sun);
  display: flex; align-items: center; justify-content: center;
}
.brandmark-badge svg { width: 38px; height: 38px; display: block; }
.brandmark-text { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.brandmark-name {
  font-weight: 800; font-size: 30px; line-height: 1;
  color: var(--court); letter-spacing: .6px;
}
.brandmark-sub {
  font-size: 11px; letter-spacing: 4px; color: var(--muted);
  font-weight: 600; text-transform: uppercase;
}
.panel {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.panel h2 { margin-top: 0; }
label { display: block; font-size: .85rem; font-weight: 600; margin: 12px 0 4px; }
input, textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-input);
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
}
input:focus, textarea:focus { outline: 2px solid var(--court); border-color: var(--court); }
.switch-link { text-align: center; margin-top: 14px; font-size: .9rem; color: var(--muted); }

/* ---------- PWA-Install ---------- */
.install-area { margin-top: 16px; }
.install-area:empty { margin-top: 0; }
.install-hint {
  background: var(--tint);
  border: 1px dashed #e6cf8a;
  border-radius: var(--r-card);
  padding: 12px 14px;
  font-size: .88rem;
  color: var(--text);
  line-height: 1.5;
}
.install-hint b { color: var(--court-dark); }
/* Einfarbige Symbole im Fliesstext (Install-Hinweise, Startseiten-Tipp). */
.ic { width: 1.05em; height: 1.05em; vertical-align: -.15em; flex: 0 0 auto; }
.switch-link a { color: var(--court-dark); font-weight: 600; cursor: pointer; text-decoration: underline; }
.form-error { color: var(--danger); font-size: .88rem; margin: 10px 0 0; min-height: 1.1em; }
.tabs { display: flex; gap: 8px; margin-bottom: 8px; }
.tabs button {
  flex: 1; padding: 10px; border: none; border-radius: var(--r-btn); cursor: pointer;
  font-weight: 600; background: #f4f4f2; color: var(--muted);
}
.tabs button.active { background: var(--sun); color: var(--ink); }

/* ---------- Dialog ---------- */
dialog {
  border: none; border-radius: var(--radius); padding: 22px;
  max-width: 420px; width: 92%; box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog h2 { margin-top: 0; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* ---------- Admin add form ---------- */
.admin-add { margin-bottom: 22px; }
.photo-pick { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.photo-preview {
  width: 64px; height: 64px; border-radius: var(--r-input); background: #f6efe0 center/cover;
  display: flex; align-items: center; justify-content: center; font-size: 1.6rem; color: #c9b58a;
}

/* ---------- Utility ---------- */
.muted { color: var(--muted); }
.hidden { display: none !important; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.empty .ball { font-size: 2.4rem; display: block; margin-bottom: 8px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--court-dark); color: #fff; padding: 12px 20px;
  border-radius: var(--r-btn); box-shadow: var(--shadow); font-weight: 600;
  z-index: 100; max-width: 90%;
}
.toast.err { background: var(--danger); }

/* ============================================================
   Mobile Bereichs-Navigation unten (Design: 4 Tabs mit Symbolen)
   Wechselt zwischen den SUTC-Apps; Konto-Punkte bleiben oben im Menue.
   ============================================================ */
.tabbar { display: none; }

@media (max-width: 720px) {
  /* ---- Feste App-Huelle: Header oben, Tab-Leiste unten, Inhalt scrollt in
     der Mitte. Einheitlich in allen SUTC-Apps. ----
     Der Trick gegen das iOS-Wackeln: der body scrollt NICHT (overflow:hidden),
     nur <main> scrollt intern. Ohne Body-Scroll animiert iOS die Adressleiste
     nicht, und die fixe Tab-Leiste bleibt ruhig am unteren Rand.
     padding-bottom haelt den Inhalt ueber der Leiste frei (border-box zieht
     es von der 100dvh-Hoehe ab). */
  body {
    height: 100dvh; overflow: hidden;
    display: flex; flex-direction: column;
    padding-bottom: var(--tabbar-h);
  }
  .topbar { flex: 0 0 auto; }
  body > main {
    flex: 1 1 auto; min-height: 0; width: 100%; min-width: 0;
    overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch;
  }

  .tabbar {
    display: grid; grid-template-columns: repeat(4, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    background: #fff;
    border-top: 1px solid var(--border);
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
    box-shadow: 0 -2px 10px rgba(0,0,0,.05);
  }
  .tabbar a {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    color: #8a858a; text-decoration: none; padding-top: 4px; margin-top: -2px;
    border-top: 2px solid transparent;
  }
  .tabbar a:hover { text-decoration: none; }
  .tabbar a.is-active { color: var(--court); border-top-color: var(--sun); }
  .tabbar svg { display: block; width: 21px; height: 21px; }
  .tabbar .tab-label { font-size: 10.5px; font-weight: 700; }

  /* Bereichs-Links doppeln sich sonst mit der Tabbar. */
  #mainNav .nav-cross { display: none; }
}

/* ============================================================
   Startseite (www.sutcgg.win) -- Aufbau aus dem Redesign-Prototyp
   ============================================================ */
main.start-main { max-width: 1100px; padding: 28px 32px 40px; }
.start-hi { font-size: 27px; font-weight: 800; color: var(--text); margin: 0; }
.start-sub { color: var(--muted); font-size: 14.5px; margin: 2px 0 0; }

.start-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 16px; margin-top: 24px;
}
.start-card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--r-card);
  overflow: hidden; display: flex; flex-direction: column;
  text-decoration: none; color: inherit;
  transition: box-shadow .15s ease, border-color .15s ease;
}
.start-card:hover {
  text-decoration: none; border-color: var(--court);
  box-shadow: 0 8px 24px rgba(0,0,0,.10);
}
/* Kopfflaeche: entweder ein Foto (.start-photo) oder -- solange keins
   hinterlegt ist -- die Tint-Flaeche mit grossem Geister-Symbol. */
/* Kein overflow:hidden -- das Badge ragt bewusst 26px in den Textteil hinein
   (wie im Design). Die runden/eckigen Aussenkanten klippt die Karte selbst. */
.start-head {
  position: relative; height: 132px; flex: 0 0 auto;
  background: var(--tint);
}
/* object-position 45%: der Kirchturm bleibt oben komplett im Bild, unten
   bleibt genug Platz sichtbar. Bei 132px Kopfhoehe und 3:2-Foto wird
   sonst entweder der Turm oder der Platz abgeschnitten. */
.start-photo {
  width: 100%; height: 100%; display: block;
  object-fit: cover; object-position: center 45%;
}
.start-head .start-ghost {
  position: absolute; left: 18px; top: 50%; transform: translateY(-50%);
  width: 82px; height: 82px; color: var(--sun); opacity: .45;
}
.start-badge {
  position: absolute; right: 16px; bottom: -26px;
  width: 58px; height: 58px; border-radius: var(--r-card);
  background: var(--sun); color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px rgba(0,0,0,.18);
}
.start-badge svg { width: 30px; height: 30px; }
.start-body {
  padding: 18px 22px 22px; display: flex; flex-direction: column;
  gap: 10px; flex: 1;
}
.start-title { font-weight: 700; font-size: 18px; color: var(--text); }
.start-desc { color: var(--muted); font-size: 14px; margin-top: 3px; }
/* Pfeil sitzt immer rechts -- auch wenn eine Karte keinen Status-Chip hat. */
.start-foot {
  margin-top: auto; display: flex; align-items: center;
  justify-content: flex-end; gap: 10px;
}
.start-chip {
  margin-right: auto;
  background: var(--tint); color: var(--court-dark);
  font-size: 12.5px; font-weight: 600;
  padding: 4px 12px; border-radius: var(--r-chip);
}
.start-arrow { width: 18px; height: 18px; color: var(--court); flex: 0 0 auto; }

.start-tip {
  margin-top: 20px; background: var(--tint); border-radius: var(--r-card);
  padding: 14px 18px; display: flex; align-items: center; gap: 12px;
  color: var(--court-dark);
}
.start-tip svg { width: 18px; height: 18px; flex: 0 0 auto; }
.start-tip span { font-size: 13.5px; font-weight: 500; }
.start-tip:empty { display: none; }

@media (max-width: 720px) {
  main.start-main { padding: 20px 16px 32px; }
  .start-hi { font-size: 23px; }
  .start-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   Startseiten-Karten: Foto verwalten (nur Admins)
   ============================================================ */
/* Der Bearbeiten-Knopf liegt NEBEN dem Link, nicht darin -- ein <button>
   im <a> waere ungueltiges Markup und wuerde den Link mitausloesen. */
.start-card-wrap { position: relative; display: flex; }
.start-card-wrap > .start-card { flex: 1; min-width: 0; }

.start-edit {
  position: absolute; top: 10px; left: 10px; z-index: 2;
  width: 34px; height: 34px; padding: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.92); color: var(--court-dark);
  border: 1px solid var(--border); border-radius: var(--r-btn);
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.start-edit svg { width: 18px; height: 18px; display: block; }
.start-edit:hover { background: #fff; }
.start-edit[hidden] { display: none; }

/* Liegt ein Foto vor, tritt das Geister-Symbol zurueck. */
.start-head.has-photo .start-ghost { display: none; }

/* ---- Dialog ---- */
.card-dlg { max-width: 460px; }
.card-dlg h2 { margin-top: 0; }
/* Gleiche Proportion wie die Kopfflaeche der Karte (343 zu 132). Mit fester
   Hoehe waere die Vorschau breiter als die Karte -- derselbe object-position-
   Wert zeigte dann einen anderen Ausschnitt als spaeter auf der Startseite. */
.crop-preview {
  aspect-ratio: 343 / 132; margin: 14px 0 6px; overflow: hidden;
  background: var(--tint); border: 1px solid var(--border);
  border-radius: var(--r-card);
}
.crop-preview img {
  width: 100%; height: 100%; display: block;
  object-fit: cover; object-position: center 45%;
}
/* display:block wuerde das hidden-Attribut sonst aushebeln -- ohne diese
   Regel bliebe das Bild der zuvor geoeffneten Karte stehen. */
.crop-preview img[hidden] { display: none; }
.crop-label { display: block; margin: 10px 0 0; font-size: .85rem; font-weight: 600; }
.crop-label input[type=range] { width: 100%; margin-top: 4px; accent-color: var(--sun); }
/* Drei Knoepfe passen auf schmalen Handys nicht in eine Zeile -- umbrechen
   lassen, sonst haengt "Foto entfernen" ausserhalb des Dialogs. */
.card-dlg .dialog-actions { align-items: center; flex-wrap: wrap; gap: 8px; }
.card-dlg .dialog-actions .btn { flex: 0 1 auto; }
/* Tippziel vergroessern: 34px sind fuer einen Knopf auf einem
   ganzflaechigen Link zu wenig. */
.start-edit { width: 40px; height: 40px; }

/* ============================================================
   Installierter App-Modus (iOS Standalone)
   Dort gibt es keine dynamische Adressleiste, aber iOS verankert
   position:fixed bottom:0 am Layout- statt am sichtbaren Viewport und
   rechnet 100dvh eigenwillig -> die Leiste rutschte unter den Rand.
   Loesung: die Leiste als normales Flex-Kind unten in die Spalte
   (kein fixed), Hoehe ueber 100vh (im Standalone stabil, keine Chrome).
   ============================================================ */
@media (display-mode: standalone) and (max-width: 720px) {
  body { height: 100vh; padding-bottom: 0; }
  .tabbar { position: static; flex: 0 0 auto; }
}
