/* Terrill Finances
   ------------------------------------------------------------------
   Design intent: this is a note left on the kitchen bench, not a bank
   dashboard. The due date leads in serif; the amount is secondary. No
   running total anywhere -- a big outstanding figure is the thing that
   makes her close the tab. Overdue is ochre rather than red for the
   same reason: "look at this", not adrenaline.
   Colour is never the only signal; the words always say it too.
*/

:root {
  --paper:      #F2F4F3;   /* cool off-white, daylight on paper */
  --surface:    #FFFFFF;
  --ink:        #1B2621;   /* desaturated green-black, softer than #000 */
  --ink-muted:  #5E6B66;
  --hairline:   #DDE3E0;
  --calm:       #2F6F5E;   /* eucalyptus -- done, primary action */
  --calm-soft:  #E6EFEB;
  --attention:  #B4622C;   /* burnt ochre -- overdue, deliberately not red */
  --attention-soft: #F6EBE1;
  --soon:       #8A6D2F;   /* due within a few days */

  --radius:     14px;
  --tap:        52px;      /* minimum touch target */
  --measure:    34rem;

  --font-body: "Public Sans", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-say:  "Newsreader", Georgia, "Times New Roman", serif;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:     #121614;
    --surface:   #1A211E;
    --ink:       #E8EDEA;
    --ink-muted: #9AA8A2;
    --hairline:  #2C3733;
    --calm:      #6FBFA5;
    --calm-soft: #1E2E29;
    --attention: #E0965E;
    --attention-soft: #2E241C;
    --soon:      #C8A458;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: 0 1.25rem 5rem;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: var(--measure); margin: 0 auto; }

/* --- masthead ---------------------------------------------------- */

.today {
  padding-top: 2rem;
  font-size: 0.8125rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.headline {
  font-family: var(--font-say);
  font-weight: 400;
  font-size: clamp(2rem, 8vw, 2.75rem);
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin: 0.35rem 0 1.75rem;
}

/* --- the bill card ----------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 0.875rem;
}

/* The due line is the point of the card: large, serif, human. */
.due {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  font-family: var(--font-say);
  font-size: 1.5rem;
  line-height: 1.25;
  margin: 0 0 0.35rem;
}
.due .dot {
  flex: none;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--calm);
  transform: translateY(-0.15rem);
}
.card.is-overdue .due { color: var(--attention); }
.card.is-overdue .due .dot { background: var(--attention); }
.card.is-soon .due { color: var(--soon); }
.card.is-soon .due .dot { background: var(--soon); }
/* No due date is not "all fine" -- don't let it read as calm green. */
.card.is-unknown .due { color: var(--ink-muted); }
.card.is-unknown .due .dot { background: var(--ink-muted); }

/* Standalone due lines (the detail page) carry the same state colours. */
.due.is-overdue { color: var(--attention); }
.due.is-soon    { color: var(--soon); }
.due.is-unknown { color: var(--ink-muted); }

.who {
  font-weight: 600;
  font-size: 1.0625rem;
  margin: 0;
}

.amount {
  font-variant-numeric: tabular-nums;
  color: var(--ink-muted);
  margin: 0.1rem 0 0;
}

.flags {
  margin-top: 0.6rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.flag {
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--calm-soft);
  color: var(--calm);
}
.flag.warn { background: var(--attention-soft); color: var(--attention); }

/* --- actions ------------------------------------------------------ */

.actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1rem;
}

.btn {
  flex: 1;
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0 1rem;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.btn:hover { background: var(--calm-soft); border-color: var(--calm); }
.btn.primary {
  background: var(--calm);
  border-color: var(--calm);
  color: #fff;
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.quiet { flex: 0 0 auto; color: var(--ink-muted); }

:where(a, button, input, summary):focus-visible {
  outline: 2px solid var(--calm);
  outline-offset: 2px;
  border-radius: 6px;
}

/* --- the reward line and empty states ----------------------------- */

.settled {
  font-family: var(--font-say);
  font-size: 1.25rem;
  color: var(--ink-muted);
  margin: 2rem 0;
  text-align: center;
}

.empty {
  font-family: var(--font-say);
  font-size: clamp(1.75rem, 7vw, 2.25rem);
  line-height: 1.2;
  margin: 3.5rem 0 1rem;
}
.empty + p { color: var(--ink-muted); margin-top: 0; }

/* --- quiet sections (direct debits, nav) -------------------------- */

.quiet-block {
  margin-top: 2.5rem;
  border-top: 1px solid var(--hairline);
  padding-top: 1.25rem;
}
.quiet-block > summary {
  cursor: pointer;
  color: var(--ink-muted);
  font-size: 0.9375rem;
  min-height: var(--tap);
  display: flex;
  align-items: center;
}
.quiet-block .card { background: transparent; border-style: dashed; }

.section-label {
  font-size: 0.8125rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 2.5rem 0 0.75rem;
}

/* --- nav ---------------------------------------------------------- */

nav.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--hairline);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}
nav.tabs a {
  flex: 1;
  min-height: var(--tap);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-muted);
  text-decoration: none;
  font-size: 0.9375rem;
}
nav.tabs a[aria-current="page"] {
  color: var(--calm);
  font-weight: 600;
  box-shadow: inset 0 2px 0 var(--calm);
}

/* --- detail / forms ----------------------------------------------- */

.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--hairline);
}
.detail-row dt { color: var(--ink-muted); font-size: 0.9375rem; margin: 0; }
.detail-row dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  text-align: right;
  word-break: break-word;
}

.copy {
  border: 1px solid var(--hairline);
  background: var(--paper);
  border-radius: 8px;
  padding: 0.35rem 0.6rem;
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  margin-left: 0.5rem;
}

input[type="text"], input[type="email"], input[type="number"], input[type="search"],
select, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

label { display: block; font-size: 0.9375rem; color: var(--ink-muted); margin: 1rem 0 0.35rem; }

/* --- chat --------------------------------------------------------- */

.bubble {
  padding: 0.85rem 1.05rem;
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  max-width: 90%;
  white-space: pre-wrap;
}
.bubble.you { background: var(--calm-soft); margin-left: auto; }
.bubble.reply { background: var(--surface); border: 1px solid var(--hairline); }

/* --- receipts ----------------------------------------------------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.75rem;
}
.thumb {
  aspect-ratio: 3 / 4;
  object-fit: cover;
  width: 100%;
  border-radius: 10px 10px 0 0;
  background: var(--paper);
  display: block;
}

/* --- the one animated moment: a bill leaving the list -------------- */

@keyframes settle {
  to { opacity: 0; transform: translateY(-6px) scale(0.985); }
}
.card.settling { animation: settle 260ms ease forwards; }

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