/* The complete light palette lives on bare :root. The dark blocks below
   redefine only the tokens, so every rule in this file is written once. */
:root {
  --red: #c61623;
  --ink: #212934;
  --body: #4a5261;
  --line: #e4e8ec;
  --bg-soft: #f8f9fb;
  --paper: #ffffff;
  --wash: #f1f3f6;

  /* The masthead's width control switches this. */
  --wrap-max: 860px;
}
:root[data-width="wide"] { --wrap-max: 1200px; }

/* Three theme states, the same pattern on every DIDAS site: no data-theme
   follows the operating system, data-theme="light" and "dark" override it. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --red: #ff6b73;
    --ink: #e6eaef;
    --body: #a6b0bd;
    --line: #2a313b;
    --bg-soft: #171c22;
    --paper: #11151a;
    --wash: #1b2128;
  }
}
:root[data-theme="dark"] {
  --red: #ff6b73;
  --ink: #e6eaef;
  --body: #a6b0bd;
  --line: #2a313b;
  --bg-soft: #171c22;
  --paper: #11151a;
  --wash: #1b2128;
}

* { box-sizing: border-box; }

/* The masthead's text-size control sets this in px; everything typographic in
   this file is in rem so that it follows. */
html { scroll-behavior: smooth; font-size: 16px; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.6;
}

a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

.wrap {
  max-width: var(--wrap-max);
  margin: 0 auto;
  padding: 0 24px;
}

/* ===========================================================================
   Shared DIDAS masthead
   The same header across the DIDAS sites: the identity line from the
   digital-health_swiyu showcase, in the bar geometry and hairline rule of
   this page. Only the four --mh-* values below differ between sites;
   everything after them is identical everywhere, so a change to the design
   can be copied across without rereading each site's stylesheet.
   =========================================================================== */
.site-masthead {
  --mh-rule:  var(--line);
  --mh-ink:   var(--body);
  --mh-hover: var(--red);
  --mh-wash:  var(--wash);
  --mh-width: var(--wrap-max);   /* this page's own content width, so the bar
                                    lines up with the text below it */

  border-bottom: 1px solid var(--mh-rule);
}
.site-masthead .bar {
  max-width: var(--mh-width);
  margin-inline: auto;
  padding-inline: 24px;
  padding-block: 22px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 24px;
}
.site-masthead .id {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 12px;
}
.site-masthead .didas { display: inline-flex; align-items: center; line-height: 0; }
.site-masthead .didas img { height: 20px; width: auto; display: block; }
.site-masthead .eyebrow {
  margin: 0;
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--mh-ink);
}
.site-masthead .repolink {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--mh-ink);
  text-decoration: none;
  white-space: nowrap;
}
.site-masthead .repolink svg { flex: none; }
.site-masthead .repolink span {
  border-bottom: 1px solid var(--mh-rule);
  padding-bottom: 2px;
}
.site-masthead .repolink:hover { color: var(--mh-hover); }
.site-masthead .repolink:hover span { border-bottom-color: currentColor; }

/* The same controls the glossary carries — colour theme, layout width and text
   size — reading and writing the same localStorage keys. All four DIDAS sites
   are served from one origin, so a preference set on any of them is the
   preference on all of them. */
.site-masthead .tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
}
.site-masthead .seg {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--mh-rule);
  border-radius: 4px;
  overflow: hidden;
}
.site-masthead button {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: 0;
  margin: 0;
  padding: 5px 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--mh-ink);
  cursor: pointer;
  font: inherit;
  line-height: 0;
}
.site-masthead .seg button + button { border-left: 1px solid var(--mh-rule); }
.site-masthead button:hover { color: var(--mh-hover); }
.site-masthead button[aria-pressed="true"] {
  color: var(--mh-hover);
  background: var(--mh-wash);
}
.site-masthead button svg { width: 14px; height: 14px; display: block; }
.site-masthead .seg.text button {
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1;
  padding-block: 4px;
}
.site-masthead .seg.text button:first-child { font-size: 0.62rem; }
.site-masthead .seg.text button:last-child  { font-size: 0.88rem; }
/* The width control shows the action it would take, so it swaps icon rather
   than carrying the pressed background the theme buttons use. */
.site-masthead button[data-width-value] .w-contract { display: none; }
.site-masthead button[data-width-value][aria-pressed="true"] { background: none; }
.site-masthead button[data-width-value][aria-pressed="true"] .w-expand { display: none; }
.site-masthead button[data-width-value][aria-pressed="true"] .w-contract { display: block; }
/* === end shared DIDAS masthead ========================================== */

/* Hero */
.hero {
  padding: 56px 0 40px;
}
.eyebrow {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--red);
  margin-bottom: 14px;
}
h1 {
  font-size: clamp(1.75rem, 4vw, 2.375rem);
  line-height: 1.2;
  margin: 0 0 16px;
  letter-spacing: -0.01em;
}
.lede {
  font-size: 1.0312rem;
  color: var(--body);
  max-width: 640px;
  margin: 0 0 4px;
}
.rule {
  width: 40px;
  height: 3px;
  background: var(--red);
  border-radius: 2px;
  margin: 22px 0 0;
}

/* Sections */
section { padding: 36px 0; border-top: 1px solid var(--line); }
h2 {
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--body);
  margin: 0 0 20px;
}

/* Flow cards */
.flows { display: flex; flex-direction: column; gap: 0; }
.flow {
  display: grid;
  grid-template-columns: 160px 1fr auto;
  gap: 20px;
  align-items: start;
  padding: 22px 0;
  border-top: 1px solid var(--line);
}
.flow:first-child { border-top: none; }
.flow-tag {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--red);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-top: 2px;
}
/* Sizes are in rem so the shared masthead's text-size control reaches them. */
.flow-noga {
  display: block;
  margin-top: 4px;
  font-size: 0.6562rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--body);
  opacity: 0.75;
}
.section-note {
  margin: -8px 0 18px;
  font-size: 0.875rem;
  color: var(--body);
  max-width: 68ch;
}
.flow-body h3 { margin: 0 0 6px; font-size: 1rem; }
.flow-body p { margin: 0; color: var(--body); font-size: 0.9062rem; }
.flow-body ul { margin: 8px 0 0; padding-left: 18px; color: var(--body); font-size: 0.875rem; }
.flow-body li { margin-bottom: 2px; }
.flow-link {
  font-size: 0.8438rem;
  font-weight: 600;
  white-space: nowrap;
  padding-top: 2px;
}
.status {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--bg-soft);
  color: var(--body);
  border: 1px solid var(--line);
  margin-top: 8px;
}

/* Back link on subpage */
.back-link { font-size: 0.8438rem; font-weight: 600; }

/* Diagram embed area */
.diagram-frame {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-soft);
}
.diagram-frame iframe {
  width: 100%;
  height: 640px;
  border: 0;
  display: block;
  /* The embedded LikeC4 diagram is a light document, so this stays white in
     both themes rather than showing a dark frame around a light page. */
  background: #fff;
}
.diagram-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  font-size: 0.8438rem;
  color: var(--body);
  background: var(--paper);
}

/* Footer */
footer.site {
  border-top: 1px solid var(--line);
  margin-top: 20px;
}
footer.site .wrap {
  padding: 28px 24px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.8125rem;
  color: var(--body);
}
footer.site a { color: var(--body); }

@media (max-width: 640px) {
  .flow { grid-template-columns: 1fr; gap: 8px; }
  .flow-link { justify-self: start; }
}
