/* style.css — the "Passbook" look.
   One accent colour (bottle green) on pale paper. "Down" is a warm umber,
   never red, and always comes with the word and an arrow. */

@font-face {
  font-family: "Source Serif 4";
  src: url("fonts/source-serif-4.woff2") format("woff2");
  font-weight: 200 900;
  font-display: swap;
}
@font-face {
  font-family: "Hanken Grotesk";
  src: url("fonts/hanken-grotesk.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --ground: #EDF1EC;  /* page */
  --card: #FAFBF8;    /* cards and inputs */
  --ink: #1B2420;     /* main text */
  --soft: #55615B;    /* secondary text (passes AA contrast on both grounds) */
  --line: #D3DCD5;    /* hairlines */
  --track: #DDE5DF;   /* empty part of a bar */
  --accent: #1D4D3F;  /* "up", buttons, the line */
  --down: #7A4A21;    /* "down" */
  --radius: 10px;
  --display: "Source Serif 4", Georgia, serif;
  --body: "Hanken Grotesk", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--ground);
  color: var(--ink);
  font: 1rem/1.5 var(--body);
  min-height: 100dvh;
}
h1, h2 { font-family: var(--display); font-weight: 600; line-height: 1.2; }
a { color: var(--accent); }

/* tabular-nums gives every digit the same width, so money lines up and
   does not wobble while the big number counts up. */
.num { font-variant-numeric: tabular-nums lining-nums; }
.soft { color: var(--soft); }
.small { font-size: 0.875rem; }
.up { color: var(--accent); }
.down { color: var(--down); }

/* ---- Home: one column, phone first, centred on wide screens ---- */
.home {
  max-width: 460px;
  margin: 0 auto;
  padding: 28px 16px 40px;
  display: grid;
  gap: 16px;
}
.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 0 4px; }
.top h1 { font-size: 1.375rem; overflow-wrap: anywhere; }
.tag {
  font-size: 0.8125rem; font-weight: 500; white-space: nowrap;
  padding: 4px 10px; border: 1px solid var(--soft); border-radius: 99px; color: var(--soft);
}
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card h1 { font-size: 1.375rem; margin-bottom: 8px; }
.card h2 { font-size: 1.125rem; }
.card p + p { margin-top: 8px; }

.worth { padding: 8px 4px 0; }
/* A real heading for screen readers that looks like quiet body text. */
.worth h2.plain { font: inherit; }
.value {
  font-family: var(--display); font-weight: 400;
  font-size: clamp(2.25rem, 14.5vw, 3.625rem); /* shrinks a little on very narrow phones */
  line-height: 1.05; letter-spacing: -0.02em;
  margin: 4px 0 10px;
}
.since { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.arrow { flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.rows { margin-top: 20px; }
.rows div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.rows dd { font-weight: 600; text-align: right; white-space: nowrap; }

.chart svg { display: block; width: 100%; height: auto; margin: 16px 0 6px; overflow: visible; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chart .base { stroke: var(--soft); stroke-width: 1; stroke-dasharray: 3 5; }
.chart .dot { fill: var(--accent); }
.axis { display: flex; justify-content: space-between; }
.empty { padding: 28px 0 12px; }

.hold { list-style: none; padding: 0; margin-top: 6px; }
.hold li { padding: 16px 0 4px; }
.hold li + li { border-top: 1px solid var(--track); margin-top: 12px; }
.hold .row { display: flex; justify-content: space-between; gap: 12px; font-weight: 600; }
.hold .row span:first-child { overflow-wrap: anywhere; }
/* The bar is a <progress> element: its length comes from its value, so no
   inline styles are needed (our security policy forbids them). */
.bar { -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 6px; margin-top: 10px; border: 0; border-radius: 99px; background: var(--track); overflow: hidden; }
.bar::-webkit-progress-bar { background: var(--track); }
.bar::-webkit-progress-value { background: var(--accent); border-radius: 99px; }
.bar::-moz-progress-bar { background: var(--accent); border-radius: 99px; }

.note-text { white-space: pre-line; overflow-wrap: anywhere; }
.note-form { display: grid; gap: 10px; margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line); }

.foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 4px 4px 0; }

.notice { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--down); border-radius: var(--radius); padding: 12px 14px; }
.notice.good { border-left-color: var(--accent); }

/* ---- Buttons and fields ---- */
.btn { font: inherit; font-weight: 600; min-height: 48px; padding: 0 20px; border-radius: var(--radius); cursor: pointer; }
.btn.quiet { background: none; border: 1px solid var(--soft); color: var(--ink); }
.btn.main { background: var(--accent); border: 0; color: #fff; width: 100%; }
.btn[disabled] { opacity: 0.7; cursor: progress; }
.field { display: grid; gap: 6px; font-weight: 500; }
.field input, .field textarea {
  font: inherit; font-weight: 400; color: var(--ink); background: var(--card);
  border: 1px solid var(--soft); border-radius: var(--radius); padding: 0 14px;
}
.field input { height: 52px; }
.field textarea { padding: 12px 14px; resize: vertical; }
.btn:focus-visible, .field input:focus-visible, .field textarea:focus-visible, a:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}

/* ---- Log in ---- */
.login { position: relative; overflow: hidden; min-height: 100dvh; display: grid; align-content: center; justify-items: center; padding: 32px 20px; }
.login form { position: relative; width: 100%; max-width: 380px; display: grid; gap: 16px; }
.login h1 { font-size: 2.125rem; font-weight: 400; }
.login .lead { margin: -8px 0 12px; }
/* Backdrop: soft drifting light made in CSS. If public/media/login-backdrop.mp4
   exists, the page uses that video (class "backdrop") instead. */
.glow {
  position: absolute; inset: -20%;
  background:
    radial-gradient(40% 30% at 30% 25%, var(--card), transparent 70%),
    radial-gradient(45% 35% at 75% 80%, var(--track), transparent 70%);
  animation: drift 28s ease-in-out infinite alternate;
}
.backdrop { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0.6; }
/* Over a video the form sits on its own card, so the text always has a known background. */
.login.has-video form { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px 20px; }
@keyframes drift { to { transform: translate3d(4%, -3%, 0) scale(1.08); } }

/* ---- Motion: one short sequence when the Home screen loads ----
   Cards fade up one after another, then the line draws once. */
.home > * { animation: rise 0.36s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.home > :nth-child(2) { animation-delay: 60ms; }
.home > :nth-child(3) { animation-delay: 120ms; }
.home > :nth-child(4) { animation-delay: 180ms; }
.home > :nth-child(5) { animation-delay: 240ms; }
.home > :nth-child(n+6) { animation-delay: 300ms; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.chart .line { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 0.4s ease-out 0.3s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
/* The end dot appears once the line has reached it. */
.chart .dot { animation: appear 0.2s ease-out 0.7s both; }
@keyframes appear { from { opacity: 0; } }

/* People who ask their device for less motion get a still page. */
@media (prefers-reduced-motion: reduce) {
  .home > *, .glow, .chart .line, .chart .dot { animation: none; }
  .backdrop { display: none; } /* no video loop: the still light shows instead */
  .chart .line { stroke-dashoffset: 0; }
}
