/* ==========================================================
   Knackebunt – Stylesheet
   Grundstimmung: bunt, freundlich, flache Flächen, runde Ecken.
   Für Kleinkinder optimiert: große Ziele, kein Zoom/Scroll/Markieren.
   ========================================================== */

* {
  box-sizing: border-box;
  /* Kinder tippen wild herum – nichts soll markierbar oder ziehbar sein */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;           /* kein Scroll-Bounce */
  overscroll-behavior: none;
  touch-action: manipulation; /* Doppeltipp-/Pinch-Zoom unterbinden */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

img {
  -webkit-user-drag: none;
  pointer-events: none; /* Klicks gehen an die umgebende Kachel, Bild lässt sich nicht ziehen */
}

button {
  font-family: inherit;
  border: none;
  cursor: pointer;
  touch-action: manipulation;
}

/* Gedrückt-Feedback für alle antippbaren Kacheln/Buttons */
.kachel:active,
.zurueck-button:active,
#player-play:active,
#vollbild-button:active {
  transform: scale(0.95);
}

/* ---------------- Home-Bildschirm ---------------- */

#home-screen {
  height: 100%;
  background: #B5D4F4;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

#kopfzeile {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#begruessung {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 22px;
  font-weight: 700;
  color: #2b4a6f;
}

#begruessung .sonne {
  font-size: 30px;
}

#vollbild-button {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
  font-size: 20px;
  color: #2b4a6f;
  align-items: center;
  justify-content: center;
}

/* display:flex nur ohne hidden-Attribut setzen (siehe Hinweis bei .ueberlagerung) */
#vollbild-button:not([hidden]) {
  display: flex;
}

#kachel-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  align-content: center;
}

.kachel {
  background: var(--farbe, #ccc);
  border-radius: 24px;
  min-height: 150px;
  min-width: 150px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  transition: transform 0.1s ease;
}

.kachel-bildkreis {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.kachel-bildkreis img {
  width: 64%;
  height: 64%;
  object-fit: contain;
}

.kachel-titel {
  font-size: 24px;
  font-weight: 800;
  color: color-mix(in srgb, var(--farbe, #333) 45%, black);
  text-align: center;
}

/* Platzhalter, falls ein Bild fehlt oder nicht lädt.
   Farbe wird von JS gezielt über --platzhalter-farbe gesetzt. */
.bild-platzhalter {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: color-mix(in srgb, var(--platzhalter-farbe, #ccc) 70%, white);
}

/* ---------------- Vollflächige Überlagerungen ---------------- */

.ueberlagerung {
  position: fixed;
  inset: 0;
  z-index: 10;
  flex-direction: column;
}

/* WICHTIG: display:flex nur setzen, wenn NICHT hidden – sonst überschreibt
   diese Regel (gleiche Spezifität wie [hidden]) das Verstecken per
   hidden-Attribut, und die Überlagerung bliebe trotz "hidden" sichtbar
   und würde Klicks auf die App darunter abfangen. */
.ueberlagerung:not([hidden]) {
  display: flex;
}

.zurueck-button {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 20;
  width: 56px;
  height: 56px;
  min-width: 48px;
  min-height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  font-size: 30px;
  font-weight: 900;
  color: #2b4a6f;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* ---------------- Kategorie-Bildschirm ---------------- */

#kategorie-screen {
  background: color-mix(in srgb, var(--farbe, #B5D4F4) 30%, white);
  padding: 24px;
  padding-top: 90px;
}

#kategorie-titel {
  position: absolute;
  top: 28px;
  left: 90px;
  font-size: 26px;
  font-weight: 800;
  color: color-mix(in srgb, var(--farbe, #333) 50%, black);
  margin: 0;
}

#kategorie-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  align-content: start;
  overflow-y: auto;
  padding-bottom: 20px;
}

@media (orientation: portrait) {
  #kategorie-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.eintrag-kachel {
  background: var(--eintrag-farbe, #fff);
  border-radius: 20px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-height: 120px;
}

.eintrag-bild {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

.eintrag-bild img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.eintrag-titel {
  font-size: 14px;
  font-weight: 700;
  color: color-mix(in srgb, var(--eintrag-farbe, #333) 55%, black);
  text-align: center;
}

.eintrag-kachel.aktiv {
  outline: 4px solid rgba(255, 255, 255, 0.9);
}

/* ---------------- Wiedergabeleiste ---------------- */

#player-leiste {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 20px;
  background: #2b2b3d;
  border-radius: 999px;
  padding: 10px 20px;
  align-items: center;
  gap: 16px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

/* display:flex nur ohne hidden-Attribut setzen (siehe Hinweis bei .ueberlagerung) */
#player-leiste:not([hidden]) {
  display: flex;
}

#player-play {
  width: 56px;
  height: 56px;
  min-width: 48px;
  border-radius: 50%;
  background: #fff;
  color: #2b2b3d;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#player-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#player-titel {
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#player-fortschritt {
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.25);
  overflow: hidden;
}

#player-fortschritt-balken {
  height: 100%;
  width: 0%;
  background: #FFD34D;
  border-radius: 4px;
}

#player-lautstaerke {
  font-size: 22px;
  flex-shrink: 0;
}

/* ---------------- Spiel-/Malen-Overlay ---------------- */

#spiel-overlay {
  background: #000;
}

#spiel-iframe {
  width: 100%;
  height: 100%;
  border: none;
}
