/* styles.css: how the app looks and moves. Phone first; light and dark mode follow the phone's setting.
   Motion rules (from the Impeccable and Emil Kowalski design skills): this is a tool used mid-conversation,
   so motion is quick (under 250ms), only explains what changed, and never bounces. */

:root {
  --bg: #f4f5f9;
  --card: #ffffff;
  --text: #171923;
  --muted: #61677c;
  --line: #e4e6ee;
  --press: #eef0f6;          /* background of a row while your finger is on it */
  --accent: #4f46e5;
  --accent-text: #ffffff;
  --accent-soft: #eceafe;
  --ok: #1b7a3d;
  --ok-soft: #e3f4e8;
  --warn: #9a5b00;
  --warn-soft: #fff0d9;
  --danger: #c62828;
  --danger-soft: #fdeaea;
  --shadow: 0 1px 2px rgb(20 23 40 / 0.04), 0 2px 8px rgb(20 23 40 / 0.05);
  --radius: 16px;
  /* Motion curves. "out" = starts fast, settles gently (things arriving or leaving).
     "in-out" = smooth start and stop (something moving across the screen). */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  accent-color: var(--accent); /* date picker, dropdowns */
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1016;
    --card: #1a1c26;
    --text: #eceef6;
    --muted: #9ba0b4;
    --line: #2a2d3a;
    --press: #242735;
    --accent: #8f89ff;
    --accent-text: #0f0f1a;
    --accent-soft: #29274f;
    --ok: #63d18f;
    --ok-soft: #15301f;
    --warn: #f3a93b;
    --warn-soft: #382811;
    --danger: #ff7070;
    --danger-soft: #3b1818;
    --shadow: none;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: calc(88px + env(safe-area-inset-bottom));
  overflow-x: clip; /* screens sliding in must not make the page scroll sideways */
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent-soft); color: var(--text); }
input, textarea { caret-color: var(--accent); }
::placeholder { color: var(--muted); opacity: 1; }

