/*
  The interface vocabulary for Duty Roster.
  ------------------------------------------------------------------
  Plain CSS on purpose: no toolchain, and nothing loads from another host,
  because a page showing a child's name should make no request to anyone else
  (docs/adr/ADR-001-thin-omakase-stack.md).

  Read docs/interface.md for what each pattern is FOR. See every pattern in
  every state at /development/style_guide while the server is in development.

  Order below: tokens, base, then one block per named pattern.
*/

/* ---------------------------------------------------------------- tokens */

:root {
  /* Surfaces, from the page backwards. */
  --surface: #f7f7f5;
  --surface-raised: #ffffff;
  --surface-sunken: #ececeb;

  /* Ink, from loudest to quietest. */
  --ink: #16202b;
  --ink-soft: #55616d;
  --ink-faint: #8a949e;

  --line: #dde1e6;
  --line-strong: #c3c9d0;

  /* One accent, used for what you can act on. Never as a page-wide surface:
     a wash of brand colour behind everything is how the header ended up
     glowing in dark mode. */
  --brand: #1f4f82;
  --brand-ink: #ffffff;
  --brand-quiet: #e8eff7;

  --good: #1a6b45;
  --warn: #8a5a00;
  --bad: #9b2226;

  /* Space, one scale, used everywhere. */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;

  /* Type, one scale. */
  --text-xs: 0.75rem;
  --text-s: 0.875rem;
  --text-m: 1rem;
  --text-l: 1.25rem;
  --text-xl: 1.625rem;

  --weight-normal: 400;
  --weight-medium: 500;
  --weight-bold: 600;

  --radius: 10px;
  --radius-s: 6px;

  /* A thumb is about this big. Every control a parent taps clears it. */
  --tap: 44px;

  --measure: 44rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --surface: #11161b;
    --surface-raised: #1a2026;
    --surface-sunken: #0c1014;

    --ink: #e9edf2;
    --ink-soft: #a7b1bb;
    --ink-faint: #717c87;

    --line: #2b333b;
    --line-strong: #3d4751;

    --brand: #8ab4e8;
    --brand-ink: #0d1218;
    --brand-quiet: #1d2a38;

    --good: #6fcf97;
    --warn: #e2b04a;
    --bad: #f08a8a;
  }
}

/* ------------------------------------------------------------------ base */

* { box-sizing: border-box; }

body {
  margin: 0;
  /* Nothing should ever scroll sideways on a phone. If something does, it is a
     long word rather than a layout, and the rules below break it. */
  overflow-x: hidden;
  background: var(--surface);
  color: var(--ink);
  font: var(--text-m)/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

main { max-width: var(--measure); margin: 0 auto; padding: var(--space-5) var(--space-4) var(--space-7); }

h1 { font-size: var(--text-xl); line-height: 1.25; margin: 0 0 var(--space-2); overflow-wrap: anywhere; }
h2 { font-size: var(--text-l); line-height: 1.3; margin: var(--space-6) 0 var(--space-2); }
h3 { font-size: var(--text-m); margin: var(--space-5) 0 var(--space-2); }
p { margin: var(--space-2) 0; }

a { color: var(--brand); }

.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
.small { font-size: var(--text-s); }
.stack > * + * { margin-top: var(--space-3); }

/* -------------------------------------------------------- pattern: bar */
/* The top bar is a surface with a rule under it, not a band of brand colour.
   Brand is for things you can act on. */

.bar {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-raised);
  border-bottom: 1px solid var(--line);
}
.bar__brand { color: var(--ink); font-weight: var(--weight-bold); text-decoration: none; }
/* On a narrow screen the bar is two rows: the pack's name, then where to go. */
@media (max-width: 30rem) {
  .bar { gap: var(--space-1); }
  .bar__nav { width: 100%; gap: var(--space-3); }
}
.bar__nav { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-4); font-size: var(--text-s); }

/* ------------------------------------------------ pattern: page header */
/* Title, then one quiet line of facts, then quiet links. Never buttons. */

.page-head { margin-bottom: var(--space-5); }
.page-head__meta { color: var(--ink-soft); font-size: var(--text-s); margin: 0; }
.meta-links { color: var(--ink-soft); font-size: var(--text-s); margin: var(--space-2) 0 0; }

/* ---------------------------------------------- pattern: section header */
/* A heading that carries the actions which act on that section. */

.section-head {
  display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4);
  align-items: baseline; justify-content: space-between;
  margin: var(--space-6) 0 var(--space-2);
}
.section-head h2 { margin: 0; }

/* -------------------------------------------------------- pattern: card */

.card {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-4);
  margin: var(--space-3) 0;
}

/* --------------------------------------------------- pattern: list rows */
/* A row is a title you can open, some quiet facts, and at most one action. */

.list { list-style: none; padding: 0; margin: 0; }
.list > li {
  display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4);
  align-items: baseline; justify-content: space-between;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--line);
}
.list > li:last-child { border-bottom: 0; }
.row { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); align-items: baseline; justify-content: space-between; }
.row__title { font-weight: var(--weight-bold); text-decoration: none; color: var(--ink); }
.row__title:hover { text-decoration: underline; }
.row__facts {
  color: var(--ink-soft); font-size: var(--text-s); font-weight: var(--weight-normal);
  /* An email address has nowhere to break, and on a 390px screen it would
     otherwise push the whole page sideways. */
  overflow-wrap: anywhere;
}

