/* BreathIn — web
   Kleuren komen 1-op-1 uit BreathIn2/Sources/Assets.xcassets */

:root {
  --accent:      #00c7be;          /* AccentColor / CircleColor1, licht */
  --bg:          #ffffff;          /* Background, licht */
  --surface:     #f2f2f7;          /* secondarySystemBackground */
  --card:        #ffffff;          /* systemBackground */
  --text:        #000000;
  --text-2:      #8e8e93;          /* TextSecondary, licht */
  --counter:     #ffffff;          /* TextPrimary — altijd wit, staat in de cirkel */
  --hairline:    rgba(0, 0, 0, .12);
  --shadow:      rgba(0, 0, 0, .10);
  --pill:        #ffffff;

  --radius:      16px;
  --tap:         44px;             /* Apple's minimum raakdoel */
  --safe-t:      env(safe-area-inset-top, 0px);
  --safe-b:      env(safe-area-inset-bottom, 0px);
  --safe-l:      env(safe-area-inset-left, 0px);
  --safe-r:      env(safe-area-inset-right, 0px);

  --ease-out:    cubic-bezier(.16, 1, .3, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent:   #66d4cf;           /* AccentColor, donker */
    --bg:       #0b0b0b;           /* Background, donker (0.043) */
    --surface:  #1c1c1e;
    --card:     #000000;
    --text:     #ffffff;
    --text-2:   #ababaf;           /* TextSecondary, donker */
    --hairline: rgba(255, 255, 255, .16);
    --shadow:   rgba(0, 0, 0, .5);
    --pill:     rgba(255, 255, 255, .10);
  }
}

:root[data-theme="dark"] {
  --accent:   #66d4cf;
  --bg:       #0b0b0b;
  --surface:  #1c1c1e;
  --card:     #000000;
  --text:     #ffffff;
  --text-2:   #ababaf;
  --hairline: rgba(255, 255, 255, .16);
  --shadow:   rgba(0, 0, 0, .5);
  --pill:     rgba(255, 255, 255, .10);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 400 17px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

button { font: inherit; color: inherit; }

/* Een tik mag geen focusring achterlaten; toetsenbordnavigatie wel */
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ─── Sessiescherm ──────────────────────────────────────────────── */

#stage {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l);
}

/* De visuals zitten op 2/5 van de veilige hoogte — zoals ContentView.swift */
#visuals {
  position: relative;
  flex: 0 0 80%;
  display: grid;
  place-items: center;
}

#rings {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--max-d, 300px);
  height: var(--max-d, 300px);
  pointer-events: none;
}

/* Buitenring: de maximale omvang, pulseert mee op ~1 Hz */
#outer-ring {
  position: absolute;
  width: 100%; height: 100%;
  border: 10px solid var(--accent);
  border-radius: 50%;
  transform: scale(var(--outer-scale, 1));
  opacity: var(--outer-opacity, 1);
  will-change: transform, opacity;
}

/* De ademcirkel zelf */
#inner-circle {
  position: absolute;
  width: 100%; height: 100%;
  border-radius: 50%;
  background: var(--accent);
  box-shadow:
    inset 0 0 0 6px color-mix(in srgb, var(--accent) 90%, transparent),
    0 6px 12px color-mix(in srgb, var(--accent) 14%, transparent),
    0 2px 3px var(--shadow);
  transform: scale(var(--breath-scale, .333));
  will-change: transform;
}

#counter {
  position: relative;
  font-size: var(--counter-size, 48px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--counter);
  opacity: var(--counter-opacity, 0);
  text-shadow: 0 1px 3px rgba(0, 0, 0, .18);
  will-change: opacity;
}

/* Onzichtbare trefzone over het hele bovenvlak: tik = start/stop */
#breath-tap {
  position: absolute;
  inset: 0;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  z-index: 2;
}

#phase-label {
  margin: 0;
  min-height: 1.5em;
  text-align: center;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: .01em;
  color: var(--text);
  opacity: var(--phase-opacity, 0);
  transition: opacity .3s ease;
}

#hint {
  margin: 6px 0 0;
  text-align: center;
  font-size: 15px;
  color: var(--text-2);
  transition: opacity .3s ease;
}

#stage-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding-bottom: max(18px, var(--safe-b));
}

#progress {
  margin: 0;
  min-height: 1.2em;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
}

