/* ============================================================
   Hochzeitsgame – Stylesheet (mobile-first & responsive)
   Schriftart: Safira March (kommerziell, selbst lizenzieren)
   -> Font-Datei ablegen unter:  frontend/fonts/SafiraMarch.woff2
   Solange die Datei fehlt, greift ein eleganter Serif-Fallback.
   ============================================================ */

@font-face {
  font-family: "Safira March";
  src: url("./fonts/SafiraMarch.woff2") format("woff2"),
       url("./fonts/SafiraMarch.woff") format("woff");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-script: "Safira March", "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --c-primary: #b08968;
  --c-accent:  #7f9172;
  --c-bg:      #faf6f0;
  --c-text:    #3a3230;
  --c-card:    #ffffff;
  --c-muted:   #9a8f86;
  --c-good:    #4b8b5a;
  --c-bad:     #c05a52;
  --c-gold:    #d4af37;
  --c-silver:  #aeb3b8;
  --c-bronze:  #c58b5b;
  --shadow:    0 6px 24px rgba(60, 45, 35, 0.10);
  --radius:    18px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--c-bg); color: var(--c-text);
  font-family: var(--font-script);
  font-size: 20px; line-height: 1.35;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }
svg.icon { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; display: block; }
svg.icon.sm { width: 20px; height: 20px; }

