/* NUDGE — components.css — reusable UI component styles */

/* ── LAYOUT ── */

#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 640px;
  margin: 0 auto;
  position: relative;
}

.main-content {
  flex: 1;
  overflow-y: auto;
  padding-bottom: calc(var(--s7) + var(--s5));
  -webkit-overflow-scrolling: touch;
}

/* ── TAB BAR ── */

.tab-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 640px;
  height: 56px;
  background: var(--surface);
  border-top: 1px solid var(--surface3);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: var(--z-sticky);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: var(--s2) var(--s4);
  min-width: 56px;
  min-height: 44px;
  justify-content: center;
  color: var(--text-faint);
  transition: color var(--fast) var(--ease);
  font-size: var(--t-xs);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tab-item.active {
  color: var(--accent);
}

.tab-item svg {
  width: 22px;
  height: 22px;
  stroke-width: 1.5;
}

/* ── FOCUS PIN BAR ── */

.focus-bar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: var(--surface);
  border-left: 3px solid var(--accent);
  padding: var(--s3) var(--s4);
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-height: 52px;
  cursor: pointer;
  transition: background var(--fast) var(--ease);
}

.focus-bar:active { background: var(--surface2); }
.focus-bar-name { font-size: var(--t-base); font-weight: 600; color: var(--text); flex: 1; }
.focus-bar-meta { font-size: var(--t-sm); color: var(--text-dim); font-family: var(--font-mono); }

/* ── TASK CARD ── */

.task-card {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  background: var(--surface);
  border-left: 3px solid transparent;
  min-height: 56px;
  cursor: pointer;
  transition: background var(--fast) var(--ease);
  border-bottom: 1px solid var(--surface2);
  position: relative;
}

.task-card:active { background: var(--surface2); }
.task-card.p1 { border-left-color: var(--p1); }
.task-card.p2 { border-left-color: var(--p2); }
.task-card.p3 { border-left-color: var(--p3); }
.task-card.p4 { border-left-color: var(--p4); }
.task-card.pinned { border-left-color: var(--accent); box-shadow: 0 0 0 1px rgba(200, 240, 96, 0.125) inset; }
.task-card.waiting { opacity: 0.6; }
.task-card.completing { animation: slideOut var(--mid) var(--ease) forwards; }

@keyframes slideOut {
  to { opacity: 0; transform: translateX(-100%); max-height: 0; padding: 0; }
}

/* Checkbox */
.task-check {
  width: 24px; height: 24px;
  min-width: 24px;
  border: 2px solid var(--surface3);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--fast) var(--ease);
  cursor: pointer;
}
.task-check:active { transform: scale(0.9); }
.task-check.checked { background: var(--success); border-color: var(--success); }
.task-check svg { width: 14px; height: 14px; stroke: var(--bg); opacity: 0; }
.task-check.checked svg { opacity: 1; }

/* Task body */
.task-body { flex: 1; min-width: 0; }
.task-name {
  font-size: var(--t-base);
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.task-name.done { text-decoration: line-through; color: var(--text-faint); }
.task-meta {
  display: flex; align-items: center; gap: var(--s2);
  margin-top: 3px; flex-wrap: wrap;
}
.task-time {
  font-size: var(--t-xs); color: var(--text-dim);
  font-family: var(--font-mono);
}
.task-time.overdue { color: var(--danger); }
.task-waiting { font-size: var(--t-xs); color: var(--warn); }

/* Task right side */
.task-right {
  display: flex; align-items: center; gap: var(--s2);
  flex-shrink: 0;
}
.task-subtask-count {
  font-size: var(--t-xs); color: var(--text-faint);
  font-family: var(--font-mono);
}
.task-chevron { color: var(--text-faint); }
.task-chevron svg { width: 16px; height: 16px; }

/* Priority dot */
.p-dot {
  width: 8px; height: 8px;
  border-radius: var(--r-full);
  flex-shrink: 0;
}
.p-dot.p1 { background: var(--p1); }
.p-dot.p2 { background: var(--p2); }
.p-dot.p3 { background: var(--p3); }
.p-dot.p4 { background: var(--p4); }

/* ── SECTION HEADERS ── */

.section-header {
  padding: var(--s2) var(--s4);
  font-size: var(--t-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  background: var(--bg);
  font-family: var(--font-mono);
  border-bottom: 1px solid var(--surface2);
}
.section-header.overdue { color: var(--danger); }

/* ── FILTER CHIPS ── */

.chip-row {
  display: flex; gap: var(--s2); padding: var(--s3) var(--s4);
  overflow-x: auto; scrollbar-width: none;
  background: var(--bg);
  position: sticky; top: 0; z-index: var(--z-sticky);
  border-bottom: 1px solid var(--surface2);
}
.chip-row::-webkit-scrollbar { display: none; }

.chip {
  display: inline-flex; align-items: center;
  padding: var(--s1) var(--s3);
  border-radius: var(--r-full);
  font-size: var(--t-sm); font-weight: 500;
  white-space: nowrap;
  background: var(--surface2);
  color: var(--text-dim);
  cursor: pointer;
  transition: all var(--fast) var(--ease);
  border: 1px solid transparent;
  min-height: 32px;
}
.chip.active {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent);
}

/* ── BUTTONS ── */

.btn-primary {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 52px;
  background: var(--accent);
  color: var(--bg);
  font-size: var(--t-base); font-weight: 700;
  border-radius: var(--r-md);
  transition: opacity var(--fast) var(--ease);
  letter-spacing: 0.02em;
}
.btn-primary:active { opacity: 0.85; }

.btn-ghost {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 52px;
  background: transparent;
  color: var(--accent);
  font-size: var(--t-base); font-weight: 600;
  border-radius: var(--r-md);
  border: 1.5px solid var(--accent);
  transition: all var(--fast) var(--ease);
}
.btn-ghost:active { background: rgba(200, 240, 96, 0.08); }

.btn-danger {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 52px;
  background: transparent;
  color: var(--danger);
  font-size: var(--t-base); font-weight: 600;
  border-radius: var(--r-md);
  border: 1.5px solid rgba(248, 113, 113, 0.25);
  transition: all var(--fast) var(--ease);
}
.btn-danger:active { background: rgba(248, 113, 113, 0.08); }

.btn-text {
  display: inline-flex; align-items: center;
  padding: var(--s2) var(--s3);
  color: var(--text-dim); font-size: var(--t-sm);
  min-height: 44px;
  transition: color var(--fast) var(--ease);
}
.btn-text:active { color: var(--text); }

/* ── INPUT ── */

.input {
  width: 100%; height: 52px;
  padding: 0 var(--s4);
  background: var(--surface2);
  border: 1.5px solid transparent;
  border-radius: var(--r-md);
  font-size: var(--t-base); color: var(--text);
  transition: border-color var(--fast) var(--ease);
}
.input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--text-faint); }