/* De ronde accentknop, zoals in de app */
.fab {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--tap); height: var(--tap);
  border: 0; border-radius: 50%;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: opacity .22s ease, transform .15s var(--ease-out);
}
/* Ruimer raakvlak dan de knop groot is — onderaan het scherm mikt niemand exact */
.fab::after {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 50%;
}
.fab:active { transform: scale(.92); }
.fab svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* Tijdens een sessie blijft er niets over dan de adem: geen knop, geen tekst.
   `visibility` erbij, want alleen opacity laat het element bestaan — dan kan het
   tijdens de fade nog even oplichten en lijken alsof er iets te bedienen valt. */
body.running #open-panel {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .22s ease, visibility 0s linear .22s;
}
body.running #hint {
  opacity: 0;
  visibility: hidden;
  transition: opacity .22s ease, visibility 0s linear .22s;
}

/* ─── Instellingenpaneel ────────────────────────────────────────── */

#panel {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  animation: rise .32s var(--ease-out);
}
#panel[hidden] { display: none; }

@keyframes rise { from { transform: translateY(100%); } to { transform: translateY(0); } }

@media (prefers-reduced-motion: reduce) {
  #panel { animation: none; }
}

.panel-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(var(--safe-t) + 12px) max(12px, var(--safe-r)) 24px max(12px, var(--safe-l));
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 2px 12px;
}
.panel-head h1 {
  flex: 1;
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.panel-foot {
  display: grid;
  place-items: center;
  padding: 12px 0 max(20px, var(--safe-b));
  background: var(--bg);
}

/* Ronde info-knoppen in accentkleur — het herkenbare patroon uit de app */
.icon-btn {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  border: 0; border-radius: 50%;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: transform .15s var(--ease-out);
}
.icon-btn:active { transform: scale(.92); }
.icon-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.round { background: none; color: var(--accent); width: var(--tap); height: var(--tap); }
.icon-btn.round svg { width: 22px; height: 22px; stroke-width: 2.4; }

/* De kaart draagt zelf de omhulling: één doorlopend vlak met afgeronde hoeken
   dat bij de kop begint en eindigt na de laatste uitgeklapte optie. Zonder dat
   zweeft de inhoud los van waar hij bij hoort — in lichte modus stond de body
   wit op wit. */
.card {
  margin-bottom: 12px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  cursor: pointer;
  user-select: none;
}
.card-head h2 {
  flex: 1;
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}
.chev {
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  color: var(--text-2);
}
.chev svg {
  width: 16px; height: 16px;
  fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round;
  transition: transform .2s var(--ease-out);
}
.chev[data-open="false"] svg { transform: rotate(-90deg); }

.card-body {
  padding: 14px;
}
.card-body[hidden] { display: none; }
/* Haarlijn tussen kop en inhoud, alleen wanneer er iets openstaat */
.card-body:not([hidden]) { border-top: 1px solid var(--hairline); }

/* Profielrij: info · naam · uitklappen */
.profile-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.profile-pick {
  flex: 1;
  padding: 11px 12px;
  border: 1.2px solid color-mix(in srgb, var(--accent) 85%, transparent);
  border-radius: 10px;
  background: var(--pill);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .18s ease, color .18s ease;
}
.profile-pick[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.icon-btn.dim { background: color-mix(in srgb, var(--accent) 35%, transparent); cursor: default; }
.icon-btn.dim svg { opacity: .7; }

/* De zucht is geen profiel dat je kiest, dus geen omkaderde keuzeknop */
.profile-pick.ghost {
  border-style: dashed;
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background: none;
  font-weight: 500;
}

/* Knop die een techniek voordoet */
.demo-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 18px;
  padding: 11px 18px 11px 14px;
  border: 0; border-radius: 24px;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.demo-btn svg { width: 18px; height: 18px; fill: currentColor; stroke: none; }
.demo-btn:active { transform: scale(.97); }

/* Uitgeklapte instellingen onder een profiel */
.profile-settings {
  margin: 0 0 14px 16px;
  padding-bottom: 4px;
}
.profile-settings[hidden] { display: none; }

/* Rij met label · stepper · waarde */
.row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
}
.row > .label {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row .value {
  flex: 0 0 62px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
  font-size: 16px;
}
.row.disabled { opacity: .4; pointer-events: none; }

/* Schakelaarrijen hebben geen kolomuitlijning nodig, dus lange labels
   mogen daar gewoon afbreken in plaats van afgekapt te worden. */
.row.wrap { min-height: 0; padding: 6px 0; }
.row.wrap > .label { white-space: normal; overflow: visible; }

/* Stepper: − | + , zoals SwiftUI's Stepper */
.stepper {
  flex: 0 0 auto;
  display: flex;
  border-radius: 8px;
  overflow: hidden;
  background: var(--pill);
  border: 1px solid var(--hairline);
}
.stepper button {
  width: 42px; height: 32px;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 20px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
}
.stepper button:active { background: var(--hairline); }
.stepper button:disabled { opacity: .3; cursor: default; }
.stepper button + button { border-left: 1px solid var(--hairline); }

/* Schakelaar */
.switch {
  flex: 0 0 auto;
  position: relative;
  width: 51px; height: 31px;
  border: 0; border-radius: 16px;
  background: color-mix(in srgb, var(--text-2) 40%, transparent);
  cursor: pointer;
  transition: background .22s ease;
}
.switch[aria-checked="true"] { background: var(--accent); }
.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 27px; height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .25);
  transition: transform .22s var(--ease-out);
}
.switch[aria-checked="true"]::after { transform: translateX(20px); }

