/* Mom & Calm — base: reset, type, shared components. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body, h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 350;
  font-size: var(--fs-md);
  line-height: 1.55;
  letter-spacing: 0.005em;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Paper grain — a soft, fixed texture over everything (no image files needed). */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .36 0 0 0 0 .18 0 0 0 0 .29 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}
:root[data-theme="dark"] body::before { mix-blend-mode: screen; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) body::before { mix-blend-mode: screen; } }

/* Fraunces with the SOFT axis fully on (brief §5). */
.display, h1, h2, h3, .num {
  font-family: var(--font-display);
  font-variation-settings: 'SOFT' 100, 'WONK' 0;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.15;
}
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
.num { font-variant-numeric: lining-nums tabular-nums; }
em.soft, .display em { font-style: italic; font-variation-settings: 'SOFT' 100, 'WONK' 1; color: var(--accent-ink); }

a { color: var(--accent-ink); text-underline-offset: 3px; text-decoration-thickness: 1px; }
.muted { color: var(--ink-2); }
.hint { color: var(--ink-3); font-size: var(--fs-sm); }
.eyebrow {
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* ---------- focus & motion ---------- */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 8px;
}
.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 300;
  background: var(--surface); color: var(--ink);
  padding: 10px 16px; border-radius: var(--r-pill); box-shadow: var(--shadow-2);
}
.skip-link:focus { top: 12px; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 20px;
  border: 1px solid transparent; border-radius: var(--r-pill);
  background: var(--surface); color: var(--ink);
  font-weight: 450; font-size: var(--fs-md); text-decoration: none; white-space: nowrap;
  transition: transform var(--t-fast) var(--ease), background var(--t-fast), box-shadow var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--plum); color: #FFF6F1; box-shadow: 0 6px 16px -8px rgba(91, 47, 74, 0.7); }
.btn-primary:hover { background: var(--plum-soft); }
.btn-accent { background: var(--accent); color: var(--on-accent); }
.btn-soft { background: var(--accent-wash); color: var(--accent-ink); }
.btn-ghost { background: transparent; border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-icon { width: var(--tap); padding: 0; }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: var(--fs-sm); }
:root[data-theme="dark"] .btn-primary { background: var(--accent); color: var(--on-accent); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-primary { background: var(--accent); color: var(--on-accent); } }

/* segmented control */
.segmented {
  display: inline-flex; padding: 4px; gap: 2px;
  background: var(--surface-sunk); border-radius: var(--r-pill);
}
.segmented button {
  min-height: 38px; padding: 0 16px; border: 0; border-radius: var(--r-pill);
  background: transparent; color: var(--ink-2); font-size: var(--fs-sm);
}
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

/* ---------- cards ---------- */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-1);
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2, .card-head h3 { font-size: var(--fs-lg); }
.card-soft { background: var(--surface-2); box-shadow: none; }

.hero {
  position: relative; overflow: hidden; isolation: isolate;
  border-radius: var(--r-xl);
  padding: 24px 22px 22px;
  color: var(--hero-ink);
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(200, 96, 122, 0.55), transparent 60%),
    radial-gradient(90% 80% at 0% 100%, rgba(232, 185, 73, 0.18), transparent 55%),
    linear-gradient(160deg, var(--hero-bg-2), var(--hero-bg));
  box-shadow: var(--shadow-hero);
}
.hero::after { /* soft concentric rings, like ripples on calm water */
  content: ""; position: absolute; z-index: -1;
  width: 340px; height: 340px; right: -120px; top: -150px; border-radius: 50%;
  background: repeating-radial-gradient(circle, rgba(255, 246, 241, 0.09) 0 1px, transparent 1px 22px);
}
.hero .eyebrow { color: var(--hero-ink-2); }

/* stat tiles */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 14px 16px; min-height: 92px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 6px;
}
.tile .num { font-size: 1.9rem; line-height: 1; color: var(--ink); }
.tile .label { font-size: var(--fs-sm); color: var(--ink-2); }
.tile[data-tone="blush"] { background: var(--blush); border-color: transparent; }
.tile[data-tone="sage"] { background: var(--sage); border-color: transparent; }
.tile[data-tone="gold"] { background: var(--gold-wash); border-color: transparent; }

