/* =====================================================================
   Treeni — Agentti D2:n näkymäkohtaiset laajennukset (today, workout,
   program, progress). Käyttää VAIN tokens.css-muuttujia; kaikki luokat
   d2-etuliitteellä, jotta ne eivät törmää design systemiin.
   ===================================================================== */

/* ---------- yhteiset ---------- */
.d2-wrap { white-space: normal; line-height: 1.45; font-size: var(--fs-sm); color: var(--text-2); }
.d2-micro { font-size: var(--fs-micro); }
.d2-why {
  display: inline-flex; align-items: center; gap: 6px; min-height: var(--touch-min);
  color: var(--text-muted); font-size: var(--fs-sm); font-weight: var(--fw-semi);
  transition: color var(--dur-fast);
}
.d2-why:hover { color: var(--text); }
.d2-why .icon { --icon-size: 16px; }
.d2-foot-link {
  display: flex; align-items: center; gap: var(--sp-2); margin-top: var(--sp-4); padding-top: var(--sp-3);
  border-top: 1px solid var(--line); min-height: var(--touch-min);
  color: var(--text-muted); font-size: var(--fs-sm); text-decoration: none;
}
.d2-foot-link > :nth-child(2) { flex: 1; }
.d2-foot-link:hover { color: var(--text); }
.d2-pills { --row-gap: 6px; }
.d2-ring-grid { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--sp-4); align-items: center; }
.d2-empty-sm { padding: var(--sp-6) var(--sp-4); }
.d2-empty-sm .empty__art { width: 56px; height: 56px; border-radius: 18px; }
.d2-empty-sm .empty__art .icon { --icon-size: 26px; }
.d2-legend { margin-top: var(--sp-3); }

/* ---------- Tänään: hero ---------- */
.d2-hero-title { margin-top: var(--sp-4); }
.d2-hero-meta { margin-top: var(--sp-2); --row-gap: var(--sp-4); color: var(--text-muted); font-size: var(--fs-sm); }
.d2-meta-item { --row-gap: 6px; }
.d2-hero-cta { margin-top: var(--sp-5); }
.d2-hero-actions { margin-top: var(--sp-5); align-items: center; }
.card--hero .progress { margin-top: var(--sp-4); }
.d2-preview {
  list-style: none; margin: var(--sp-4) 0 0; padding: var(--sp-3) 0 0;
  border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px;
}
.d2-preview li { display: flex; justify-content: space-between; gap: var(--sp-3); font-size: var(--fs-sm); color: var(--text-2); }
.d2-preview li .mono { font-size: var(--fs-xs); flex: none; }
.d2-preview__more { font-family: var(--font-mono); font-size: var(--fs-xs) !important; }

.d2-rest-head { display: flex; gap: var(--sp-4); align-items: center; margin-top: var(--sp-4); }
.d2-rest-head .t-muted { margin-top: 4px; font-size: var(--fs-sm); }
.d2-rest-orb {
  width: 64px; height: 64px; flex: none; border-radius: 22px; display: grid; place-items: center;
  background: var(--cyan-a10); color: var(--cyan); border: 1px solid rgba(39,232,255,.3);
  box-shadow: 0 0 30px -8px rgba(39,232,255,.6);
}
.d2-rest-orb .icon { filter: var(--dropglow-cyan); }
.d2-rest-orb.is-done { background: var(--lime-a10); color: var(--lime); border-color: rgba(182,255,59,.3); box-shadow: var(--glow-soft); }
.d2-rest-orb.is-done .icon { filter: var(--dropglow-lime); }
.d2-tips__head { margin-top: var(--sp-5); }
.d2-tips { list-style: none; padding: 0; margin: var(--sp-2) 0 0; display: flex; flex-direction: column; gap: var(--sp-2); }
.d2-tips li { display: flex; align-items: center; gap: var(--sp-3); font-size: var(--fs-sm); color: var(--text-2); }
.d2-tips .list-row__lead { width: 32px; height: 32px; }
.d2-next { margin-top: var(--sp-4); padding-top: var(--sp-4); border-top: 1px solid var(--line); }
.d2-next__name { font-weight: var(--fw-bold); margin-top: 2px; }
.d2-mini-stats { margin-top: var(--sp-4); }
.d2-mini-stats .stat__value { font-size: var(--fs-xl); }

.d2-tile { text-align: left; color: inherit; }
.d2-tile .stat__value { font-size: var(--fs-2xl); }
.d2-muted-delta { color: var(--text-muted); }
.d2-tile--flame { display: flex; align-items: center; }
.d2-tile--flame .streak { gap: var(--sp-3); }

