/* Mobile first. One card, centred, with the count as the largest thing on the
   page: on a phone held at arm's length the number should be readable before
   anything else is. */

:root {
  /* Hands the native date picker -- its calendar button, its popup, the
     scrollbars -- to the same theme as the rest of the page. Without it the
     button stays a black glyph on the dark card. */
  color-scheme: light dark;

  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #16181d;
  --ink-soft: #5c6270;
  --line: #e2e5ea;
  --accent: #1f6feb;
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --card: #1c1f25;
    --ink: #e8eaee;
    --ink-soft: #9aa1ae;
    --line: #2b2f37;
    --accent: #4a9eff;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 1rem;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.card {
  max-width: 34rem;
  margin: 0 auto;
  padding: 1.1rem 1.1rem 1.4rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.page-head h1 { margin: 0; font-size: 1.35rem; letter-spacing: -0.01em; }

/* Label above the field rather than beside it: a date input is already three
   controls wide, and a side label pushes it into wrapping on a small phone. */
.pick {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin: 1.1rem 0 0;
}

.pick label {
  color: var(--ink-soft);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pick input {
  /* Inherit the page font: Safari otherwise gives date inputs their own, and
     16px keeps iOS from zooming the page when the field is tapped. */
  font: inherit;
  font-size: 16px;

  /* Take the field out of native sizing.
   *
   * A date input keeps the platform's own control appearance, and a control
   * drawn that way is laid out from the platform's metrics: it is sized to the
   * date it holds and to its own minimum, not to the row it was handed. On iOS
   * those metrics win over the CSS box, so width and box-sizing read as
   * suggestions and the field lands at some other width than the one asked for.
   * Dropping the appearance is what makes the box below authoritative.
   *
   * Tapping still opens the system date picker. That follows from the input's
   * type, not from how it is painted. */
  -webkit-appearance: none;
  appearance: none;

  /* Said on the element rather than left to the * rule and the UA sheet, since
     these two are precisely what a natively drawn control disregards. */
  box-sizing: border-box;
  margin: 0;

  /* Fills its row on a phone, where the width is scarce and a short field would
     sit out of line with the count and the facts under it. min-width: 0 lets it
     shrink to the row on a narrow screen; max-width stops it leaving the row
     under any engine's idea of a minimum. */
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 0.55rem 0.65rem;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.pick input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* Past a phone there is more row than a date can use, so the field stops
   growing rather than becoming a wide box around ten characters. */
@media (min-width: 40rem) {
  .pick input { max-width: 16rem; }
}

.pick button {
  font: inherit;
  align-self: flex-start;
  margin-top: 0.4rem;
  padding: 0.5rem 0.9rem;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 8px;
}

.result { margin-top: 1.3rem; }

.count {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  /* Plain size first for browsers without clamp(), which drop the line below
     rather than half-applying it. */
  font-size: 4rem;
  font-size: clamp(3rem, 16vw, 5.5rem);
  /* Equal-width digits, so a count that ticks over at midnight does not shove
     the rest of the line sideways. */
  font-variant-numeric: tabular-nums;
}

.count-unit {
  margin: 0.15rem 0 0;
  font-size: 1.05rem;
}

.count-date { color: var(--ink-soft); }

/* Two columns from the first: label and value, each pair on its own row. */
.facts {
  margin: 1.2rem 0 0;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.4rem 0.9rem;
  font-size: 0.9rem;
}

.facts dt {
  color: var(--ink-soft);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  /* The labels are small caps and the values are not, so align their baselines
     by hand instead of letting the grid row centre them. */
  padding-top: 0.1rem;
}

.facts dd { margin: 0; }

.prompt { margin: 0; color: var(--ink-soft); }