/* chips, dots, avatars */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 28px; padding: 2px 12px; border-radius: var(--r-pill);
  background: var(--surface-sunk); color: var(--ink-2); font-size: var(--fs-xs); font-weight: 450;
}
.chip[data-color] { background: var(--m-wash); color: var(--ink); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--m, var(--ink-3)); flex: none; }
.avatar {
  display: inline-grid; place-items: center; flex: none;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--m-wash, var(--surface-sunk));
  box-shadow: inset 0 0 0 2px var(--m, var(--line));
  font-size: 1.25rem; line-height: 1;
}

/* list rows */
.rows { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 14px;
  min-height: 56px; padding: 10px 4px;
  border-top: 1px solid var(--line);
}
.row:first-child { border-top: 0; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 450; }
.row-sub { font-size: var(--fs-sm); color: var(--ink-2); }

/* empty / coming-soon states */
.empty {
  display: grid; justify-items: center; text-align: center; gap: 10px;
  padding: 36px 20px;
  border: 1.5px dashed var(--line-strong); border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--surface) 60%, transparent);
}
.empty .emoji { font-size: 2.4rem; line-height: 1; }
.empty h2 { font-size: var(--fs-xl); }
.empty p { max-width: 34ch; color: var(--ink-2); }

/* toast */
.toast-wrap {
  position: fixed; z-index: 250; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + 18px + env(safe-area-inset-bottom));
  display: grid; gap: 8px; width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px 12px 18px; border-radius: var(--r-md);
  background: var(--ink); color: var(--bg); box-shadow: var(--shadow-2);
  animation: toast-in var(--t-med) var(--ease);
}
.toast .btn { min-height: 36px; background: transparent; color: inherit; border-color: color-mix(in srgb, var(--bg) 40%, transparent); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } }
@media (min-width: 900px) { .toast-wrap { bottom: 24px; } }

/* staggered entrance for screen content */
.rise > * { animation: rise 520ms var(--ease) both; }
.rise > *:nth-child(2) { animation-delay: 60ms; }
.rise > *:nth-child(3) { animation-delay: 120ms; }
.rise > *:nth-child(4) { animation-delay: 180ms; }
.rise > *:nth-child(5) { animation-delay: 240ms; }
.rise > *:nth-child(n+6) { animation-delay: 300ms; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

/* ---------- Font Awesome icons (self-hosted sprite, see js/ui/icon.js) ---------- */
.fa { display: inline-block; width: 1em; height: 1em; vertical-align: -0.125em; fill: currentColor; flex: none; overflow: visible; }
.btn .fa { font-size: 0.95em; }
.ico-lg { font-size: 1.5rem; }
.empty .ico { font-size: 2.4rem; color: var(--accent); }
.card-head h2 .fa, .card-head h3 .fa { color: var(--accent-ink); margin-right: 2px; }

/* icon placement helpers */
.ico { font-size: 2.4rem; line-height: 1; color: var(--accent); }
.sorter-done .ico { font-size: 2.6rem; }
.more-ico { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: var(--accent-wash); color: var(--accent-ink); font-size: 1.25rem; flex: none; }
.dump-ico, .quick-ico, .nudge-ico { color: var(--accent-ink); }
.nav-ico .fa { width: 1em; height: 1em; }
/* the hero card is deep plum in both themes, so its icon is always a light tint (about 10:1 light, 14:1 dark) */
.one-emoji { color: #FBF3F5; }
.one-emoji .fa { width: 1em; height: 1em; color: #FBF3F5; }
.tl-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; }
.tl-sub .fa, .ev-sub .fa, .todo-meta .fa { opacity: 0.85; }
.row-title .fa, .subnav-link .fa { color: var(--accent-ink); }
.row-chev { color: var(--ink-3); }
