/* Foosball Pass – Fullscreen-Übungsmodus: ein Rang als One-Pager (Ringe, Text, Treffer, Ergebnis, Video). */

/* Defaults; JS setzt --training-vh (visualViewport) und --training-hit-cols inline.
   Ältere Android-WebViews (< Chrome 108/88/87/79) kennen dvh, aspect-ratio, inset und clamp()/min()/max()
   nicht: vor jeder solchen Angabe steht ein Fallback, die Variable ist nur mit dvh-Support dvh. */
:root{--training-vh:100vh}
@supports (height:100dvh){:root{--training-vh:100dvh}}

/* Seite hinter der Übung: kein App-Header/Footer, kein Hintergrund-Scrollen */
body.training-detail-open{overflow:hidden;overscroll-behavior:none}
body.training-detail-open .site-header,
body.training-detail-open .site-footer{display:none}

/* Stage: echte Bildschirmhöhe (100dvh, per visualViewport in --training-vh präzisiert) + Safe Areas */
.training-stage{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1000;display:grid;grid-template-rows:auto auto minmax(0,1fr);grid-gap:10px;gap:10px;gap:clamp(6px,1.6dvh,14px);
  height:100vh;height:var(--training-vh,100vh);
  padding:8px 12px 10px;padding:max(8px,env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) max(10px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left));
  background:var(--theme-gradient,var(--theme-bg,var(--bg)));background-color:var(--theme-bg,var(--bg));color:var(--theme-text,var(--text));overflow:hidden}
.training-stage>*{width:100%;max-width:1280px;justify-self:center}
.training-stage button{font-family:inherit;touch-action:manipulation;-webkit-tap-highlight-color:transparent}
.training-stage button:focus-visible{outline:3px solid var(--theme-focus-ring);outline-offset:2px}

/* Kopfzeile der Übung */
.training-stage-bar{display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:10px}
.training-stage-back,.training-arrow{display:grid;place-items:center;width:44px;height:44px;padding:0;border:1px solid var(--theme-border);border-radius:50%;background:var(--theme-surface);color:var(--theme-text);cursor:pointer}
.training-stage-back{font-size:1.25rem}
.training-stage-titles{min-width:0}
.training-stage-titles .training-kicker{margin:0 0 2px;font-size:.68rem}
.training-stage-titles h2{margin:0;font-size:1.15rem;font-size:clamp(1rem,2.4vw + .4rem,1.4rem);line-height:1.15;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--theme-text)}
.training-stage-score{padding:7px 12px;border-radius:999px;background:var(--theme-primary-soft);color:var(--theme-text);font-size:.92rem;white-space:nowrap}

