/*
 * appview.css — App-Fenster: oeffnet sich vom Icon aus (Zoom wie iOS),
 * Kopfleiste im Stil der Tool-Topbar (Loop/Marka).
 * --origin-x/-y setzt js/appview.js zur Laufzeit (Icon-Position).
 */

.appview {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  background: #000;
  transform-origin: var(--origin-x, 50%) var(--origin-y, 50%);
  animation: app-open var(--transition-app) both;
}

.appview.is-closing {
  animation: app-close 280ms cubic-bezier(0.4, 0, 0.6, 1) both;
}

@keyframes app-open {
  from { transform: scale(0.08); opacity: 0; border-radius: 40px; }
  to   { transform: scale(1); opacity: 1; border-radius: 0; }
}

@keyframes app-close {
  from { transform: scale(1); opacity: 1; }
  to   { transform: scale(0.08); opacity: 0; border-radius: 40px; }
}

.appbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  height: calc(var(--appbar-h) + var(--safe-top));
  padding: var(--safe-top) var(--gutter) 0 var(--sp-2);
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0.6));
  border-bottom: 1px solid var(--bar-border);
}

.appbar-btn {
  appearance: none;
  border: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 36px;
  padding: 0 var(--sp-2) 0 var(--sp-1);
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.appbar-btn:hover,
.appbar-btn:focus-visible {
  background: var(--bar-hover);
  outline: none;
}

.appbar-btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Titel nimmt den freien Platz zwischen "Beenden" und den Knoepfen und steht dort mittig */
.appbar-title-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  justify-content: center;
}

/* Titel als Kapsel wie .app-name der Tools */
.appbar-title {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  padding: 3px 6px 3px 8px;
  border: 1px solid var(--bar-fg);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.appbar-tools {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}

/* Werkzeuge der App reihen sich neben dem Vollbild-Knopf ein */
.appbar-tools-list {
  display: contents;
}

.appview-body {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.app-root {
  position: absolute;
  inset: 0;
  overflow: auto;
}

@media (max-width: 420px) {
  .appbar-btn span {
    display: none;
  }
}

/* Problem melden: dezent, erst beim Hinzeigen deutlich */
.tool-report {
  opacity: 0.55;
}

.tool-report:hover,
.tool-report:focus-visible {
  opacity: 1;
}

/* ---------- Spiele: Kopfleiste hinter dem Zahnrad (js/appview.js) ---------- */

/* Platz der Kopfleiste bleibt frei: das Spiel beginnt darunter, nichts wird verdeckt */
.appview.is-game .appview-body {
  margin-top: calc(var(--appbar-h) + var(--safe-top));
}

/* Ganze Kopfleisten-Flaeche (links bis rechts) blendet die Leiste ein */
.appbar-reveal {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  height: calc(var(--appbar-h) + var(--safe-top));
  padding: 0;
  border: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: #000;
  cursor: pointer;
}

.appbar-reveal[hidden] {
  display: none;
}

/* Griff mittig als Hinweis: hier geht's zur Kopfleiste */
.appbar-reveal::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 10px;
  width: 36px;
  height: 4px;
  margin-left: -18px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.22);
  transition: background var(--transition-fast);
}

.appbar-reveal:hover::after {
  background: rgba(255, 255, 255, 0.45);
}

.appview.is-game .appbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 4;
  padding-right: calc(var(--gutter) + 52px);
  transform: translateY(-105%);
  transition: transform 260ms cubic-bezier(0.2, 0.8, 0.2, 1);
  /* liegt ueber dem Spiel: deckend, damit nichts durchscheint */
  background: rgba(12, 12, 14, 0.96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.appview.is-game.bar-open .appbar {
  transform: none;
}

.appbar-gear {
  position: absolute;
  top: calc(var(--safe-top) + 7px);
  right: var(--gutter);
  z-index: 5;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: var(--bar-fg);
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: transform 260ms ease, background var(--transition-fast);
}

.appbar-gear:hover,
.appbar-gear:focus-visible {
  background: rgba(0, 0, 0, 0.7);
  outline: none;
}

.bar-open .appbar-gear {
  transform: rotate(90deg);
  background: transparent;
}

.appbar-gear svg,
.app-hold-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Pause in der Bildmitte, solange die Kopfleiste offen ist (Tippen = weiter) */
.app-hold {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  border: 0;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font: inherit;
  cursor: pointer;
  animation: hold-in 200ms ease both;
}

.app-hold[hidden] {
  display: none;
}

.app-hold-icon {
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  border: 2px solid rgba(255, 255, 255, 0.7);
}

.app-hold-icon svg {
  width: 44px;
  height: 44px;
  stroke-width: 3;
}

.app-hold-label {
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

@keyframes hold-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Kopfleiste offen: Steuerungs-Knopf tritt zurueck (liegt sonst ueber Leiste/Pause) */
.bar-open .game-help-btn {
  visibility: hidden;
}
