/*
 * theme.css — Household Ledger's design-system values.
 *
 * Mood: editorial × swiss — a paper ledger. Hairline rules, near-square
 * corners (2px), no shadow, a serif (Fraunces) reserved for the numbers
 * that matter and a quiet sans (Inter) for everything else. Category
 * colours (Groceries green, Rent blue, Travel orange, …) are stored per
 * row as data and are the only decoration on the page — this file stays
 * warm, neutral paper.
 */

:root {
  --canvas: #fbf8f2;
  --surface: #fdfcf9;
  --surface-2: #f2ecdd;
  --border: #e1d8c3;
  --border-strong: #c7b99a;
  --ink: #241e17;
  --muted: #67635e;

  --accent: #1f3a5f;
  --accent-hover: #172c48;
  --accent-ink: #ffffff;
  --accent-text: #8b5a2b;
  --accent-strong: #1f3a5f;
  --accent-soft: #e6e9de;
  --accent-border: color-mix(in srgb, var(--accent) 38%, transparent);

  --success: #2f7d4f;
  --success-ink: #ffffff;
  --success-soft: #e1ecdf;
  --success-strong: #235f3c;

  --warning: #a15a1c;
  --warning-ink: #ffffff;
  --warning-soft: #f1e5d5;
  --warning-strong: #8a4b17;

  --danger: #a3372c;
  --danger-ink: #ffffff;
  --danger-soft: #f2e0dc;
  --danger-strong: #8a2d23;

  --chart-1: #1f3a5f;
  --chart-2: #2f7d4f;
  --chart-3: #c2701d;
  --chart-4: #6b4c9a;
  --chart-5: #a44a86;
  --chart-6: #6b6b3f;

  --font-display: "Fraunces", "Iowan Old Style", ui-serif, Georgia, serif;
  --font-body: "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-sans: "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --display-weight: 600;
  --display-tracking: -0.01em;
  --eyebrow-tracking: 0.06em;

  --radius-btn: 2px;
  --radius-card: 2px;
  --radius-input: 2px;
  --border-w: 1px;
  --border-strong-w: 1px;
  --shadow-card: none;
  --shadow-btn: none;
  --shadow-raised: 0 10px 30px rgba(36, 30, 23, 0.16);
  --card-pad: 1.5rem;
  --caps: none;
  --caps-tracking: 0.02em;
  --btn-weight: 600;
  --measure: 62ch;
}

html[data-theme="dark"] {
  --canvas: #17140f;
  --surface: #201b14;
  --surface-2: #29231a;
  --border: #382f22;
  --border-strong: #4f4330;
  --ink: #f2ecdd;
  --muted: #b0a690;

  --accent: #7ea3cf;
  --accent-hover: #93b3da;
  --accent-ink: #12202f;
  --accent-text: #d99a5b;
  --accent-strong: #a8c4e2;
  --accent-soft: #24344a;
  --accent-border: color-mix(in srgb, var(--accent) 42%, transparent);

  --success: #6fb389;
  --success-ink: #0f2417;
  --success-soft: #1d3324;
  --success-strong: #8fca9f;

  --warning: #d19457;
  --warning-ink: #2a1808;
  --warning-soft: #3a2a17;
  --warning-strong: #e2ac78;

  --danger: #d1897d;
  --danger-ink: #2c130f;
  --danger-soft: #3a2320;
  --danger-strong: #e2a89c;

  --chart-1: #7ea3cf;
  --chart-2: #7fbd97;
  --chart-3: #e0a05a;
  --chart-4: #af8fd6;
  --chart-5: #cf8ab6;
  --chart-6: #b8b876;
}

/*
 * app.css — Household Ledger's own stylesheet: the shell (side-rail +
 * content pane), the mobile drawer, the category chart, the coloured pills
 * and tags, and the dense day-grouped expense rows. Nothing here repeats a
 * primitive's own selector — see components.css for those. Colours are
 * tokens throughout, except the category swatch (--sw) and its matching
 * ink (--ink-on), which are the household's OWN data, set inline per row.
 */

