/* Rutina semanal — estilos mobile-first, sin dependencias externas. */

:root {
  color-scheme: light dark;

  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-alt: #eceef1;
  --border: #dcdfe4;
  --text: #16191d;
  --text-muted: #5c636e;
  --accent: #1f6feb;
  --accent-contrast: #ffffff;
  --rest: #7a5af5;
  --bike-yes: #128a5b;
  --bike-no: #b4551a;
  --danger: #c02b2b;

  --kind-push: #1f6feb;
  --kind-pull: #128a5b;
  --kind-legs: #b4551a;
  --kind-rest: #7a5af5;

  --radius: 12px;
  --gap: 1rem;
  --wrap: 46rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101418;
    --surface: #181d23;
    --surface-alt: #212832;
    --border: #2c343e;
    --text: #e7eaee;
    --text-muted: #9aa4b1;
    --accent: #58a6ff;
    --accent-contrast: #0b0f14;
    --rest: #a78bfa;
    --bike-yes: #4ade9b;
    --bike-no: #f0a35e;
    --danger: #ff8080;

    --kind-push: #58a6ff;
    --kind-pull: #4ade9b;
    --kind-legs: #f0a35e;
    --kind-rest: #a78bfa;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 1rem;
}

h1, h2, h3, h4 { line-height: 1.25; margin: 0; }

/* ------------------------------------------------------------- cabecera */

.site-header {
  padding: 1.5rem 0 1rem;
}

.site-header h1 {
  font-size: 1.5rem;
  letter-spacing: -0.01em;
}

.tagline {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ------------------------------------------------------------ pestañas */

.day-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 0;
}

.day-tabs {
  display: grid;
  /* minmax(0, 1fr) evita que el contenido ensanche las columnas y desborde la fila. */
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.25rem;
}

.day-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  min-width: 0;
  min-height: 48px;
  padding: 0.4rem 0.15rem;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-muted);
  font: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.day-tab-label {
  font-size: 0.85rem;
  font-weight: 650;
  letter-spacing: 0.01em;
}

/* Punto de color: identifica el tipo de sesión cuando el nombre no entra. */
.day-tab-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--kind-push);
}

.day-tab[data-kind="pull"] .day-tab-dot { background: var(--kind-pull); }
.day-tab[data-kind="legs"] .day-tab-dot { background: var(--kind-legs); }
.day-tab[data-kind="rest"] .day-tab-dot { background: var(--kind-rest); }

/* El nombre de la sesión solo aparece cuando hay ancho para leerlo entero. */
.day-tab-name { display: none; }

.day-tab.is-today {
  border-color: var(--accent);
  color: var(--text);
}

.day-tab.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

.day-tab.is-active.is-rest {
  background: var(--rest);
  border-color: var(--rest);
}

.day-tab.is-active .day-tab-dot { background: currentColor; }

.day-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Leyenda del punto de color, junto a las pestañas. */
.kind-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.kind-legend li {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.kind-legend i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--kind-push);
}

.kind-legend li[data-kind="pull"] i { background: var(--kind-pull); }
.kind-legend li[data-kind="legs"] i { background: var(--kind-legs); }
.kind-legend li[data-kind="rest"] i { background: var(--kind-rest); }

/* --------------------------------------------------------------- rutina */

main { padding-bottom: 2rem; }

.routine:focus { outline: none; }

.routine-header {
  padding: 1.25rem 0 0.5rem;
}