/* ----------------------------------------------------- pattern: buttons */
/* Three weights and two sizes. One primary per view, at most. */

button, .button, input[type="submit"] {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--tap); padding: var(--space-2) var(--space-4);
  font-size: var(--text-m); font-weight: var(--weight-bold); line-height: 1;
  text-decoration: none; white-space: nowrap;
  color: var(--brand-ink); background: var(--brand);
  border: 1px solid transparent; border-radius: var(--radius-s); cursor: pointer;
}
.button--quiet, input[type="submit"].button--quiet {
  background: transparent; color: var(--brand); border-color: var(--line-strong);
}
.button--danger, input[type="submit"].button--danger {
  background: transparent; color: var(--bad); border-color: var(--line);
  font-weight: var(--weight-medium);
}
.button--small, input[type="submit"].button--small {
  min-height: 2.25rem; padding: var(--space-1) var(--space-3);
  font-size: var(--text-s); font-weight: var(--weight-medium);
}
.link-button {
  background: none; border: 0; padding: 0; min-height: 0;
  font-weight: var(--weight-normal); font-size: inherit;
  color: var(--brand); text-decoration: underline; cursor: pointer;
}
.actions { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin-top: var(--space-4); }
.section-head .actions, .list .actions { margin-top: 0; }

/* ------------------------------------------------------- pattern: forms */

label { display: block; font-weight: var(--weight-bold); margin-bottom: var(--space-1); }
.field { margin-bottom: var(--space-4); }
.field__hint { display: block; color: var(--ink-soft); font-size: var(--text-s); font-weight: var(--weight-normal); margin-bottom: var(--space-1); }

input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]), select, textarea {
  width: 100%; min-height: var(--tap);
  padding: var(--space-2) var(--space-3);
  font: inherit; color: var(--ink);
  background: var(--surface-raised);
  border: 1px solid var(--line-strong); border-radius: var(--radius-s);
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px;
}
input[type="checkbox"] { width: 1.1rem; height: 1.1rem; min-height: 0; }
input[type="number"] { max-width: 8rem; }
.code-input { font-size: var(--text-l); letter-spacing: 0.3em; text-align: center; font-variant-numeric: tabular-nums; max-width: 12rem; }
.errors { color: var(--bad); }

/* -------------------------------------------------- pattern: status tag */

.tag {
  display: inline-block; font-size: var(--text-xs); font-weight: var(--weight-bold);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.tag--admin, .tag--update { color: var(--warn); }
.tag--scout { color: var(--ink-faint); }
.tag--blocked { color: var(--bad); }
.tag--create { color: var(--good); }

/* ------------------------------------------------------ pattern: notice */

.flash {
  position: sticky; top: var(--space-2); z-index: 2;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line); border-left-width: 3px;
  border-radius: var(--radius-s);
  background: var(--surface-raised);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.12);
}
.flash--notice { border-left-color: var(--good); }
.flash--alert { border-left-color: var(--bad); }

/* ------------------------------------------------------ pattern: steps */
/* What happens next, in order. For the end of a flow, where the person has
   done their part and is waiting on someone else. */

.steps { margin: var(--space-3) 0; padding-left: var(--space-5); }
.steps > li { margin-bottom: var(--space-2); }

/* ------------------------------------------------- pattern: empty state */
/* What is missing, and the one thing to do about it. */

.empty {
  padding: var(--space-5) var(--space-4);
  border: 1px dashed var(--line-strong); border-radius: var(--radius);
  color: var(--ink-soft); text-align: center;
}
.empty .actions { justify-content: center; }

/* ------------------------------------------------------ pattern: footer */

.footer {
  max-width: var(--measure); margin: 0 auto;
  padding: var(--space-6) var(--space-4) var(--space-7);
  color: var(--ink-faint); font-size: var(--text-xs);
}

/* -------------------------------------------------------------- printing */
/* The day sheet is the one page meant to leave the screen: an organizer
   carries it on a clipboard. Everything you cannot tap on paper comes off, and
   a day never splits across two sheets if it can be helped. */

.no-print { display: none; }

@media print {
  .bar, .footer, .actions, .meta-links, .no-print, form { display: none !important; }

  body { background: #fff; color: #000; font-size: 11pt; }
  main { max-width: none; padding: 0; }

  a { color: #000; text-decoration: none; }

  .card { border: 1px solid #999; break-inside: avoid; margin: 0 0 0.4cm; padding: 0.3cm; }
  .day-sheet__block { break-inside: avoid-page; margin-bottom: 0.6cm; }
  .list > li { border-color: #ccc; padding: 0.15cm 0; }

  h1 { font-size: 16pt; }
  h2 { font-size: 13pt; margin: 0.4cm 0 0.2cm; }

  /* Nothing is "muted" on paper: grey text photocopies badly and this is read
     in a hall. */
  .muted, .row__facts, .faint, .small { color: #000; }
}