/* ---- The shell: side-rail + content pane --------------------------------- */

.ledger-shell {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

.sidebar {
  display: none;
  flex-direction: column;
  width: 17rem;
  flex-shrink: 0;
  gap: 1.75rem;
  padding: 1.5rem 1.25rem 2rem;
  border-right: var(--border-w, 1px) solid var(--border);
  background: var(--surface);
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  overflow-y: auto;
}

.drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--ink) 45%, transparent);
}

.ledger-shell.is-nav-open .sidebar { display: flex; }
.ledger-shell.is-nav-open .drawer-backdrop { display: block; }

.ledger-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.mobile-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-bottom: var(--border-w, 1px) solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 20;
}
.mobile-bar-title { font-weight: 600; }

#ledger-pane {
  padding: 1.75rem 1.25rem 4rem;
  max-width: 52rem;
  margin: 0 auto;
  width: 100%;
}

@media (min-width: 64rem) {
  .drawer-backdrop, .mobile-bar { display: none; }
  .sidebar { display: flex; position: sticky; top: 0; height: 100vh; }
  #ledger-pane { padding: 2.5rem 3rem 5rem; max-width: 48rem; margin: 0 auto; }
}

/* ---- Sidebar furniture ---------------------------------------------------- */

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.0625rem;
}

.rail-section { display: flex; flex-direction: column; gap: 0.75rem; }
.rail-heading {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
  font-variant: small-caps;
  letter-spacing: 0.03em;
}

.nav-list { display: flex; flex-direction: column; gap: 0.125rem; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.625rem;
  border-radius: var(--radius-btn, 2px);
  color: var(--muted);
  font-size: 0.9rem;
  border-left: 2px solid transparent;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-left-color: var(--accent);
  font-weight: 600;
}

.cat-list { display: flex; flex-direction: column; gap: 0.5rem; }
.cat-row { display: flex; align-items: center; gap: 0.625rem; font-size: 0.9rem; min-width: 0; }

/* Swatch dot: used in the rail list, the chart, and category tags. */
.swatch-dot {
  display: inline-block;
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 999px;
  background: var(--sw, var(--accent));
  flex-shrink: 0;
}

/* ---- Add-category: a disclosure with a small swatch grid ------------------ */

.cat-add { padding-top: 0.25rem; }
.cat-add-summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  list-style: none;
  color: var(--accent-text);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.375rem 0;
}
.cat-add-summary::-webkit-details-marker { display: none; }
.cat-add-summary:hover { text-decoration: underline; }

.swatch-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.5rem;
}
.swatch {
  display: block;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 999px;
  background: var(--sw);
  cursor: pointer;
  border: 2px solid transparent;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--sw) 55%, transparent);
}
.swatch:has(input:checked) {
  border-color: var(--surface);
  box-shadow: 0 0 0 2px var(--sw);
}
.swatch:has(input:focus-visible) { box-shadow: var(--ring); }

/* ---- Page head: month nav + the one total figure -------------------------- */

.ledger-head {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding-bottom: 1.5rem;
  border-bottom: var(--border-w, 1px) solid var(--border);
  margin-bottom: 1.75rem;
}
.month-nav {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 1rem;
}
.month-arrow {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted);
  padding: 0.25rem 0.5rem;
}
.month-arrow:hover { color: var(--accent-text); text-decoration: none; }
.month-label {
  font-size: 1.0625rem;
  font-weight: 600;
  font-variant: small-caps;
  letter-spacing: 0.03em;
  min-width: 11rem;
  text-align: center;
}
.month-total {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  text-align: center;
}
.total-figure {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.5rem, 6vw, 3.5rem);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.total-sub { color: var(--muted); font-size: 0.875rem; }

@media (min-width: 40rem) {
  .ledger-head { flex-direction: row; align-items: center; justify-content: space-between; }
  .month-nav { justify-content: flex-start; }
  .month-total { align-items: flex-end; text-align: right; }
}

