/* trainer v2 — component styles.
   Loaded AFTER all legacy CSS so v2 selectors win where they apply.
   Pair with /static/css/00-v2-tokens.css. */

/* Body scope — only when v2 layout is the host (new templates) */
body.v2 {
  margin: 0;
  font-family: var(--v2-font-body);
  font-size: var(--v2-t-base);
  line-height: 1.5;
  color: var(--v2-ink);
  background: var(--v2-bg);
  -webkit-font-smoothing: antialiased;
}
body.v2 * { box-sizing: border-box; }
body.v2 a { color: inherit; }

/* Page topbar */
/* v2-topbar internal gap */
.v2-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--v2-s-5) var(--v2-s-5) var(--v2-s-3);
  background: var(--v2-bg);
  position: sticky;
  top: 0;
  z-index: 2;
}
.v2-topbar h1 {
  margin: 0 0 0 var(--v2-s-3);  /* breathing room after back arrow */
  font-size: var(--v2-t-xl);
  font-weight: 600;
  letter-spacing: -0.015em;
}
.v2-topbar-action {
  font-size: var(--v2-t-sm);
  color: var(--v2-ink-2);
  text-decoration: none;
  padding: var(--v2-s-2) var(--v2-s-3);
  border-radius: var(--v2-r-full);
  border: 1px solid var(--v2-hairline-strong);
  background: var(--v2-surface);
}
.v2-topbar-back {
  width: 36px; height: 36px;
  border-radius: var(--v2-r-full);
  border: 1px solid var(--v2-hairline-strong);
  background: var(--v2-surface);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--v2-ink-2);
  text-decoration: none;
  font-size: 18px;
}

/* CTA strip */
.v2-cta {
  margin: 0 var(--v2-s-5) var(--v2-s-4);
  font-size: var(--v2-t-sm);
  color: var(--v2-ink-3);
}

/* Scroll container */
.v2-scroll { padding: 0 var(--v2-s-1) 110px; }

/* Fixed app-shell — opt-in via {% set shell = true %} on the standard nav pages.
   Pins the bottom nav to the dynamic-viewport bottom so it can't float above a
   browser's bottom toolbar. Player/practice pages (no .v2-scroll) keep doc scroll. */
body.v2-shell { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
body.v2-shell .v2-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: var(--v2-s-4); }
body.v2-shell .v2-bottomnav { position: static; }
/* Bottom nav is for the top-level tabs. On deep pages (anything with a Back
   arrow) hide it — you navigate out via Back. Tabs (.v2-shell) always keep it.
   No-back pages keep it too, so nothing is ever stranded. */
body.v2:not(.v2-shell):has(.v2-topbar-back) .v2-bottomnav { display: none; }

/* Card */
.v2-card {
  background: var(--v2-surface);
  border: 1px solid var(--v2-hairline);
  border-radius: var(--v2-r-lg);
  padding: var(--v2-s-4);
  margin-bottom: var(--v2-s-3);
}
.v2-card-title { margin: 0 0 var(--v2-s-2); font-size: var(--v2-t-md); font-weight: 600; }
.v2-card-meta { font-size: var(--v2-t-sm); color: var(--v2-ink-3); }
.v2-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--v2-s-2); }

/* Row */
.v2-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--v2-s-3) 0;
  border-bottom: 1px solid var(--v2-hairline);
  text-decoration: none;
  color: var(--v2-ink);
}
.v2-row:last-child { border-bottom: 0; padding-bottom: var(--v2-s-1); }
.v2-row-label { display: flex; align-items: center; gap: var(--v2-s-3); }
.v2-row-dot {
  width: 8px; height: 8px;
  border-radius: var(--v2-r-full);
  background: var(--v2-ink-4);
  flex: 0 0 auto;
}
.v2-row-dot--done { background: var(--v2-correct); }
.v2-row-dot--progress { background: var(--v2-target); }
.v2-row-dot--new { background: transparent; border: 1px solid var(--v2-ink-4); }
.v2-row-meta { font-size: var(--v2-t-xs); color: var(--v2-ink-3); font-variant-numeric: tabular-nums; }

