/* =====================================================================
   Treeni — Agentti D1:n laajennukset (onboarding, profiili, ravinto).
   Vain tokeneita (css/tokens.css); ei uusia värejä.
   ===================================================================== */

/* ---------- yhteiset ---------- */
.mb-0 { margin-bottom: 0 !important; }
.d1-wrap { white-space: normal !important; }
.d1-opt {
  margin-left: var(--sp-2); padding: 2px 8px; border-radius: var(--r-pill);
  font-family: var(--font-mono); font-size: var(--fs-micro); font-weight: var(--fw-medium);
  letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); background: var(--surface-3);
  vertical-align: 1px;
}
.d1-inline-note { display: inline; margin-left: var(--sp-2); font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: var(--fw-medium); color: var(--lime); }
.d1-subhead { display: flex; flex-direction: column; gap: var(--sp-1); }
.d1-subhead p { margin: 0; }
.d1-disclaimer-line { --row-gap: 8px; align-items: flex-start; }
.d1-disclaimer-line .icon { margin-top: 2px; }
.d1-dot { width: 10px; height: 10px; flex: none; border-radius: 3px; background: var(--dc); box-shadow: 0 0 8px var(--dc); }
.d1-dot--lg { width: 12px; height: 12px; border-radius: 4px; }
.field.is-error .stepper { border-color: var(--red); box-shadow: 0 0 0 4px var(--red-a10); }
.field.is-error .segmented, .field.is-error .select { border-color: var(--red); }
.field.is-error .choice { border-color: rgba(255, 77, 94, .45); }
.field__error[hidden] { display: none; }
.field__error .icon { flex: none; }

/* Suuret segmentit (sukupuoli, treenipäivät) */
.d1-seg-lg span, .d1-seg-lg > button { min-height: 48px; font-size: var(--fs-md); }

/* Kokemustason pylväsikoni */
.d1-level rect { stroke: none; }
.d1-level .on { fill: currentColor; }
.d1-level .off { fill: currentColor; opacity: .25; }

/* Lukittu valinta (johdettu, esim. alle 18 v syntymävuodesta) */
.choice.is-locked { cursor: default; }
.choice.is-locked:active { transform: none; }

/* Isot chipit (välineet) */
.d1-chips-lg .chip { min-height: 48px; padding: 0 var(--sp-4); font-size: var(--fs-md); }

/* Onboarding */
.d1-onb { padding-bottom: 0; }
.d1-onb__body { flex: 1 0 auto; padding-top: var(--sp-3); }
.d1-onb .onb__q { font-size: clamp(1.75rem, 8.4vw, var(--fs-3xl)); }
.d1-sec + .d1-sec { padding-top: var(--sp-2); border-top: 1px solid var(--line); }
.d1-sec .d1-subhead { padding-top: var(--sp-4); }
.d1-sport { background: var(--surface-1); }
.d1-ot { display: flex; flex-direction: column; gap: var(--sp-3); }
.d1-ot .field__label { font-size: var(--fs-xs); }
.d1-add { border-style: dashed; }
.d1-foot > .d1-back { flex: none; width: var(--touch-xl); }
.d1-foot > .d1-next { flex: 1; }
.d1-goal { min-height: 92px; }
.d1-goal .choice__icon { width: 52px; height: 52px; }
.d1-goal--fat_loss .choice__icon { color: var(--orange); }
.d1-goal--hypertrophy .choice__icon { color: var(--lime); }
.d1-goal--strength .choice__icon { color: var(--cyan); }
.d1-goal--sport .choice__icon { color: var(--magenta); }
.d1-goal:has(input:checked) .choice__icon { color: var(--text-on-accent); }
.d1-sumlist .list-row { min-height: 64px; }
.d1-sum-k { font-family: var(--font-mono); font-size: var(--fs-micro) !important; letter-spacing: var(--ls-caps); text-transform: uppercase; }
.d1-sum-v { font-weight: var(--fw-semi); line-height: 1.35; }
.d1-care .alert__icon { color: var(--lime); }

