/* ============================================================================
   ATLAS design system

   A sibling to Flexili, not a twin. The greys, the spacing rhythm and the
   display typeface are shared, so a parent who has used Flexili recognises the
   family. The colour is deeper and quieter, so a report landing on a
   paediatrician's desk does not read as consumer software.

   Two densities from one system:
     .dense  the clinician workspace   — information-rich, used daily
     .calm   the collateral form       — used once, on a phone, by a stranger

   Nunito is self-hosted. docs/COMPLIANCE.md commits to no external fonts and no
   CDN calls, so that nothing about a client's session leaks to a third party
   through a referer header.
   ========================================================================= */

@font-face {
  font-family: 'Nunito';
  src: url('/assets/fonts/nunito-var.woff2') format('woff2');
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;

  /* --- neutrals: shared with Flexili, which is most of the family likeness --- */
  --grey-900: #111827;
  --grey-700: #374151;
  --grey-500: #6b7280;
  --grey-400: #9ca3af;
  --grey-200: #e5e7eb;
  --grey-100: #f3f4f6;
  --grey-50:  #f9fafb;

  /* --- colour: Flexili's hues, taken deeper and desaturated --- */
  --accent:        #245c7e;   /* Flexili blue, clinical weight */
  --accent-strong: #19455f;
  --accent-soft:   #e9f1f6;
  --warn:          #a35a0b;   /* Flexili orange, same */
  --warn-soft:     #fdf3e7;
  --crit:          #9b2c2c;
  --crit-soft:     #fbeaea;
  --ok:            #2f6b52;
  --ok-soft:       #e8f1ed;

  --bg:        var(--grey-50);
  --surface:   #ffffff;
  --surface-2: var(--grey-100);
  --border:    var(--grey-200);
  --border-strong: #d4d8de;
  --text:      var(--grey-900);
  --text-2:    var(--grey-700);
  --muted:     var(--grey-500);
  --faint:     var(--grey-400);

  /* --- type --- */
  --display: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;

  --t-xs: .75rem;    --t-sm: .8125rem;  --t-base: .9375rem;
  --t-md: 1.0625rem; --t-lg: 1.25rem;   --t-xl: 1.5rem;  --t-2xl: 1.875rem;

  /* --- rhythm --- */
  --s1: .25rem; --s2: .5rem;  --s3: .75rem; --s4: 1rem;
  --s5: 1.5rem; --s6: 2rem;   --s7: 3rem;

  --r-sm: 6px; --r-md: 10px; --r-lg: 14px;
  --shadow: 0 1px 2px rgba(17, 24, 39, .04), 0 1px 3px rgba(17, 24, 39, .06);
  --shadow-lift: 0 2px 4px rgba(17, 24, 39, .05), 0 4px 12px rgba(17, 24, 39, .08);
  --ring: 0 0 0 3px rgba(36, 92, 126, .18);
}

/* Light only, deliberately.
   A clinical record is read, printed, screen-shared in supervision and shown across a desk
   to a parent. Dark mode makes every one of those worse, and an interface that changes
   appearance depending on the reader's operating system is not something to hand a
   referring clinician. Flexili is white; so is this. */

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: var(--t-base);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

h1, h2, h3, h4 {
  font-family: var(--display);
  line-height: 1.2;
  letter-spacing: -.011em;
  margin: 0 0 var(--s2);
  font-weight: 700;
}
h1 { font-size: var(--t-xl); }
h2 { font-size: var(--t-lg); }
h3 { font-size: var(--t-md); font-weight: 700; }
h4 { font-size: var(--t-base); font-weight: 700; }
p  { margin: 0 0 var(--s3); }

a { color: var(--accent); text-underline-offset: 2px; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-strong); }

.muted  { color: var(--muted); }
.small  { font-size: var(--t-sm); }
.lead   { font-size: var(--t-md); color: var(--text-2); }
.mono   { font-family: var(--mono); font-size: var(--t-sm); }
.hidden { display: none !important; }

/* ---------- layout ---------- */

.wrap   { max-width: 1180px; margin: 0 auto; padding: var(--s5) var(--s4); }
.narrow { max-width: 680px; }
.row    { display: flex; gap: var(--s3); flex-wrap: wrap; }
.row > * { flex: 1 1 14rem; min-width: 0; }
.inline { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.spacer { flex: 1; }
.grid2  { display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); gap: var(--s4); }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

