/*
 * Dunkel, kantig, große Flächen. Gebaut für einen Daumen im
 * Halbdunkeln hinter der Bühne, nicht für einen Schreibtisch.
 *
 * Made2Merch nur dort, wo ich den Text selbst bestimme — der gelieferte
 * Schriftauszug hat keine Umlaute. Produktnamen kommen aus Shopify und
 * laufen deshalb immer in Inter.
 */

@font-face {
  font-family: 'Made2Merch';
  src: url('schriften/made2merch.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('schriften/inter-400.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('schriften/inter-600.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}

:root {
  --grund: #0f0f0f;
  --flaeche: #1b1717;
  --linie: #302828;
  --text: #e8e6e6;
  --text-leise: #9a9494;
  --akzent: #00a96e;
  --warnung: #ff5861;

  --schrift: 'Inter', system-ui, -apple-system, sans-serif;
  --marke: 'Made2Merch', 'Inter', sans-serif;

  --rand: 16px;
  --tippziel: 56px;
}

* { box-sizing: border-box; }

/*
 * hidden muss stärker sein als die display-Regeln der Bauteile.
 * Ohne das bleibt ein .knopf[hidden] sichtbar, weil .knopf
 * display: inline-flex setzt.
 */
[hidden] { display: none !important; }

/*
 * Die Seite selbst scrollt nie. Das ist der Unterschied zwischen
 * "Webseite" und "App": Kein Gummiband am Rand, kein Nachziehen zum
 * Neuladen, keine Adressleiste, die beim Wischen ein- und ausfährt.
 * Gescrollt wird ausschliesslich in der Artikelliste.
 */
/*
 * Kein position: fixed am body. Die Ebenen sind selbst fest verankert,
 * und ein fester body zusammen mit einem verschachtelten Scrollbereich
 * ist auf iOS genau die Kombination, bei der der Schwung beim Scrollen
 * verloren geht.
 */
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--grund);
  color: var(--text);
  font-family: var(--schrift);
  font-size: 17px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  /* Text markieren ist auf einem Zählgerät nur im Weg */
  -webkit-user-select: none;
  user-select: none;
}

input {
  -webkit-user-select: text;
  user-select: text;
}

button, input { font: inherit; color: inherit; }
input { -webkit-appearance: none; appearance: none; }

/*
 * Ebenenwechsel schiebt seitlich, wie in einer iOS-App: Die neue Ebene
 * kommt von rechts, die alte zieht ein Stück nach links und liegt
 * darunter. Beim Zurueck laeuft es rueckwaerts.
 */
.schirm {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--grund);
  /*
   * translate3d statt translateX: zwingt iOS, die Ebene als eigene
   * Schicht auf der Grafikeinheit zu halten. will-change wird nur
   * waehrend der Bewegung gesetzt — dauerhaft drei bildschirmgrosse
   * Schichten vorzuhalten kostet Speicher und macht es langsamer,
   * nicht schneller.
   */
  transform: translate3d(100%, 0, 0);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  backface-visibility: hidden;
}

body.bewegt .schirm { will-change: transform; }
.schirm[hidden] { display: none; }

#anmeldung { z-index: 1; }
#liste     { z-index: 2; }
#zaehler   { z-index: 3; }

.schirm--aktiv  { transform: translate3d(0, 0, 0); }
.schirm--links  { transform: translate3d(-24%, 0, 0); }
.schirm--rechts { transform: translate3d(100%, 0, 0); }

@media (prefers-reduced-motion: reduce) {
  .schirm { transition: none; }
}

/* ── Marke ───────────────────────────────────────────────────── */
.marke {
  margin: 0;
  font-family: var(--marke);
  font-size: 40px;
  font-weight: 400;
  letter-spacing: 6px;
  text-transform: uppercase;
}
.marke.klein { font-size: 20px; letter-spacing: 4px; }

.unterzeile {
  margin: 4px 0 40px;
  color: var(--text-leise);
  letter-spacing: 2px;
  text-transform: uppercase;
  font-size: 13px;
}

/* ── Anmeldung ───────────────────────────────────────────────── */
.mitte {
  margin: auto;
  padding-block: env(safe-area-inset-top) env(safe-area-inset-bottom);
  padding: var(--rand);
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.feldlabel {
  display: block;
  margin-bottom: 8px;
  text-align: left;
  font-size: 13px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-leise);
}

#pin {
  width: 100%;
  height: var(--tippziel);
  padding: 0 14px;
  margin-bottom: 12px;
  background: rgb(255 255 255 / 0.04);
  border: 1px solid rgb(255 255 255 / 0.28);
  border-radius: 0;
  text-align: center;
  letter-spacing: 8px;
  font-size: 22px;
}
#pin:focus-visible, #suche:focus-visible { outline: 2px solid var(--akzent); outline-offset: 2px; }