/* Chips */
.v2-chips {
  display: flex;
  gap: var(--v2-s-2);
  overflow-x: auto;
  padding: 0 var(--v2-s-5) var(--v2-s-3);
  scrollbar-width: none;
}
.v2-chips::-webkit-scrollbar { display: none; }
.v2-chip {
  flex: 0 0 auto;
  padding: var(--v2-s-2) var(--v2-s-3);
  border-radius: var(--v2-r-full);
  border: 1px solid var(--v2-hairline-strong);
  background: transparent;
  color: var(--v2-ink-2);
  font-size: var(--v2-t-sm);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.v2-chip--on { background: var(--v2-ink); color: #fff; border-color: #fff; }
/* <a>-form chips lose to `body.v2 a { color: inherit }` (0,0,1,2) — bump
   specificity to (0,0,2,0) so the on-state white text survives. */
.v2-chip.v2-chip--on { color: #fff; }
.v2-chip.v2-chip { color: var(--v2-ink-2); }
.v2-chip.v2-chip.v2-chip--on { color: #fff; }
.v2-chip--mute { color: var(--v2-ink-3); }

/* Bottom nav */
.v2-bottomnav {
  position: fixed;
  transition: transform 220ms var(--v2-ease);
  bottom: 0; left: 0; right: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--v2-surface);
  border-top: 1px solid var(--v2-hairline);
  padding: var(--v2-s-2) var(--v2-s-2) calc(var(--v2-s-2) + env(safe-area-inset-bottom));
  z-index: 10;
}
.v2-bottomnav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--v2-s-2);
  color: var(--v2-ink-3);
  text-decoration: none;
  font-size: var(--v2-t-xs);
  position: relative;
}
.v2-bottomnav svg { width: 22px; height: 22px; display: block; }
.v2-bottomnav a.is-on { color: var(--v2-brand); }
.v2-bottomnav a.is-on::before {
  content: "";
  position: absolute;
  top: 0;
  width: 22px; height: 2px;
  background: var(--v2-brand);
  border-radius: var(--v2-r-full);
}

/* Buttons */
.v2-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--v2-s-2);
  padding: var(--v2-s-3) var(--v2-s-4);
  border-radius: var(--v2-r-md);
  border: 1px solid var(--v2-hairline-strong);
  background: var(--v2-surface);
  color: var(--v2-ink);
  font-family: inherit;
  font-size: var(--v2-t-base);
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}
.v2-btn--primary { background: var(--v2-brand); color: white; border-color: var(--v2-brand); }
.v2-btn--primary:hover { background: var(--v2-brand-darker); }
.v2-btn--ghost { border-color: transparent; background: transparent; color: var(--v2-ink-2); }
.v2-btn--full { width: 100%; }
.v2-btn--sm { padding: var(--v2-s-2) var(--v2-s-3); font-size: var(--v2-t-sm); }

/* Streak strip */
.v2-streak {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--v2-surface);
  border: 1px solid var(--v2-hairline);
  border-radius: var(--v2-r-lg);
  padding: var(--v2-s-3) var(--v2-s-4);
  margin-bottom: var(--v2-s-3);
}
.v2-streak-num { font-size: var(--v2-t-xl); font-weight: 600; font-variant-numeric: tabular-nums; }
.v2-streak-label { font-size: var(--v2-t-xs); color: var(--v2-ink-3); margin-top: -2px; letter-spacing: 0.04em; text-transform: uppercase; }
.v2-streak-goal { font-size: var(--v2-t-sm); color: var(--v2-ink-3); text-align: right; }
.v2-streak-bar {
  height: 6px;
  background: var(--v2-surface-2);
  border-radius: var(--v2-r-full);
  overflow: hidden;
  margin-bottom: var(--v2-s-4);
}
.v2-streak-bar-fill { height: 100%; background: var(--v2-brand); border-radius: var(--v2-r-full); }