header.app {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
header.app .wrap {
  display: flex; align-items: center; gap: var(--s4);
  padding: var(--s3) var(--s4);
}
.brand {
  font-family: var(--display);
  font-weight: 800;
  letter-spacing: -.02em;
  font-size: var(--t-md);
  color: var(--text);
}
.brand span {
  font-family: var(--body);
  color: var(--muted); font-weight: 400;
  font-size: var(--t-xs); margin-left: var(--s2);
  letter-spacing: 0;
}

/* ---------- surfaces ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s4);
  margin-bottom: var(--s4);
  box-shadow: var(--shadow);
}
.card > h2:first-child, .card > h3:first-child, .card > h4:first-child { margin-top: 0; }

.banner {
  border-radius: var(--r-md);
  padding: var(--s3) var(--s4);
  margin-bottom: var(--s4);
  background: var(--accent-soft);
  border: 1px solid transparent;
  color: var(--text);
}

.notice {
  border-radius: var(--r-sm);
  padding: var(--s3);
  margin: var(--s3) 0;
  background: var(--ok-soft);
  border-left: 3px solid var(--ok);
  font-size: var(--t-sm);
}
.notice.warn { background: var(--warn-soft); border-left-color: var(--warn); }
.notice.crit { background: var(--crit-soft); border-left-color: var(--crit); }
.notice > :last-child { margin-bottom: 0; }

/* ---------- controls ---------- */

button, .btn {
  font: inherit;
  font-family: var(--display);
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--r-sm);
  padding: .45rem .85rem;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  transition: background .12s, border-color .12s, box-shadow .12s;
}
button:hover, .btn:hover { background: var(--surface-2); border-color: var(--muted); }
button:focus-visible, .btn:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; box-shadow: var(--ring); border-color: var(--accent);
}
button.primary, .btn.primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
button.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
button.link {
  background: none; border: none; padding: .15rem .1rem;
  color: var(--accent); text-decoration: underline;
  text-underline-offset: 2px; font-weight: 600;
}
button.link:hover { background: none; color: var(--accent-strong); }
button[disabled], .btn[disabled] { opacity: .5; cursor: not-allowed; }

label {
  display: block;
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--text-2);
  margin: var(--s3) 0 var(--s1);
}
input, select, textarea {
  font: inherit; width: 100%;
  padding: .5rem .65rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
}
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--accent); }
textarea { min-height: 5rem; resize: vertical; }
::placeholder { color: var(--faint); }

/* ---------- data ---------- */

table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
th {
  text-align: left; font-weight: 600; color: var(--muted);
  font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .04em;
  padding: var(--s2) var(--s3); border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { padding: var(--s2) var(--s3); border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-2); }