/* viikon 7 päivää */
.d2-weekdays { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin-top: var(--sp-4); }
.d2-wd { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: var(--sp-2) 0; border-radius: var(--r-sm); }
.d2-wd__name { font-family: var(--font-mono); font-size: var(--fs-micro); letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.d2-wd__dot {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-3); border: 1px solid var(--line);
}
.d2-wd__dot .icon { --icon-size: 15px; stroke-width: 3; }
.d2-wd.is-planned .d2-wd__dot { background: transparent; border: 2px dashed var(--lime-dim); }
.d2-wd.is-done .d2-wd__dot { background: var(--lime); border-color: var(--lime); color: var(--text-on-accent); box-shadow: 0 0 12px -2px rgba(182,255,59,.7); }
.d2-wd.is-today { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-strong); }
.d2-wd.is-today .d2-wd__name { color: var(--text); }

/* ---------- Treeni ---------- */
.d2-workout { gap: var(--sp-3); }
.d2-topbar { display: flex; align-items: center; gap: var(--sp-2); min-height: 52px; }
.d2-topbar__mid { flex: 1; min-width: 0; text-align: center; }
.d2-topbar__title { font-weight: var(--fw-bold); font-size: var(--fs-md); }
.d2-elapsed { font-size: var(--fs-xs); color: var(--lime); letter-spacing: .06em; }
.d2-progress { display: flex; align-items: center; gap: var(--sp-3); width: 100%; min-height: 28px; }
.d2-progress .progress-steps { flex: 1; }
.d2-progress__n { font-size: var(--fs-micro); }

.d2-ex { padding: var(--sp-5); }
.d2-ex__name { font-size: var(--fs-3xl); font-weight: var(--fw-heavy); letter-spacing: -.035em; line-height: 1.04; margin: var(--sp-3) 0 var(--sp-3); }
.d2-target { margin-top: var(--sp-4); gap: var(--sp-2); }
.d2-target .stat-tile { padding: var(--sp-3); }
.d2-target__v { font-size: var(--fs-lg) !important; letter-spacing: -.02em !important; white-space: nowrap; }
.d2-load { margin-top: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); background: var(--lime-a10); border: 1px solid rgba(182,255,59,.22); }
.d2-load__v { font-family: var(--font-display); font-variant-numeric: tabular-nums; font-weight: var(--fw-heavy); font-size: var(--fs-xl); color: var(--lime); letter-spacing: -.02em; }
.d2-note { margin-top: var(--sp-3); height: auto; min-height: 24px; padding: 4px 10px; white-space: normal; line-height: 1.3; }
.d2-ex .alert { margin-top: var(--sp-3); }

.d2-cues { margin-top: var(--sp-3); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); }
.d2-cues summary {
  display: flex; align-items: center; gap: var(--sp-2); min-height: var(--touch-min); padding: 0 var(--sp-4);
  cursor: pointer; list-style: none; font-size: var(--fs-sm); font-weight: var(--fw-semi); color: var(--text-2);
}
.d2-cues summary::-webkit-details-marker { display: none; }
.d2-cues summary > .icon:first-child { color: var(--cyan); }
.d2-cues__chev { transition: transform var(--dur-base) var(--ease-out); }
.d2-cues[open] .d2-cues__chev { transform: rotate(180deg); }
.d2-cues ol, .d2-cue-list { margin: 0; padding: 0 var(--sp-4) var(--sp-4) calc(var(--sp-4) + 1.2em); display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-sm); color: var(--text-2); }
.d2-cue-list { padding: var(--sp-2) 0 0 1.2em; }
.d2-cues li::marker, .d2-cue-list li::marker { color: var(--lime); font-family: var(--font-mono); }

.d2-prev { margin-top: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-2); }
.d2-prev__sets { --row-gap: 6px; }
.d2-chip-mono {
  font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-2);
  padding: 4px 8px; border-radius: var(--r-xs); background: var(--surface-3); border: 1px solid var(--line);
}

.d2-sets .set-row { cursor: pointer; }
.d2-sets .set-row.is-active { border-color: var(--lime); box-shadow: 0 0 0 3px var(--lime-a10); background: var(--surface-2); }
.d2-sets .set-row.is-active .set-row__n { color: var(--lime); }
.d2-sets .set-row__head { cursor: default; }
.d2-val { font-family: var(--font-display); font-variant-numeric: tabular-nums; font-weight: var(--fw-bold); font-size: var(--fs-lg); color: var(--text); }
.d2-val.is-ghost { color: var(--text-faint); }
.set-row.is-active .d2-val.is-ghost { color: var(--text-2); }
.d2-pr-ic { color: var(--lime); filter: var(--dropglow-lime); margin: 0 auto; }

