/* ALBGYM Yoga Coach – Styles
 * Ruhige Wellness-Optik, große Schrift für 1–2 m Leseabstand.
 * Keine externen Schriften, keine Frameworks.
 */

:root {
  --bg: #F7F5F2;
  --surface: #FFFFFF;
  --surface-2: #EFEBE5;
  --text: #2B2A28;
  --muted: #625E57;          /* Kontrast auf --bg ≈ 6:1 */
  --line: #E2DDD5;
  --accent: #0059E0;         /* ALBGYM-Blau (wie im Logo): Flächen, Balken; Weiß darauf ≈ 6:1 */
  --accent-text: #0059E0;    /* auch für kleinen Text geeignet (≈ 5,5:1 auf --bg) */
  --accent-soft: #E1EBFB;
  --warn-bg: #FFF4E0;
  --warn-text: #7A4A00;
  --radius: 20px;
  --radius-s: 14px;
  --shadow: 0 1px 2px rgba(43, 42, 40, .06), 0 6px 20px rgba(43, 42, 40, .06);
  --gap: clamp(12px, 2vw, 24px);
  --pad-x: max(var(--gap), env(safe-area-inset-left), env(safe-area-inset-right));
  --font: -apple-system, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fade: 280ms;
}

@media (prefers-reduced-motion: reduce) {
  :root { --fade: 0ms; }
}

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

/* Kein Doppeltipp-Zoom auf der ganzen Seite. touch-action vererbt sich nicht,
   daher auf alle Elemente. Scrollen und Zwei-Finger-Zoom (Bedienungshilfen) bleiben. */
html, body, body * {
  touch-action: manipulation;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  overflow-x: hidden; /* nur Absicherung – das Layout passt ohnehin */
}

/* Bedienoberfläche: kein Markieren, kein Tap-Highlight */
.app, .controls, .modal-actions, .finish {
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button, select, input, .overview-item {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 8px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.muted { color: var(--muted); }

/* ---------- Grundgerüst ---------- */

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  padding-top: env(safe-area-inset-top);
}

/* ---------- Kopfzeile ---------- */

.topbar {
  flex: none;
  padding: 12px var(--pad-x) 10px;
}

.topbar-row {
  display: flex;
  align-items: center;
  gap: 12px 20px;
  flex-wrap: wrap;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: .01em;
  white-space: nowrap;
}

.brand-mark {
  display: block;
  flex: none;
  width: 34px; height: 34px;
  border-radius: 9px;
}

.course-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 200px;
  min-width: 0;
}

.course-name {
  font-size: 18px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.course-select {
  font-size: 17px;
  min-height: 44px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  max-width: 100%;
}

.total-time {
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  margin-left: auto;
}

.total-time .remaining {
  font-size: 17px;
  font-weight: 500;
  color: var(--muted);
  margin-left: 10px;
}

.course-progress {
  position: relative;
  margin-top: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.course-progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: var(--accent);
  border-radius: 999px;
}

.course-progress-markers .marker {
  position: absolute;
  top: 0; bottom: 0;
  width: 3px;
  margin-left: -1.5px;
  background: var(--bg);
}

/* ---------- Hinweise ---------- */

.banner {
  flex: none;
  margin: 0 var(--pad-x) 10px;
  padding: 12px 16px;
  border-radius: var(--radius-s);
  font-size: 17px;
  line-height: 1.4;
}

.banner-warn { background: #FDE8E6; color: #8A1C12; font-weight: 600; }

.banner-hint {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--warn-bg);
  color: var(--warn-text);
}

.banner-hint span { flex: 1; }

.banner-close {
  flex: none;
  min-width: 56px;
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  background: rgba(122, 74, 0, .12);
  color: var(--warn-text);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
}

/* ---------- Hauptbereich ---------- */

.stage {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 4px var(--pad-x) var(--gap);
  display: grid;
  gap: var(--gap);
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "media" "info" "extra";
  align-content: start;
}

.media { grid-area: media; min-width: 0; }
.info  { grid-area: info;  min-width: 0; }
.extra { grid-area: extra; min-width: 0; display: flex; flex-direction: column; gap: 12px; }

/* Bild: feste 4:3-Box, nie verzerrt */
.img-box {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  margin: 0 auto;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* Fallback für sehr alte Safari-Versionen ohne aspect-ratio */
@supports not (aspect-ratio: 4 / 3) {
  .img-box { height: 0; padding-top: 75%; }
}

.ex-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  opacity: 1;
  transition: opacity var(--fade) ease;
}

.img-box.is-fading .ex-image,
.img-box.is-fading .img-placeholder { opacity: 0; }

.img-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  background: var(--surface-2);
  transition: opacity var(--fade) ease;
}

.img-placeholder strong {
  font-size: clamp(26px, 3vw, 40px);
  font-weight: 650;
}

.img-placeholder span {
  font-size: 17px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.side-banner {
  position: absolute;
  left: 16px; right: 16px; top: 16px; /* oben: Beine/Füße der Pose bleiben sichtbar */
  padding: 12px 18px;
  border-radius: var(--radius-s);
  background: var(--accent);
  color: #fff;
  font-size: clamp(26px, 2.8vw, 38px);
  line-height: 1.2;
  font-weight: 750;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 60, 140, .25);
}

/* Übungsinfos */
.info { display: grid; gap: var(--gap); align-content: start; }

.phase-name {
  font-size: 18px;
  font-weight: 650;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--accent-text);
}

