/* Jengo Home portal — React (static/home.js) mounted into #home-mount inside
   #tab-study. Replaces the legacy non-React #study-landing launcher cards and
   the New/Today/Learning/Tomorrow #stats-bar. Forest notebook system, tokens
   only (docs/DESIGN.md). All selectors scoped under #home-mount.

   Layout: a top "Coming up" box (combined reader+flashcard review forecast,
   next 7 days) over three mode cards. The Reader/Flashcards cards each carry
   their OWN progress bar (Due then New); Listening keeps a compact stat. */

#home-mount { display: block; }

.hm {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  max-width: var(--home-col-w, 640px);
  margin: 0 auto;
  /* Just a breathing pad — the .tab-content scroll host is ALREADY inset above
     the nav (style.css: bottom = nav-h + sab). Re-adding the nav inset here
     double-counted it: ~65px of dead space that pushed the landing into a
     needless scroll. Removing it lets the page fit the viewport (it scrolls
     only when a device is genuinely too short). */
  padding-bottom: 1rem;
}

/* ── Coming-up box (combined review forecast) ───────────────────────────── */
.hm-forecast {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  padding: 0.85rem 1rem 0.9rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03), 0 4px 16px rgba(0, 0, 0, 0.04);
}
.hm-fc-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}
.hm-fc-label {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.hm-fc-summary {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-secondary);
}

/* one contained column chart: bars sit in faint slot tracks separated by hair
   gaps, all resting on a shared baseline — reads as a single plot, not a row of
   floating ticks. count above each slot, weekday letter below. */
.hm-fc-bars {
  display: flex;
  align-items: stretch;
  gap: 3px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-light, var(--color-border));
  border-radius: 10px;
  padding: 0.5rem 0.5rem 0.4rem;
}
.hm-fc-bars.is-loading { opacity: 0.4; min-height: 64px; }
.hm-fc-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.hm-fc-num {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--color-text-secondary);
  line-height: 1;
}
.hm-fc-col.is-zero .hm-fc-num { color: var(--color-text-muted); opacity: 0.55; }
.hm-fc-col.is-today .hm-fc-num { color: var(--brand); }
.hm-fc-track {
  width: 100%;
  height: 38px;
  display: flex;
  align-items: flex-end;
  /* faint slot so empty days read as part of the chart, not a gap */
  background: color-mix(in oklab, var(--color-text-muted) 7%, transparent);
  border-radius: 5px 5px 3px 3px;
  overflow: hidden;
}
.hm-fc-bar {
  width: 100%;
  height: var(--h, 2%);
  border-radius: 5px 5px 0 0;
  background: color-mix(in oklab, var(--brand) 38%, var(--color-surface));
  transition: height 0.4s cubic-bezier(.2, .7, .2, 1);
}
.hm-fc-col.is-zero .hm-fc-bar { background: transparent; }
.hm-fc-col.is-today .hm-fc-bar { background: var(--brand); }
.hm-fc-dow {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.hm-fc-col.is-today .hm-fc-dow { color: var(--brand); }

/* ── Metric bar (embedded inside a mode card) ───────────────────────────── */
.hm-bar {
  display: flex;
  align-items: stretch;
  height: 34px;
  border-radius: 9px;
  overflow: hidden;
  border: 1px solid var(--color-border-light, var(--color-border));
  background: var(--color-surface);
}
.hm-bar.is-loading {
  opacity: 0.55;
}
.hm-block {
  --c: var(--brand);
  position: relative;
  flex: var(--w, 1) 1 0;
  min-width: 60px;
  overflow: hidden;
  /* subtle hatch = work still owed */
  background:
    repeating-linear-gradient(135deg,
      color-mix(in oklab, var(--c) 13%, transparent) 0 6px,
      transparent 6px 12px),
    var(--color-surface);
}
/* clean seam between adjacent segments (one continuous bar) */
.hm-block + .hm-block { border-left: 1.5px solid var(--color-bg); }
.hm-block-fill {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: var(--fill, 0%);
  background: color-mix(in oklab, var(--c) 12%, white);
  transition: width 0.45s cubic-bezier(.2, .7, .2, 1);
}
.hm-block-label {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0 0.6rem;
  line-height: 1;
  color: color-mix(in oklab, var(--c) 48%, var(--color-text-secondary));
}
.hm-block-num { font-size: 0.86rem; font-weight: 700; }
.hm-block-tag {
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.75;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* completed segment: a solid, saturated fill so a finished bar reads as done
   at a glance — not the pale 12% tint. Label flips to white for contrast. */
.hm-block.is-done { background: color-mix(in oklab, var(--c) 62%, white); }
.hm-block.is-done .hm-block-fill { display: none; }
.hm-block.is-done .hm-block-label { color: #fff; }
.hm-block.is-done .hm-block-tag { opacity: 0.85; }
.hm-block.is-empty {
  --c: var(--brand);
  background: color-mix(in oklab, var(--brand) 8%, var(--color-surface));
}
.hm-block.is-empty .hm-block-label { justify-content: flex-start; }

/* ── Mode cards ─────────────────────────────────────────────────────────── */
.hm-cards {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.hm-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  padding: 0.85rem 1rem 0.9rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03), 0 4px 16px rgba(0, 0, 0, 0.04);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.hm-card:hover {
  border-color: color-mix(in oklab, var(--brand) 30%, var(--color-border));
}
.hm-card:active { transform: scale(0.985); }
.hm-card:hover .hm-card-chev { color: var(--color-text-secondary); transform: translateX(2px); }
.hm-card-head {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}
.hm-card-icon {
  flex: none;
  width: 42px; height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  background: color-mix(in oklab, var(--orange) 12%, white);
  color: var(--orange);
}
.hm-card-icon svg { width: 22px; height: 22px; }
.hm-card-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.hm-card-title {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--color-text-primary, var(--color-text-secondary));
}
.hm-card-meta {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hm-card-stat {
  --c: var(--brand);
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1;
}
.hm-card-stat-num { font-size: 1.4rem; font-weight: 700; color: var(--c); }
.hm-card-stat-unit {
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-top: 3px;
}
.hm-card-chev {
  flex: none;
  width: 18px; height: 18px;
  color: var(--color-text-muted);
  transition: transform 0.15s ease, color 0.15s ease;
}
.hm-training-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--color-border-light, var(--color-border));
}
.hm-training-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.hm-training-title {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--color-text-primary);
}
.hm-training-meta {
  font-size: 0.74rem;
  color: var(--color-text-muted);
}
.hm-training-btn {
  flex: none;
  border: none;
  border-radius: 999px;
  background: var(--brand);
  color: var(--color-bg);
  padding: 0.42rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}
.hm-training-btn:hover { opacity: 0.92; }

/* No entry animation: the landing should feel like hardware — present and
   solid the instant it renders, not painting itself in. The cards come alive
   through tactile press feedback (.hm-card:active), the live counts in each
   embedded bar, and the streak/sparkline up top; the motion budget lives on
   the mode-open transition instead. */
@media (prefers-reduced-motion: reduce) {
  .hm-block-fill, .hm-fc-bar, .hm-card-chev { transition: none; }
}
