/* ==========================================================================
   Game — Habits (unit A). Prefix gm-hb-.
   ==========================================================================
   Tokens only. A habit's colour is a token name set as --hb-c on the element
   (var(--accent), var(--good), …), so palette presets recolour it. Empty
   heat-map cells use --heat-0, the Fitness grid's own empty step; the defeat
   map deepens through --critical.                                          */

.gm-hb { gap: 18px; }

.gm-hb-bar { display: flex; align-items: center; gap: 10px; }
.gm-hb-bar .gm-seg { flex: 1; max-width: 360px; }
.gm-hb-new { display: inline-flex; align-items: center; gap: 5px; margin-left: auto; }
.gm-hb .section-head .note { flex: 1 1 auto; }

.gm-hb-cards { display: grid; gap: 12px; }
@media (min-width: 700px) { .gm-hb-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .gm-hb-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.gm-hb-card { display: flex; flex-direction: column; gap: 12px; }

.gm-hb-head { display: flex; align-items: center; gap: 11px; min-width: 0; }
.gm-hb-ico {
  width: 38px; height: 38px; flex: none; border-radius: 11px;
  display: grid; place-items: center;
  color: var(--hb-c, var(--accent));
  background: color-mix(in srgb, var(--hb-c, var(--accent)) 14%, transparent);
}
.gm-hb-ico.sm { width: 28px; height: 28px; border-radius: 8px; }
.gm-hb-name-wrap { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.gm-hb-name {
  appearance: none; background: none; border: 0; padding: 0; text-align: left; cursor: pointer;
  font: inherit; font-size: 16px; font-weight: 600; color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
div.gm-hb-name { cursor: default; font-size: 18px; }
.gm-hb-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }

.gm-hb-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.gm-hb-act { display: inline-flex; align-items: center; gap: 5px; min-width: 92px; justify-content: center; }
.gm-hb-act.bad { color: var(--critical); border-color: color-mix(in srgb, var(--critical) 40%, transparent); background: none; }
.gm-hb-act.bad:hover { background: color-mix(in srgb, var(--critical) 12%, transparent); }
.gm-hb-act.done:disabled { opacity: 1; color: var(--good-text); background: color-mix(in srgb, var(--good-text) 12%, transparent); border-color: transparent; cursor: default; }

/* LiFE RPG's status line, in the mono voice: "✗ To be grown today · 🔥 7". */
.gm-hb-status { display: flex; align-items: center; gap: 6px; font-family: var(--s-mono); font-size: 11.5px; }
.gm-hb-pill { padding: 3px 7px; border-radius: 5px; white-space: nowrap; }
.gm-hb-pill.lost { color: var(--critical); background: color-mix(in srgb, var(--critical) 12%, transparent); }
.gm-hb-pill.won  { color: var(--good-text); background: color-mix(in srgb, var(--good-text) 12%, transparent); }
.gm-hb-dot { color: var(--text-muted); }
.gm-hb-clean { color: var(--text-secondary); white-space: nowrap; }
.gm-hb-flame {
  display: inline-flex; align-items: center; gap: 3px; white-space: nowrap;
  font-family: var(--s-mono); font-size: 11.5px; font-variant-numeric: tabular-nums;
  color: var(--serious); padding: 3px 7px; border-radius: 5px;
  background: color-mix(in srgb, var(--serious) 12%, transparent);
}
.gm-hb-flame.cold { color: var(--text-muted); background: var(--surface-2); }

/* --- heat map: one month, ISO-week rows, Monday first ------------------------ */

.gm-hb-month { display: flex; flex-direction: column; gap: 8px; }
.gm-hb-month-t {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--text-secondary);
}
.gm-hb-month-t::before, .gm-hb-month-t::after { content: ""; flex: 1; border-top: 1px dashed var(--border-strong); }
.gm-hb-map {
  display: grid; grid-template-columns: 38px repeat(7, minmax(0, 1fr));
  gap: 4px; max-width: 290px; width: 100%; align-self: center;
}
.gm-hb-wk, .gm-hb-dow {
  font-family: var(--s-mono); font-size: 10.5px; color: var(--text-muted);
  display: grid; place-items: center; border-radius: 5px;
}
.gm-hb-wk { background: var(--surface-2); }
.gm-hb-dow { height: 18px; }
.gm-hb-cell {
  aspect-ratio: 1; border-radius: 5px; background: var(--heat-0);
  display: grid; place-items: center;
}
.gm-hb-cell i { width: 42%; height: 42%; border-radius: 2px; }
.gm-hb-cell.out { visibility: hidden; }
.gm-hb-cell.future { opacity: 0.45; }
.gm-hb-cell.today { box-shadow: inset 0 0 0 1.5px var(--text-muted); }
.gm-hb-cell.on { background: color-mix(in srgb, var(--hb-c, var(--accent)) 20%, var(--heat-0)); }
.gm-hb-cell.on i { background: var(--hb-c, var(--accent)); }
.gm-hb-cell.on.auto i { background: none; box-shadow: inset 0 0 0 2px var(--hb-c, var(--accent)); border-radius: 50%; }
.gm-hb-cell.on.repair i {
  background: repeating-linear-gradient(45deg, var(--hb-c, var(--accent)) 0 2px, transparent 2px 4px);
}
.gm-hb-cell.slip i { background: var(--critical); }
.gm-hb-cell[data-l="1"] { background: color-mix(in srgb, var(--critical) 16%, var(--heat-0)); }
.gm-hb-cell[data-l="2"] { background: color-mix(in srgb, var(--critical) 30%, var(--heat-0)); }
.gm-hb-cell[data-l="3"] { background: color-mix(in srgb, var(--critical) 46%, var(--heat-0)); }
.gm-hb-card.bad .gm-hb-map, .gm-hb-page-head.bad .gm-hb-map { --hb-c: var(--critical); }

.gm-hb-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 12px; justify-content: center; }
.gm-hb-legend .gm-hb-cell { width: 16px; }

