/* Echte Fründe – Visitenkarten
   Mobile-first: die Seite wird praktisch immer vom Handy aus gescannt. */

/* UnifrakturMaguntia, SIL Open Font License 1.1 – selbst gehostet, damit beim
   Scannen kein Fremdserver kontaktiert wird. Nur die Startseite benutzt sie;
   die Kartenseiten laden die Datei deshalb gar nicht erst. */
@font-face {
  font-family: 'UnifrakturMaguntia';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/unifrakturmaguntia-latin.woff2') format('woff2');
}

:root {
  --accent: #e8623d;
  --bg: #f3f1ee;
  --surface: #ffffff;
  --text: #16181d;
  --muted: #6b7280;
  --line: rgba(0, 0, 0, 0.09);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 18px 40px -14px rgba(0, 0, 0, 0.28);
  --radius: 22px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0e11;
    --surface: #17191f;
    --text: #eceef2;
    --muted: #949aa6;
    --line: rgba(255, 255, 255, 0.11);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 18px 40px -14px rgba(0, 0, 0, 0.7);
  }
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 28px 18px 24px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  background-image: radial-gradient(
    120% 70% at 50% 0%,
    color-mix(in srgb, var(--accent) 16%, transparent) 0%,
    transparent 65%
  );
  background-repeat: no-repeat;
}

/* ---------- Visitenkarte ---------- */

.card {
  position: relative;
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  padding-bottom: 26px;
  text-align: center;
  animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .card {
    animation: none;
  }
}

.card__band {
  height: 92px;
  background: linear-gradient(
    135deg,
    var(--accent) 0%,
    color-mix(in srgb, var(--accent) 62%, #000) 100%
  );
}

.avatar {
  display: block;
  width: 108px;
  height: 108px;
  margin: -56px auto 0;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface);
  border: 4px solid var(--surface);
  box-shadow: 0 6px 18px -6px rgba(0, 0, 0, 0.35);
}

.name {
  margin: 16px 22px 0;
  font-size: 1.6rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.spruch {
  margin: 10px 26px 0;
  font-size: 1.02rem;
  line-height: 1.55;
  color: var(--muted);
  text-wrap: pretty;
}

/* ---------- Kontakt-Buttons ---------- */

.links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 11px;
  margin: 22px 22px 0;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.card--nolinks .links {
  display: none;
}

.link {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--line);
  color: var(--accent);
  text-decoration: none;
  transition: background-color 0.18s, color 0.18s, transform 0.18s;
}

.link svg {
  width: 22px;
  height: 22px;
}

.link:active {
  transform: scale(0.94);
}

@media (hover: hover) {
  .link:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
  }
}

/* ---------- Footer ---------- */

.footer {
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
}

.footer a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ---------- Übersicht / Textseiten ---------- */

.page {
  width: 100%;
  max-width: 760px;
  margin-inline: auto;
}

body.page-wide {
  justify-content: flex-start;
}

.page h1 {
  font-size: 1.9rem;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}

.page .lead {
  color: var(--muted);
  margin: 0 0 28px;
}

/* Startseite: Titel mittig, in der Fraktur-Schrift. */
.home-header {
  text-align: center;
  margin-bottom: 30px;
}

.home-header .brand {
  font-family: 'UnifrakturMaguntia', Georgia, 'Times New Roman', serif;
  font-weight: 400;
  font-size: clamp(2.4rem, 11vw, 3.6rem);
  line-height: 1.1;
  letter-spacing: 0;
  margin: 0;
}

.page h2 {
  font-size: 1.1rem;
  margin: 26px 0 6px;
}

.page p,
.page li {
  line-height: 1.65;
  color: var(--muted);
}

/* Kacheln bringen ihre eigene Farbe mit und dürfen hier nicht mitgefärbt werden. */
.page a:not(.tile) {
  color: var(--accent);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 20px 12px;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 10px 24px -16px rgba(0, 0, 0, 0.5);
  text-decoration: none;
  color: var(--text);
  transition: transform 0.18s;
}