/* Ohjelman luonti */
.d1-creating { justify-content: center; }
.d1-creating__inner { display: flex; flex-direction: column; align-items: center; gap: var(--sp-6); width: 100%; max-width: 360px; margin: auto; padding: var(--sp-8) 0; }
.d1-creating__title { text-align: center; font-size: var(--fs-2xl); }
.d1-orb { position: relative; width: 140px; height: 140px; display: grid; place-items: center; }
.d1-orb .loader-orb { position: absolute; inset: 0; }
.d1-orb__core {
  width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--lime);
  box-shadow: var(--glow-soft); transition: transform var(--dur-slow) var(--ease-spring), background-color var(--dur-base);
}
.d1-orb__core .icon { filter: var(--dropglow-lime); }
.d1-orb.is-done .loader-orb { animation-duration: .9s; }
.d1-orb.is-done .d1-orb__core { background: var(--lime); color: var(--text-on-accent); transform: scale(1.08); box-shadow: var(--glow-lime); }
.d1-orb.is-error .loader-orb { animation: none; opacity: .3; }
.d1-orb.is-error .d1-orb__core { color: var(--red); }
.d1-creating__steps { list-style: none; margin: 0; padding: 0; width: 100%; display: flex; flex-direction: column; gap: var(--sp-3); }
.d1-creating__steps li {
  display: flex; align-items: center; gap: var(--sp-3); color: var(--text-muted); font-weight: var(--fw-medium);
  opacity: .5; transition: opacity var(--dur-base), color var(--dur-base);
}
.d1-creating__steps li.is-active, .d1-creating__steps li.is-done { opacity: 1; color: var(--text); }
.d1-creating__dot {
  width: 26px; height: 26px; flex: none; border-radius: 50%; display: grid; place-items: center;
  border: 2px solid var(--line-hi); color: transparent; transition: all var(--dur-base) var(--ease-spring);
}
.d1-creating__steps li.is-active .d1-creating__dot { border-color: var(--lime); box-shadow: 0 0 12px -2px rgba(182,255,59,.6); }
.d1-creating__steps li.is-done .d1-creating__dot { background: var(--lime); border-color: var(--lime); color: var(--text-on-accent); }
.d1-creating__msg { width: 100%; display: flex; flex-direction: column; gap: var(--sp-3); }

/* ---------- Profiili ---------- */
.d1-phero { display: flex; flex-direction: column; gap: var(--sp-4); }
.d1-phero__icon {
  width: 56px; height: 56px; flex: none; border-radius: var(--r-md); display: grid; place-items: center;
  background: var(--cyan-a10); color: var(--cyan); border: 1px solid rgba(39,232,255,.25);
}
.d1-phero__icon .icon { filter: var(--dropglow-cyan); }
.d1-phero__icon--magenta { background: var(--magenta-a10); color: var(--magenta); border-color: rgba(255,61,154,.25); }
.d1-phero__icon--magenta .icon { filter: var(--dropglow-magenta); }
.d1-phero__badges { --row-gap: var(--sp-2); }
.d1-acc { overflow: visible; }
.d1-acc__item { border-bottom: 1px solid var(--line); }
.d1-acc__item:last-child { border-bottom: 0; }
.d1-acc__item .list-row { border-bottom: 0; }
.d1-acc__chev .icon { transition: transform var(--dur-base) var(--ease-out); }
.d1-acc__item.is-open .d1-acc__chev .icon { transform: rotate(180deg); color: var(--lime); }
.d1-acc__item.is-open > .d1-acc__head { background: linear-gradient(90deg, var(--lime-a10), transparent 70%); }
.d1-acc__item.has-error .list-row__lead { background: var(--red-a10); color: var(--red); }
.d1-acc__panel { padding: var(--sp-2) var(--sp-4) var(--sp-5); animation: rise var(--dur-base) var(--ease-out) both; }
.d1-acc__inner .d1-sport { padding: var(--sp-4); }
.d1-danger .list-row__title { color: #FF8E99; }
.d1-profile.has-savebar { padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + var(--sp-8) + 116px); }
.d1-savebar {
  position: fixed; z-index: calc(var(--z-nav) - 1);
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--safe-bottom) + var(--nav-h) + 18px);
  width: min(calc(100% - 2 * var(--sp-3)), calc(var(--app-max-w) - 2 * var(--sp-3)));
  display: flex; flex-direction: column; gap: var(--sp-3);
  padding: var(--sp-3);
  background: var(--surface-glass);
  -webkit-backdrop-filter: blur(20px) saturate(1.6); backdrop-filter: blur(20px) saturate(1.6);
  border: 1px solid rgba(182,255,59,.3); border-radius: var(--r-lg);
  box-shadow: 0 20px 40px -10px rgba(0,0,0,.9), var(--glow-soft);
  animation: toast-in var(--dur-slow) var(--ease-spring) both;
}
.d1-savebar[hidden] { display: none; }
.d1-savebar__text { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); font-weight: var(--fw-semi); color: var(--lime); padding: 0 var(--sp-1); }
.d1-savebar .btn { min-height: 48px; }
.d1-about { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-3); }
.d1-about li { display: flex; gap: var(--sp-3); align-items: flex-start; font-size: var(--fs-sm); color: var(--text-2); }
.d1-about li .icon { margin-top: 2px; color: var(--text-muted); }

