/* Great Traits — habit-tracker UI. Builds on the great-apps framework.css. */

:root { --traits: #22c55e; }

/* Green "Traits" wordmark. */
.header-accent {
  background: linear-gradient(90deg, #4ade80, #22c55e 55%, #10b981);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  font-weight: 700;
}

.header-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn.add:hover { border-color: var(--traits); color: var(--traits); }

/* ── Today summary strip ───────────────── */
.today-summary {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  flex-shrink: 0;
}
.ring-wrap { position: relative; width: 52px; height: 52px; flex-shrink: 0; }
#ring-fg { transition: stroke-dasharray 0.45s cubic-bezier(0.22, 1, 0.36, 1), stroke 0.3s; }
.ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.today-text { min-width: 0; }
.today-date { font-size: 1.02rem; font-weight: 700; line-height: 1.2; }
.today-sub { font-size: 0.82rem; color: var(--text-muted); margin-top: 2px; }
.today-sub b { color: var(--traits); }

/* ── Habit cards ───────────────────────── */
#habit-list { padding: 6px 0 12px; }

.habit-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px 11px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  transition: background 0.12s, opacity 0.2s;
}
.habit-card:active { background: var(--bg-hover); }
.habit-card.rest { opacity: 0.62; }
.habit-card.dragging {
  background: var(--bg-active);
  opacity: 0.96;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.5);
  border-radius: 10px;
}

.drag-handle {
  flex-shrink: 0;
  width: 22px;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  opacity: 0.5;
  cursor: grab;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.drag-handle:active { cursor: grabbing; }
.drag-handle svg { pointer-events: none; }

.habit-emoji {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  border: 1px solid var(--border);
}

.habit-main { flex: 1; min-width: 0; cursor: pointer; }
.habit-name {
  font-size: 0.98rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.habit-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.streak-chip { color: #f59e0b; font-weight: 600; font-variant-numeric: tabular-nums; }
.rest-chip { color: var(--text-muted); }

/* Check-off circle */
.check-btn {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--check-color, var(--traits));
  background: transparent;
  color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s, background 0.15s, color 0.15s;
}
.check-btn svg { width: 18px; height: 18px; }
.check-btn.done {
  background: var(--check-color, var(--traits));
  color: #06130a;
}
.check-btn.rest { border-color: var(--border); }
.check-btn.pop { transform: scale(1.22); }
.check-btn:active { transform: scale(0.9); }

/* ── Empty state ───────────────────────── */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px 30px;
  gap: 6px;
}
.empty-emoji { font-size: 3rem; margin-bottom: 4px; }
.empty-title { font-size: 1.25rem; font-weight: 700; }
.empty-copy { font-size: 0.92rem; color: var(--text-muted); line-height: 1.5; max-width: 300px; margin-bottom: 12px; }
.empty-copy b { color: var(--traits); }

.foot-hint { font-size: 0.75rem; color: var(--text-muted); }
.foot-counts { font-size: 0.75rem; color: var(--text-muted); }
.foot-counts b { color: var(--text); font-weight: 600; }

/* ── Scrim + bottom sheets ─────────────── */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(8, 8, 12, 0.55);
  backdrop-filter: blur(2px);
}
.scrim[hidden] { display: none; }

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  max-width: 560px;
  margin: 0 auto;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  padding: 16px 18px calc(18px + env(safe-area-inset-bottom, 0px));
  transform: translateY(110%);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), visibility 0s linear 0.28s;
  visibility: hidden;
  max-height: 90vh;
  overflow-y: auto;
}
.sheet.open {
  transform: translateY(0);
  visibility: visible;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.55);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), visibility 0s;
}
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--border); margin: -6px auto 12px; }
.sheet-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  z-index: 2;
}
.sheet-title { font-size: 1.4rem; font-weight: 700; line-height: 1.2; }

/* Detail sheet */
.hs-head { display: flex; align-items: center; gap: 10px; }
.hs-emoji {
  width: 42px; height: 42px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.35rem; border: 1px solid var(--border); flex-shrink: 0;
}
.hs-cadence { font-size: 0.82rem; color: var(--text-muted); margin: 6px 0 14px; }