/* ── Knöpfe ─────────────────────────────────────────────────── */
.knopf {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tippziel);
  padding: 0 18px;
  border: 1px solid var(--akzent);
  border-radius: 0;
  background: var(--akzent);
  color: #000;
  font-weight: 600;
  letter-spacing: 0.4px;
  cursor: pointer;
  touch-action: manipulation;
}
.knopf--voll { width: 100%; }
.knopf--gross { min-height: 64px; font-size: 19px; }
.knopf--still {
  background: transparent;
  border-color: var(--linie);
  color: var(--text);
  font-weight: 400;
  padding: 0 12px;
}
.knopf:disabled { opacity: 0.45; cursor: default; }

/*
 * Druckgefuehl: Beim Druecken sofort, beim Loslassen weich zurueck.
 * Deshalb zwei verschiedene Uebergangsdauern — eine Animation beim
 * Antippen wuerde sich wie Verzoegerung anfuehlen, nicht wie Reaktion.
 */
.knopf {
  transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1),
              opacity 0.18s ease;
}
.knopf:active {
  transition-duration: 0s;
  transform: scale(0.96);
  opacity: 0.9;
}
.knopf--gross:active { transform: scale(0.975); }
.knopf:disabled:active { transform: none; opacity: 0.45; }

.symbol { width: 22px; height: 22px; }

/* ── Kopfzeile ───────────────────────────────────────────────── */
/*
 * Ohne Nachladen-Knopf steht links der Zurueck-Pfeil und daneben der
 * Titel. Kein space-between mehr, sonst wandert der Titel an den
 * rechten Rand, sobald nur zwei Dinge in der Zeile stehen.
 */
.kopf {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) var(--rand) 12px;
  border-bottom: 1px solid var(--linie);
}

/*
 * Produktnamen kommen aus Shopify und enthalten Umlaute — die fehlen
 * im gelieferten Schriftauszug. Deshalb in der Textschrift.
 */
#listentitel.titel-produkt {
  font-family: var(--schrift);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Hinweis, dass hinter einer Zeile noch eine Ebene liegt */
.pfeil {
  flex: 0 0 auto;
  width: 18px; height: 18px;
  color: var(--text-leise);
}

/* ── Suche und Liste ─────────────────────────────────────────── */
.suchzeile { flex: 0 0 auto; padding: 12px var(--rand); }

#suche {
  width: 100%;
  height: var(--tippziel);
  padding: 0 14px;
  background: rgb(255 255 255 / 0.04);
  border: 1px solid rgb(255 255 255 / 0.28);
  border-radius: 0;
}

.standzeile {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 var(--rand) 8px;
}

.stand {
  margin: 0;
  color: var(--text-leise);
  font-size: 13px;
}

.knopf--klein {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
}

/* Schon gezählt: eine ruhige Markierung am Rand, kein Farbrausch */
.zeile--fertig {
  box-shadow: inset 3px 0 0 var(--akzent);
}
.zeile--fertig .produkt { color: var(--text-leise); }

/*
 * Der einzige Scrollbereich der ganzen App. overscroll-behavior haelt
 * das Gummiband am Listenende auf, statt die Seite darunter mitzuziehen.
 */
.varianten {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  /* Nur senkrecht wischen — spart iOS das Abwarten, ob eine Geste quer geht */
  touch-action: pan-y;
  list-style: none;
  margin: 0;
  padding: 0 0 calc(24px + env(safe-area-inset-bottom));
  scrollbar-width: none;
}
.varianten::-webkit-scrollbar { display: none; }

.zeile {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 72px;
  padding: 10px var(--rand);
  border: 0;
  border-bottom: 1px solid var(--linie);
  background: var(--flaeche);
  text-align: left;
  cursor: pointer;
}
/*
 * Kein Uebergang und kein transform auf den Zeilen: Beides laeuft beim
 * Scrollen mit und erzeugt genau das Ruckeln, das man vermeiden will.
 * Die Rueckmeldung beim Druecken kommt sofort, ohne Animation.
 */