/* Rangringe mit Pfeilen */
.training-ring-nav{display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;grid-gap:8px;gap:8px;gap:clamp(4px,1.4vw,14px)}
.training-arrow{font-size:1.7rem;line-height:1}
.training-arrow:disabled{opacity:.3;cursor:default}
.training-rings{position:relative;display:grid;grid-template-columns:repeat(10,minmax(0,1fr));grid-gap:4px;gap:4px;gap:clamp(2px,.9vw,10px);margin:0;padding:4px 0;list-style:none}
.training-rings::before{content:"";position:absolute;left:5%;right:5%;top:50%;height:2px;background:var(--theme-border)}
.training-rings li{position:relative;display:flex;justify-content:center;min-width:0}
.training-ring{position:relative;display:grid;place-items:center;width:100%;max-width:52px;min-width:24px;aspect-ratio:1;padding:0;border:2px solid var(--theme-border);border-radius:50%;background:var(--theme-surface-strong);font-size:1rem;font-size:clamp(.7rem,2.4vw,1.25rem);line-height:1;cursor:pointer;transition:transform .15s ease,box-shadow .15s ease,border-color .15s ease}
.training-ring.is-done{border-color:#3fbf6a;background:#173c26}
.training-ring.is-done::after{content:"✓";position:absolute;right:-4px;bottom:-4px;display:grid;place-items:center;width:16px;height:16px;width:clamp(12px,40%,20px);border-radius:50%;background:#2fa65a;color:#fff;font-size:.62rem;font-size:clamp(.5rem,1.6vw,.72rem);font-weight:900}
/* Ohne aspect-ratio (< Chrome 88): feste Höhen statt ovaler oder flacher Ringe/Icons */
@supports not (aspect-ratio:1){.training-ring{height:30px}.training-ring.is-done::after{width:16px}}
@supports (aspect-ratio:1){.training-ring.is-done::after{height:auto;aspect-ratio:1}}
.training-ring.is-active{border-color:var(--theme-primary);box-shadow:0 0 0 3px var(--theme-focus-ring);transform:scale(1.14)}

/* Inhalt eines Rangs: Hochformat gestapelt (Text, Treffer, Video) */
.training-stage-body{display:grid;grid-template-columns:minmax(0,1fr);align-content:start;grid-gap:12px;gap:12px;gap:clamp(8px,1.6dvh,16px);min-height:0;max-width:820px;overflow-y:auto;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;touch-action:pan-y}
.training-stage-body.has-video{max-width:1280px}
.training-exercise-text{padding:14px 16px;padding:clamp(10px,1.8dvh,18px) clamp(12px,2vw,20px);border:1px solid var(--theme-border);border-radius:16px;background:var(--theme-surface)}
.training-exercise-head{display:flex;align-items:center;gap:10px}
/* Flex-gap fehlt vor Chrome 84; aspect-ratio-Support dient als Merkmal moderner Engines */
.training-exercise-icon{margin-right:10px}
@supports (aspect-ratio:1){.training-exercise-icon{margin-right:0}}
.training-exercise-icon{font-size:2rem;font-size:clamp(1.5rem,4dvh,2.4rem);line-height:1}
.training-exercise-head h3{margin:0;font-size:1.15rem;font-size:clamp(1rem,2.3dvh + .3rem,1.3rem);line-height:1.25;color:var(--theme-text)}
.training-exercise-task{margin:8px 0 0;margin:clamp(6px,1dvh,10px) 0 0;font-size:.95rem;font-size:clamp(.88rem,1.8dvh + .3rem,1.02rem);line-height:1.4;color:var(--theme-text-muted)}
.training-exercise-task strong{color:var(--theme-text)}

/* Trefferfelder: offener Versuch = Kickerball im klar umrandeten Feld, Treffer = grüner Haken.
   Rahmen nutzt die Textfarbe des Themes (immer kontrastreich), mit Fallbacks ohne Theme-Variablen. */
.training-exercise-score{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:stretch;gap:10px}
.training-hits{--training-hit-cols:4;--training-hit-line:var(--theme-text-muted,var(--muted,#8a958f));--training-hit-bg:var(--theme-surface-strong,var(--surface-strong,rgba(127,127,127,.12)));
  --training-ball-fill:#f6f3ea;--training-ball-ink:#1f2622;--training-hit-on:#2fa65a;--training-hit-on-line:#3fbf6a;
  display:grid;grid-template-columns:repeat(var(--training-hit-cols,4),minmax(0,1fr));grid-gap:6px;gap:6px;gap:clamp(5px,1vw,8px)}
.training-hit{display:grid;place-items:center;min-width:44px;min-height:44px;height:50px;height:clamp(44px,6.4dvh,58px);padding:0;border:2px solid var(--training-hit-line);border-radius:12px;background:var(--training-hit-bg);color:var(--theme-text,var(--text,currentColor));cursor:pointer;transition:background .12s ease,border-color .12s ease,transform .08s ease}
.training-hit:active{transform:scale(.95)}
.training-hit svg{display:block;width:26px;max-width:62%;height:26px;width:min(62%,30px);pointer-events:none}
@supports (aspect-ratio:1){.training-hit svg{height:auto;aspect-ratio:1}}
.training-hit-ball circle{fill:var(--training-ball-fill);stroke:var(--training-ball-ink);stroke-width:1.4}
.training-hit-ball-patch{fill:var(--training-ball-ink)}
.training-hit-ball-seam{fill:none;stroke:var(--training-ball-ink);stroke-width:1.3;stroke-linecap:round}
.training-hit.is-hit{border-color:var(--training-hit-on-line);background:var(--training-hit-on)}
.training-hit-check path{fill:none;stroke:#fff;stroke-width:3.2;stroke-linecap:round;stroke-linejoin:round}
@media(forced-colors:active){.training-hit{border-color:ButtonText}.training-hit.is-hit{border-color:Highlight}.training-hit-check path{stroke:Highlight}}
.training-result{display:grid;align-content:center;gap:2px;min-width:104px;padding:8px 12px;border:1px solid var(--theme-border);border-radius:14px;background:var(--theme-surface);text-align:center}
.training-result strong{font-size:1.6rem;font-size:clamp(1.3rem,3.4dvh,1.9rem);line-height:1.1;color:var(--theme-text)}
.training-result span{font-size:.76rem;color:var(--theme-text-muted)}
.training-result.is-passed{border-color:#3fbf6a;background:rgba(38,160,88,.22)}
.training-result.is-passed .training-result-status{font-weight:800;color:#bdf3cb}

/* Video: Box folgt dem Seitenverhältnis des Videos (16:9 bis Metadaten da sind; ohne aspect-ratio
   das Standardformat 2:1) und ist in der Höhe begrenzt – keine riesige schwarze Fläche, Steuerleiste
   bleibt immer am sichtbaren Videorand. */
.training-exercise-video{display:flex;justify-content:center;align-items:flex-start;min-width:0;min-height:0}
.training-exercise-video video{display:block;width:100%;height:auto;max-height:46vh;max-height:calc(var(--training-vh,100vh) * .46);border-radius:16px;background:#000;object-fit:contain}
@supports (aspect-ratio:1){.training-exercise-video video{aspect-ratio:auto 16/9}}

/* Rangwechsel-Animation */
.training-stage-body[data-direction="next"]>*{animation:training-in-next .22s ease}
.training-stage-body[data-direction="prev"]>*{animation:training-in-prev .22s ease}
@keyframes training-in-next{from{opacity:0;transform:translateX(24px)}}
@keyframes training-in-prev{from{opacity:0;transform:translateX(-24px)}}
@media(prefers-reduced-motion:reduce){.training-stage-body>*{animation:none!important}.training-ring,.training-hit{transition:none}}

/* Schmale Telefone */
@media(max-width:420px){
  .training-stage-bar{gap:8px}
  .training-stage-score{padding:6px 9px;font-size:.84rem}
  .training-ring-nav .training-arrow{width:36px;height:36px}
  .training-exercise-score{grid-template-columns:1fr}
  .training-result{grid-auto-flow:column;justify-content:space-between;align-items:center;min-width:0;padding:6px 12px;text-align:left}
}

/* Querformat / Tablet / Desktop: Text + Treffer links, Video rechts */
@media(orientation:landscape) and (min-width:540px){
  .training-stage-body.has-video{grid-template-columns:minmax(0,1fr) minmax(0,1.05fr);grid-template-rows:auto minmax(0,1fr);grid-template-areas:"text video" "score video"}
  .training-stage-body.has-video .training-exercise-text{grid-area:text}
  .training-stage-body.has-video .training-exercise-score{grid-area:score;align-self:start}
  .training-stage-body.has-video .training-exercise-video{grid-area:video;height:100%}
  .training-stage-body.has-video .training-exercise-video video{max-height:100%}
}
@media(min-width:1024px) and (min-height:640px){
  .training-stage{padding-left:24px;padding-right:24px;padding-left:max(24px,env(safe-area-inset-left));padding-right:max(24px,env(safe-area-inset-right))}
  .training-exercise-text{padding:20px 24px}
  .training-stage-body.has-video{grid-template-columns:minmax(0,1fr) minmax(0,1.25fr)}
}
/* Große Desktops: breitere Bühne, damit das Video mitwächst statt Rand zu lassen */
@media(min-width:1440px) and (min-height:900px){.training-stage>*,.training-stage-body.has-video{max-width:1520px}}

/* Niedrige Querformat-Displays (Telefon quer): alles kompakter */
@media(orientation:landscape) and (max-height:520px){
  .training-stage{gap:6px;padding-top:6px;padding-bottom:6px;padding-top:max(6px,env(safe-area-inset-top));padding-bottom:max(6px,env(safe-area-inset-bottom))}
  .training-stage-titles .training-kicker{display:none}
  .training-stage-back,.training-arrow{width:36px;height:36px}
  .training-ring{max-width:34px}
  .training-rings{padding:2px 0}
  .training-stage-body:not(.has-video){grid-template-columns:minmax(0,1.2fr) minmax(0,1fr);max-width:1100px}
  .training-exercise-text{padding:8px 12px}
  .training-exercise-icon{font-size:1.4rem}
  .training-hit{height:44px}
}

/* Sehr kleine Displays: Inhalt scrollt im Übungsbereich statt sich zu überlagern */
@media(orientation:landscape) and (max-height:300px){
  .training-stage-body.has-video{grid-template-columns:minmax(0,1fr);grid-template-rows:auto auto auto;grid-template-areas:"text" "score" "video"}
  .training-stage-body.has-video .training-exercise-video{height:auto}
  .training-stage-body.has-video .training-exercise-video video{max-height:55vh;max-height:calc(var(--training-vh,100vh) * .55)}
}

/* Lade-/Fehlerhinweis statt leerer Stationsliste oder Übung (Skript fehlt, veraltet oder Renderfehler) */
.training-load-error{grid-column:1/-1;margin:0;padding:14px 16px;border:1px solid var(--theme-border);border-radius:14px;background:var(--theme-surface);color:var(--theme-text)}
.training-load-error button{margin-left:8px}