/* ==========================================================================
   components.css — reusable pieces. No screen-specific layout lives here.
   ========================================================================== */

/* --- Card ---------------------------------------------------------------- */

.card {
  background: var(--c-surface);
  border: 1px solid var(--c-line-soft);
  border-radius: var(--r-lg);
  padding: var(--s-5);
}
.card--tight  { padding: var(--s-4); }
.card--flush  { padding: 0; overflow: hidden; }
.card--quiet  { background: transparent; border-color: var(--c-line); }
.card--accent { border-color: var(--c-brass-dim); }

.card__head { display: flex; align-items: flex-start; justify-content: space-between;
              gap: var(--s-3); margin-bottom: var(--s-3); }

/* Tappable card */
.card[role="button"], a.card, button.card { width: 100%; text-align: left;
  transition: transform var(--d-fast) var(--e-out), background var(--d-fast) var(--e-out); }
.card[role="button"]:active, button.card:active { transform: scale(0.985);
  background: var(--c-surface-2); }

/* --- Buttons ------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 52px;
  padding: 0 var(--s-6);
  border-radius: var(--r-md);
  font-size: var(--t-lead);
  font-weight: 620;
  letter-spacing: -0.01em;
  background: var(--c-surface-2);
  color: var(--c-bone);
  border: 1px solid var(--c-line);
  transition: transform var(--d-fast) var(--e-out), opacity var(--d-fast) var(--e-out);
}
.btn:active { transform: scale(0.97); }
.btn[disabled] { opacity: .38; pointer-events: none; }
.btn--block { width: 100%; }
.btn--primary {
  background: var(--c-brass);
  border-color: var(--c-brass);
  color: #14110A;
}
.btn--ghost { background: transparent; border-color: var(--c-line); }
.btn--bare  { background: none; border: 0; min-height: 44px; padding: 0 var(--s-2);
              color: var(--c-brass); font-size: var(--t-body); }
.btn--danger { color: var(--c-clay); border-color: var(--c-line); }
@supports (color: color-mix(in srgb, red 50%, transparent)) {
  .btn--danger { border-color: color-mix(in srgb, var(--c-clay) 40%, transparent); }
}
.btn--sm { min-height: 40px; font-size: var(--t-small); padding: 0 var(--s-4); }

/* Sticky action dock at the bottom of immersive screens */
.dock {
  position: sticky;
  bottom: 0;
  margin: var(--s-6) calc(var(--s-4) * -1) 0;
  padding: var(--s-4) var(--s-4) calc(var(--safe-b) + var(--s-4));
  /* Fades the page out behind the primary action without a hard edge. */
  background: linear-gradient(to top, var(--c-ink) 62%, transparent);
}
.dock .btn + .btn { margin-top: var(--s-2); }

/* --- Progress ring -------------------------------------------------------- */

.ring { position: relative; display: grid; place-items: center; }
.ring svg { transform: rotate(-90deg); }
.ring__track { stroke: var(--c-line); fill: none; }
.ring__fill  { stroke: var(--c-brass); fill: none; stroke-linecap: round;
               transition: stroke-dashoffset var(--d-slow) var(--e-out); }
.ring__label { position: absolute; text-align: center; line-height: 1.1; }

/* --- Linear progress ------------------------------------------------------ */

.bar { height: 4px; border-radius: 2px; background: var(--c-line); overflow: hidden; }
.bar__fill { height: 100%; background: var(--c-brass); border-radius: 2px;
             transition: width var(--d-base) var(--e-out); }
.bar--sage .bar__fill { background: var(--c-sage); }

/* --- Chips / pills -------------------------------------------------------- */

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px;
  border-radius: var(--r-pill);
  background: var(--c-surface-2);
  border: 1px solid var(--c-line);
  font-size: var(--t-caption);
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--c-bone-2);
  white-space: nowrap;
}
.chip--brass { color: var(--c-brass); border-color: var(--c-brass-dim);
               background: var(--c-brass-wash); }
.chip--sage  { color: var(--c-sage); border-color: var(--c-line);
               background: var(--c-surface-2); }
.chip--clay  { color: var(--c-clay); border-color: var(--c-line);
               background: var(--c-surface-2); }
@supports (color: color-mix(in srgb, red 50%, transparent)) {
  .chip--sage { border-color: color-mix(in srgb, var(--c-sage) 40%, transparent);
                background: color-mix(in srgb, var(--c-sage) 12%, transparent); }
  .chip--clay { border-color: color-mix(in srgb, var(--c-clay) 40%, transparent);
                background: color-mix(in srgb, var(--c-clay) 12%, transparent); }
}