/* Tiles (Activation) */
.v2-tiles { display: grid; grid-template-columns: 1fr; gap: var(--v2-s-3); }
.v2-tile {
  background: var(--v2-surface);
  border: 1px solid var(--v2-hairline);
  border-radius: var(--v2-r-lg);
  padding: var(--v2-s-4);
  text-decoration: none;
  color: var(--v2-ink);
  display: flex;
  flex-direction: column;
  gap: var(--v2-s-1);
  min-height: 96px;
  position: relative;
}
.v2-tile-icon { width: 28px; height: 28px; margin-bottom: var(--v2-s-2); color: var(--v2-ink-3); }
.v2-tile-title { font-size: var(--v2-t-md); font-weight: 600; }
.v2-tile-sub { font-size: var(--v2-t-sm); color: var(--v2-ink-3); margin-top: auto; }
.v2-tile-badge {
  position: absolute; top: var(--v2-s-3); right: var(--v2-s-3);
  font-size: var(--v2-t-xs);
  font-variant-numeric: tabular-nums;
  color: var(--v2-target);
  background: var(--v2-target-tint);
  padding: 2px 8px;
  border-radius: var(--v2-r-full);
}

/* Comparison cards (Apple-Watch-fitness style) */
.v2-cmpcards { display: grid; grid-template-columns: 1fr 1fr; gap: var(--v2-s-3); }
.v2-cmpcard {
  background: var(--v2-surface);
  border: 1px solid var(--v2-hairline);
  border-radius: var(--v2-r-lg);
  padding: var(--v2-s-3) var(--v2-s-4);
  display: flex;
  flex-direction: column;
  gap: var(--v2-s-1);
}
.v2-cmpcard--wide { grid-column: 1 / -1; }
.v2-cmpcard-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--v2-ink-3);
  display: flex;
  justify-content: space-between;
  gap: var(--v2-s-2);
}
.v2-cmpcard-title .ctx { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--v2-ink-4); }
.v2-cmpcard-now { display: flex; align-items: baseline; gap: var(--v2-s-2); margin-top: var(--v2-s-1); }
.v2-cmpcard-num {
  font-size: var(--v2-t-2xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}
.v2-cmpcard-unit { font-size: var(--v2-t-sm); color: var(--v2-ink-3); }
.v2-cmpcard-delta {
  font-size: var(--v2-t-sm);
  font-variant-numeric: tabular-nums;
  margin-left: auto;
  font-weight: 500;
  font-family: var(--v2-font-mono);
}
.v2-cmpcard-delta--up { color: var(--v2-correct); }
.v2-cmpcard-delta--down { color: var(--v2-warn); }
.v2-cmpcard-delta--flat { color: var(--v2-ink-3); }
.v2-cmpcard-spark {
  height: 28px;
  display: flex;
  gap: 2px;
  align-items: flex-end;
  margin: var(--v2-s-2) 0 var(--v2-s-1);
}
.v2-cmpcard-spark span {
  flex: 1;
  background: var(--v2-ink-4);
  border-radius: 2px;
  min-height: 2px;
}
.v2-cmpcard-spark span:last-child { background: var(--v2-ink); }
.v2-cmpcard-bars {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: var(--v2-s-2);
  align-items: center;
  margin: var(--v2-s-2) 0 var(--v2-s-1);
  font-size: var(--v2-t-xs);
  color: var(--v2-ink-3);
}
.v2-cmpcard-bars-label { text-align: right; font-variant-numeric: tabular-nums; }
.v2-cmpcard-bars-rail {
  height: 6px;
  background: var(--v2-surface-2);
  border-radius: var(--v2-r-full);
  overflow: hidden;
}
.v2-cmpcard-bars-fill { height: 100%; background: var(--v2-ink-4); border-radius: var(--v2-r-full); }
.v2-cmpcard-bars-fill--now { background: var(--v2-ink); }
.v2-cmpcard-prev { font-size: var(--v2-t-xs); color: var(--v2-ink-3); }
.v2-cmpcard-prev b { font-weight: 500; color: var(--v2-ink-2); font-variant-numeric: tabular-nums; }

/* Library grid */
.v2-lib-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--v2-s-3); }
.v2-lib-tile {
  background: var(--v2-surface);
  border: 1px solid var(--v2-hairline);
  border-radius: var(--v2-r-lg);
  overflow: hidden;
  text-decoration: none;
  color: var(--v2-ink);
  display: flex;
  flex-direction: column;
}
.v2-lib-thumb {
  aspect-ratio: 4 / 3;
  background: var(--v2-surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--v2-ink-3);
  font-size: var(--v2-t-sm);
}
.v2-lib-meta { padding: var(--v2-s-3); display: flex; flex-direction: column; gap: var(--v2-s-1); }
.v2-lib-title { font-size: var(--v2-t-sm); font-weight: 600; line-height: 1.3; }
.v2-lib-sub { font-size: var(--v2-t-xs); color: var(--v2-ink-3); }
.v2-lib-level {
  align-self: flex-start;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--v2-ink-2);
  padding: 2px 6px;
  border: 1px solid var(--v2-hairline-strong);
  border-radius: var(--v2-r-sm);
  margin-top: var(--v2-s-1);
}