.d2-editor { display: flex; flex-direction: column; gap: var(--sp-4); }
.d2-editor__grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.d2-editor__grid--one { grid-template-columns: 1fr; }
.d2-editor .stepper--sm .stepper__btn { width: 44px; }
.d2-field { display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; }
.d2-field__label { font-family: var(--font-mono); font-size: var(--fs-micro); letter-spacing: var(--ls-caps); text-transform: uppercase; color: var(--text-muted); }
.d2-field__label .d2-why { min-height: 0; font-family: var(--font-sans); text-transform: none; letter-spacing: 0; font-size: var(--fs-xs); }
.d2-rir > button { min-height: 44px; font-family: var(--font-display); font-variant-numeric: tabular-nums; font-weight: var(--fw-bold); font-size: var(--fs-md); }
.d2-editor--done { align-items: center; text-align: center; }
.d2-done-orb {
  width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center;
  background: var(--lime); color: var(--text-on-accent); box-shadow: var(--glow-lime);
}
.d2-done-orb .icon { stroke-width: 2.6; }
.d2-done-orb--lg { width: 76px; height: 76px; margin-bottom: var(--sp-4); }

.d2-rest { display: flex; flex-direction: column; gap: var(--sp-4); background: radial-gradient(90% 70% at 50% 40%, var(--cyan-a10), transparent 70%), var(--surface-2); border-color: rgba(39,232,255,.25); }
.d2-rest__wrap { display: flex; justify-content: center; }
.d2-rest__next { text-align: center; color: var(--text-2); font-size: var(--fs-sm); margin: 0; }
.d2-rest .btn-row .btn { padding: 0 var(--sp-3); }

.d2-sum { text-align: center; display: flex; flex-direction: column; align-items: center; }
.d2-sum .screen__title { margin-top: var(--sp-2); font-size: var(--fs-3xl); }
.d2-sum__stats { width: 100%; margin-top: var(--sp-5); text-align: left; }
.d2-sum__stats .stat__value { font-size: var(--fs-xl); }

.d2-footer { align-items: center; }
.d2-footer > .btn { flex: 1; }
.d2-footer > .d2-footer__icon { flex: none; width: var(--touch-xl); border-radius: var(--r-lg); }

/* ---------- Ohjelma ---------- */
.d2-why-card { display: block; width: 100%; text-align: left; color: inherit; font: inherit; }
.d2-sum3 { gap: var(--sp-2); }
.d2-sum3__v { font-family: var(--font-display); font-weight: var(--fw-heavy); font-size: var(--fs-md); letter-spacing: -.01em; line-height: 1.2; }
.d2-why-card__cta { margin-top: var(--sp-4); padding-top: var(--sp-3); border-top: 1px solid var(--line); color: var(--lime); font-weight: var(--fw-bold); font-size: var(--fs-sm); }

.d2-weeks { gap: var(--sp-2); padding: 4px 2px var(--sp-2); margin: 0 calc(-1 * var(--gutter)); padding-left: var(--gutter); padding-right: var(--gutter); scroll-padding: 0 var(--gutter); }
.d2-week {
  --wc: var(--lime);
  position: relative; width: 54px; height: 76px; flex: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border-radius: var(--r-md); background: var(--surface-1); border: 1px solid var(--line-strong); overflow: hidden;
  transition: background-color var(--dur-fast), border-color var(--dur-fast), box-shadow var(--dur-base), transform var(--dur-fast) var(--ease-spring);
}
.d2-week:active { transform: scale(.95); }
.d2-week--cyan { --wc: var(--cyan); }
.d2-week--magenta { --wc: var(--magenta); }
.d2-week--orange { --wc: var(--orange); }
.d2-week__lbl { font-family: var(--font-mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-muted); }
.d2-week__n { font-family: var(--font-display); font-weight: var(--fw-heavy); font-size: var(--fs-xl); font-variant-numeric: tabular-nums; letter-spacing: -.03em; line-height: 1; }
.d2-week__bar { position: absolute; left: 6px; right: 6px; bottom: 6px; height: 3px; border-radius: 2px; background: color-mix(in srgb, var(--wc) 22%, transparent); overflow: hidden; }
.d2-week__bar::after { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--fill, 0%); background: var(--wc); box-shadow: 0 0 6px var(--wc); }
.d2-week.is-deload { background: repeating-linear-gradient(-45deg, var(--cyan-a10) 0 4px, transparent 4px 9px), var(--surface-1); }
.d2-week.is-current .d2-week__lbl { color: var(--lime); }
.d2-week.is-current::before { content: ""; position: absolute; top: 0; left: 50%; width: 18px; height: 3px; margin-left: -9px; border-radius: 0 0 3px 3px; background: var(--lime); box-shadow: 0 0 8px var(--lime); }
.d2-week.is-selected { border-color: var(--wc); background-color: color-mix(in srgb, var(--wc) 12%, var(--surface-1)); box-shadow: 0 0 18px -6px var(--wc); }
.d2-week.is-complete .d2-week__n { color: var(--text-2); }