.chiprow { display: flex; flex-wrap: wrap; gap: var(--s-2); }

/* --- List rows ------------------------------------------------------------ */

.list { border: 1px solid var(--c-line-soft); border-radius: var(--r-lg);
        overflow: hidden; background: var(--c-surface); }
.list__row {
  display: flex; align-items: center; gap: var(--s-3);
  width: 100%;
  min-height: 56px;
  padding: var(--s-3) var(--s-4);
  text-align: left;
  border-bottom: 1px solid var(--c-line-soft);
}
.list__row:last-child { border-bottom: 0; }
.list__row:active { background: var(--c-surface-2); }
.list__row .chev { color: var(--c-bone-3); flex: none; }

/* --- Inputs --------------------------------------------------------------- */

.field { display: block; }
.field__label { display: block; margin-bottom: var(--s-2); }
.input, select.input, textarea.input {
  width: 100%;
  min-height: 52px;
  padding: var(--s-3) var(--s-4);
  background: var(--c-surface-2);
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
  color: var(--c-bone);
  font-size: var(--t-lead);
  font-family: inherit;
  appearance: none;
}
textarea.input { min-height: 96px; padding-top: var(--s-3); resize: vertical; line-height: 1.45; }
.input::placeholder { color: var(--c-bone-3); }
.input:focus { outline: none; border-color: var(--c-brass-dim); }

/* Numeric stepper — the primary weight/RPE control. Huge targets on purpose. */
.stepper { display: flex; align-items: stretch; gap: var(--s-2); }
.stepper__btn {
  flex: none; width: 56px;
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
  background: var(--c-surface-2);
  font-size: 1.4rem; font-weight: 500; color: var(--c-bone);
  display: grid; place-items: center;
}
.stepper__btn:active { background: var(--c-surface-3); }
.stepper__value {
  flex: 1;
  display: flex; align-items: baseline; justify-content: center; gap: 4px;
  padding: var(--s-3) var(--s-2);
  background: var(--c-surface-2);
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
}
.stepper__value input {
  width: 100%; text-align: center; background: none; border: 0; color: var(--c-bone);
  font-family: var(--font-num); font-size: var(--t-display); font-weight: 640;
  font-variant-numeric: tabular-nums;
}
.stepper__value input:focus { outline: none; }
.stepper__unit { font-size: var(--t-small); color: var(--c-bone-3); }

/* Segmented scale, 1–5 and RPE 1–10 */
.scale { display: grid; gap: var(--s-2); }
.scale--5  { grid-template-columns: repeat(5, 1fr); }
.scale--10 { grid-template-columns: repeat(5, 1fr); }
.scale__opt {
  min-height: 48px;
  border: 1px solid var(--c-line);
  border-radius: var(--r-sm);
  background: var(--c-surface-2);
  font-family: var(--font-num);
  font-size: var(--t-lead);
  font-weight: 620;
  color: var(--c-bone-2);
  font-variant-numeric: tabular-nums;
}
.scale__opt[aria-pressed="true"] {
  background: var(--c-brass); border-color: var(--c-brass); color: #14110A;
}
.scale__ends { display: flex; justify-content: space-between; margin-top: var(--s-2); }

/* Segmented control */
.segmented {
  display: flex; padding: 3px; gap: 3px;
  background: var(--c-surface-2); border: 1px solid var(--c-line);
  border-radius: var(--r-md);
}
.segmented__opt {
  flex: 1; min-height: 42px; border-radius: calc(var(--r-md) - 4px);
  font-size: var(--t-small); font-weight: 620; color: var(--c-bone-2);
}
.segmented__opt[aria-pressed="true"] { background: var(--c-surface-3); color: var(--c-bone); }

/* Checkbox row (setup lists, habits) */
.check {
  display: flex; align-items: center; gap: var(--s-3);
  width: 100%; min-height: 52px; padding: var(--s-2) var(--s-4);
  text-align: left; border-bottom: 1px solid var(--c-line-soft);
}
.check:last-child { border-bottom: 0; }
.check__box {
  flex: none; width: 24px; height: 24px; border-radius: 7px;
  border: 1.5px solid var(--c-line); display: grid; place-items: center;
  transition: background var(--d-fast) var(--e-out), border-color var(--d-fast) var(--e-out);
}
.check__box svg { width: 14px; height: 14px; stroke: #14110A; stroke-width: 3;
                  fill: none; stroke-linecap: round; stroke-linejoin: round;
                  opacity: 0; transition: opacity var(--d-fast); }
