/* One stylesheet, one screen. This is a utility, not a showcase: the only
   thing it has to do is let someone standing up, holding a phone in one hand,
   hit the right box every time.

   Mobile first throughout -- the base rules ARE the phone layout, and the one
   media query only widens things once there is room. Nothing has a fixed
   width, so 390px never scrolls sideways. */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --ink: #1b1b1b;
  --quiet: #5f5f5f;
  --line: #d4d4d4;
  --paper: #fdfdfb;
  --field: #ffffff;
  --flag: #9a3412;
  --flag-bg: #fff3ec;
  --good: #14532d;
  --good-bg: #eefaf1;
  --tap: 3rem;            /* every target is at least this tall */
}

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

body {
  margin: 0;
  padding: 0 0 4rem;
  background: var(--paper);
  color: var(--ink);
  font: 1rem/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  overflow-x: hidden;
}

main { padding: 0 0.75rem; }

/* -- chrome --------------------------------------------------------------- */

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--line);
  background: var(--field);
}
.bar a { color: var(--ink); text-decoration: none; }
.bar .home { font-weight: 700; letter-spacing: 0.02em; }
.bar nav a { color: var(--quiet); }

.jump {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--line);
  background: var(--field);
}
.jump input, .jump select { flex: 1 1 7rem; min-width: 0; }
.jump button { flex: 0 0 auto; }

h1 {
  margin: 1rem 0 0.75rem;
  font-size: 1.35rem;
  line-height: 1.2;
}
h1 .when {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--quiet);
}

h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--quiet);
}

/* -- messages ------------------------------------------------------------- */

.flash {
  margin: 0.75rem 0;
  padding: 0.6rem 0.75rem;
  border-radius: 0.4rem;
  background: var(--good-bg);
  color: var(--good);
}
.flash.bad { background: var(--flag-bg); color: var(--flag); }
.flash a { color: inherit; }

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

.block {
  margin: 0 0 1.25rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--field);
}

.lines { margin: 0; padding: 0; list-style: none; }

/* One column on a phone: label left, box right, nothing to scroll to. */
.line {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.25rem 0;
  flex-wrap: wrap;
}
.line + .line { border-top: 1px solid var(--line); }
.line label {
  flex: 1 1 auto;
  min-width: 0;
  min-height: var(--tap);
  display: flex;
  align-items: center;
}

input, select, button {
  font: inherit;
  min-height: var(--tap);
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 0.4rem;
  background: var(--field);
  color: var(--ink);
  padding: 0.35rem 0.6rem;
}

/* Wide enough for '89+3=91', still far from the edge of a 390px screen. */
.count {
  flex: 0 0 7rem;
  width: 7rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 1.15rem;
}
input:focus { outline: 3px solid #2563eb; outline-offset: 1px; }

.line.bad input { border-color: var(--flag); }
.why { flex: 1 0 100%; margin: 0.15rem 0 0.35rem; color: var(--flag); font-size: 0.85rem; }
.hint { flex: 1 0 100%; margin: 0.15rem 0 0.35rem; color: var(--quiet); font-size: 0.8rem; }

.foot { margin-top: 0.75rem; padding-top: 0.6rem; border-top: 2px solid var(--ink); }
.computed { margin: 0 0 0.4rem; font-size: 1.05rem; }
.computed output { font-weight: 700; font-variant-numeric: tabular-nums; }
.foot .line + .line { border-top: 0; }

.mismatch {
  margin: 0.4rem 0 0;
  padding: 0.5rem 0.6rem;
  border-radius: 0.4rem;
  background: var(--flag-bg);
  color: var(--flag);
  font-size: 0.9rem;
}
.mismatch[hidden] { display: none; }

.minor { display: block; margin-top: 0.6rem; font-size: 0.8rem; color: var(--quiet); }
.foot input:not(.count) { width: 100%; }

.save {
  position: sticky;
  bottom: 0.75rem;
  width: 100%;
  min-height: 3.25rem;
  border: 0;
  background: var(--ink);
  color: var(--paper);
  font-size: 1.05rem;
  font-weight: 600;
}

/* -- recent --------------------------------------------------------------- */

.weeks { margin: 0; padding: 0; list-style: none; }
.week {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.cell {
  flex: 1 1 10rem;
  min-width: 0;
  min-height: var(--tap);
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: 0.4rem;
  background: var(--field);
  color: var(--ink);
  text-decoration: none;
}
.cell .day { display: block; font-weight: 600; }
.cell .figure { display: block; font-size: 0.85rem; color: var(--quiet); }
.cell.done { border-left-color: var(--good); }
.cell.gap { border-left-color: var(--flag); background: var(--flag-bg); }
.cell.gap .gapmark { color: var(--flag); font-weight: 600; }
.cell.future { opacity: 0.55; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Only once there is room. Below this, everything above already fits. */
@media (min-width: 34rem) {
  main { max-width: 34rem; margin: 0 auto; }
  .count { flex-basis: 8rem; width: 8rem; }
}

/* -- problems -------------------------------------------------------------
   Loud enough to be seen from a pocket, quiet enough not to be the page. */

.problems {
  display: block;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--flag);
  background: var(--flag-bg);
  color: var(--flag);
  text-decoration: none;
  font-size: 0.95rem;
}

.problems-list { margin: 0; padding: 0; list-style: none; }
.problem {
  margin: 0 0 0.75rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line);
  border-left: 4px solid var(--flag);
  border-radius: 0.4rem;
  background: var(--field);
}
.problem .head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 0.25rem;
  font-size: 0.8rem;
  color: var(--quiet);
}
.problem .level { color: var(--flag); font-weight: 700; }
.problem .what { margin: 0 0 0.25rem; overflow-wrap: anywhere; }
.problem .where { margin: 0; font-size: 0.8rem; color: var(--quiet); overflow-wrap: anywhere; }
.problem details { margin-top: 0.4rem; font-size: 0.85rem; }
.problem summary { cursor: pointer; color: var(--quiet); min-height: 2rem; }
/* A traceback is the one thing here that is genuinely wide. Let it scroll
   inside its own box rather than taking the page sideways with it. */
.problem pre {
  margin: 0.4rem 0 0;
  padding: 0.5rem;
  max-width: 100%;
  overflow-x: auto;
  background: #f4f4f2;
  border-radius: 0.3rem;
  font-size: 0.75rem;
  line-height: 1.35;
}
