/**
 * Dayly — Today dashboard polish.
 *
 * Extends the existing visual language: same charcoal surfaces, same accent,
 * same rounded cards. No new design system.
 */

/* ---------------------------------------------------------------------------
 * Insight strip — one short, data-derived line above the cards.
 * ------------------------------------------------------------------------- */

.insight {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  background: var(--surface-1);
  border-radius: var(--radius-md);
  /* A quiet left edge carries the tone; the text says the same thing, so
   * nothing depends on colour alone. */
  border-left: 3px solid var(--border-strong);
}

.insight--good,
.insight--done { border-left-color: var(--success); }
.insight--attention { border-left-color: var(--warning); }

.insight__icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text-secondary);
}

.insight--good .insight__icon,
.insight--done .insight__icon { background: var(--success-soft); color: var(--success); }
.insight--attention .insight__icon { background: var(--warning-soft); color: var(--warning); }

.insight__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.insight__title {
  font-size: var(--text-small);
  font-weight: var(--weight-semibold);
}

.insight__body {
  font-size: var(--text-small);
  color: var(--text-secondary);
}

/* ---------------------------------------------------------------------------
 * Still left today
 * ------------------------------------------------------------------------- */

.left-group + .left-group {
  margin-top: var(--space-5);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border);
}

.left-group__title {
  font-size: var(--text-caption);
  font-weight: var(--weight-semibold);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  margin-bottom: var(--space-3);
}

/* --- Quantitative remaining --- */
.left-metrics {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: var(--space-3);
}

.left-metric {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-3);
  background: var(--surface-2);
  border-radius: var(--radius-md);
}

.left-metric__top {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  min-height: 26px;
}

.left-metric__amount {
  font-size: var(--text-body);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
}

.left-metric__unit {
  font-size: var(--text-caption);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
}

.left-metric__label {
  font-size: var(--text-caption);
  color: var(--text-secondary);
}

.left-metric__bar {
  display: block;
  height: 3px;
  margin-top: var(--space-1);
  border-radius: var(--radius-pill);
  background: var(--track);
  overflow: hidden;
}

.left-metric__fill {
  display: block;
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width var(--duration-slow) var(--ease-out);
}

/* Met targets read as quietly done — a tick plus words, never a red state. */
.left-metric.is-met { background: var(--success-soft); }
.left-metric.is-met .left-metric__amount { color: var(--success); font-size: var(--text-small); }
.left-metric__tick { color: var(--success); font-weight: var(--weight-bold); }

/* --- Outstanding habits --- */
.left-habits {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* Tappable: completing a habit from here saves a trip to the Habits card. */
.left-habit {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 40px;
  padding: var(--space-2) var(--space-4) var(--space-2) var(--space-3);
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border-strong);
  background: var(--surface-2);
  font-size: var(--text-small);
  color: var(--text);
  transition: background var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
}

.left-habit:hover {
  background: var(--surface-3);
  border-color: var(--accent);
}

.left-habit:active { transform: scale(0.98); }

.left-habit__box {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1.5px solid var(--text-tertiary);
}

.left-habit:hover .left-habit__box { border-color: var(--accent); }

/* --- Completion state --- */
.day-done {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-2) 0;
}

.day-done__icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: var(--radius-pill);
  background: var(--success-soft);
  color: var(--success);
}

.day-done__title {
  font-size: var(--text-body);
  font-weight: var(--weight-semibold);
}

.day-done__body {
  font-size: var(--text-small);
  color: var(--text-secondary);
}

/* ---------------------------------------------------------------------------
 * Weight stats and goal bar
 * ------------------------------------------------------------------------- */

.wt-stats {
  list-style: none;
  margin: var(--space-4) 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-5);
}

.wt-stats li {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.wt-stats__value {
  font-size: var(--text-small);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
}

.wt-stats__label {
  font-size: var(--text-caption);
  color: var(--text-tertiary);
}

/* Movement toward the goal is highlighted; movement away is simply neutral,
   never alarming. The arrow in the text carries the direction regardless. */
.wt-stats li.is-good .wt-stats__value { color: var(--success); }
.wt-stats li.is-neutral .wt-stats__value { color: var(--text-secondary); }

.goal-bar { margin-top: var(--space-5); }

.goal-bar__track {
  position: relative;
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--track);
}

.goal-bar__fill {
  display: block;
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--accent);
  transition: width var(--duration-slow) var(--ease-out);
}

.goal-bar__marker {
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface-1);
  transform: translate(-50%, -50%);
  transition: left var(--duration-slow) var(--ease-out);
}

.goal-bar__ends {
  display: flex;
  justify-content: space-between;
  margin-top: var(--space-2);
  font-size: var(--text-caption);
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------------------
 * Responsive
 * ------------------------------------------------------------------------- */

@media (max-width: 639px) {
  /* Hero ring shrinks so the date and greeting stay on one line. */
  .today-hero { gap: var(--space-4); }
  .today-hero__ring { transform: scale(0.82); transform-origin: right center; }

  /* Two stat tiles per row reads better than four cramped ones. */
  .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* Keep "still left" compact rather than one tall column. */
  .left-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .macro-rings { gap: var(--space-3); }

  .wt-stats { gap: var(--space-4); }
}

/* Very narrow phones: let the water buttons breathe instead of clipping. */
@media (max-width: 380px) {
  .water-actions { flex-wrap: wrap; }
  .water-actions .btn { flex: 1 1 40%; }
  .water-actions .btn--quiet { flex: 0 0 100%; }
}

/* ---------------------------------------------------------------------------
 * Today layout — two independently flowing columns.
 *
 * A normal two-column grid puts each pair of cards in a shared row, so a short
 * card cannot rise into the space left by a tall neighbour: with Habits taller
 * than Water, Body was pinned to the next row boundary and the left column got
 * a dead region. `align-items: start` stops the stretch but not the row.
 *
 * Two explicit column containers, each a flex column, remove rows entirely.
 * Each column stacks on its own, so Body sits directly beneath Water no matter
 * how tall Habits grows.
 * ------------------------------------------------------------------------- */

.today-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.today-cols {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.today-col {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}

@media (min-width: 640px) {
  .today-cols {
    flex-direction: row;
    align-items: flex-start;
  }

  .today-col {
    flex: 1 1 0;
    min-width: 0;
  }
}

/* Mobile: one column in order of daily usefulness. `display: contents` lifts
 * the cards out of their column wrappers so they can be ordered against each
 * other; the wrappers are purely presentational, so nothing semantic is lost. */
@media (max-width: 639px) {
  .today-col { display: contents; }

  .today-order-1 { order: 1; }
  .today-order-2 { order: 2; }
  .today-order-3 { order: 3; }
  .today-order-4 { order: 4; }
}