/* ---------- Layout ---------- */
.wrap {
  max-width: 620px; margin: 0 auto;
  padding: 0 16px calc(96px + env(safe-area-inset-bottom));
  min-height: 100vh;
}
.app-header {
  position: sticky; top: 0; z-index: 10;
  background: var(--c-bg); padding: 14px 0 10px; text-align: center;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
.app-header h1 { margin: 0; font-size: 2.4rem; color: var(--c-primary); font-weight: 400; line-height: 1.1; }
.admin-link { display: inline-block; margin-top: 6px; color: var(--c-muted); text-decoration: none; font-size: .8rem; border: 1px solid #e3d9cd; padding: 3px 14px; border-radius: 999px; }
.tagline { text-align: center; color: var(--c-muted); font-size: 1.05rem; margin-top: 2px; }

/* Bildverwaltung (Admin) */
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
.img-cell { position: relative; aspect-ratio: 1 / 1; border-radius: 10px; overflow: hidden; background: #000; box-shadow: var(--shadow); }
.img-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-cell .cap { position: absolute; left: 0; right: 0; bottom: 0; font-size: .7rem; color: #fff; padding: 4px 6px; background: linear-gradient(transparent, rgba(0,0,0,.8)); }
.img-cell .del { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border: none; border-radius: 8px; background: rgba(192,90,82,.92); color: #fff; font-size: 1rem; line-height: 1; display: flex; align-items: center; justify-content: center; }
.score-pill {
  display: inline-block; margin-top: 6px; background: var(--c-accent); color: #fff;
  padding: 4px 16px; border-radius: 999px; font-size: 1.1rem; letter-spacing: .3px;
}

/* ---------- Gate (Passcode) ---------- */
.gate {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; padding: 24px; gap: 16px;
}
.gate h1 { font-size: 3rem; color: var(--c-primary); margin: 0; font-weight: 400; }
.gate p  { color: var(--c-muted); margin: 0 0 8px; max-width: 24em; }
.gate input {
  font-family: inherit; font-size: 1.1rem; padding: 14px 16px;
  border: 2px solid #e3d9cd; border-radius: 14px; width: min(360px, 90vw);
  text-align: center; letter-spacing: 2px; background: #fff;
}
.gate .hint { font-size: .85rem; }

/* ---------- Views ---------- */
.view { display: none; padding-top: 12px; }
.view.active { display: block; }
.section-title { font-size: 1.7rem; color: var(--c-primary); margin: 4px 0 14px; text-align: center; }

/* ---------- Cards ---------- */
.card { background: var(--c-card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card .q { font-size: 1.25rem; margin: 0 0 14px; }
.options { display: grid; gap: 10px; }
.option {
  display: block; width: 100%; text-align: left; background: #fbf7f1;
  border: 2px solid #ece2d6; border-radius: 14px; padding: 14px 16px;
  font-size: 1.05rem; color: var(--c-text);
  transition: transform .06s ease, background .15s ease, border-color .15s ease;
}
.option:active { transform: scale(.98); }
.option.correct { background: #e7f2e9; border-color: var(--c-good); color: var(--c-good); }
.option.wrong   { background: #f7e7e5; border-color: var(--c-bad);  color: var(--c-bad); }
.option:disabled { cursor: default; opacity: 1; }
.points-tag { float: right; font-size: .85rem; color: var(--c-muted); }

/* ---------- Foto-Aufgaben ---------- */
.task { display: flex; align-items: center; gap: 14px; }
.task .txt { flex: 1; }
.task .txt .t { font-size: 1.1rem; }
.task .txt .p { font-size: .85rem; color: var(--c-muted); }
.task .thumb { width: 62px; height: 62px; border-radius: 12px; object-fit: cover; border: 2px solid var(--c-accent); }
.task .actions { display: flex; gap: 8px; }
.icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 48px; height: 48px; border-radius: 12px; border: 2px solid var(--c-primary);
  background: #fff; color: var(--c-primary);
}
.icon-btn.solid { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }
.icon-btn:active { transform: scale(.96); }

.btn { border: none; background: var(--c-primary); color: #fff; border-radius: 14px; padding: 12px 18px; font-size: 1rem; }
.btn.secondary { background: #fff; color: var(--c-primary); border: 2px solid var(--c-primary); }
.btn.small { padding: 8px 12px; font-size: .9rem; }
.btn.danger { background: #fff; color: var(--c-bad); border: 2px solid var(--c-bad); }
.btn:disabled { opacity: .55; }
.btn.block { width: 100%; }
.badge-done { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; background: #e7f2e9; color: var(--c-good); }

/* ---------- Rangliste ---------- */
.rang-row { display: flex; align-items: center; gap: 12px; background: var(--c-card); border-radius: 14px; padding: 12px 16px; margin-bottom: 8px; box-shadow: var(--shadow); }
.rank-badge {
  width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 1rem; background: #efe7db; color: var(--c-primary); flex: 0 0 auto;
}
.rank-badge.g1 { background: var(--c-gold);   color: #fff; }
.rank-badge.g2 { background: var(--c-silver); color: #fff; }
.rank-badge.g3 { background: var(--c-bronze); color: #fff; }
.rang-row .nm { flex: 1; font-size: 1.1rem; }
.rang-row .pts { font-size: 1.1rem; color: var(--c-accent); }
.rang-row.me { outline: 3px solid var(--c-accent); }

/* ---------- Bottom Nav ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; background: #fff;
  border-top: 1px solid rgba(0,0,0,.08); display: flex;
  padding-bottom: env(safe-area-inset-bottom); z-index: 20;
}
.tabbar button {
  flex: 1; border: none; background: none; padding: 10px 4px; font-size: .8rem;
  color: var(--c-muted); display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.tabbar button.active { color: var(--c-primary); }
.tabbar button.hidden { display: none; }

/* ---------- Foto-Vorschau (Modal) ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(30,24,20,.86); z-index: 60;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.overlay.show { display: flex; }
.overlay .box { background: #fff; border-radius: 18px; padding: 16px; max-width: 460px; width: 100%; max-height: 92vh; overflow: auto; }
.overlay .box h3 { margin: 0 0 12px; color: var(--c-primary); font-weight: 400; font-size: 1.4rem; text-align: center; }
.overlay .preview-img { width: 100%; border-radius: 12px; margin-bottom: 14px; }
.overlay .row { display: flex; gap: 10px; }
.overlay .row .btn { flex: 1; }

/* ---------- Admin ---------- */
.subtabs { display: flex; gap: 6px; margin: 6px 0 16px; }
.subtabs button {
  flex: 1; border: 2px solid #e3d9cd; background: #fff; color: var(--c-muted);
  border-radius: 12px; padding: 10px 6px; font-size: 1rem;
}
.subtabs button.active { border-color: var(--c-primary); color: var(--c-primary); background: #fbf7f1; }
.adm-section { display: none; }
.adm-section.active { display: block; }
.toggle-card { display: flex; align-items: center; gap: 12px; }
.toggle-card label { flex: 1; font-size: 1.05rem; }
.toggle-card input[type=checkbox] { width: 26px; height: 26px; flex: 0 0 auto; }
.adm-input { font-family: inherit; font-size: 1.05rem; width: 100%; padding: 10px 12px; border: 2px solid #e3d9cd; border-radius: 12px; background: #fff; margin-bottom: 8px; }
.opt-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.opt-row input[type=radio] { width: 22px; height: 22px; }
.opt-row input[type=text] { flex: 1; margin: 0; }
.opt-row .rm { background: none; border: none; color: var(--c-bad); font-size: 1.3rem; line-height: 1; }
.row-actions { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; align-items: center; }
.pts-in { width: 110px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 8px 0 14px; }
.link { color: var(--c-primary); text-decoration: none; font-size: .95rem; }

/* ---------- Gäste / QR ---------- */
.guest-row { display: flex; align-items: center; gap: 12px; }
.guest-row .gn { flex: 1; }
.guest-row .gn .nm { font-size: 1.1rem; }
.guest-row .gn .cd { font-size: .8rem; color: var(--c-muted); font-family: monospace; letter-spacing: 1px; }
.qr-box { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.qr-box .qr-holder { background: #fff; padding: 10px; border-radius: 12px; }

/* ---------- Diverses ---------- */
.center { text-align: center; }
.muted  { color: var(--c-muted); }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 4px solid #e6dccf; border-top-color: var(--c-primary); animation: spin 1s linear infinite; margin: 24px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Inline-Spinner in Buttons */
.btn-spin { display: inline-block; width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255,255,255,.5); border-top-color: #fff; animation: spin .8s linear infinite; vertical-align: -2px; margin-right: 8px; }
.btn.secondary .btn-spin, .icon-btn .btn-spin { border-color: rgba(176,137,104,.35); border-top-color: var(--c-primary); }
.btn.is-loading, .icon-btn.is-loading { pointer-events: none; opacity: .8; }

/* Skeleton-Ladeflächen */
.skeleton { background: linear-gradient(90deg, #efe7db 25%, #f7f1e8 37%, #efe7db 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 12px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.sk-card { height: 96px; margin-bottom: 16px; }

/* Vollflächige Lade-Überlagerung (z. B. Foto-Upload) */
.uploading { position: relative; }
.uploading::after { content: ""; position: absolute; inset: 0; background: rgba(255,255,255,.6); border-radius: 12px; }
.upload-spin { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 2; }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--c-text); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: .95rem; z-index: 80; opacity: 0; transition: opacity .25s ease; pointer-events: none; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; }
.hidden { display: none !important; }

@media (min-width: 700px) {
  body { font-size: 21px; }
  .app-header h1 { font-size: 2.8rem; }
}