.zeile:active { background: #241f1f; }
.zeile:active .produkt { opacity: 0.75; }

/*
 * Jede Zeile rechnet nur fuer sich. Ohne das prueft der Browser beim
 * Scrollen die ganze Liste auf Umbrueche.
 */
.zeile { contain: layout style paint; }
.zeile--gesperrt { opacity: 0.45; cursor: default; }

.zeile img, .bildleer {
  width: 52px; height: 52px; flex: 0 0 52px;
  object-fit: contain;
  background: #000;
}

.zeile .namen { flex: 1; min-width: 0; }
.zeile .produkt {
  margin: 0;
  font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.zeile .variante { margin: 0; color: var(--text-leise); font-size: 14px; }

.zmenge {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  font-size: 19px;
  font-weight: 600;
}
.zmenge small { display: block; font-size: 11px; font-weight: 400; color: var(--text-leise); text-align: right; }

/* Wer sonst noch an derselben Groesse zaehlt */
.mitzaehler {
  flex: 0 0 auto;
  margin: 0;
  padding: 10px var(--rand);
  background: rgb(0 169 110 / 0.12);
  border-bottom: 1px solid var(--akzent);
  color: var(--akzent);
  font-size: 14px;
  font-weight: 600;
}

.leise { color: var(--text-leise); font-weight: 400; text-transform: none; letter-spacing: 0; }

#name {
  width: 100%;
  height: var(--tippziel);
  padding: 0 14px;
  margin-bottom: 16px;
  background: rgb(255 255 255 / 0.04);
  border: 1px solid rgb(255 255 255 / 0.28);
  border-radius: 0;
  text-align: center;
}
#name:focus-visible { outline: 2px solid var(--akzent); outline-offset: 2px; }

/* ── Zähler ─────────────────────────────────────────────────── */
.artikel {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 14px;
  padding: var(--rand);
  border-bottom: 1px solid var(--linie);
}
.zbild { flex: 0 0 64px; }
.zbild { width: 64px; height: 64px; object-fit: contain; background: #000; }
.zprodukt { margin: 0; font-weight: 600; font-size: 19px; }
.zvariante { margin: 2px 0 0; color: var(--text-leise); }
.zbestand { margin: 6px 0 0; color: var(--text-leise); font-size: 14px; }

/*
 * Aufteilung nach Blick und Daumen: Die Zahl steht gross in der Mitte,
 * wo der Blick hinfaellt. Die beiden Knoepfe liegen unten, wo der Daumen
 * hinkommt, wenn das Telefon in einer Hand liegt und die andere zaehlt.
 */
.zahlfeld {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 16px var(--rand);
}

/*
 * Die Zahl zuckt bei jeder Aenderung kurz. Beim Zaehlen von Hand ist
 * das die Bestaetigung, dass der Tipp angekommen ist — ohne hinsehen
 * zu muessen, ob sich die Ziffer wirklich geaendert hat.
 */
@keyframes zahlpuls {
  from { transform: scale(1.07); }
  to   { transform: scale(1); }
}

.zahl--puls {
  animation: zahlpuls 0.16s cubic-bezier(0.22, 1, 0.36, 1);
}

.zahlhinweis {
  margin: 0;
  color: var(--text-leise);
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.tipps {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 0 var(--rand) 12px;
}

.tipp {
  height: min(112px, 15vh);
  border: 1px solid var(--linie);
  border-radius: 0;
  background: var(--flaeche);
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.tipp {
  transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1),
              background-color 0.18s ease;
}
.tipp:active {
  transition-duration: 0s;
  background: var(--akzent);
  color: #000;
  transform: scale(0.94);
}
.tipp svg { width: 48px; height: 48px; }

.zahl {
  width: 100%;
  max-height: 100%;
  border: 0;
  background: transparent;
  text-align: center;
  font-family: var(--marke);
  /* An der Hoehe mitgedeckelt, damit der Zaehler auch mit Mitzaehler-Zeile passt */
  font-size: min(34vw, 20vh, 160px);
  line-height: 1;
  letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
}
.zahl:focus-visible { outline: 2px solid var(--akzent); outline-offset: 6px; }

.entwurf {
  margin: 0;
  padding: 0 var(--rand) 8px;
  color: var(--akzent);
  font-size: 13px;
}

.fuss {
  flex: 0 0 auto;
  padding: var(--rand) var(--rand) calc(var(--rand) + env(safe-area-inset-bottom));
  border-top: 1px solid var(--linie);
}
.vergleich {
  margin: 0 0 12px;
  text-align: center;
  color: var(--text-leise);
  font-variant-numeric: tabular-nums;
}
.vergleich b { color: var(--text); font-weight: 600; }

.zustaendig {
  margin: 0;
  padding: 18px 12px;
  text-align: center;
  color: var(--text-leise);
  border: 1px dashed var(--linie);
}

.fehler {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-left: 3px solid var(--warnung);
  background: rgb(255 88 97 / 0.1);
  color: var(--text);
  font-size: 15px;
}

/* ── Hinweis unten ───────────────────────────────────────────── */
.hinweis {
  position: fixed;
  left: var(--rand); right: var(--rand);
  bottom: calc(var(--rand) + env(safe-area-inset-bottom));
  padding: 14px 16px;
  background: var(--akzent);
  color: #000;
  font-weight: 600;
  text-align: center;
  z-index: 50;
}
.hinweis[hidden] { display: none; }
.hinweis--fehler { background: var(--warnung); color: #fff; }

@media (prefers-reduced-motion: reduce) {
  .knopf, .tipp { transition: none; }
  .knopf:active, .tipp:active, .knopf--gross:active { transform: none; }
  .zahl--puls { animation: none; }
}
