/* ============================================================
   Hub — styles
   Colors live in CSS variables so the whole look can be changed
   from one place. Dark mode switches automatically with your
   system setting.
   ============================================================ */

/* The "dreamy pastels" palette: a lavender-to-peach morning sky
   with white cards floating on it. Every colour in the app comes
   from these variables — change them, and Hub changes outfit. */
:root {
  --bg-top: #e6d9f8;    /* lavender, the top of the sky */
  --bg-mid: #f9dcea;    /* pink, the middle */
  --bg: #fdeee2;        /* peach, where the sky settles */
  --card: #ffffff;
  --ink: #43395c;
  --muted: #7f7398;
  --line: #eadef4;
  --accent: #b0548f;    /* orchid pink */
  --accent-deep: #8f3d76;
  --accent-soft: #f8e2f0;
  --good: #3f8a63;
  --bad: #c9506b;
  --bad-soft: #fbdfe7;
  /* Each tab has its own colour family. */
  --c-today: #a86f15;
  --c-today-soft: #fdf0d4;
  --c-rem: #c95b6c;
  --c-rem-soft: #fbe1de;
  --c-hab: #3f8a63;
  --c-hab-soft: #ddf2e5;
  --shadow: 0 1px 3px rgba(96, 70, 140, 0.08), 0 4px 16px rgba(96, 70, 140, 0.08);
}

/* Dark mode: a deep indigo night with plum-tinted cards. */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-top: #322a55;
    --bg-mid: #262047;
    --bg: #1d1936;
    --card: #2a2449;
    --ink: #eae4f8;
    --muted: #a99ecb;
    --line: #3f3766;
    --accent: #dd8fc7;
    --accent-deep: #b76aa4;
    --accent-soft: #45305a;
    --good: #83cba0;
    --bad: #ec92ab;
    --bad-soft: #4c2b41;
    --c-today: #eec27a;
    --c-today-soft: #423a2e;
    --c-rem: #f09a8c;
    --c-rem-soft: #4a2f38;
    --c-hab: #8ed3aa;
    --c-hab-soft: #29413a;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  /* The sky: lavender up top, pink in the middle, settling into peach. */
  background: linear-gradient(180deg, var(--bg-top), var(--bg-mid) 300px, var(--bg) 640px);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  /* Leave room so the fixed tab bar never covers the footer.
     env(safe-area-inset-bottom) clears the iPhone home bar. */
  padding-bottom: calc(66px + env(safe-area-inset-bottom));
}

/* Phone-first: one comfortable column, centered on big screens. */
#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

/* ---------- header ---------- */

.top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 4px 16px;
}

h1 {
  font-size: 1.5rem;
  margin: 0;
  letter-spacing: -0.02em;
}

.streak {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
  font-size: 0.95rem;
}

/* ---------- cards ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  /* Each tab paints this top edge in its own colour (see below). */
  border-top: 3px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}

.card h2 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 12px;
  font-weight: 600;
}

.muted { color: var(--muted); margin: 2px 0 0; }
.small { font-size: 0.85rem; }

/* ---------- mood row ---------- */

.mood-row {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 14px;
}

.mood-btn {
  flex: 1;
  font-size: 1.6rem;
  line-height: 1;
  padding: 10px 0 8px;
  background: transparent;
  border: 2px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  filter: grayscale(0.7);
  opacity: 0.55;
  transition: transform 0.1s ease, opacity 0.1s ease;
}

.mood-btn:hover { transform: scale(1.12) rotate(6deg); opacity: 0.9; }

.mood-btn.selected {
  filter: none;
  opacity: 1;
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: scale(1.08);
}

/* ---------- habits ---------- */

.habit-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.habit-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}

.habit-list label {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  cursor: pointer;
  padding: 7px 6px;
  border-radius: 10px;
  min-height: 40px;
}

.habit-list label:hover { background: var(--accent-soft); }

.habit-list input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--good);
  cursor: pointer;
  flex-shrink: 0;
}

.habit-list li.done .habit-name {
  color: var(--muted);
  text-decoration: line-through;
}

.habit-tools {
  margin-top: 6px;
  display: flex;
  gap: 14px;
}

