/* Atem-Coach — eigenes Design: ruhiges Teal -> Blau, viel Weissraum */

:root {
  --c-teal: #14b8a6;
  --c-sky: #0ea5e9;
  --c-deep: #0369a1;

  --bg: #f3fbfd;
  --bg-grad-1: #eafaf8;
  --bg-grad-2: #e6f4fd;
  --surface: #ffffff;
  --surface-2: #f1f8fb;
  --text: #0f2730;
  --text-soft: #496673;
  --border: #d6eaf0;
  --ring: rgba(14, 165, 233, 0.45);
  --shadow: 0 10px 30px rgba(3, 105, 161, 0.10);
  --circle-shadow: 0 18px 60px rgba(20, 184, 166, 0.30);

  --radius: 18px;
  --radius-sm: 12px;
  --maxw: 540px;
  --tap: 48px;
}

[data-theme="dark"] {
  --bg: #061418;
  --bg-grad-1: #07191e;
  --bg-grad-2: #08222e;
  --surface: #0d2530;
  --surface-2: #103040;
  --text: #e7f6fb;
  --text-soft: #8fb6c4;
  --border: #1c4456;
  --ring: rgba(56, 189, 248, 0.55);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --circle-shadow: 0 18px 60px rgba(20, 184, 166, 0.25);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1100px 700px at 15% -10%, var(--bg-grad-1), transparent 60%),
    radial-gradient(1000px 700px at 100% 0%, var(--bg-grad-2), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding:
    env(safe-area-inset-top)
    env(safe-area-inset-right)
    env(safe-area-inset-bottom)
    env(safe-area-inset-left);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

.visually-hidden, .skip-link:not(:focus) {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: fixed;
  left: 12px; top: 12px;
  z-index: 50;
  background: var(--c-sky);
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 600;
}

/* Header */
.app-header {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 16px 18px 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, var(--c-teal), var(--c-sky));
  box-shadow: var(--shadow);
}
.brand-name { font-weight: 700; font-size: 1.1rem; letter-spacing: 0.2px; }

.icon-btn {
  min-width: var(--tap); min-height: var(--tap);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  font-size: 1.25rem;
  cursor: pointer;
  display: grid; place-items: center;
  transition: transform .12s ease, background .2s ease;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(0.96); }

/* Main / Views */
.app-main {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 8px 18px 24px;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}
.view { animation: fade .35s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.title { font-size: 1.7rem; margin: 14px 0 6px; letter-spacing: -0.3px; }
.subtitle { color: var(--text-soft); margin: 0 0 18px; }

/* Fields */
.field { margin: 0 0 22px; }
.field-label {
  display: block;
  font-weight: 600;
  margin-bottom: 10px;
  font-size: 0.98rem;
}
.field-value { color: var(--c-sky); font-variant-numeric: tabular-nums; }
.field-hint { color: var(--text-soft); font-size: 0.88rem; margin: 8px 2px 0; }

/* Technique cards */
.technique-group {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
@media (min-width: 460px) {
  .technique-group { grid-template-columns: repeat(3, 1fr); }
}
.technique-card {
  text-align: left;
  border: 1.5px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--text);
  transition: border-color .18s ease, transform .12s ease, box-shadow .2s ease;
}
.technique-card:hover { transform: translateY(-2px); }
.technique-card.is-active {
  border-color: var(--c-sky);
  box-shadow: 0 0 0 3px var(--ring);
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
}
.tc-name { font-weight: 700; font-size: 1.02rem; }
.tc-pattern { color: var(--c-teal); font-weight: 600; font-variant-numeric: tabular-nums; }
[data-theme="dark"] .tc-pattern { color: #5eead4; }
.tc-desc { color: var(--text-soft); font-size: 0.85rem; }

/* Range */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--c-teal), var(--c-sky));
  outline: none;
  margin: 2px 0;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--c-sky);
  box-shadow: var(--shadow);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--c-sky);
  cursor: pointer;
}