.hs-stats { display: flex; gap: 10px; margin-bottom: 18px; }
.hs-stat {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 6px;
  text-align: center;
}
.hs-stat-num { display: block; font-size: 1.5rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.hs-stat-lbl { display: block; font-size: 0.72rem; color: var(--text-muted); margin-top: 5px; }

.hs-heat-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); margin-bottom: 8px;
}
.heat-legend { display: flex; align-items: center; gap: 3px; text-transform: none; letter-spacing: 0; }
.heat-legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.heat-legend .l-miss { background: rgba(255, 255, 255, 0.045); border: 1px solid var(--border); }
.heat-legend .l-done { background: #22c55e; }

/* Heatmap grid — columns are weeks, rows Sun..Sat */
.heatmap {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 1fr);
  gap: 3px;
  margin-bottom: 18px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.heat-cell {
  width: 100%;
  aspect-ratio: 1;
  min-width: 13px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid transparent;
  cursor: pointer;
}
.heat-cell.empty { background: rgba(255, 255, 255, 0.03); border-color: transparent; cursor: default; }
.heat-cell.rest { background: rgba(255, 255, 255, 0.045); border-color: transparent; }
.heat-cell.miss { background: rgba(255, 255, 255, 0.045); border-color: var(--border); }
.heat-cell.done { border-color: transparent; }
.heat-cell.today { box-shadow: 0 0 0 2px var(--text-muted); }

.visit-btn {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: none;
  color: #06130a;
  background: var(--check-color, var(--traits));
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s, filter 0.15s;
}
.visit-btn.accent { background: var(--traits); }
.visit-btn:active { filter: brightness(0.94); }
.visit-btn.logged { background: var(--bg-active) !important; color: var(--text); }

.hs-actions { display: flex; gap: 10px; margin-top: 10px; }
.ghost-btn {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.ghost-btn:active { background: var(--bg-hover); }
.ghost-btn.wide { width: 100%; margin-top: 8px; }
.ghost-btn.danger { color: #ff7a9c; border-color: #55344a; }
.ghost-btn.danger:active { background: rgba(255, 122, 156, 0.08); }

/* ── Edit form ─────────────────────────── */
.field-label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 16px 0 8px;
}
.text-input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}
.text-input:focus { border-color: var(--traits); }
.text-input::placeholder { color: var(--text-muted); }

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}
.emoji-opt {
  aspect-ratio: 1;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 9px;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.emoji-opt.sel { border-color: var(--traits); background: rgba(34, 197, 94, 0.14); }
.emoji-input { margin-top: 8px; }

.swatch-row { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.swatch.sel { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg-surface) inset; }

.segmented {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  gap: 4px;
}
.seg-btn {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 7px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.seg-btn.sel { background: var(--bg-active); color: var(--text); }

.day-row { display: flex; gap: 6px; margin-top: 10px; }
.day-toggle {
  flex: 1;
  aspect-ratio: 1;
  max-width: 44px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  border-radius: 50%;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.day-toggle.sel { background: var(--traits); color: #06130a; border-color: var(--traits); }

#es-save { margin-top: 20px; }

/* ── Stats overlay ─────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(8, 8, 12, 0.72);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.overlay[hidden] { display: none; }
.sheet.stats-sheet {
  position: relative;
  transform: none;
  visibility: visible;
  width: 100%;
  max-height: 86vh;
}

.st-summary { font-size: 0.92rem; color: var(--text-muted); line-height: 1.6; margin-bottom: 16px; }
.st-summary b { color: var(--text); }

.recent-head {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 4px 0 10px;
}

.week-strip { display: flex; gap: 6px; margin-bottom: 20px; }
.week-day { flex: 1; text-align: center; }
.week-dot {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.week-lbl { font-size: 0.66rem; color: var(--text-muted); margin-top: 5px; }

.stat-group { margin-bottom: 18px; }
.stat-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.stat-emoji { width: 20px; text-align: center; flex-shrink: 0; }
.stat-name {
  width: 96px;
  font-size: 0.85rem;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-bar { flex: 1; height: 9px; background: var(--bg); border: 1px solid var(--border); border-radius: 5px; overflow: hidden; }
.stat-bar > i { display: block; height: 100%; border-radius: 5px; transition: width 0.4s ease; }
.stat-count { font-size: 0.78rem; color: var(--text-muted); font-variant-numeric: tabular-nums; width: 34px; text-align: right; }

.danger-btn {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid #55344a;
  background: transparent;
  color: #ff7a9c;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
}
.danger-btn:active { background: rgba(255, 122, 156, 0.08); }

/* ── Desktop niceties ──────────────────── */
@media (min-width: 769px) {
  .foot-hint { font-size: 0.8rem; }
  .foot-counts { font-size: 0.8rem; }
  .habit-card:hover { background: var(--bg-hover); }
}