.ex-name {
  margin: 4px 0 0;
  font-size: clamp(34px, 3.6vw, 52px);
  line-height: 1.1;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.side-label {
  margin-top: 8px;
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 22px;
  font-weight: 650;
}

.countdown {
  margin-top: 6px;
  font-size: clamp(96px, 9vw + 2vh, 150px);
  line-height: 1;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}

.ex-progress {
  margin-top: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.ex-progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 999px;
}

.steps {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.steps li {
  position: relative;
  padding-left: 30px;
  font-size: clamp(22px, 2vw, 28px);
  line-height: 1.3;
}

.steps li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: .5em;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent);
}

.variants {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-top: var(--gap);
}

.card {
  background: var(--surface);
  border-radius: var(--radius-s);
  box-shadow: var(--shadow);
  padding: 14px 18px;
}

.variant h2 {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
}

.variant p { margin: 0; font-size: 21px; line-height: 1.35; }
.variant-harder h2 { color: var(--accent-text); }

.cue {
  border-left: 6px solid var(--accent);
}

.cue-label {
  display: block;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--accent-text);
}

.cue p { margin: 4px 0 0; font-size: clamp(22px, 2vw, 28px); line-height: 1.3; font-weight: 550; }

.next {
  font-size: 21px;
  color: var(--muted);
  padding: 0 4px;
}

.next strong { color: var(--text); font-weight: 650; }

/* ---------- Bedienleiste ---------- */

.controls {
  flex: none;
  display: grid;
  grid-template-columns: 1fr 1fr 1.9fr 1fr 1fr 1fr;
  gap: 10px;
  padding: 10px var(--pad-x) max(10px, env(safe-area-inset-bottom));
  background: rgba(247, 245, 242, .96);
  border-top: 1px solid var(--line);
}

.ctl {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 56px;
  min-height: 64px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.ctl svg {
  width: 26px; height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#iconPlay, #iconPause { fill: currentColor; stroke: none; }

.ctl:active { background: var(--surface-2); }
.ctl:disabled { opacity: .45; cursor: default; }

.ctl-primary {
  flex-direction: row;
  gap: 10px;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-size: 21px;
  font-weight: 700;
}

.ctl-primary:active { background: #004BBE; }
.ctl-primary svg { width: 28px; height: 28px; }

.ctl[aria-pressed="false"] { color: var(--muted); background: var(--surface-2); }

.ctl-small { min-height: 48px; flex-direction: row; font-size: 16px; padding: 6px 16px; }
.ctl-wide  { flex-direction: row; min-height: 60px; padding: 8px 22px; font-size: 19px; }

/* ---------- Kursübersicht ---------- */

.sheet-backdrop, .modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(43, 42, 40, .35);
  z-index: 20;
}

.sheet {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(500px, 100%);
  z-index: 21;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  box-shadow: -10px 0 40px rgba(43, 42, 40, .18);
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 0 16px;
  -webkit-user-select: text;
  user-select: text;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sheet-head h2 { margin: 0; font-size: 26px; }

.sheet-settings { padding: 12px 0; border-bottom: 1px solid var(--line); }

.toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  font-size: 18px;
  cursor: pointer;
}

.toggle input { width: 26px; height: 26px; accent-color: var(--accent); }

.overview-list {
  list-style: none;
  margin: 0;
  padding: 8px 0 max(16px, env(safe-area-inset-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}

.overview-phase {
  margin: 16px 4px 6px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--accent-text);
}

.overview-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 60px;
  margin: 4px 0;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-s);
  background: var(--surface);
  color: var(--text);
  font-size: 19px;
  text-align: left;
  cursor: pointer;
}

.overview-item .ov-num { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 2ch; }
.overview-item .ov-name { flex: 1; }
.overview-item .ov-time { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 17px; }

.overview-item.is-current {
  border-color: var(--accent);
  background: var(--accent-soft);
  font-weight: 650;
}

.overview-item.is-done .ov-name { color: var(--muted); }

/* ---------- Dialog ---------- */

.modal-backdrop {
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 30;
}

.modal {
  width: min(520px, 100%);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(43, 42, 40, .25);
  padding: 26px;
}

.modal h2 { margin: 0 0 8px; font-size: 26px; }
.modal p  { margin: 0 0 22px; font-size: 19px; line-height: 1.45; color: var(--muted); }

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* ---------- Kursende ---------- */

.finish {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
  text-align: center;
}

.finish-kicker {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--accent-text);
}

.finish h2 {
  margin: 12px 0;
  font-size: clamp(40px, 6vw, 72px);
  line-height: 1.1;
}

.finish-sub { margin: 0 0 32px; font-size: 22px; color: var(--muted); }

.noscript { padding: 24px; font-size: 20px; }

/* ---------- Layouts ---------- */

/* Querformat (iPad quer): Bild links, Infos rechts */
@media (orientation: landscape) and (min-width: 820px) {
  .stage {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "media info"
      "extra info";
  }
}

/* Hochformat (iPad hoch): Bild oben, Infos darunter in zwei Spalten */
@media (orientation: portrait) and (min-width: 700px) {
  .img-box { width: min(100%, calc(40vh * 4 / 3)); }
  .info { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  .variants { grid-template-columns: minmax(0, 1fr); }
}

/* Schmale Bildschirme (Smartphone) – Notbetrieb, ohne horizontales Scrollen */
@media (max-width: 699px) {
  .total-time { margin-left: 0; font-size: 19px; }
  .controls { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
  .controls .ctl-primary { grid-column: 1 / -1; grid-row: 1; min-height: 60px; }
  .ctl { font-size: 12px; min-width: 0; padding: 4px 2px; }
  .ctl-primary { font-size: 19px; }
  .side-banner { font-size: 24px; }
}