/* ---------- note ---------- */

.note {
  width: 100%;
  margin-top: 12px;
  font-size: 1rem;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--ink);
}

/* ---------- tasks ---------- */

#task-form, #reminder-form, #habit-form, #commit-form {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

#new-task, #new-reminder, #new-habit, #new-commit {
  flex: 1;
  font-size: 1rem;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--ink);
}

.add-btn {
  width: 46px;
  font-size: 1.4rem;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fff;
  cursor: pointer;
}

.add-btn:hover { filter: brightness(1.1); }

.task-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.task-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 4px;
  border-bottom: 1px solid var(--line);
  min-height: 44px;
}

.task-list li:last-child { border-bottom: none; }

.tick {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border: 2px solid var(--muted);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  color: transparent;
  padding: 0;
}

.tick:hover { border-color: var(--good); }

li.done .tick {
  background: var(--good);
  border-color: var(--good);
  color: #fff;
}

.task-text { flex: 1; overflow-wrap: anywhere; }

li.done .task-text {
  color: var(--muted);
  text-decoration: line-through;
}

.del {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 6px 8px;
  border-radius: 8px;
  opacity: 0.6;
}

.del:hover { opacity: 1; color: var(--accent); background: var(--accent-soft); }

/* ---------- week strip ---------- */

.week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  text-align: center;
}

.week .day {
  padding: 8px 2px;
  border-radius: 10px;
}

.week .day.today {
  background: var(--accent-soft);
}

.week .dow {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}

.week .mood {
  font-size: 1.25rem;
  min-height: 1.5rem;
}

.week .mood.empty { color: var(--line); }

.week .habits-done {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 3px;
}

/* ---------- buttons & footer ---------- */

.link-btn {
  border: none;
  background: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 4px 2px;
}

.link-btn:hover { text-decoration: underline; }

.foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 4px 0;
}

/* ---------- tab pages & bottom tab bar ---------- */

.page { display: none; }
.page.active { display: block; }

.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  gap: 8px;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}

.tab-btn {
  position: relative;
  flex: 1;
  max-width: 130px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 1.3rem;
  line-height: 1;
  padding: 7px 4px 6px;
  border: none;
  border-radius: 12px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  filter: grayscale(1);
  opacity: 0.7;
}

.tab-ico { display: inline-block; }
.tab-label { font-size: 0.68rem; letter-spacing: 0.02em; }

.tab-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  filter: none;
  opacity: 1;
}

/* The little count on the ⏰ tab when something is due. */
.badge {
  position: absolute;
  top: 2px;
  right: 16%;
  min-width: 17px;
  height: 17px;
  line-height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
}

/* ---------- reminders ---------- */

.due-card { border-color: var(--accent); }

.date-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.date-row input[type="date"] {
  flex: 1;
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
}

.group-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
  margin: 14px 0 2px;
}

.group-title:first-child { margin-top: 0; }
.group-title.overdue { color: var(--bad); }

.rem-date {
  font-size: 0.72rem;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.rem-date.overdue {
  background: var(--bad-soft);
  color: var(--bad);
}

/* ---------- habits tab ---------- */

.hint { margin: 0 0 12px; }

.habit-manage {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.habit-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}

.habit-card .row {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* The name and the why are quiet inputs — click to edit in place. */
.h-name {
  flex: 1;
  font: inherit;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--ink);
  padding: 4px 2px;
  border-radius: 8px;
}

.h-why {
  width: 100%;
  font: inherit;
  font-size: 0.85rem;
  font-style: italic;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 2px;
  margin-top: 2px;
}

.h-stats {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.dots { display: flex; gap: 4px; }

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--line);
}

.dot.filled { background: var(--good); }

.h-streak { font-size: 0.78rem; color: var(--muted); }

/* ---------- commitments ---------- */

.commit-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
}

.commit-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 4px;
  border-bottom: 1px solid var(--line);
}

.commit-list li:last-child { border-bottom: none; }

.commit-mark {
  color: var(--accent);
  flex-shrink: 0;
  padding-top: 1px;
}

.commit-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.commit-text { overflow-wrap: anywhere; }