.pill {
  display: inline-block;
  font-family: var(--display); font-weight: 700;
  font-size: var(--t-xs); line-height: 1.5;
  padding: .05rem .5rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text-2);
  white-space: nowrap;
}
.pill.a { background: var(--ok-soft);   border-color: var(--ok);   color: var(--ok); }
.pill.b { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.pill.c { background: var(--surface-2); border-color: var(--border-strong); color: var(--muted); }

.bar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.bar > span.warn { background: var(--warn); }
.bar > span.crit { background: var(--crit); }

.conf { font-size: var(--t-xs); color: var(--muted); }
.entry { padding: var(--s3) 0; border-bottom: 1px solid var(--border); }
.entry:last-child { border-bottom: none; }
.item { padding: var(--s2) 0; }
.line { height: 1px; background: var(--border); border: none; margin: var(--s4) 0; }
.meta-grid { display: grid; grid-template-columns: auto 1fr; gap: var(--s1) var(--s4); font-size: var(--t-sm); }
.evidence { font-size: var(--t-sm); color: var(--text-2); }
.sub { font-size: var(--t-sm); color: var(--muted); }

.copy {
  display: block; font-family: var(--mono); font-size: var(--t-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: var(--s2) var(--s3);
  word-break: break-all; margin: var(--s2) 0;
}

.tabs { display: flex; gap: var(--s1); border-bottom: 1px solid var(--border); margin-bottom: var(--s4); flex-wrap: wrap; }
.tabs button {
  border: none; background: none; border-radius: 0;
  border-bottom: 2px solid transparent;
  padding: var(--s2) var(--s3); color: var(--muted);
}
.tabs button:hover { background: none; color: var(--text); }
.tabs button[aria-current="true"] { color: var(--accent); border-bottom-color: var(--accent); }

.toolbar { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; margin-bottom: var(--s4); }

/* ---------- the collateral form: calm, one column, thumb-reachable ---------- */

.calm { font-size: var(--t-md); line-height: 1.6; }
.calm .wrap { max-width: 34rem; padding: var(--s5) var(--s4) var(--s7); }
.calm h1 { font-size: var(--t-2xl); }
.calm .card { padding: var(--s5); border-radius: var(--r-lg); margin-bottom: var(--s5); }
.calm .q { margin-bottom: var(--s6); }
.calm .q > p { font-size: var(--t-md); font-weight: 600; margin-bottom: var(--s3); }
.calm .opts { display: grid; gap: var(--s2); }
.calm .opts label {
  display: flex; align-items: center; gap: var(--s3);
  margin: 0; padding: var(--s3) var(--s4);
  border: 1px solid var(--border); border-radius: var(--r-md);
  font-size: var(--t-base); font-weight: 500; color: var(--text);
  cursor: pointer; background: var(--surface);
  transition: border-color .12s, background .12s;
  min-height: 3rem;
}
.calm .opts label:hover { border-color: var(--accent); background: var(--accent-soft); }
.calm button { padding: .7rem 1.3rem; font-size: var(--t-base); }
.calm .progress {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg); padding: var(--s3) 0;
  font-size: var(--t-sm); color: var(--muted);
}
.qr { display: block; width: 220px; height: 220px; background: #fff; padding: var(--s2); border-radius: var(--r-md); }

/* ---------- print ---------- */

.masthead { border-bottom: 2px solid var(--text); padding-bottom: var(--s3); margin-bottom: var(--s5); }
.docfoot { border-top: 1px solid var(--border); padding-top: var(--s3); margin-top: var(--s6); font-size: var(--t-xs); color: var(--muted); }
.sig { margin-top: var(--s6); }
@media print { .no-print { display: none !important; } }

@media (max-width: 640px) {
  .wrap { padding: var(--s4) var(--s3); }
  .row > * { flex-basis: 100%; }
  h1 { font-size: var(--t-lg); }
}

/* ---------- sign-in: the first thing anyone sees ---------- */

.signin {
  display: flex; align-items: center; justify-content: center;
  min-height: calc(100vh - 14rem);
  padding: var(--s5) 0;
}
.signin .card {
  width: 100%; max-width: 23rem;
  padding: var(--s5);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lift);
  margin: 0;
}
.signin h2 { font-size: var(--t-lg); margin-bottom: var(--s1); }
.signin label:first-of-type { margin-top: 0; }

/* The header must not wrap into two rows of buttons on a laptop. */
header.app .wrap { flex-wrap: nowrap; }
header.app .brand { white-space: nowrap; flex: 0 0 auto; }
header.app #whoami { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
header.app nav { display: flex; gap: var(--s2); flex: 0 0 auto; }
header.app nav button { white-space: nowrap; }
@media (max-width: 900px) {
  header.app .brand span { display: none; }
  header.app #whoami { display: none; }
}

/* ---------- the Snapshot: situations grouped by setting ---------- */

.calm .setting {
  font-size: var(--t-sm); font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted);
  margin: var(--s6) 0 var(--s3); padding-bottom: var(--s2);
  border-bottom: 1px solid var(--border);
}
.calm .setting:first-child { margin-top: 0; }
.calm .probe {
  padding: var(--s4) 0;
  border-bottom: 1px solid var(--border);
}
.calm .probe:last-child { border-bottom: none; }
.calm .probe .stem {
  font-size: var(--t-md); font-weight: 650; color: var(--text);
  margin: 0 0 var(--s3);
}
.calm .facet { margin-bottom: var(--s3); }
.calm .facet-q {
  font-size: var(--t-sm); color: var(--muted); font-weight: 600;
  margin: 0 0 var(--s2);
}
/* Compact chips: four facets per situation would be unbearable as full-height cards. */
.calm .opts.tight { display: flex; flex-wrap: wrap; gap: var(--s2); }
.calm .opts.tight label {
  flex: 0 1 auto; min-height: 2.25rem; padding: var(--s2) var(--s3);
  font-size: var(--t-sm); font-weight: 500; border-radius: 999px; gap: var(--s2);
}
