/* Habit tracker widget: a row of tick boxes per habit. Tokens from _shared/embed.css. */

.hb {
  --name-w: min(7.5em, 30%);
  --streak-w: 0px;

  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.35em;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0 2%;
  font-size: clamp(9px, min(4vw, 7.5vh), 20px);
}

.hb--month {
  --name-w: min(6em, 18%);
  font-size: clamp(7px, min(1.75vw, 6vh), 14px);
}

.hb--streaks {
  --streak-w: 3em;
}

.hb-title {
  flex: none;
  overflow: hidden;
  color: var(--fg);
  font-size: 1.05em;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hb-grid {
  display: flex;
  flex: 0 1 auto;
  flex-direction: column;
  gap: 0.3em;
  min-height: 0;
}

.hb-row {
  display: grid;
  grid-template-columns: var(--name-w) repeat(var(--days, 7), minmax(0, 1fr)) var(--streak-w);
  align-items: center;
  column-gap: 0.25em;
}

.hb--month .hb-row {
  column-gap: 0.12em;
}

.hb-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 0.72em;
  font-weight: 600;
  line-height: 1.15;
}

.hb-day.is-today {
  color: var(--accent);
  font-weight: 750;
}

.hb--month .hb-dn {
  font-size: 0.9em;
}

.hb-name {
  overflow: hidden;
  padding-right: 0.4em;
  font-size: 0.86em;
  font-weight: 560;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hb-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.hb-tick {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(100%, 1.9em);
  aspect-ratio: 1;
  margin: 0;
  padding: 0;
  border: 1px solid var(--card-line);
  border-radius: 0.4em;
  background: var(--card-bg);
  color: var(--on-accent);
  font: inherit;
  font-size: 0.85em;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

.hb--month .hb-tick {
  border-radius: 0.25em;
}

.hb-tick:hover:not(:disabled) {
  background: var(--accent-soft);
}

.hb-tick:active:not(:disabled) {
  transform: scale(0.9);
}

.hb-tick:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.hb-tick.on {
  border-color: transparent;
  background: var(--accent);
}

.hb-tick.on::after {
  content: "\2713";
}

.hb--month .hb-tick.on::after {
  content: "";
}

:root[data-style="neon"] .hb-tick.on {
  box-shadow: 0 0 0.4em color-mix(in srgb, var(--accent) 60%, transparent);
}

.hb-cell.is-today .hb-tick:not(.on) {
  border-color: var(--accent);
}

.hb-tick:disabled {
  opacity: 0.35;
  cursor: default;
}

.hb-streak,
.hb-streak-head {
  text-align: center;
  white-space: nowrap;
}

.hb-streak {
  font-size: 0.9em;
  font-weight: 750;
}

.hb-streak-head {
  font-size: 0.68em;
  font-weight: 600;
}

.hb-note {
  flex: none;
  font-size: 0.7em;
}
