/* Today tab: date navigation, progress bar, habit rows, add form. */

.date-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.date-nav-text { flex: 1; }
.date-nav-label { font-size: 15px; font-weight: 600; color: var(--text); }
.date-nav-sub { font-size: 12px; color: var(--text-subtle); font-weight: 400; }

.progress-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.progress-bar-track { flex: 1; height: 6px; background: var(--cell-empty); border-radius: 3px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--success); border-radius: 3px; transition: width .35s ease; }
.progress-label { font-size: 13px; color: var(--text-muted); white-space: nowrap; }

/* ── Habit rows ── */
.habit-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.habit-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 14px; background: var(--surface);
  border-radius: var(--radius-md); border: 1px solid var(--border);
  transition: border-color .15s, box-shadow .15s, transform .15s;
  position: relative;
}
.habit-row:hover { border-color: var(--border-hover); }
/* The row being dragged follows the pointer exactly; its siblings animate out of the way. */
.habit-row.dragging {
  transition: none; z-index: 2;
  border-color: var(--accent); box-shadow: var(--shadow-drag), 0 0 0 2px var(--accent-ring);
}

.drag-handle {
  cursor: grab; flex-shrink: 0;
  display: flex; align-items: center; padding: 2px 2px 0 0;
  background: none; border: none; border-radius: 4px;
  user-select: none; -webkit-user-select: none;
  touch-action: none; /* let pointer events drive the drag instead of scrolling on touch */
}
.drag-handle:active, .habit-row.dragging .drag-handle { cursor: grabbing; }
.drag-handle svg { display: block; fill: var(--icon-faint); }
.drag-handle:hover svg, .drag-handle:focus-visible svg { fill: var(--text-soft); }

.checkmark {
  width: 24px; height: 24px; border-radius: 7px;
  border: 2px solid var(--border-hover); background: transparent;
  cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, border-color .15s; position: relative;
  margin-top: 1px;
}
.checkmark.done { background: var(--success); border-color: var(--success); }
.checkmark.done::after {
  content: ''; display: block; width: 7px; height: 12px;
  border: 2.5px solid var(--on-success); border-top: none; border-left: none;
  transform: rotate(42deg) translate(-1px, -2px);
}
.checkmark:hover:not(:disabled) { border-color: var(--success); }
.checkmark:disabled { opacity: .35; cursor: default; }

.habit-main { flex: 1; min-width: 0; }
.habit-name-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.habit-name-text { font-size: 14px; color: var(--text); overflow-wrap: anywhere; }
.habit-name-text.done { color: var(--text-faint); text-decoration: line-through; }
.habit-streak { font-size: 12px; color: var(--text-soft); white-space: nowrap; }

/* Habit-level note, shown under the name every day. */
.habit-global-note {
  font-size: 12px; color: var(--text-soft); margin-top: 3px;
  font-style: italic; line-height: 1.4;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Per-day completion note. */
.habit-log-note {
  display: block; font-size: 12px; color: var(--accent-alt); margin-top: 4px;
  line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere;
}
.habit-log-note.placeholder { color: var(--text-ghost); font-style: italic; }
.habit-log-note.placeholder:hover { color: var(--accent); }

.habit-actions { display: flex; gap: 4px; flex-shrink: 0; margin-top: 1px; }

/* ── Add form ── */
.add-form { display: flex; gap: 8px; flex-wrap: wrap; }
.add-form .text-input { flex: 1; min-width: 150px; width: auto; padding: 9px 13px; }

/* Not due today (rest day / weekly goal already met): still tickable, visually quieter. */
.habit-row.not-due { background: var(--bg); }
.habit-row.not-due .habit-name-text:not(.done) { color: var(--text-subtle); }
.habit-meta { font-size: 11px; color: var(--text-faint); margin-top: 2px; }

/* Counted habits: − 3/8 glasses + */
/* min-width: 0 so a long unit is truncated instead of pushing the + button out of the card
   (a flex item's automatic minimum width is its full unwrapped text). */
.counter { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; min-width: 0; max-width: 100%; }
.counter-btn {
  width: 24px; height: 24px; border-radius: 6px; padding: 0;
  border: 1px solid var(--border-input); background: var(--surface); color: var(--accent);
  font: inherit; font-size: 15px; line-height: 1; cursor: pointer;
}
.counter-btn:hover:not(:disabled) { background: var(--accent-soft); }
.counter-btn:disabled { opacity: .35; cursor: default; }
.counter-val {
  font-size: 12px; color: var(--text-muted); min-width: 36px; text-align: center; font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 16em;
}

/* ── Archived list ── */
.archived-list { margin-top: 28px; font-size: 13px; color: var(--text-muted); }
.archived-list summary { cursor: pointer; color: var(--text-subtle); font-weight: 500; padding: 4px 0; }
.archived-hint { font-size: 12px; color: var(--text-faint); margin: 6px 0 10px; }
.archived-list ul { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.archived-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
}
.archived-name { flex: 1; min-width: 120px; color: var(--text); overflow-wrap: anywhere; }
.archived-date { font-size: 11px; color: var(--text-faint); }

/* Tapping the name ticks the habit, like the checkbox (so no text-selection flash on double-click). */
.habit-name-text { cursor: pointer; -webkit-user-select: none; user-select: none; }

/* Date picker: a calendar button with the real date input invisibly on top of it. */
.date-pick { position: relative; overflow: hidden; color: var(--accent); }
.date-pick:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.date-pick input {
  position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0;
  cursor: pointer; border: none; padding: 0; font-size: 16px;
}
.date-pick input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: auto; height: auto; cursor: pointer; }

