/* =====================================================================
   STAFFELWALZE – Layout und Menüs.
   Die Maschine selbst zeichnet app.js auf das Canvas.
   ===================================================================== */


:root {
  --bg: #0a0b0d;
  --dim: #2b3137;
  --line: #c5ccd3;
  --text: #c5ccd3;
  --digit: #c5ccd3;
  --accent: #009100;
  --magenta: #ff2bd6;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

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

/* Kein Scrollen, kein Zoom, keine Textauswahl: Die Seite ist ein Gerät. */
html, body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 var(--mono);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
  touch-action: none;
}

#app {
  position: fixed;
  inset: 0;
  height: 100vh;
  height: 100dvh;
  /* Safe-Areas: Notch und Home-Balken freihalten */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#stage {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: default;
}

/* --- Tafeln (Menü, Protokoll) ---------------------------------------- */
[hidden] { display: none !important; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  background: rgba(10, 11, 13, 0.82);
}

.panel {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
}

.overlay .panel {
  width: min(720px, 100%);
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding: 0 14px 12px;
}

.panel header {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  background: var(--bg);
  border-bottom: 1px solid var(--dim);
}

.panel h2 {
  flex: 1;
  margin: 0;
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

button {
  min-width: 44px;
  min-height: 44px;
  padding: 0 14px;
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--digit);
  background: none;
  border: 1px solid var(--line);
  border-radius: 0;
  cursor: pointer;
  touch-action: manipulation;
}
button:active { color: var(--accent); border-color: var(--accent); }
button:focus-visible, .switch input:focus-visible + i { outline: 1px solid var(--accent); outline-offset: 2px; }

/* --- Schalter --------------------------------------------------------- */
.switches {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 18px;
}

.switch {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 6px 0;
  border-bottom: 1px solid var(--dim);
  cursor: pointer;
  touch-action: manipulation;
}
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch i {
  position: relative;
  flex: none;
  width: 44px;
  height: 24px;
  border: 1px solid var(--line);
}
.switch i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: var(--line);
  transition: transform 0.12s linear;
}
.switch input:checked + i { border-color: var(--accent); }
.switch input:checked + i::after { background: var(--accent); transform: translateX(20px); }
.switch span { color: var(--digit); font-size: 12px; }
.switch small { display: block; color: var(--text); font-size: 10px; line-height: 1.35; }

.note, .howto p { margin: 10px 0 0; font-size: 10.5px; line-height: 1.5; }
.note { padding: 8px 10px; border-left: 1px solid var(--magenta); }
.note b, .howto b { color: var(--digit); font-weight: 400; }

/* --- Rechenprotokoll -------------------------------------------------- */
#log {
  position: fixed;
  z-index: 10;
  top: max(8px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  width: min(430px, 60vw);
  max-height: calc(100dvh - 130px);
  display: flex;
  flex-direction: column;
}
#log header { padding: 0 0 0 12px; min-height: 46px; }
#log header button { border-width: 0 0 0 1px; border-color: var(--dim); min-height: 46px; }
#logList {
  flex: 1;
  min-height: 44px;
  margin: 0;
  padding: 8px 12px;
  list-style: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  font-size: 10.5px;
  white-space: pre;
  color: var(--digit);
}
#logList:empty::before { content: "Noch keine Umdrehung."; color: var(--text); }
#logList li.warn { color: var(--magenta); }

/* --- Hinweis im Hochformat ------------------------------------------- */
#rotate {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 30;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--bg);
  text-align: center;
}
#rotate p { margin: 8px 0 0; color: var(--digit); font-size: 14px; letter-spacing: 0.18em; text-transform: uppercase; }
#rotate small { font-size: 10.5px; letter-spacing: 0.06em; }

/* Nur auf schmalen Geräten: Ein Tablet oder Desktopfenster im Hochformat ist breit genug. */
@media (orientation: portrait) and (max-width: 699px) {
  #rotate { display: flex; }
}

@media (max-height: 340px) {
  .switch { min-height: 46px; }
  .switch small { display: none; }
}

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