.routine-eyebrow {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.badge-today {
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.routine-title {
  margin: 0.3rem 0 0;
  font-size: 1.75rem;
  letter-spacing: -0.02em;
}

.routine-focus {
  margin: 0.2rem 0 0;
  color: var(--text-muted);
}

.routine-duration {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* --------------------------------------------------------------- tarjetas */

.card {
  margin-top: var(--gap);
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.card > h2,
.card > h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

/* ------------------------------------------------------------ ejercicios */

.exercise-list,
.simple-list,
.equipment-list,
.tags {
  list-style: none;
  margin: 0;
  padding: 0;
}

.exercise + .exercise {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.exercise-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 0.75rem;
}

.exercise-name {
  font-size: 1.05rem;
  font-weight: 650;
}

.exercise-dose {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin: 0;
  font-size: 0.9rem;
  white-space: nowrap;
}

.exercise-dose strong {
  font-variant-numeric: tabular-nums;
}

.exercise-rest {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 0.5rem 0;
}

/*
 * Chips de equipamiento. Antes eran gris sobre gris y se perdían entre las
 * tarjetas; ahora llevan borde propio y texto a contraste pleno. Todos iguales:
 * la fila responde a "qué necesito para esto", y jerarquizarlos por tipo solo
 * agregaba ruido.
 */
.tag {
  padding: 0.2rem 0.6rem;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 550;
  line-height: 1.5;
  white-space: nowrap;
}

.exercise-cues {
  margin: 0.4rem 0 0;
  font-size: 0.92rem;
  color: var(--text);
}

.variations {
  margin-top: 0.6rem;
  font-size: 0.88rem;
}

.variations > summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
  width: fit-content;
  padding: 0.2rem 0;
}

.variations > summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.variations-list {
  margin: 0.5rem 0 0;
  padding: 0.75rem;
  background: var(--surface-alt);
  border-radius: 8px;
}

.variations-list dt {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.variations-list dt + dd {
  margin: 0.15rem 0 0;
}

.variations-list dd + dt { margin-top: 0.6rem; }

/* ------------------------------------------------------------ diagramas */

.exercise-figure {
  margin: 0.6rem 0 0.2rem;
  padding: 0.4rem 0.2rem 0.1rem;
  background: var(--surface-alt);
  border-radius: 8px;
}

.figure {
  display: block;
  width: 100%;
  height: auto;
  /* Los trazos heredan el color del texto, así el diagrama sigue el tema. */
  color: var(--text);
}

.fig-limb,
.fig-torso {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.fig-head {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
}

/* Extremidades del lado lejano: más tenues, para dar profundidad. */
.fig-far {
  opacity: 0.35;
  stroke-width: 2;
}

.fig-gear {
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  color: var(--accent);
}

.fig-gear-fill { fill: var(--surface-alt); stroke: none; }

.fig-band {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.8;
  stroke-dasharray: 4 3;
  stroke-linecap: round;
}

.fig-prop {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  opacity: 0.45;
  stroke-linecap: round;
}

.fig-ground {
  stroke: currentColor;
  stroke-width: 1.6;
  opacity: 0.3;
  stroke-linecap: round;
}

.fig-arrow {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.fig-label {
  fill: currentColor;
  opacity: 0.5;
  font-size: 8px;
  font-family: inherit;
  text-anchor: middle;
}

/* --------------------------------------------------------- pie ejercicio */

.exercise-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

.exercise-footer .variations {
  flex: 1 1 auto;
  min-width: 0;
  margin-top: 0;
}

.video-link {
  flex: 0 0 auto;
  padding: 0.2rem 0;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.video-link::after {
  content: " \2197";
  font-weight: 400;
}

.video-link:hover { text-decoration: underline; }

.video-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* -------------------------------------------- calentamiento / sugerencias */

.simple-list li {
  display: flex;
  flex-direction: column;
  font-size: 0.92rem;
}

.simple-list li + li {
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
}

.simple-list strong { font-weight: 650; }

.simple-list span { color: var(--text-muted); }

.rest-card {
  border-left: 3px solid var(--rest);
}

.rest-card p { margin: 0; color: var(--text-muted); }

/* ----------------------------------------------------------------- bici */

.bike { border-left: 3px solid var(--border); }
.bike-yes { border-left-color: var(--bike-yes); }
.bike-no { border-left-color: var(--bike-no); }

.bike > h3 { color: var(--text); text-transform: none; letter-spacing: 0; font-size: 0.95rem; }
.bike-yes > h3 { color: var(--bike-yes); }
.bike-no > h3 { color: var(--bike-no); }

.bike p { margin: 0; font-size: 0.92rem; }

.note {
  margin: 0.5rem 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ------------------------------------------------------------------ IMC */

.bmi-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.bmi-fields label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.bmi-fields input {
  min-height: 44px;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.bmi-fields input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.bmi-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.btn-primary,
.btn-ghost {
  min-height: 44px;
  padding: 0 1rem;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-contrast);
}

.btn-ghost {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
}

.btn-primary:focus-visible,
.btn-ghost:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.bmi-error {
  margin: 0.75rem 0 0;
  color: var(--danger);
  font-size: 0.85rem;
}

.bmi-result {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-top: 0.9rem;
  padding: 0.75rem;
  background: var(--surface-alt);
  border-radius: 8px;
}

.bmi-value {
  font-size: 1.9rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.bmi-category {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
}

.bmi-result[data-level="normal"] .bmi-category { color: var(--bike-yes); }
.bmi-result[data-level="high"] .bmi-category,
.bmi-result[data-level="low"] .bmi-category { color: var(--bike-no); }
.bmi-result[data-level="very-high"] .bmi-category { color: var(--danger); }

/* -------------------------------------------------- seguimiento de sesión */

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

.session {
  margin-top: var(--gap);
  padding: 0.75rem 1rem 0.6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.session-track {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-alt);
  overflow: hidden;
}

.session-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.25s ease;
}

.session.is-complete .session-fill { background: var(--bike-yes); }

.session-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.session-summary {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.session.is-complete .session-summary {
  color: var(--bike-yes);
  font-weight: 600;
}

.btn-sm {
  min-height: 36px;
  padding: 0 0.7rem;
  font-size: 0.8rem;
}

.session-reset:disabled {
  opacity: 0.4;
  cursor: default;
}

.session-reset.is-armed {
  border-color: var(--danger);
  color: var(--danger);
}

/* ------------------------------------------------------- series por ejercicio */

.tracker { margin-top: 0.7rem; }

.sets {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  background: var(--surface-alt);
  border-radius: 8px 8px 0 0;
}

.sets-caption {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.sets-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  flex: 1 1 auto;
}

/* Indicadores, no botones: toda la interacción pasa por .set-action. */
.set-dot {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  transition: background 0.15s, border-color 0.15s;
}

.set-dot.is-done {
  background: var(--accent);
  border-color: var(--accent);
}

.sets-count {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.sets-undo {
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
}

.sets-undo:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Botón único que encadena empezar serie -> terminar serie. */
.set-action {
  display: block;
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--accent);
  border-radius: 0 0 8px 8px;
  background: var(--accent);
  color: var(--accent-contrast);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.set-action.is-working {
  background: var(--bike-yes);
  border-color: var(--bike-yes);
}

.set-action.is-resting {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
  font-weight: 600;
}

.set-action:disabled {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
  font-weight: 600;
  cursor: default;
}

.set-action:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Ejercicio terminado: se atenúa pero sigue legible y corregible. */
.exercise.is-complete .exercise-name,
.exercise.is-complete .exercise-dose {
  opacity: 0.55;
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.exercise.is-complete .exercise-figure,
.exercise.is-complete .exercise-cues { opacity: 0.5; }

.exercise.is-complete .sets {
  background: color-mix(in srgb, var(--bike-yes) 14%, var(--surface-alt));
}

/* ------------------------------------------------------------- cronómetro */

.activity-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgb(0 0 0 / 0.12);
  padding-bottom: env(safe-area-inset-bottom);
}

/* Deja sitio para que la barra no tape el final del contenido. */
body.has-activity { padding-bottom: 5.5rem; }

.activity-progress {
  height: 4px;
  background: var(--surface-alt);
}

.activity-progress > span {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--accent);
  transition: width 0.25s linear;
}

.activity-bar.is-work .activity-progress > span,
.activity-bar.is-done .activity-progress > span { background: var(--bike-yes); }

.activity-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.activity-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.activity-time {
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.activity-bar.is-work .activity-time,
.activity-bar.is-done .activity-time { color: var(--bike-yes); }

.activity-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 0 0 auto;
}

.icon-btn {
  min-width: 36px;
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  cursor: pointer;
}

.icon-btn.is-off {
  color: var(--text-muted);
  opacity: 0.55;
  text-decoration: line-through;
}

.icon-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --------------------------------------------------------- equipamiento */

.equipment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

/* La lista del pie reutiliza los mismos chips. */
.equipment-list { gap: 0.4rem; }

/* --------------------------------------------------------------- footer */

.site-footer {
  padding: 1.5rem 0 2rem;
  border-top: 1px solid var(--border);
}

.site-footer p {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* -------------------------------------------------------------- ≥ 40rem */

@media (min-width: 40rem) {
  body { font-size: 17px; }
  .site-header h1 { font-size: 1.75rem; }
  .routine-title { font-size: 2rem; }
  .day-tab { min-height: 58px; }
  .day-tab-label { font-size: 0.95rem; }
  .day-tab-name {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.68rem;
    line-height: 1.2;
    text-align: center;
  }
  .kind-legend { display: none; }
  .card { padding: 1.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
