/* =========================================================
   Origen FR — sección Rutinas (rutinas.html)
   Usa los tokens y componentes de styles.css (.chip, .btn, .section…);
   las clases propias llevan el prefijo rt- para no chocar con ellos.
   ========================================================= */

:root { --ok: #58d68d; }

:where(.rt-page, .rt-rest) button { cursor: pointer; }
.rt-page { padding-top: calc(var(--header-h) + clamp(40px, 6vw, 72px)); }
.rt-page .section__head { margin-bottom: clamp(24px, 3vw, 36px); }
.rt-filters { display: grid; gap: 14px; margin-bottom: 28px; }

/* ---------- Filtros ---------- */

.rt-fgroup { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.rt-flabel { font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); min-width: 8.5em; }
.rt-seg { display: inline-flex; flex-wrap: wrap; gap: 4px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 99px; padding: 4px; }
.rt-seg button {
  border: 0; background: transparent; border-radius: 99px; padding: .45em 1em; font-weight: 700; font-size: .9rem; color: var(--muted);
  transition: background .2s, color .2s;
}
.rt-seg button[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); }
.rt-seg button:not([aria-pressed="true"]):hover { color: var(--text); }
/* En móvil el selector ocupa todo el ancho como bloque de pestañas: sin cápsula partida en dos líneas */
@media (max-width: 640px) {
  .rt-seg { display: grid; grid-template-columns: repeat(4, auto); width: 100%; border-radius: 12px; }
  .rt-seg button { border-radius: 8px; padding: .55em .5em; }
}
@media (max-width: 360px) {
  .rt-seg { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.chip .rt-n { font-variant-numeric: tabular-nums; opacity: .65; font-size: .8em; }
.rt-fsummary { margin: 0; font-size: .88rem; color: var(--muted); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.rt-linkbtn { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Disposición principal ---------- */
.rt-layout { display: grid; gap: 28px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 960px) {
  .rt-layout { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: start; }
  .rt-stage { position: sticky; top: calc(var(--header-h) + 16px); }
}

/* ---------- Visor ---------- */
.rt-stage { display: grid; gap: 14px; min-width: 0; }
.rt-viewer {
  position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line);
  background:
    radial-gradient(120% 70% at 20% 0%, rgba(227, 6, 19, .22), transparent 60%),
    radial-gradient(80% 60% at 100% 100%, rgba(90, 125, 255, .12), transparent 60%),
    var(--bg-2);
  aspect-ratio: 1 / 1.3; max-width: 100%;
}
@media (max-width: 640px) { .rt-hint { display: none; } }
@media (min-width: 960px) { .rt-viewer { aspect-ratio: auto; height: min(calc(100vh - var(--header-h) - 260px), 620px); min-height: 440px; } }
.rt-viewer canvas { display: block; width: 100%; height: 100%; touch-action: none; transition: opacity .2s ease; }
.rt-loading { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; color: var(--muted); font-size: .9rem; letter-spacing: .04em; }
.rt-ov { position: absolute; left: 0; right: 0; display: flex; justify-content: space-between; gap: 10px; padding: 14px; pointer-events: none; }
.rt-ov > * { pointer-events: auto; }
.rt-ov.rt-ov--top { top: 0; align-items: flex-start; }
.rt-ov.rt-ov--bottom { bottom: 0; flex-direction: column; gap: 10px; background: linear-gradient(transparent, rgba(12, 11, 10, .85) 45%); padding-top: 40px; }
.rt-exname { display: grid; gap: 2px; pointer-events: none; }
.rt-exname h2 {
  font-weight: 900; text-transform: uppercase; font-size: clamp(1.4rem, 1.1rem + 1.2vw, 2rem); font-variation-settings: "wdth" 72; letter-spacing: -.01em;
}
.rt-exname small { color: var(--muted); font-size: .82rem; }
.rt-views { display: inline-flex; gap: 2px; background: rgba(12, 11, 10, .7); border: 1px solid var(--line); border-radius: 99px; padding: 3px; backdrop-filter: blur(6px); }
.rt-views button { border: 0; background: transparent; padding: .3em .75em; border-radius: 99px; font-size: .78rem; font-weight: 700; color: var(--muted); }
.rt-views button[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.rt-phase { display: grid; gap: 6px; }
.rt-phase__top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.rt-phase__name { font-weight: 800; font-style: italic; text-transform: uppercase; font-size: 1.05rem; font-variation-settings: "wdth" 85; }
.rt-phase__name b { color: var(--accent); font-weight: 900; }
.rt-reps { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .88rem; }
.rt-reps strong { color: var(--text); font-size: 1.15rem; font-weight: 900; }
.rt-pbar { display: flex; gap: 3px; height: 6px; }
.rt-pbar span { position: relative; flex: var(--w) 1 0; background: rgba(242, 238, 232, .14); border-radius: 3px; overflow: hidden; }
.rt-pbar span i { position: absolute; inset: 0; transform-origin: left; transform: scaleX(var(--f, 0)); background: var(--text); }
.rt-pbar span.is-on i { background: var(--accent); }
.rt-ctrls { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.rt-ctrls__group { display: flex; align-items: center; gap: 8px; }
.rt-play {
  width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--brand); color: var(--brand-ink);
  display: grid; place-items: center; transition: transform .2s var(--ease);
}
.rt-play:hover { transform: scale(1.06); }
.rt-play svg { width: 18px; height: 18px; fill: currentColor; }
.rt-speed { display: inline-flex; gap: 2px; }
.rt-speed button { border: 1px solid var(--line); background: rgba(12, 11, 10, .6); border-radius: 8px; padding: .3em .55em; font-size: .78rem; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.rt-speed button[aria-pressed="true"] { border-color: var(--text); color: var(--text); }
.rt-legend { display: flex; gap: 12px; font-size: .75rem; color: var(--muted); }
.rt-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.rt-legend .is-primary { background: var(--brand); }
.rt-legend .is-secondary { background: #7a2a24; }
.rt-hint { font-size: .75rem; color: var(--muted); margin-top: 4px; transition: opacity .6s; }
.rt-glfail { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px; color: var(--muted); }

/* ---------- Ficha del ejercicio ---------- */
.rt-detail { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 14px; }
.rt-musc { display: flex; flex-wrap: wrap; gap: 6px; }
.rt-tag { font-size: .75rem; font-weight: 700; padding: .25em .7em; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.rt-tag.is-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.rt-tabs { display: flex; gap: 18px; border-bottom: 1px solid var(--line); }
.rt-tabs button { border: 0; background: none; padding: 0 0 8px; font-weight: 700; font-size: .9rem; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.rt-tabs button[aria-selected="true"] { color: var(--text); border-color: var(--accent); }
.rt-tabpanel ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.rt-tabpanel li { display: grid; grid-template-columns: 18px 1fr; gap: 8px; color: var(--text); font-size: .93rem; }
.rt-tabpanel li::before { content: ""; width: 8px; height: 8px; margin-top: .5em; border-radius: 2px; background: var(--accent); transform: skewX(-12deg); }
.rt-tabpanel.rt-tabpanel--bad li::before { background: transparent; border: 1.5px solid var(--muted); border-radius: 50%; }
.rt-rm { display: grid; gap: 10px; }
.rt-rm label { font-size: .9rem; color: var(--muted); }
.rt-rm__row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rt-rm input {
  width: 7.5em; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: .55em .8em;
  font-weight: 800; font-size: 1.1rem; font-variant-numeric: tabular-nums;
}
.rt-rm input:focus { border-color: var(--accent); outline: none; }
.rt-rm .rt-rm__unit { color: var(--muted); font-weight: 700; }
.rt-rm small { color: var(--muted); font-size: .82rem; }

/* ---------- Rutinas ---------- */
.rt-routines { display: grid; gap: 20px; min-width: 0; }
.rt-routine { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.rt-rhead { padding: 18px 18px 14px; display: grid; gap: 8px; }
.rt-rhead__top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.rt-rtype {
  font-size: .7rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; padding: .3em .75em; border-radius: 6px;
  background: var(--bg-3); color: var(--muted);
}
.rt-rtype.rt-rtype--fuerza { background: var(--brand); color: var(--brand-ink); }
.rt-rtype.rt-rtype--hipertrofia { background: var(--text); color: var(--bg); }
.rt-rhead h3 { font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem); font-weight: 900; text-transform: uppercase; font-variation-settings: "wdth" 78; }
.rt-rmeta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .85rem; color: var(--muted); }
.rt-rnote { margin: 0; font-size: .9rem; color: var(--muted); }
.rt-prog { display: flex; align-items: center; gap: 10px; font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.rt-prog__bar { flex: 1; height: 4px; background: var(--bg-3); border-radius: 2px; overflow: hidden; }
.rt-prog__bar i { display: block; height: 100%; width: var(--p, 0%); background: var(--ok); transition: width .4s var(--ease); }
.rt-prog.is-done { color: var(--ok); }

.rt-rows { border-top: 1px solid var(--line); }
.rt-rlabels, .rt-row {
  display: grid; gap: 10px 14px; align-items: center;
  grid-template-columns: minmax(0, 1fr) 5.5rem 8.5rem 4.6rem 4.2rem;
  padding: 10px 18px;
}
.rt-rlabels { font-size: .68rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); }
.rt-row { border-bottom: 1px solid var(--line); position: relative; }
.rt-row:last-child { border-bottom: 0; }
.rt-row[aria-current="true"] { background: color-mix(in srgb, var(--brand) 10%, transparent); }
.rt-row[aria-current="true"]::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.rt-exbtn { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 12px; align-items: center; border: 0; background: none; padding: 0; text-align: left; min-width: 0; }
.rt-exbtn .rt-exbtn__ico {
  width: 40px; height: 40px; border-radius: 10px; background: var(--bg-3); display: grid; place-items: center; transition: background .2s;
}
.rt-exbtn .rt-exbtn__ico svg { width: 16px; height: 16px; fill: var(--text); margin-left: 2px; }
.rt-exbtn:hover .rt-exbtn__ico, .rt-row[aria-current="true"] .rt-exbtn__ico { background: var(--brand); }
.rt-exbtn strong { display: block; font-weight: 800; font-size: 1rem; line-height: 1.2; }
.rt-exbtn .rt-exbtn__muscles { display: block; font-size: .78rem; color: var(--muted); }
.rt-cell { font-variant-numeric: tabular-nums; font-size: .92rem; }
.rt-cell .rt-cell__k { display: none; }
.rt-cell.rt-cell--big { white-space: nowrap; font-weight: 900; font-size: 1.1rem; font-variation-settings: "wdth" 85; }
.rt-cell small { display: block; color: var(--muted); font-size: .76rem; line-height: 1.25; }
.rt-sets { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-left: 52px; }
.rt-sets > span { font-size: .75rem; color: var(--muted); margin-right: 2px; }
.rt-dot {
  width: 30px; height: 30px; border-radius: 8px; border: 1.5px solid var(--line); background: transparent;
  font-size: .75rem; font-weight: 800; color: var(--muted); display: grid; place-items: center; font-variant-numeric: tabular-nums;
  transition: background .15s, border-color .15s, color .15s;
}
.rt-dot:hover { border-color: var(--muted); color: var(--text); }
.rt-dot[aria-pressed="true"] { background: var(--ok); border-color: var(--ok); color: #0c0b0a; }
.rt-rfoot { display: flex; justify-content: flex-end; padding: 10px 18px 14px; }
.rt-rfoot button { border: 0; background: none; color: var(--muted); font-size: .8rem; text-decoration: underline; text-underline-offset: 3px; padding: 4px 0; }
.rt-rfoot button:hover { color: var(--text); }
.rt-empty p { margin: 0; }
.rt-empty { border: 1px dashed var(--line); border-radius: var(--radius); padding: 28px; text-align: center; color: var(--muted); display: grid; gap: 10px; justify-items: center; }

@media (max-width: 640px) {
  .rt-rlabels { display: none; }
  .rt-row { grid-template-columns: minmax(0, .9fr) minmax(0, 1.3fr) minmax(0, .9fr) minmax(0, .9fr); padding: 14px 16px; align-items: start; }
  .rt-exbtn { grid-column: 1 / -1; }
  .rt-cell .rt-cell__k { display: block; font-size: .65rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
  .rt-sets { padding-left: 0; }
  .rt-rhead, .rt-rfoot { padding-left: 16px; padding-right: 16px; }
}

/* ---------- Temporizador de descanso ---------- */
.rt-rest {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding: 0 max(16px, env(safe-area-inset-right, 0px)) calc(14px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  pointer-events: none;
}
.rt-rest__in {
  pointer-events: auto; max-width: 620px; margin: 0 auto; background: var(--text); color: var(--bg); border-radius: 18px;
  padding: 12px 14px; display: flex; align-items: center; gap: 14px; box-shadow: 0 18px 50px rgba(0, 0, 0, .55);
  animation: up .35s var(--ease);
}
@keyframes up { from { transform: translateY(20px); opacity: 0; } }
.rt-ring { width: 52px; height: 52px; flex: none; }
.rt-ring circle { fill: none; stroke-width: 5; }
.rt-ring .rt-ring__bg { stroke: rgba(12, 11, 10, .12); }
.rt-ring .rt-ring__fg { stroke: var(--brand); stroke-linecap: round; transform: rotate(-90deg); transform-origin: center; transition: stroke-dashoffset .25s linear; }
.rt-rest__txt { flex: 1; min-width: 0; }
.rt-rest__time { font-weight: 900; font-size: 1.6rem; line-height: 1; font-variant-numeric: tabular-nums; font-variation-settings: "wdth" 80; }
.rt-rest__lbl { font-size: .82rem; color: #4a4540; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rt-rest__btns { display: flex; gap: 6px; }
.rt-rest__btns button { border: 1.5px solid rgba(12, 11, 10, .2); background: transparent; border-radius: 99px; padding: .45em .8em; font-weight: 700; font-size: .82rem; color: var(--bg); }
.rt-rest__btns button.rt-rest__skip { background: var(--bg); color: var(--text); border-color: var(--bg); }

/* ---------- Llamada final ---------- */
.rt-cta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 20px 40px; }
.rt-cta .section__lead { margin-top: 12px; }
.rt-cta .section__lead a { color: var(--text); font-weight: 700; white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  .rt-rest__in { animation: none; }
  .rt-viewer canvas, .rt-prog__bar i, .rt-ring__fg { transition: none; }
}