/* Switches */
.options { display: flex; flex-direction: column; gap: 14px; }
.switch {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track {
  position: relative;
  flex: 0 0 auto;
  width: 48px; height: 28px;
  border-radius: 999px;
  background: var(--border);
  transition: background .2s ease;
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: transform .2s ease;
}
.switch input:checked + .switch-track {
  background: linear-gradient(90deg, var(--c-teal), var(--c-sky));
}
.switch input:checked + .switch-track::after { transform: translateX(20px); }
.switch input:focus-visible + .switch-track {
  box-shadow: 0 0 0 3px var(--ring);
}
.switch-label { font-size: 0.96rem; }

/* Buttons */
.btn-primary, .btn-secondary, .btn-ghost {
  font: inherit;
  font-weight: 700;
  border-radius: 14px;
  min-height: var(--tap);
  padding: 13px 20px;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: transform .12s ease, box-shadow .2s ease, background .2s ease;
}
.btn-primary {
  width: 100%;
  color: #fff;
  background: linear-gradient(135deg, var(--c-teal), var(--c-sky));
  box-shadow: var(--shadow);
}
.btn-primary:hover { transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0) scale(0.99); }
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--c-sky);
}
.btn-ghost {
  background: transparent;
  color: var(--text-soft);
  border-color: var(--border);
}
.btn-ghost:hover, .btn-secondary:hover { background: var(--surface-2); }

.stats-line {
  text-align: center;
  color: var(--text-soft);
  margin-top: 22px;
  font-size: 0.95rem;
}
.stats-line strong { color: var(--text); }

/* Exercise view */
.view-exercise {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.exercise-top {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 6px 0 4px;
  color: var(--text-soft);
  font-weight: 600;
}
.ex-technique { color: var(--text); }
.ex-round { font-variant-numeric: tabular-nums; }

.circle-stage {
  flex: 1 1 auto;
  width: 100%;
  display: grid;
  place-items: center;
  padding: 18px 0;
}
.circle-track {
  width: min(78vw, 320px);
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
}
.breath-circle {
  width: 56%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,0.55), transparent 55%),
              linear-gradient(135deg, var(--c-teal), var(--c-sky));
  box-shadow: var(--circle-shadow);
  display: grid;
  place-items: center;
  transition: transform 0.2s linear;
  will-change: transform;
}
.breath-circle.is-animating {
  transition-property: transform;
  transition-timing-function: cubic-bezier(0.37, 0, 0.63, 1);
}
.circle-inner {
  text-align: center;
  color: #fff;
  text-shadow: 0 1px 6px rgba(3,105,161,0.35);
}
.phase-label {
  display: block;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.phase-counter {
  display: block;
  font-size: 2.4rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.exercise-controls {
  width: 100%;
  display: flex;
  gap: 12px;
  margin-top: 8px;
}
.exercise-controls .btn-secondary,
.exercise-controls .btn-ghost { flex: 1 1 0; }

/* Done view */
.view-done {
  text-align: center;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.done-mark {
  width: 84px; height: 84px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--c-teal), var(--c-sky));
  box-shadow: var(--circle-shadow);
  margin-bottom: 8px;
}
.done-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 320px;
  margin-top: 18px;
}

/* Footer */
.app-footer {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 4px 18px 16px;
  text-align: center;
  color: var(--text-soft);
  font-size: 0.82rem;
}

/* Focus visibility */
:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
  border-radius: 8px;
}

/* Reduced motion: keine Skalierungs-Animation, Kreis bleibt ruhig */
@media (prefers-reduced-motion: reduce) {
  .view { animation: none; }
  .breath-circle,
  .breath-circle.is-animating {
    transition: none !important;
    transform: none !important;
  }
  .btn-primary:hover, .technique-card:hover { transform: none; }
}

body.reduced-motion .breath-circle,
body.reduced-motion .breath-circle.is-animating {
  transition: none !important;
  transform: none !important;
}