.check[aria-checked="true"] .check__box { background: var(--c-brass); border-color: var(--c-brass); }
.check[aria-checked="true"] .check__box svg { opacity: 1; }
.check[aria-checked="true"] .check__text { color: var(--c-bone-3); }

/* --- Sheet (bottom modal) -------------------------------------------------- */

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(3px);
  animation: fadeIn var(--d-fast) var(--e-out);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: var(--wrap);
  max-height: 88vh; overflow-y: auto;
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-bottom: 0;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: var(--s-3) var(--s-5) calc(var(--safe-b) + var(--s-6));
  animation: sheetUp var(--d-base) var(--e-out);
}
@keyframes sheetUp { from { transform: translateY(24px); opacity: .6 } to { transform: none; opacity: 1 } }
.sheet__grip { width: 36px; height: 4px; border-radius: 2px; background: var(--c-line);
               margin: 0 auto var(--s-4); }

/* --- Toast ---------------------------------------------------------------- */

.toast {
  position: fixed; z-index: 80;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + var(--safe-b) + var(--s-4));
  padding: var(--s-3) var(--s-5);
  background: var(--c-surface-3);
  border: 1px solid var(--c-line);
  border-radius: var(--r-pill);
  font-size: var(--t-small); font-weight: 600;
  box-shadow: var(--shadow-2);
  animation: riseIn var(--d-base) var(--e-out);
}

/* --- Figure (exercise illustration) ---------------------------------------- */

.figure {
  background: var(--c-surface-2);
  border: 1px solid var(--c-line-soft);
  border-radius: var(--r-md);
  overflow: hidden;
}
.figure svg { width: 100%; height: auto; display: block; }
.figure__stroke  { stroke: var(--fig-body); fill: none; stroke-width: 3.2;
                   stroke-linecap: round; stroke-linejoin: round; }
.figure__head    { fill: var(--fig-body); }
.figure__ground  { stroke: var(--fig-ground); stroke-width: 2; stroke-linecap: round; }
.figure__prop    { fill: var(--fig-accent); }
.figure__propline{ stroke: var(--fig-accent); stroke-width: 3; fill: none; stroke-linecap: round; }

/* --- The spine: session progress rail. The app's signature element. --------
   A hairline column of ticks, one per exercise, that fills top-to-bottom as
   the session runs. It is the printed page's numbered exercise list, standing
   up. Always visible, never in the way.                                      */

.spine {
  position: fixed;
  left: 6px; top: calc(var(--safe-t) + 76px);
  bottom: calc(var(--safe-b) + 96px);
  width: 14px;
  display: flex; flex-direction: column; gap: 3px;
  z-index: 10;
  pointer-events: none;
}
.spine__tick {
  flex: 1; min-height: 2px;
  border-radius: 1px;
  background: var(--c-line);
  transition: background var(--d-base) var(--e-out), transform var(--d-base) var(--e-out);
  transform-origin: left center;
}
.spine__tick--done    { background: var(--c-brass-dim); }
.spine__tick--current { background: var(--c-brass); transform: scaleX(1.9); }
.spine__tick--break   { background: transparent;
                        border-top: 1px dashed var(--c-line); border-radius: 0; }

@media (max-width: 380px) { .spine { display: none; } }

/* --- Charts (hand-rolled SVG) ---------------------------------------------- */

.chart { width: 100%; }
.chart__grid { stroke: var(--c-line-soft); stroke-width: 1; }
.chart__line { fill: none; stroke: var(--c-brass); stroke-width: 2;
               stroke-linecap: round; stroke-linejoin: round; }
.chart__line--soft { stroke: var(--c-bone-3); stroke-width: 1.5; stroke-dasharray: 3 3; }
.chart__area { fill: var(--c-brass-wash); stroke: none; }
.chart__dot  { fill: var(--c-brass); }
.chart__bar  { fill: var(--c-brass-dim); }
.chart__label{ fill: var(--c-bone-3); font-size: 10px; font-family: var(--font-sans); }

/* --- Empty state ----------------------------------------------------------- */

.empty { text-align: center; padding: var(--s-12) var(--s-5); }
.empty__title { margin-bottom: var(--s-2); }
