/* ============================================================================
   components.css — reusable UI pieces (buttons, fields, chips, the page
   sheet, nav items). Contract rule 8: every class used anywhere in js/pages/
   must have an entry in the CLASS INVENTORY below, added in the same commit
   that introduces it — this is what keeps this file from drifting out of
   sync with the markup the way an unaudited stylesheet eventually does.

   CLASS INVENTORY
     .btn .btn--primary .btn--ghost .btn--icon .btn--sm
     .field .field-label .input
     .nav-item .nav-item--active .nav-emoji
     .sheet .sheet-inner .sheet-title .sheet-sub .paper
     .chip .pill .pill--brand .pill--muted
     .table-wrap table.table .table--compact
     .stack .stack--tight .grid .grid--2 .grid--7
     .progress-track .progress-fill
     .modal-root .modal-scrim .modal-panel .modal-head .modal-x .modal-body
     .save-badge .save-badge--visible
     .star-row
     .content-card .content-card-mark
     .month-motif-icon
     .welcome-list
   ============================================================================ */

.btn {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font: inherit; font-size: 14px; cursor: pointer;
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(0.98); }
.btn--primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn--primary:hover { filter: brightness(1.05); }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--icon { padding: var(--space-2); min-width: 44px; min-height: 44px; justify-content: center; }
.btn--sm { padding: var(--space-1) var(--space-2); font-size: 12px; }

.field { display: block; margin-bottom: var(--space-3); }
.field-label { display: block; font-size: 12px; color: var(--ink-soft); margin-bottom: var(--space-1); }
.input {
  width: 100%; padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 14px;
}
.input:focus { outline: 2px solid var(--brand); outline-offset: 1px; }

.nav-item {
  display: flex; align-items: center; gap: var(--space-2);
  width: 100%; text-align: left; padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md); border: 0; background: none; color: var(--ink-soft);
  font: inherit; font-size: 13px; cursor: pointer; min-height: 44px;
}
.nav-item:hover { background: var(--surface-2); }
.nav-item--active { background: var(--brand-tint); color: var(--ink); font-weight: 600; }
.nav-emoji { font-size: 16px; }

/* The sheet: the visual "page" surface every journal page renders inside,
   sized so its proportions echo a real sheet of paper on screen too — not
   just at print time. */
.sheet {
  max-width: 820px; margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 8px 24px rgba(0,0,0,0.04);
  padding: var(--space-6);
}

/* The 5mm dot-grid paper texture (docs/DESIGN-SYSTEM.md §4) — decorative
   "this is a paper page" signature behind static content, not a ruling the
   UI writes on top of. --line is already tuned per-palette for a subtle,
   non-competing dot colour, so no separate opacity hack is needed. 18.9px is
   5mm at the 96dpi screen baseline (5mm x 96/25.4); css/print.css switches
   this to a true 5mm print-only rule, since "dpi" is fiction on screen but
   accurate on paper. */
.paper {
  background-color: var(--surface);
  background-image: radial-gradient(circle, var(--line) 0.6px, transparent 0.6px);
  background-size: 18.9px 18.9px;
}
.sheet-title { font-family: var(--font-display); font-size: 26px; margin: 0 0 var(--space-1); }
.sheet-sub { color: var(--ink-faint); font-size: 13px; margin: 0 0 var(--space-5); }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--surface-2); color: var(--ink-soft); font-size: 12px; cursor: pointer;
}
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; }
.pill--brand { background: var(--brand-tint); color: var(--brand); }
.pill--muted { background: var(--surface-3); color: var(--ink-faint); }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table--compact th, .table--compact td { padding: var(--space-2); vertical-align: top; border: 1px solid var(--line); font-size: 13px; }
.table--compact th { background: var(--surface-2); }

.stack { display: flex; flex-direction: column; gap: var(--space-3); }
.stack--tight { display: flex; flex-direction: column; gap: var(--space-1); }
.grid { display: grid; gap: var(--space-3); }
.grid--2 { grid-template-columns: 1fr 1fr; }
.grid--7 { grid-template-columns: repeat(7, 1fr); }
@media (max-width: 480px) { .grid--2 { grid-template-columns: 1fr; } }