/* Segmenten (thema, taal) */
.segments {
  display: flex;
  gap: 4px;
  padding: 3px;
  border-radius: 9px;
  background: var(--card);      /* niet --surface: dat is nu de kaart zelf */
}
.segments button {
  flex: 1;
  padding: 7px 4px;
  border: 0; border-radius: 7px;
  background: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.segments button[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
}

.picker {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--hairline);
  border-radius: 9px;
  background: var(--card);      /* niet --surface: dat is nu de kaart zelf */
  color: var(--text);
  font: inherit;
}

.field { margin-bottom: 16px; }
.field > .label { display: block; margin-bottom: 8px; font-size: 16px; }
.field .note { margin: 6px 0 0; font-size: 13px; color: var(--text-2); }

.divider { height: 1px; margin: 4px 0 14px; background: var(--hairline); border: 0; }

.version {
  margin: 4px 0 0;
  text-align: center;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-line;      /* de copyrightregel staat op een eigen regel */
  color: var(--text-2);
}

/* ─── Info-sheet ────────────────────────────────────────────────── */

#sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  background: rgba(0, 0, 0, .35);
  animation: fade .2s ease;
}
#sheet[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.sheet-inner {
  width: 100%;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  border-radius: 14px 14px 0 0;
  background: var(--bg);
  animation: rise .3s var(--ease-out);
}
@media (min-width: 640px) {
  #sheet { align-items: center; justify-content: center; }
  .sheet-inner { max-width: 560px; border-radius: 14px; max-height: 86vh; }
}
@media (prefers-reduced-motion: reduce) {
  .sheet-inner, #sheet { animation: none; }
}

.sheet-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 20px;
  border-bottom: 1px solid var(--hairline);
}
.sheet-head h2 {
  flex: 1;
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.sheet-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px 20px max(28px, var(--safe-b));
}
.sheet-body h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 22px 0 8px;
  font-size: 17px;
  font-weight: 600;
}
.sheet-body h3:first-child { margin-top: 0; }
.sheet-body h3 svg { flex: 0 0 auto; width: 18px; height: 18px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sheet-body p { margin: 0 0 8px; font-size: 16px; }
.sheet-body ul { margin: 0; padding-left: 20px; }
.sheet-body li { margin-bottom: 6px; font-size: 16px; }
.sheet-body a { color: var(--accent); overflow-wrap: anywhere; }
/* Markeert dat de link de app verlaat en een browservenster opent */
.sheet-body a .ext {
  width: 13px; height: 13px;
  vertical-align: -1px;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
  opacity: .75;
}

/* Waarschuwing wanneer instellingen niet bewaard kunnen worden */
.note.warn {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--text);
  font-size: 14px;
}

.refs summary {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 22px;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.refs summary::-webkit-details-marker { display: none; }
.refs summary svg { width: 18px; height: 18px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.refs ul { margin-top: 10px; }

.cadence {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 2px 0 14px;
  font-variant-numeric: tabular-nums;
  font-size: 15px;
  color: var(--text-2);
}
.cadence b {
  padding: 3px 9px;
  border-radius: 7px;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--text);
  font-weight: 600;
}

.install-steps { padding-left: 20px; }