.icon {
  display: block; width: 24px; height: 24px;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 4px;
  padding: calc(10px + env(safe-area-inset-top)) 10px 10px 16px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.topbar h1 {
  flex: 1; margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#back-btn:not([hidden]) { margin-left: -8px; }
.icon-btn {
  display: inline-grid; place-items: center; min-width: 44px; min-height: 44px;
  border: 0; border-radius: 12px; background: none; color: var(--muted); font-size: 20px;
  transition: background-color 150ms ease, transform 150ms var(--ease-out);
}
.topbar .icon-btn { color: var(--text); }
.icon-btn:active { background: var(--press); transform: scale(0.95); }

main { max-width: 640px; margin: 0 auto; padding: 14px 16px; }

/* ---------- Screen changes (app.js adds these classes in go()) ----------
   Opening something slides in a little from the right, going back from the left.
   Switching tabs just fades, because you do it all the time. */
main.enter-forward { animation: slide-from-right 200ms var(--ease-out); }
main.enter-back { animation: slide-from-left 200ms var(--ease-out); }
main.enter-fade { animation: fade-in 150ms var(--ease-out); }

/* ---------- Bottom tabs ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex;
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
/* The soft pill behind the active tab glides to the tab you tap (app.js sets its position). */
.tab-pill {
  position: absolute; top: 8px; left: 0; width: 25%; height: 32px; pointer-events: none;
  transition: transform 250ms var(--ease-in-out);
}
.tab-pill::before {
  content: ""; position: absolute; left: 50%; width: 60px; height: 100%; margin-left: -30px;
  border-radius: 999px; background: var(--accent-soft);
}
.tabbar button {
  position: relative; flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 10px 0; border: 0; background: none; color: var(--muted);
  transition: color 150ms ease;
}
.tabbar .icon { margin: 2px 0; }
.tabbar button span { font-size: 12px; line-height: 16px; font-weight: 500; }
.tabbar button.on { color: var(--accent); }
.tabbar button.on span { font-weight: 700; }
.badge {
  position: absolute; top: 5px; left: calc(50% + 8px); min-width: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--danger); color: var(--card);
  font-size: 11px; font-weight: 700; line-height: 18px; font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 2px var(--card);
  animation: badge-in 200ms var(--ease-out);
}

.fab {
  position: fixed; right: 18px; bottom: calc(88px + env(safe-area-inset-bottom)); z-index: 6;
  display: grid; place-items: center; width: 58px; height: 58px;
  border: 0; border-radius: 20px;
  background: var(--accent); color: var(--accent-text);
  box-shadow: 0 10px 24px -8px rgb(79 70 229 / 0.7), 0 2px 6px rgb(0 0 0 / 0.12);
  transition: transform 150ms var(--ease-out);
}
.fab .icon { width: 28px; height: 28px; stroke-width: 2.25; }
.fab:active { transform: scale(0.95); }

/* ---------- Lists ---------- */
.search {
  width: 100%; padding: 12px 14px 12px 42px;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a8fa3' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 14px center / 18px;
  box-shadow: var(--shadow);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.filters { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0; scrollbar-width: none; }
.filter {
  flex: none; padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); font-size: 14px; font-weight: 500;
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease, transform 150ms var(--ease-out);
}
.filter .count { margin-left: 2px; opacity: 0.6; font-variant-numeric: tabular-nums; }
.filter.on { border-color: var(--accent); background: var(--accent); color: var(--accent-text); }
.filter.on .count { opacity: 0.85; }
.filter:active { transform: scale(0.96); }

.row {
  margin-bottom: 10px; overflow: hidden;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.row-main {
  display: flex; align-items: flex-start; gap: 12px; width: 100%;
  padding: 14px; border: 0; background: none; text-align: left;
  transition: background-color 150ms ease;
}
.row-main:active { background: var(--press); }
.row-body { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.row-sub {
  color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.row-actions { display: flex; gap: 8px; padding: 0 14px 14px 66px; }

/* The coloured circle with initials. --h (a colour-wheel angle) comes from the name. */
.avatar {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  background: hsl(var(--h) 75% 93%); color: hsl(var(--h) 50% 30%);
  font-size: 15px; font-weight: 700; letter-spacing: 0.02em;
}
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }
@media (prefers-color-scheme: dark) {
  .avatar { background: hsl(var(--h) 30% 22%); color: hsl(var(--h) 75% 80%); }
}

.chip, .due {
  display: inline-flex; align-items: center; padding: 1px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; line-height: 20px; font-variant-numeric: tabular-nums;
  background: var(--accent-soft); color: var(--accent);
}
.chip::before { content: ""; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: currentColor; }
.chip.met { background: var(--ok-soft); color: var(--ok); }
.chip.done, .due { background: var(--line); color: var(--muted); }
.due.today { background: var(--warn-soft); color: var(--warn); }
.due.overdue { background: var(--danger-soft); color: var(--danger); }

.muted { color: var(--muted); font-weight: 400; }
.section {
  display: flex; align-items: center; gap: 8px; margin: 22px 2px 10px;
  font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
.section:first-child { margin-top: 4px; }
.section .muted {
  padding: 0 8px; border-radius: 999px; background: var(--line); color: var(--text);
  font-size: 12px; font-weight: 600; letter-spacing: 0; font-variant-numeric: tabular-nums;
}
.empty {
  margin: 20px 0; padding: 36px 20px; text-align: center; color: var(--muted);
  border: 1.5px dashed var(--line); border-radius: var(--radius);
}
.hint { margin: 6px 2px 14px; color: var(--muted); font-size: 14px; }

/* ---------- Buttons (they shrink a little under your finger) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 16px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--text); font-weight: 500; text-decoration: none;
  transition: transform 150ms var(--ease-out), background-color 150ms ease, filter 150ms ease;
}
.btn:active { transform: scale(0.97); background: var(--press); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn.primary {
  border-color: transparent; background: var(--accent); color: var(--accent-text); font-weight: 600;
  box-shadow: 0 6px 16px -8px var(--accent);
}
.btn.primary:active { background: var(--accent); filter: brightness(0.92); }
.btn.ghost { background: none; }
.btn.danger { color: var(--danger); }
.btn.wide { width: 100%; margin: 6px 0; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.btn-row.end { justify-content: space-between; margin-top: 24px; }

/* Hover only on a laptop with a mouse (a phone tap would leave it stuck on). */
@media (hover: hover) and (pointer: fine) {
  .btn:hover, .filter:not(.on):hover, .icon-btn:hover, .row-main:hover { background: var(--press); }
  .btn.primary:hover { background: var(--accent); filter: brightness(1.06); }
  .btn.ghost:hover { background: var(--press); }
  .tabbar button:not(.on):hover { color: var(--text); }
}

/* ---------- Person page ---------- */
.person-head { display: flex; align-items: center; gap: 14px; margin: 6px 0 14px; }
.person-head h2 { margin: 0; font-size: 22px; line-height: 1.2; letter-spacing: -0.01em; }
.field {
  margin: 10px 0; padding: 12px 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.label { margin-bottom: 4px; font-size: 12px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.value { white-space: pre-wrap; overflow-wrap: anywhere; }
audio { display: block; width: 100%; height: 40px; }
.voice { display: flex; align-items: center; gap: 6px; margin: 6px 0; }
.voice audio { flex: 1; width: auto; min-width: 0; }

/* ---------- Forms ---------- */
.form label { display: block; margin-top: 14px; font-size: 14px; font-weight: 500; color: var(--muted); }
.form input, .form textarea, .form select, .capture textarea {
  display: block; width: 100%; margin-top: 6px; padding: 12px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--text);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
:is(.search, .form input, .form textarea, .form select, .capture textarea):focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; }
.form details { margin: 16px 0; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* Fold-out sections (prep cards, "More details"): our own arrow that turns when opened. */
summary { display: flex; align-items: center; gap: 10px; list-style: none; cursor: pointer; }
summary::-webkit-details-marker { display: none; }
summary::after {
  content: ""; flex: none; width: 8px; height: 8px; margin-left: auto;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; opacity: 0.55;
  transform: translateY(-2px) rotate(45deg);
  transition: transform 200ms var(--ease-out);
}
details[open] > summary::after { transform: translateY(2px) rotate(225deg); }
details[open] > summary ~ * { animation: drop-in 200ms var(--ease-out); }
.form summary { padding: 6px 0; color: var(--accent); font-weight: 600; }
.form summary::after { margin-left: 0; }

/* ---------- Prep cards ---------- */
.card {
  margin-bottom: 10px; padding: 0 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.card summary { padding: 15px 0; font-weight: 600; }
.card[open] summary { margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.card ul { margin: 0 0 10px; padding-left: 20px; }
.card li { margin-bottom: 8px; }
.card li::marker { color: var(--accent); }
.card .btn { margin-bottom: 12px; }

/* ---------- Ideas ---------- */
.capture {
  padding: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.capture textarea { margin-top: 0; }
.capture .btn-row { justify-content: flex-end; margin: 10px 0 0; }
.idea {
  margin-bottom: 10px; padding: 12px 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.idea.starred { background: var(--warn-soft); border-color: transparent; }
.idea-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.idea audio { margin-top: 6px; }
.idea-meta { display: flex; align-items: center; gap: 4px; margin-top: 6px; }
.idea-meta .muted { flex: 1; font-size: 13px; }
.star { color: var(--warn); }

/* ---------- Recording bar and pop-up message ---------- */
.rec-bar {
  position: fixed; left: 12px; right: 12px; bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 7;
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--radius);
  background: #c62828; color: #fff; font-weight: 600; font-variant-numeric: tabular-nums;
  box-shadow: 0 12px 30px -10px rgb(198 40 40 / 0.7);
  animation: rise-in 200ms var(--ease-out);
}
.rec-bar .btn { margin-left: auto; min-height: 36px; border: 0; background: #fff; color: #c62828; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #fff; animation: pulse 1.2s ease-out infinite; }

/* The toast uses a transition (not a keyframe animation), so a new message never restarts a jump. */
.toast {
  position: fixed; left: 50%; bottom: calc(160px + env(safe-area-inset-bottom)); z-index: 8;
  width: max-content; max-width: calc(100vw - 32px); padding: 10px 18px; border-radius: 14px;
  transform: translateX(-50%);
  background: var(--text); color: var(--bg); font-size: 14px; font-weight: 500; text-align: center;
  box-shadow: 0 10px 28px -10px rgb(0 0 0 / 0.45);
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out);
}
@starting-style {
  .toast { opacity: 0; transform: translate(-50%, 8px); }
}

/* ---------- The animations themselves ---------- */
@keyframes slide-from-right { from { opacity: 0; transform: translateX(16px); } }
@keyframes slide-from-left { from { opacity: 0; transform: translateX(-16px); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes drop-in { from { opacity: 0; transform: translateY(-4px); } }
@keyframes badge-in { from { opacity: 0; transform: scale(0.9); } }
@keyframes pulse {
  from { box-shadow: 0 0 0 0 rgb(255 255 255 / 0.7); }
  to { box-shadow: 0 0 0 10px rgb(255 255 255 / 0); }
}

/* "Reduce motion" on the phone: nothing moves or slides, but quick fades and colour changes stay,
   so you still see that something happened. */
@media (prefers-reduced-motion: reduce) {
  main.enter-forward, main.enter-back, main.enter-fade,
  details[open] > summary ~ *, .rec-bar, .badge { animation: fade-in 150ms ease-out; }
  .tab-pill, summary::after { transition: none; }
  .btn:active, .icon-btn:active, .fab:active, .filter:active { transform: none; }
  .rec-dot { animation: none; }
  .toast { transition: opacity 150ms ease-out; }
  @starting-style {
    .toast { opacity: 0; transform: translateX(-50%); }
  }
}