/* ── Week strip: Mon–Sun, ring = share of the day's due habits done ── */
.week-strip { display: flex; align-items: center; justify-content: space-between; gap: 2px; margin: -4px 0 14px; }
.ws-nav {
  width: 26px; height: 44px; flex-shrink: 0; border: none; background: none; border-radius: 6px;
  color: var(--text-faint); font: inherit; font-size: 22px; line-height: 1; cursor: pointer;
}
.ws-nav:hover:not(:disabled) { color: var(--accent); background: var(--accent-soft); }
.ws-nav:disabled { opacity: .3; cursor: default; }
.ws-day {
  flex: 1; max-width: 64px; /* compact on desktop instead of a wide selected box */ display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 4px 0; border: none; background: none; border-radius: var(--radius-sm);
  font: inherit; color: var(--text-subtle); cursor: pointer; min-width: 0;
}
.ws-day:hover:not(:disabled) { background: var(--surface); }
.ws-day:disabled { opacity: .35; cursor: default; }
.ws-name { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.ws-ring {
  --size: clamp(28px, 8.6vw, 34px); /* rings mustn't touch at 320px wide */
  width: var(--size); height: var(--size); border-radius: 50%; position: relative;
  display: grid; place-items: center;
  background: conic-gradient(var(--success) calc(var(--p) * 360deg), var(--cell-empty) 0);
}
.ws-ring::before { content: ''; position: absolute; inset: 3px; border-radius: 50%; background: var(--bg); }
.ws-num { position: relative; font-size: 13px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.ws-day.full .ws-ring::before { background: var(--success); }
.ws-day.full .ws-num { color: var(--on-success); }
.ws-day.is-today .ws-name { color: var(--accent); }
.ws-day.selected { background: var(--surface); box-shadow: 0 0 0 1.5px var(--accent) inset; }
.ws-day.selected .ws-ring::before { background: var(--surface); }
.ws-day.selected.full .ws-ring::before { background: var(--success); }

/* Day changes slide in from the side you swiped/stepped towards. */
@keyframes slide-from-right { from { opacity: 0; transform: translateX(24px); } }
@keyframes slide-from-left { from { opacity: 0; transform: translateX(-24px); } }
.habit-list.slide-from-right { animation: slide-from-right .18s ease-out; }
.habit-list.slide-from-left { animation: slide-from-left .18s ease-out; }

/* A satisfying tick. */
@keyframes pop { 40% { transform: scale(1.22); } 100% { transform: scale(1); } }
.checkmark.pop { animation: pop .28s ease-out; }

/* ── Suggestions (empty / near-empty list) ── */
.starters { margin-top: 18px; }
.starters-title { font-size: 11px; font-weight: 600; color: var(--text-faint); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.starter-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.starter-chip {
  padding: 7px 12px; font: inherit; font-size: 13px; border-radius: 999px; cursor: pointer;
  border: 1px dashed var(--border-input); background: var(--surface); color: var(--text-muted);
}
.starter-chip:hover { border-style: solid; border-color: var(--accent); color: var(--accent); }

/* ── iPhone "Add to Home Screen" hint ── */
.hint-banner {
  display: flex; align-items: flex-start; gap: 10px; margin-bottom: 16px;
  padding: 12px 12px 12px 14px; border-radius: var(--radius-md);
  background: var(--accent-soft); border: 1px solid var(--accent-ring);
  font-size: 13px; line-height: 1.5; color: var(--text-muted);
}
.hint-banner strong { color: var(--text); }
.hint-banner em { font-style: normal; font-weight: 600; color: var(--text); }
.hint-icon { font-size: 20px; line-height: 1.2; }
.hint-text { flex: 1; }
.share-glyph { display: inline-flex; vertical-align: -2px; color: var(--accent); }
.hint-close { flex-shrink: 0; width: 32px; height: 32px; font-size: 20px; background: transparent; border: none; }

/* Desktop-only hint; shortcuts mean nothing without a keyboard. */
.kbd-hint { display: none; margin-top: 28px; font-size: 12px; color: var(--text-faint); text-align: center; }
@media (hover: hover) and (pointer: fine) { .kbd-hint { display: block; } }

/* ── Touch screens: comfortable targets (Apple's guideline is 44pt) ── */
@media (pointer: coarse) {
  .habit-row { padding: 12px 12px; gap: 10px; }
  .checkmark { width: 28px; height: 28px; border-radius: 8px; }
  .checkmark::before { content: ''; position: absolute; inset: -9px; } /* bigger hit area, same look */
  .drag-handle { padding: 6px 4px; margin: -4px 0 0 -6px; }
  .counter-btn { width: 34px; height: 34px; font-size: 17px; }
  .habit-actions .btn-sm { min-width: 38px; min-height: 36px; justify-content: center; }
  .btn-icon { width: 40px; height: 40px; }
  .habit-name-text { font-size: 15px; }
}
/* Narrow phones: archive lives in the edit sheet (✎) to free up the row, and a counter gets its
   own line under the name instead of squeezing between the name and the buttons. */
@media (max-width: 480px) {
  .habit-actions [data-action="archive"] { display: none; }
  .counter { flex-basis: 100%; margin-left: 0; margin-top: 4px; }
  .counter-val { max-width: none; flex: 0 1 auto; min-width: 0; }
}