/* ---- Category spend: mono label + total to the left of a filled bar ------- */

.chart-card { padding-bottom: 1.75rem; margin-bottom: 1.75rem; border-bottom: var(--border-w, 1px) solid var(--border); }
.cat-bars { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 1rem; }
.cat-bar-row { display: flex; align-items: center; gap: 1rem; }
.cat-bar-meta {
  flex: 0 0 auto;
  width: 9rem;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  font-family: var(--font-mono);
  line-height: 1.25;
}
.cat-bar-name { font-size: 0.8125rem; font-weight: 500; color: var(--ink); }
.cat-bar-amt { font-size: 0.8125rem; color: var(--muted); }
.cat-bar-track {
  flex: 1 1 auto;
  min-width: 0;
  height: 0.625rem;
  background: var(--surface-2);
  border-radius: 1px;
  overflow: hidden;
}
.cat-bar-fill { height: 100%; background: var(--sw, var(--accent)); border-radius: 1px; }

/* ---- Ledger card: the form docked over the list --------------------------- */

.ledger-card { border: var(--border-w, 1px) solid var(--border); border-radius: var(--radius-card, 2px); background: var(--surface); }
.ledger-form-wrap { padding: 1.5rem; }
.ledger-card-rule { height: var(--border-w, 1px); background: var(--border); }

.expense-form { display: flex; flex-direction: column; gap: 1.25rem; }
.expense-form-row { display: flex; flex-direction: column; gap: 1rem; }
@media (min-width: 34rem) {
  .expense-form-row { flex-direction: row; align-items: flex-end; }
  .expense-field-amount { flex: 0 0 8rem; }
  .expense-field-date { flex: 0 0 10rem; }
  .expense-field-note { flex: 1 1 auto; min-width: 0; }
}

.pill-grid { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.cat-pill {
  display: inline-flex;
  align-items: center;
  height: 2rem;
  padding: 0 0.75rem;
  border-radius: var(--radius-btn, 2px);
  border: 1px solid color-mix(in srgb, var(--sw) 45%, var(--border));
  background: color-mix(in srgb, var(--sw) 8%, var(--surface));
  color: color-mix(in srgb, var(--ink) 70%, var(--sw) 30%);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease;
}
.cat-pill:hover { background: color-mix(in srgb, var(--sw) 16%, var(--surface)); }
.cat-pill:has(input:focus-visible) { box-shadow: var(--ring); }
.cat-pill:has(input:checked) {
  background: var(--sw);
  border-color: var(--sw);
  color: var(--ink-on, var(--accent-ink));
}

/* ---- Recent expenses: dense, grouped by day -------------------------------- */

.expense-list { display: flex; flex-direction: column; }
.expense-day + .expense-day { border-top: var(--border-w, 1px) solid var(--border); }
.expense-day-heading {
  padding: 1rem 1.5rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  font-variant: small-caps;
  letter-spacing: 0.03em;
}

.expense-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1.5rem;
  border-top: var(--border-w, 1px) solid color-mix(in srgb, var(--border) 60%, transparent);
}
.expense-day-heading + .expense-row { border-top: none; }

.cat-tag {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  height: 1.375rem;
  padding: 0 0.5rem;
  border-radius: var(--radius-btn, 2px);
  background: var(--sw);
  color: var(--ink-on, var(--accent-ink));
  font-size: 0.6875rem;
  font-weight: 600;
  white-space: nowrap;
}
.expense-note { flex: 1 1 auto; min-width: 0; color: var(--ink); font-size: 0.9rem; }
.expense-amount {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.expense-del {
  flex: 0 0 auto;
  opacity: 0;
  transition: opacity 150ms ease;
}
.expense-row:hover .expense-del,
.expense-row:focus-within .expense-del { opacity: 1; }
@media (hover: none) { .expense-del { opacity: 1; } }