.textarea {
  width: 100%;
  padding: var(--s3) var(--s4);
  background: var(--surface2);
  border: 1.5px solid transparent;
  border-radius: var(--r-md);
  font-size: var(--t-base); color: var(--text);
  resize: none; min-height: 120px;
  line-height: 1.6;
  transition: border-color var(--fast) var(--ease);
}
.textarea:focus { border-color: var(--accent); }
.textarea::placeholder { color: var(--text-faint); }

/* ── OVERLAYS & SHEETS ── */

.overlay-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: var(--z-overlay);
  animation: fadeIn var(--mid) var(--ease);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 640px;
  background: var(--surface);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  z-index: calc(var(--z-overlay) + 1);
  padding: var(--s5) var(--s4) calc(var(--s5) + env(safe-area-inset-bottom));
  animation: slideUp var(--mid) var(--ease);
  max-height: 90dvh;
  overflow-y: auto;
}

@keyframes slideUp {
  from { transform: translateX(-50%) translateY(100%); }
  to   { transform: translateX(-50%) translateY(0); }
}

.sheet-handle {
  width: 36px; height: 4px;
  background: var(--surface3);
  border-radius: var(--r-full);
  margin: 0 auto var(--s4);
}

.overlay-full {
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: var(--z-alert);
  display: flex; flex-direction: column;
  padding: var(--s7) var(--s5) var(--s5);
  animation: alertIn var(--mid) var(--ease);
}

@keyframes alertIn {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}

/* ── RHYTHM NUDGE BANNER ── */

.rhythm-banner {
  position: fixed; top: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 640px;
  background: var(--surface);
  border-bottom: 2px solid var(--warn);
  z-index: var(--z-alert);
  padding: var(--s3) var(--s4);
  display: flex; align-items: center; gap: var(--s3);
  animation: bannerDown var(--mid) var(--ease);
}

@keyframes bannerDown {
  from { transform: translateX(-50%) translateY(-100%); }
  to   { transform: translateX(-50%) translateY(0); }
}

.rhythm-banner-text { flex: 1; font-size: var(--t-sm); color: var(--text); }
.rhythm-banner-actions { display: flex; gap: var(--s2); }

/* ── NEXT TASK PROMPT ── */

.next-task-prompt {
  background: var(--surface2);
  border-radius: var(--r-md);
  margin: var(--s3) var(--s4);
  padding: var(--s4);
  border-left: 3px solid var(--accent);
  animation: slideUp var(--fast) var(--ease);
}
.next-task-label { font-size: var(--t-sm); color: var(--text-dim); margin-bottom: var(--s2); }
.next-task-name  { font-size: var(--t-md); font-weight: 600; color: var(--text); margin-bottom: var(--s3); }
.next-task-actions { display: flex; gap: var(--s2); }

/* ── EMPTY STATE ── */

.empty-state {
  padding: var(--s8) var(--s5);
  text-align: center;
  color: var(--text-faint);
  font-size: var(--t-base);
  line-height: 1.6;
}

/* ── ONBOARDING ── */