@media (hover: hover) {
  .tile:hover {
    transform: translateY(-3px);
  }
}

.tile img {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--tile-accent, var(--accent));
}

.tile span {
  font-weight: 600;
  font-size: 0.95rem;
}

/* ---------- Scan-Statistik ---------- */

.stats-link {
  margin: 26px 0 0;
  text-align: center;
}

.stats-total {
  font-size: 1.25rem;
  font-weight: 650;
  margin: 0;
}

.stats-breakdown {
  font-size: 0.88rem;
  color: var(--muted);
  margin: 4px 0 16px;
}

.stats-hint {
  font-size: 0.85rem;
  margin-top: 20px;
}

.legend {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  padding: 0;
  margin: 0 0 20px;
  font-size: 0.82rem;
  color: var(--muted);
}

.legend li {
  display: flex;
  align-items: center;
  gap: 7px;
}

.legend-swatch {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  flex: none;
}

/* Repräsentativ – im echten Balken hat jede Person ihre eigene Akzentfarbe. */
.legend-swatch--scan {
  background: var(--accent);
}

.legend-swatch--panel {
  background: color-mix(in srgb, var(--text) 45%, transparent);
}

.legend-swatch--direct {
  background: color-mix(in srgb, var(--text) 18%, transparent);
}

.rank {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rank-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 10px 24px -18px rgba(0, 0, 0, 0.6);
}

.rank-pos {
  width: 1.4em;
  flex: none;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: right;
}

.rank-img {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  object-fit: cover;
}

.rank-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rank-name {
  font-weight: 600;
  font-size: 0.98rem;
  color: var(--text);
}

/* Gesamtlänge kommt als --w aus dem Skript (Anteil an der grössten Person),
   die drei Segmente darin verteilen sich per flex-grow proportional zu ihren
   eigenen Aufrufzahlen – wächst automatisch mit, schrumpft bei 0 auf nichts. */
.rank-bar {
  display: flex;
  width: var(--w, 0%);
  height: 6px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}

.rank-seg {
  flex-shrink: 0;
  flex-basis: 0;
  height: 100%;
}

.rank-seg--scan {
  background: var(--accent);
}

.rank-seg--panel {
  background: color-mix(in srgb, var(--text) 45%, transparent);
}

.rank-seg--direct {
  background: color-mix(in srgb, var(--text) 18%, transparent);
}

.rank-count {
  flex: none;
  font-size: 1.05rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

/* Das Zähl-Pixel darf das Layout nicht anfassen. */
.px {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ---------- QR-Bogen zum Drucken ---------- */

.qr-zip {
  margin: 0 0 26px;
}

/* `.page a.qr-zip__button` statt nur `.qr-zip__button`: die allgemeine Regel
   „.page a:not(.tile)“ weiter oben hat höhere Spezifität (Klasse+Pseudo+Element)
   und würde die weisse Schrift sonst wieder auf die Akzentfarbe zurückfärben –
   Text auf gleichfarbigem Grund, unsichtbar. */
.page a.qr-zip__button {
  display: inline-block;
  padding: 12px 20px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
}

@media (hover: hover) {
  .qr-zip__button:hover {
    filter: brightness(1.08);
  }
}

.qr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 18px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.page li.qr-item {
  background: #fff;
  color: #000;
  border: 1px solid #ddd;
  border-radius: 12px;
  padding: 14px 12px;
  text-align: center;
  break-inside: avoid;
}

.qr-item img {
  width: 100%;
  max-width: 150px;
  aspect-ratio: 1;
  display: block;
  margin: 0 auto 10px;
}

.qr-item strong {
  display: block;
  font-size: 0.95rem;
}

.qr-item code {
  display: block;
  margin-top: 4px;
  font-size: 0.66rem;
  color: #666;
  word-break: break-all;
}

.qr-item a {
  font-size: 0.72rem;
}

@media print {
  body {
    background: #fff;
    padding: 0;
    display: block;
  }

  .noprint {
    display: none;
  }

  .qr-item {
    border-color: #eee;
  }
}