/* ---------- Ravinto ---------- */
.d1-nut-hero { display: flex; flex-direction: column; gap: var(--sp-5); }
.d1-nut-hero .card__header { margin-bottom: 0; align-items: flex-start; }
.d1-nut-ring { display: grid; place-items: center; }
.d1-macros { gap: var(--sp-2); }
.d1-macro { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); min-width: 0; }
.d1-macro__label {
  display: inline-flex; align-items: center; gap: 6px; min-height: var(--touch-min); max-width: 100%;
  font-size: var(--fs-xs); font-weight: var(--fw-semi); color: var(--text-2); padding: 0 var(--sp-1);
}
.d1-macro__label .icon { --icon-size: 14px; color: var(--text-muted); flex: none; }
.d1-minis { gap: var(--sp-2); }
.d1-mini { text-align: left; padding: var(--sp-3); min-width: 0; }
.d1-mini .stat__label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.d1-mini .stat__value { font-size: var(--fs-xl); }
.d1-sv-sm { font-size: var(--fs-xl) !important; }
.d1-tdee-total .num-md { font-size: var(--fs-2xl); }
.d1-stackbar {
  display: flex; height: 18px; border-radius: var(--r-pill); overflow: hidden; gap: 2px;
  background: var(--surface-3);
}
.d1-stackbar__seg {
  width: var(--w); min-width: 4px; background: linear-gradient(180deg, color-mix(in srgb, var(--c) 85%, #fff), var(--c));
  box-shadow: 0 0 14px -2px var(--c);
  transform-origin: left; animation: d1-grow var(--dur-chart) var(--ease-out) both; animation-delay: calc(var(--i) * 80ms);
}
@keyframes d1-grow { from { transform: scaleX(0); opacity: 0; } }
.d1-tdee-list .list-row { padding-left: 0; padding-right: 0; min-height: 52px; }
.d1-tdee-list .list-row__trail .icon { color: var(--text-faint); }
.d1-adjrow { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3); border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--line); }
.d1-adjrow .list-row__title { white-space: normal; }
.d1-adapt__main { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-3); }
.d1-adapt__main .stat__value { font-size: var(--fs-num-lg); }
.d1-suggest {
  display: flex; flex-direction: column; gap: var(--sp-3); padding: var(--sp-4); border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--lime-a10), transparent 70%), var(--surface-2);
  border: 1px solid rgba(182,255,59,.3);
}
.d1-suggest p { margin: 0; }
.d1-suggest__nums { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 4px; font-size: var(--fs-xl); }
.d1-suggest__nums .num { font-size: var(--fs-2xl); font-weight: var(--fw-heavy); }
.d1-suggest__nums .badge { margin-left: var(--sp-1); }
.d1-wstats { gap: var(--sp-2); }
.d1-wstats .stat__value { font-size: var(--fs-xl); }
.d1-wchart { margin: 0 calc(-1 * var(--sp-2)); }
.d1-legend-why { margin-left: auto; min-height: 32px; }
.d1-recent .list-row { padding-left: 0; padding-right: 0; min-height: 52px; }
.d1-recent .btn--icon { color: var(--text-muted); }
.d1-empty-sm { padding: var(--sp-6) var(--sp-4); }
.d1-food { display: flex; flex-direction: column; gap: var(--sp-3); }
.d1-food .list-row__title { white-space: normal; }
.d1-food__btn { min-height: 44px; }
.d1-care-card { align-items: flex-start; }

@media (prefers-reduced-motion: reduce) {
  .d1-stackbar__seg, .d1-acc__panel, .d1-savebar { animation: none !important; }
}

/* korjaukset kuvakaappausten perusteella */
.stepper__input:focus-visible { outline: none; box-shadow: none; }
.d1-tdee-list .list-row__title { white-space: normal; }
.d1-adapt__main { align-items: flex-start; }
.d1-adapt__main .stat__value small { font-size: .32em; }