/* Anchor selector */
.v2-anchor {
  display: flex;
  gap: 2px;
  background: var(--v2-surface-2);
  padding: 2px;
  border-radius: var(--v2-r-full);
  margin-bottom: var(--v2-s-3);
  font-size: var(--v2-t-xs);
}
.v2-anchor a {
  flex: 1;
  text-align: center;
  padding: var(--v2-s-2) 0;
  border-radius: var(--v2-r-full);
  color: var(--v2-ink-3);
  text-decoration: none;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.v2-anchor a.is-on { background: var(--v2-surface); color: var(--v2-ink); }

/* Helpers */
.v2-muted { color: var(--v2-ink-3); }
.v2-small { font-size: var(--v2-t-sm); }
.v2-tiny { font-size: var(--v2-t-xs); }
.v2-mono { font-family: var(--v2-font-mono); font-variant-numeric: tabular-nums; }
.v2-center { text-align: center; }
.v2-section-title {
  font-size: var(--v2-t-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--v2-ink-3);
  margin: var(--v2-s-5) 0 var(--v2-s-2);
}


/* form chrome overrides for v2 (anketa / profile / settings legacy forms) */
body.v2 .anketa-header { margin-bottom: var(--v2-s-3); }
body.v2 .anketa-header h2 {
  margin: 4px 0 0;
  font-size: var(--v2-t-xl);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--v2-ink);
}
body.v2 .anketa-step {
  font-family: var(--v2-font-mono);
  font-size: var(--v2-t-xs);
  color: var(--v2-ink-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
body.v2 .anketa .hint, body.v2 .hint {
  font-size: var(--v2-t-sm);
  color: var(--v2-ink-3);
  margin-top: 4px;
}
body.v2 .field-row {
  display: flex; gap: var(--v2-s-2); align-items: center;
  margin-bottom: var(--v2-s-2);
}
body.v2 .field-row label {
  font-size: var(--v2-t-sm);
  color: var(--v2-ink-2);
  min-width: 32px;
  flex-shrink: 0;
}
body.v2 .field-row input,
body.v2 input[type="text"]:not(.v2-no-restyle),
body.v2 input[type="email"]:not(.v2-no-restyle),
body.v2 input[type="number"]:not(.v2-no-restyle),
body.v2 textarea:not(.v2-no-restyle),
body.v2 select:not(.v2-no-restyle) {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--v2-hairline);
  border-radius: var(--v2-r-md);
  background: var(--v2-surface);
  color: var(--v2-ink);
  font: var(--v2-t-base)/1.4 var(--v2-font-body);
  outline: none;
  transition: border-color 120ms var(--v2-ease);
}
body.v2 input[type="text"]:focus, body.v2 input[type="email"]:focus,
body.v2 input[type="number"]:focus, body.v2 textarea:focus, body.v2 select:focus,
body.v2 .field-row input:focus {
  border-color: var(--v2-ink-3);
}
body.v2 .anketa-nav {
  display: flex; justify-content: space-between; gap: var(--v2-s-2);
  margin-top: var(--v2-s-5);
}
body.v2 .anketa-nav .btn,
body.v2 .btn,
body.v2 .btn-add,
body.v2 .btn-outline,
body.v2 .btn-accent,
body.v2 .btn-primary {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 16px;
  font: 500 var(--v2-t-base) var(--v2-font-body);
  border-radius: var(--v2-r-md);
  border: 1px solid var(--v2-hairline-strong);
  background: var(--v2-surface);
  color: var(--v2-ink);
  text-decoration: none;
  cursor: pointer;
  transition: background 120ms var(--v2-ease), border-color 120ms var(--v2-ease);
}
body.v2 .anketa-nav .btn:hover, body.v2 .btn:hover { background: var(--v2-surface-2); }
body.v2 .anketa-nav button[name="_action"][value="next"],
body.v2 .anketa-nav button[name="_action"][value="finish"],
body.v2 .btn-accent,
body.v2 .btn-primary {
  background: var(--v2-brand);
  border-color: var(--v2-brand);
  color: #fff;
}
body.v2 .anketa-nav button[name="_action"][value="next"]:hover,
body.v2 .anketa-nav button[name="_action"][value="finish"]:hover,
body.v2 .btn-accent:hover, body.v2 .btn-primary:hover {
  background: var(--v2-brand-darker);
  border-color: var(--v2-brand-darker);
}
body.v2 .anketa-nav .btn-outline,
body.v2 .btn-outline {
  background: var(--v2-surface);
  color: var(--v2-ink-2);
}
body.v2 .btn-add {
  font-size: var(--v2-t-sm);
  padding: 6px 12px;
  margin-top: var(--v2-s-2);
}
body.v2 .radio-label {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 6px 0;
  font-size: var(--v2-t-sm);
  line-height: 1.4;
  cursor: pointer;
}
body.v2 .radio-label input { margin-top: 3px; flex-shrink: 0; }
body.v2 .anketa .card,
body.v2 .container .card {
  background: var(--v2-surface);
  border: 1px solid var(--v2-hairline);
  border-radius: var(--v2-r-lg);
  padding: var(--v2-s-4);
  margin-bottom: var(--v2-s-3);
}
body.v2 .anketa h2,
body.v2 .anketa h3,
body.v2 .anketa h4 {
  font-family: var(--v2-font-body);
  font-weight: 600;
  color: var(--v2-ink);
  letter-spacing: -0.01em;
}
body.v2 .anketa ol, body.v2 .anketa ul {
  font-size: var(--v2-t-sm);
  color: var(--v2-ink-2);
  padding-left: 20px;
}
body.v2 .anketa p, body.v2 .container.anketa p { font-size: var(--v2-t-base); line-height: 1.55; }
body.v2 .anketa #anketa-error {
  background: rgba(255, 71, 0, 0.08);
  color: var(--v2-brand);
  border: 1px solid var(--v2-brand);
  border-radius: var(--v2-r-md);
  padding: var(--v2-s-3);
  font-weight: 500;
}