/* A generic progress bar — first used by the reading challenge, but any
   future goal (savings, packing lists, habit completion %) reuses this
   rather than a one-off bar per feature. */
.progress-track { width: 100%; height: 10px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress-fill { height: 100%; background: var(--brand); border-radius: 999px; transition: width var(--dur) var(--ease); }
@media (prefers-reduced-motion: reduce) { .progress-fill { transition: none; } }

/* The modal. index.html scaffolds the markup and app.js's openModal()/
   closeModal() toggle [hidden] and fill the content, but this presentation
   layer never existed until a real click (not just checking hidden===false
   afterward) proved it: the panel was rendering as a normal block element
   in document flow, ~1700px below the page, instead of a centered overlay.
   Every App.openModal() caller in this app — the year switcher, the mood
   picker, editing a reading-log entry — silently inherited this the whole
   time it was missing.
   [hidden] needs its own rule here: an author stylesheet's plain class
   selector at EQUAL specificity to the browser's built-in `[hidden]{
   display:none}` rule beats it (author styles win ties against user-agent
   defaults), so .modal-root{display:flex} alone would make the panel
   permanently visible — this higher-specificity override is what lets
   closeModal()'s hidden=true actually hide it again. */
.modal-root[hidden] { display: none; }
.modal-root {
  position: fixed; inset: 0; z-index: 300;
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-4);
}
.modal-scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.45); }
.modal-panel {
  position: relative;
  background: var(--surface); color: var(--ink);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
  width: 100%; max-width: 420px; max-height: 85vh; overflow-y: auto;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-4); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--surface);
}
.modal-head h2 { margin: 0; font-size: 17px; font-family: var(--font-display); }
.modal-x {
  background: none; border: 0; font-size: 16px; cursor: pointer; color: var(--ink-soft);
  width: 32px; height: 32px; min-width: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.modal-x:hover { background: var(--surface-2); }
.modal-body { padding: var(--space-4); }

/* Journal.saveBadge()/flashSaved() — see js/ui.js's header for why this
   exists. Invisible at rest (a field nobody has touched yet has nothing to
   confirm), fades in on the first keystroke. */
.save-badge {
  display: inline-block; font-size: 11px; color: var(--ink-faint);
  margin-top: 2px; opacity: 0; transition: opacity var(--dur) var(--ease);
}
.save-badge--visible { opacity: 1; color: var(--mint); }

/* A row of tap-to-rate stars — first used by reading.js's own inline
   .book-row-stars, generalized here so travel.js's Destination Review can
   share the identical widget instead of a second copy of the same five
   buttons. */
.star-row { display: flex; white-space: nowrap; gap: 2px; }

/* A soft-tinted card for freeform/reflective content — same visual family
   as selfcare.js's .quote-card (tint + a big decorative mark in the corner)
   but with a neutral --sec-N seed set per use, so any page can reach for
   this instead of inventing its own one-off "pretty box". First used by
   goals.js's Brain Dump, which used to be a bare heading + textarea. */
.content-card { position: relative; background: color-mix(in oklab, var(--sec-4) 12%, var(--surface)); border-radius: var(--radius-md); padding: var(--space-4) var(--space-4) var(--space-4) var(--space-6); margin: var(--space-3) 0; }
.content-card-mark { position: absolute; left: var(--space-2); top: -6px; font-family: var(--font-display); font-size: 32px; color: color-mix(in oklab, var(--sec-4) 60%, transparent); line-height: 1; }

/* One consistent motif per calendar month everywhere it shows up (month.js,
   week.js) — Motifs.ofMonth() already existed for the cover, this just
   gives it a second, tiny home next to the heading it belongs to. */
.month-motif-icon { display: inline-block; width: 28px; height: 28px; vertical-align: -7px; margin-right: 6px; }
.month-motif-icon svg { width: 100%; height: 100%; display: block; }

/* Welcome tour (js/welcome.js) — a plain, readable list inside the modal
   body, no bullets fighting the emoji each line already leads with. */
.welcome-list { list-style: none; margin: 0 0 var(--space-3); padding: 0; display: flex; flex-direction: column; gap: var(--space-2); font-size: 13px; line-height: 1.4; }
