/* ============================================================
   base.css – Grundgerüst für alle Apps.
   App-Hülle, Bedienelemente, Hinweisleisten, Dialoge.
   Eigene Styles der App gehören in eine eigene Datei (css/app.css).
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
}

body { overflow: hidden; }

/* ── App-Hülle: Kopf, scrollender Inhalt, Navigation unten ── */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;               /* Rückfall für alte Browser */
  height: 100dvh;              /* sichtbare Höhe auf dem Handy */
  max-width: var(--content-width);
  margin: 0 auto;
}

.app__header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top, 0px))
           max(var(--gap), env(safe-area-inset-right, 0px))
           12px
           max(var(--gap), env(safe-area-inset-left, 0px));
  border-bottom: 1px solid var(--border);
}

.app__title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 400;
  letter-spacing: 2px;
  line-height: 1;
  color: var(--accent);
  text-shadow: 0 0 18px var(--accent-glow);
}

.app__main {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: var(--gap)
           max(var(--gap), env(safe-area-inset-right, 0px))
           calc(var(--gap) + 96px)        /* Platz für Hinweisleisten */
           max(var(--gap), env(safe-area-inset-left, 0px));
}

.app__nav {
  flex-shrink: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.nav-btn {
  flex: 1;
  min-height: var(--nav-height);
  border: 0;
  background: none;
  color: var(--text-muted);
  font: 600 12px var(--font-body);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}
.nav-btn[aria-current='page'] { color: var(--accent); box-shadow: inset 0 2px 0 var(--accent); }

/* ── Text ── */
h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 400;
  letter-spacing: 1.5px;
  margin-bottom: 10px;
}
p + p { margin-top: 8px; }
.muted { color: var(--text-muted); font-size: 14px; }
.mono { font-family: var(--font-mono); font-size: 13px; }

/* ── Karten ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--gap);
  margin-bottom: var(--gap);
}

.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

/* ── Knöpfe ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;                 /* gut tippbar */
  padding: 10px 18px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-small);
  background: var(--accent);
  color: var(--accent-contrast);
  font: 600 15px var(--font-body);
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn:focus-visible, .nav-btn:focus-visible, .input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn--ghost { background: none; color: var(--text); border-color: var(--border); }
.btn--danger { background: none; color: var(--danger); border-color: var(--danger); }
.btn--small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn:disabled { opacity: 0.45; cursor: default; }

/* ── Eingaben ── */
.label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.input {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  color: var(--text);
  font: 16px var(--font-body);       /* 16px: iOS zoomt sonst beim Tippen */
}

/* ── Listen ── */
.list { list-style: none; padding: 0; }
.list__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}
.list__item:first-child { border-top: 0; }
.list__text { min-width: 0; overflow-wrap: anywhere; }

/* ── Tabelle für Statuswerte ── */
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.facts dt { color: var(--text-muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

/* ── Hinweisleisten (notice.js) ── */
.cp-notices {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 10px);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 max(12px, env(safe-area-inset-right, 0px)) 0 max(12px, env(safe-area-inset-left, 0px));
  pointer-events: none;
}
.cp-notice {
  pointer-events: auto;
  width: 100%;
  max-width: calc(var(--content-width) - 24px);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: 0 0 24px var(--accent-dim), 0 8px 24px rgba(0, 0, 0, 0.5);
  font-size: 14px;
}
.cp-notice__text { flex: 1; min-width: 150px; }
.cp-notice__actions { display: flex; gap: 8px; }

/* ── Dialog ── */
dialog.dialog {
  width: min(92vw, 420px);
  margin: auto;
  padding: 20px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
dialog.dialog::backdrop { background: rgba(0, 0, 0, 0.7); }
.dialog__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

/* ── Sperrbildschirm (lock-screen.js) ── */
.cp-lock {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--gap) + env(safe-area-inset-top, 0px)) var(--gap) calc(var(--gap) + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
  overflow-y: auto;
}
.cp-lock__box { width: 100%; max-width: 380px; }
.cp-lock__error { color: var(--danger); font-size: 14px; min-height: 1.4em; }

/* ── Breite Bildschirme ── */
@media (min-width: 600px) {
  .app { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}

/* ── Weniger Bewegung, wenn im System so eingestellt ── */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