.d2-phase { --pc: var(--lime); border-left: 3px solid var(--pc); background: linear-gradient(90deg, color-mix(in srgb, var(--pc) 9%, transparent), transparent 70%), var(--surface-1); }
.d2-phase--cyan { --pc: var(--cyan); }
.d2-phase--magenta { --pc: var(--magenta); }
.d2-phase--orange { --pc: var(--orange); }
.d2-phase__title { margin: var(--sp-2) 0 var(--sp-1); }
.d2-phase__kcal { --row-gap: 6px; margin-top: var(--sp-2); font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-2); }
.d2-phase__kcal .icon { color: var(--orange); }

.d2-day { padding: var(--sp-4); }
.d2-day.is-done { opacity: .78; }
.d2-day__head { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-2); }
.d2-dow {
  width: 44px; height: 44px; flex: none; border-radius: var(--r-sm); display: grid; place-items: center;
  background: var(--surface-3); font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: var(--fw-semi);
  text-transform: uppercase; letter-spacing: .06em; color: var(--text-2);
}
.d2-dow.is-today { background: var(--lime); color: var(--text-on-accent); box-shadow: var(--glow-soft); }
.d2-blocks { margin: 0 calc(-1 * var(--sp-4)); }
.d2-blocks .list-row { min-height: 56px; padding: var(--sp-2) var(--sp-4); }
.d2-blocks .list-row__lead { width: 32px; height: 32px; font-size: var(--fs-xs); }
.d2-blocks .list-row__title { font-size: var(--fs-sm); }
.d2-blocks .list-row__meta { font-size: var(--fs-xs); font-family: var(--font-mono); }
.d2-load-chip { font-family: var(--font-display); font-variant-numeric: tabular-nums; font-weight: var(--fw-bold); color: var(--text); font-size: var(--fs-sm); }
.d2-day__start { margin-top: var(--sp-3); min-height: var(--touch-min); }

.d2-dow-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-2); }
.d2-dow-chip { justify-content: center; text-transform: capitalize; position: relative; }
.d2-dow-chip .badge__dot { position: absolute; top: 8px; right: 10px; color: var(--orange); }
.d2-why-row { align-items: flex-start; }

/* ---------- Seuranta ---------- */
.d2-lifts { display: flex; flex-direction: column; }
.d2-lift {
  display: grid; grid-template-columns: minmax(0, 1fr) 130px; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) 0; border-bottom: 1px solid var(--line); text-align: left; color: inherit; width: 100%;
}
.d2-lift:last-child { border-bottom: 0; padding-bottom: 0; }
.d2-lift:first-child { padding-top: 0; }
.d2-lift__txt { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.d2-lift__v { display: flex; align-items: baseline; }
.d2-lift__v .num-unit { font-size: var(--fs-xs); }
.d2-cal-wrap { overflow: hidden; }
.d2-cal { width: 100%; height: auto; }
.d2-cal__lbl { font-family: var(--font-mono); font-size: 9px; fill: var(--text-muted); text-transform: uppercase; }
.d2-cal__c--0 { fill: var(--surface-3); }
.d2-cal__c--1 { fill: var(--heat-1); }
.d2-cal__c--2 { fill: var(--heat-2); }
.d2-cal__c--3 { fill: var(--heat-3); }
.d2-cal__c--4 { fill: var(--heat-4); filter: drop-shadow(0 0 3px rgba(182,255,59,.6)); }
.d2-cal .is-future { opacity: .35; }
.d2-cal .is-today { stroke: var(--text); stroke-width: 1.5; }
.d2-cal-legend { --row-gap: 4px; justify-content: flex-end; margin-top: var(--sp-3); font-family: var(--font-mono); font-size: var(--fs-micro); color: var(--text-muted); }
.d2-cal-legend span { margin: 0 4px; }
.d2-cal__sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.d2-cal__sw.d2-cal__c--0 { background: var(--surface-3); }
.d2-cal__sw.d2-cal__c--1 { background: var(--heat-1); }
.d2-cal__sw.d2-cal__c--2 { background: var(--heat-2); }
.d2-cal__sw.d2-cal__c--3 { background: var(--heat-3); }
.d2-cal__sw.d2-cal__c--4 { background: var(--heat-4); }
.d2-pr-trail { flex-direction: column; align-items: flex-end; gap: 0; }

.d2-tiles3 .stat-tile { justify-content: space-between; }
.d2-tiles3 .stat__label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* treenin alapalkki ei kellu: päätoiminto ("Sarja valmis") pysyy aina näkyvissä */
.d2-workout .d2-footer { position: static; background: none; margin-top: 0; padding-top: var(--sp-2); }