.gm-hb-pager { align-items: center; }
.gm-hb-pager h2 { flex: 1; text-align: center; }
.gm-hb-pager .icon-btn { font-size: 20px; line-height: 1; }

/* --- statistics -------------------------------------------------------------- */

.gm-hb-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 440px) { .gm-hb-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.gm-hb-stat {
  display: flex; flex-direction: column; gap: 3px; padding: 11px 12px;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius);
}
.gm-hb-stat-n {
  font-family: var(--s-value-f); font-weight: var(--s-value-w, 600); font-size: 24px;
  font-variant-numeric: tabular-nums; line-height: 1.1;
}
.gm-hb-stat-n .gm-hb-flame { font-size: 20px; padding: 2px 8px; }
.gm-hb-stat-sub { font-size: 11.5px; color: var(--text-muted); }

.gm-hb-log .gm-feed-chips { align-items: center; }
.gm-hb-archived { line-height: 1.8; }

/* --- editor ------------------------------------------------------------------- */

.gm-hb-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.gm-hb-swatches button {
  appearance: none; width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
  background: var(--hb-c); border: 2px solid var(--surface-1);
  box-shadow: 0 0 0 1px var(--border);
}
.gm-hb-swatches button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--text-primary); }

/* --- Black Market --------------------------------------------------------------- */

.gm-hb-bm-note { margin-bottom: 10px; line-height: 1.5; }
.gm-hb-bm-coins { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.gm-hb-bm { display: flex; flex-direction: column; }
.gm-hb-bm-row {
  display: grid; grid-template-columns: 28px minmax(0, 1fr) auto auto;
  gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--grid);
  font-size: 14px;
}
.gm-hb-bm-row:last-child { border-bottom: 0; }
.gm-hb-bm-what { min-width: 0; }
.gm-hb-bm-what > div:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gm-hb-buy { display: inline-flex; align-items: center; }
.gm-hb-buy .gm-coins { color: var(--warning); }

/* --- hub card ------------------------------------------------------------------- */

.gm-hb-hub { display: flex; flex-direction: column; gap: 4px; }
.gm-hb-hub-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.gm-hb-hub-count { font-family: var(--s-mono); font-size: 11.5px; color: var(--text-secondary); }
.gm-hb-hub-head .gm-link { margin-left: auto; }
.gm-hb-hub-row {
  display: grid; grid-template-columns: 28px minmax(0, 1fr) auto 40px;
  gap: 10px; align-items: center; padding: 6px 0; border-top: 1px solid var(--grid);
}
.gm-hb-hub-name {
  appearance: none; background: none; border: 0; padding: 0; cursor: pointer; text-align: left;
  font: inherit; font-size: 14.5px; color: var(--text-primary);
  display: flex; align-items: baseline; gap: 7px; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.gm-hb-hub-row.done .gm-hb-hub-name { color: var(--text-secondary); }
.gm-hb-auto {
  font-family: var(--s-mono); font-size: 9.5px; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--text-muted);
}
/* The one-tap tick: an empty ring, filled in the habit's colour once grown. */
.gm-hb-tick {
  appearance: none; width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; justify-self: end;
  color: transparent; background: none;
  border: 2px solid color-mix(in srgb, var(--hb-c, var(--accent)) 55%, var(--border-strong));
  transition: background 0.15s ease, transform 0.12s ease;
}
.gm-hb-tick:hover { color: color-mix(in srgb, var(--hb-c, var(--accent)) 45%, transparent); }
.gm-hb-tick:active { transform: scale(0.92); }
.gm-hb-tick.on { background: var(--hb-c, var(--accent)); border-color: var(--hb-c, var(--accent)); color: var(--surface-1); }
.gm-hb-tick.locked { cursor: default; opacity: 0.8; }
.gm-hb-tick:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- settings ------------------------------------------------------------------- */

.gm-hb-defaults { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.gm-hb-sub-title { margin-top: 6px; }
.gm-hb-sugg { display: flex; flex-direction: column; gap: 2px; }
.gm-hb-sugg-row {
  display: grid; grid-template-columns: 18px auto minmax(0, 1fr) auto;
  gap: 8px; align-items: center; font-size: 14px; color: var(--text-primary);
}
.gm-hb-sugg-row svg { color: var(--accent); }
.gm-hb-sugg-row .hint { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  .gm-hb-tick { transition: none; }
  .gm-hb-tick:active { transform: none; }
}