/* Pre-session card list — links should look like v2-card */
body.v2 .container > a.card { display: block; text-decoration: none; color: inherit; }


/* Sub-topbar that sticks below v2-topbar */
body.v2 .v2-topbar-extra {
  position: sticky;
  top: 56px;   /* below the topbar (which is ~56px tall) */
  z-index: 2;
  background: var(--v2-bg);
  padding-bottom: var(--v2-s-2);
}


/* Bottom-nav hidden when scrolling down. Toggled by a tiny JS hook in base.html. */
body.v2 .v2-bottomnav.is-hidden { transform: translateY(110%); }


/* Square pillow option (used by Settings daily-minutes picker) */
body.v2 .v2-pillow {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 64px;
  padding: 10px 14px;
  border-radius: var(--v2-r-md);
  border: 1px solid var(--v2-hairline);
  background: var(--v2-surface);
  color: var(--v2-ink-2);
  font: 500 var(--v2-t-sm) var(--v2-font-body);
  cursor: pointer;
  user-select: none;
  transition: background 120ms var(--v2-ease), border-color 120ms var(--v2-ease);
}
body.v2 .v2-pillow:hover { background: var(--v2-surface-2); }
body.v2 .v2-pillow.is-on {
  background: var(--v2-ink);
  color: #fff;
  border-color: var(--v2-ink);
}