.commit-since { font-size: 0.72rem; color: var(--muted); }

/* ============================================================
   The delight layer: colour per tab, the streak buddy, and the
   little emoji animations. All plain CSS — the only JS involved
   is the spark helper in app.js that drops .spark elements.
   ============================================================ */

/* Today is golden, Reminders warm coral, Habits leafy green. */
#page-today .card { border-top-color: var(--c-today); }
#page-today .card h2 { color: var(--c-today); }
#page-today .due-card { border-color: var(--accent); }
#page-reminders .card { border-top-color: var(--c-rem); }
#page-reminders .card h2 { color: var(--c-rem); }
#page-habits .card { border-top-color: var(--c-hab); }
#page-habits .card h2 { color: var(--c-hab); }

.tab-btn { transition: background 0.2s, color 0.2s, filter 0.2s; }
.tab-btn[data-tab="today"].active { background: var(--c-today-soft); color: var(--c-today); }
.tab-btn[data-tab="reminders"].active { background: var(--c-rem-soft); color: var(--c-rem); }
.tab-btn[data-tab="habits"].active { background: var(--c-hab-soft); color: var(--c-hab); }

/* The week strip becomes a little mood heat map. */
.week .mood { border-radius: 8px; }
.week .mood.m0 { background: var(--bad-soft); }
.week .mood.m1 { background: var(--c-rem-soft); }
.week .mood.m2 { background: var(--c-today-soft); }
.week .mood.m3 { background: var(--c-hab-soft); }
.week .mood.m4 { background: var(--c-hab-soft); box-shadow: inset 0 0 0 2px var(--good); }

/* ---------- the moving parts ---------- */

@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes floaty { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-5px) rotate(3deg); } }
@keyframes wiggle { 0%, 88%, 100% { transform: rotate(0); } 91% { transform: rotate(12deg); } 94% { transform: rotate(-10deg); } 97% { transform: rotate(6deg); } }
@keyframes pop { 0% { transform: scale(0.5); } 60% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes flicker { 0%, 100% { transform: scale(1) rotate(-2deg); } 50% { transform: scale(1.12) rotate(2deg); } }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(203, 110, 172, 0.55); } 70%, 100% { box-shadow: 0 0 0 8px rgba(203, 110, 172, 0); } }
@keyframes spark-fly {
  0% { transform: translate(0, 0) scale(0.5); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1.2); opacity: 0; }
}

.hero-emoji { display: inline-block; font-size: 1.3rem; animation: floaty 4s ease-in-out infinite; }

/* The daily line of encouragement under the greeting. */
.cheer { margin: 4px 0 0; font-size: 0.85rem; font-style: italic; color: var(--accent-deep); }
/* In the dark the deep shade vanishes — use the bright orchid instead. */
@media (prefers-color-scheme: dark) {
  .cheer { color: var(--accent); }
}

/* The streak buddy: a seed that grows with your streak (app.js
   picks the emoji). It bobs along next to the flame. */
.top-right { display: flex; align-items: center; gap: 8px; }
.buddy { font-size: 1.5rem; line-height: 1; display: inline-block; animation: bob 3s ease-in-out infinite; cursor: help; }

.streak .flame { display: inline-block; animation: flicker 1.6s ease-in-out infinite; }
.badge { animation: ping 2.2s ease-out infinite; }
.wiggle-emoji { display: inline-block; animation: wiggle 3.5s ease-in-out infinite; }
.float-emoji { display: inline-block; animation: floaty 3.5s ease-in-out infinite; }
.mood-btn.selected { animation: pop 0.35s ease; }
.tab-btn.active .tab-ico { animation: pop 0.35s ease; }
.dot.filled { animation: pop 0.3s ease; }

/* Emoji sparks that fly out when you tick something off. */
.spark {
  position: fixed;
  z-index: 99;
  font-size: 1rem;
  pointer-events: none;
  animation: spark-fly 0.8s ease-out forwards;
}

/* If your system asks for less motion, Hub sits still. */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- focus ---------- */

button:focus-visible, input:focus-visible, label:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input:focus { outline: 2px solid var(--accent); border-color: transparent; }