.onboarding-screen {
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: var(--z-alert);
  display: flex; flex-direction: column;
  padding: var(--s8) var(--s5) var(--s5);
  animation: fadeIn var(--slow) var(--ease);
}
.onboarding-step { font-size: var(--t-xs); color: var(--accent); font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: var(--s4); }
.onboarding-question { font-size: var(--t-2xl); font-weight: 700; color: var(--text);
  line-height: 1.2; margin-bottom: var(--s5); }
.onboarding-sub { font-size: var(--t-base); color: var(--text-dim); line-height: 1.6;
  margin-bottom: var(--s6); }

/* ── IDENTITY REINFORCEMENT ── */

.identity-nudge {
  background: var(--surface2);
  border-left: 3px solid var(--accent);
  padding: var(--s3) var(--s4);
  margin: var(--s3) var(--s4);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  font-size: var(--t-sm); color: var(--text-dim);
  line-height: 1.5;
}

/* ── TASK DETAIL ── */

.detail-field {
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--surface2);
}
.detail-label { font-size: var(--t-xs); color: var(--text-faint);
  text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: var(--s2); }
.priority-row { display: flex; gap: var(--s2); }
.priority-btn {
  flex: 1; height: 40px;
  border-radius: var(--r-sm);
  font-size: var(--t-sm); font-weight: 600;
  background: var(--surface2);
  color: var(--text-faint);
  transition: all var(--fast) var(--ease);
  border: 1.5px solid transparent;
}
.priority-btn.p1.active { color: var(--p1); border-color: var(--p1); background: transparent; }
.priority-btn.p2.active { color: var(--p2); border-color: var(--p2); background: transparent; }
.priority-btn.p3.active { color: var(--p3); border-color: var(--p3); background: transparent; }
.priority-btn.p4.active { color: var(--p4); border-color: var(--p4); background: transparent; }

/* ── MISC ── */

.divider { height: 1px; background: var(--surface2); margin: var(--s4) 0; }
.spacer { flex: 1; }
.mono { font-family: var(--font-mono); }
.accent { color: var(--accent); }
.danger { color: var(--danger); }
.dim { color: var(--text-dim); }
.faint { color: var(--text-faint); }



/* ── NOTE CARDS ── */

.note-card-wrapper {
  position: relative;
  overflow: hidden;
}

.note-archive-btn {
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 80px;
  background: var(--danger);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--t-sm); font-weight: 600;
  transform: translateX(100%);
  transition: transform var(--fast) var(--ease);
  cursor: pointer;
  border: none;
}

.note-card-wrapper.swiped .note-archive-btn {
  transform: translateX(0);
}

.note-card-wrapper.swiped .note-card {
  transform: translateX(-80px);
  transition: transform var(--fast) var(--ease);
}

/* Desktop hover X button */
.note-x-btn {
  display: none;
  width: 28px; height: 28px;
  border-radius: var(--r-full);
  background: var(--surface2);
  color: var(--text-faint);
  font-size: 16px; font-weight: 600;
  align-items: center; justify-content: center;
  cursor: pointer;
  border: none;
  flex-shrink: 0;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}

.note-x-btn:hover {
  background: var(--danger);
  color: white;
}

@media (min-width: 768px) {
  .note-card:hover .note-x-btn,
  .task-card:hover .note-x-btn {
    display: flex;
  }
}

/* ── SPACE SWITCHER ── */

.space-switcher {
  display: flex;
  gap: var(--s1);
  padding: var(--s2) var(--s4);
}
.space-btn {
  flex: 1; height: 32px;
  border-radius: var(--r-full);
  font-size: var(--t-xs); font-weight: 600;
  background: var(--surface2); color: var(--text-faint);
  transition: all var(--fast) var(--ease);
  cursor: pointer;
  border: none;
}
.space-btn.active[data-space="personal"] { background: #c8f060; color: #000; }
.space-btn.active[data-space="work"]     { background: #60a8f0; color: #000; }
.space-btn.active[data-space="projects"] { background: #f87171; color: #000; }

/* Safe area bottom padding */
.safe-bottom { padding-bottom: env(safe-area-inset-bottom); }

/* ── Clock display ── */
.clock-display {
  font-family: var(--font-mono);
  color: var(--text-dim);
  font-size: var(--t-sm);
  padding: 0 var(--s4) var(--s3);
  line-height: 1.4;
}
.clock-time { font-size: var(--t-lg); color: var(--text); font-weight: 500; }
.clock-date { font-size: var(--t-xs); color: var(--text-faint); }

/* ── Session focus timer ── */
.session-timer {
  padding: var(--s2) var(--s4);
  margin-bottom: var(--s3);
}
.session-timer-label {
  font-size: var(--t-xs);
  color: var(--text-faint);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--s1);
  display: flex;
  justify-content: space-between;
}
.session-timer-bar {
  height: 3px;
  background: var(--surface3);
  border-radius: var(--r-full);
  overflow: hidden;
}
.session-timer-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--r-full);
  transition: width 1s linear;
}
.session-timer-fill.rest { background: var(--success); }

/* Mobile progress bar */
.mobile-session-bar {
  height: 2px;
  background: var(--surface2);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}
.mobile-session-bar-fill {
  height: 100%;
  background: var(--accent);
  transition: width 30s linear;
}
