/* HL7 Australia trainer registry.
 *
 * Brand values sampled from hl7.au: ink #0C0C0C, red #DA2128 for solid fills,
 * #EE2E24 for links, #C72026 for the darker shade, #F3F4F2 for panels.
 *
 * The red is a brand colour, not an interface colour. At roughly 4.1:1 on white
 * it fails WCAG AA for body text, so it is used for the logo, solid buttons and
 * focus rings — never for small text on a light background. Links take the darker
 * shade, and a lighter red returns in dark mode where contrast works the other way.
 */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/inter-latin-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/inter-latin-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/inter-latin-700.woff2') format('woff2');
}

/* Open Sauce One is the display face on hl7.au, self-hosted there as TTF from
 * their own CDN under the SIL Open Font License. Only the two weights the
 * headings need are carried, as woff2. */
@font-face {
  font-family: 'Open Sauce One';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/open-sauce-one-latin-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Open Sauce One';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/open-sauce-one-latin-700.woff2') format('woff2');
}

:root {
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Open Sauce One', var(--font-body);

  --brand-red: #da2128;
  --brand-red-dark: #c72026;
  --brand-red-bright: #ee2e24;

  --ink: #0c0c0c;
  --ink-soft: #4a4f55;
  --muted: #6b7280;
  --line: #dcdfe3;
  --line-strong: #c3c8ce;
  --bg: #ffffff;
  --panel: #f3f4f2;
  --panel-raised: #ffffff;

  --accent: var(--brand-red-dark);
  --accent-fill: var(--brand-red);
  --accent-contrast: #ffffff;
  --danger: #a3301f;
  --warn: #8a5a00;
  --ok: #1d6b3f;

  --radius: 6px;
  --shadow: 0 1px 2px rgba(12, 12, 12, 0.06), 0 2px 8px rgba(12, 12, 12, 0.04);
}

/* Dark mode follows the system unless an explicit choice is recorded on
 * <html data-theme>. Both blocks set the same tokens, so nothing downstream
 * needs to know which is in force. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --ink: #e9edf1;
    --ink-soft: #b4bcc6;
    --muted: #949ca8;
    --line: #2b323a;
    --line-strong: #3b434d;
    --bg: #101418;
    --panel: #171c22;
    --panel-raised: #1c222a;

    --accent: #ff6b60;
    --danger: #f0776a;
    --warn: #e0a955;
    --ok: #68c58d;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 2px 10px rgba(0, 0, 0, 0.3);
  }
}

:root[data-theme='dark'] {
  --ink: #e9edf1;
  --ink-soft: #b4bcc6;
  --muted: #949ca8;
  --line: #2b323a;
  --line-strong: #3b434d;
  --bg: #101418;
  --panel: #171c22;
  --panel-raised: #1c222a;

  --accent: #ff6b60;
  --danger: #f0776a;
  --warn: #e0a955;
  --ok: #68c58d;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 2px 10px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

main { max-width: 68rem; margin: 0 auto; padding: 2rem 1rem 4rem; }

a { color: var(--accent); }
a:hover { color: var(--brand-red-bright); }

:focus-visible {
  outline: 2px solid var(--brand-red);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ------------------------------------------------------------------ header */

.site-header {
  display: flex; flex-wrap: wrap; gap: 1rem 1.5rem; align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel-raised);
}

.brand { display: flex; align-items: center; gap: 0.8rem; text-decoration: none; color: var(--ink); }
.brand img { display: block; height: 30px; width: auto; }
.brand-text { display: block; line-height: 1.25; }
.brand .brand-name {
  display: block; font-family: var(--font-display);
  font-weight: 700; font-size: 0.98rem;
}
.brand .brand-sub { display: block; font-weight: 400; font-size: 0.76rem; color: var(--muted); }

.site-header nav {
  display: flex; gap: 1.25rem; align-items: center; flex-wrap: wrap;
  font-size: 0.925rem;
}
.site-header nav a { color: var(--ink-soft); text-decoration: none; }
.site-header nav a:hover { color: var(--accent); text-decoration: underline; }

/* The logo is artwork on a light ground; in dark mode it keeps its own light
 * chip rather than being inverted, which would wreck the gradient in the map. */
:root[data-theme='dark'] .brand img {
  background: #ffffff; border-radius: 3px; padding: 2px 5px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .brand img {
    background: #ffffff; border-radius: 3px; padding: 2px 5px;
  }
}

.theme-toggle {
  background: none; border: 1px solid var(--line-strong); color: var(--ink-soft);
  font: inherit; font-size: 0.82rem; padding: 0.3rem 0.75rem;
  border-radius: 999px; cursor: pointer; line-height: 1.3;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

.site-footer {
  border-top: 1px solid var(--line); padding: 1.25rem;
  color: var(--muted); font-size: 0.85rem; background: var(--panel);
}

/* ------------------------------------------------------------------ type */

/* Open Sauce for display, Inter for everything else — the same division
 * hl7.au makes. Its letterforms are wider than Inter's, so the headings carry
 * less negative tracking than they did. */
h1, h2, h3 { font-family: var(--font-display); }

h1 {
  font-size: 1.75rem; line-height: 1.2; margin: 0 0 0.5rem;
  letter-spacing: -0.01em; font-weight: 700;
}
h2 {
  font-size: 1.2rem; margin: 2.25rem 0 0.6rem; font-weight: 700;
  letter-spacing: 0;
}
h3 { font-size: 1.05rem; margin: 0 0 0.5rem; font-weight: 600; }

.lede { color: var(--muted); margin-top: 0; }
.empty { color: var(--muted); font-style: italic; }
.hint { display: block; color: var(--muted); font-size: 0.85rem; }
.error { display: block; color: var(--danger); font-size: 0.85rem; }

.notice {
  background: var(--panel); border-left: 3px solid var(--accent-fill);
  padding: 0.8rem 1rem; margin: 0 0 1.5rem;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.error-notice { border-left-color: var(--danger); }

/* ------------------------------------------------------------------ cards */

.card-list {
  list-style: none; padding: 0; display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
}
.card {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem; background: var(--panel-raised); box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 0.25rem; font-size: 1.05rem; }
.card .org { color: var(--muted); margin: 0 0 0.6rem; font-size: 0.9rem; }
.card .group-label {
  margin: 0.7rem 0 0.1rem; font-size: 0.7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted);
}
.card .credentials { margin: 0; padding-left: 1.1rem; font-size: 0.875rem; }

.status {
  display: inline-block; font-size: 0.75rem; font-weight: 500;
  padding: 0.15rem 0.6rem; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line-strong); color: var(--ink-soft);
}
.status-approved {
  background: rgba(29, 107, 63, 0.12); border-color: rgba(29, 107, 63, 0.4); color: var(--ok);
}
.status-interim {
  background: rgba(138, 90, 0, 0.12); border-color: rgba(138, 90, 0, 0.4); color: var(--warn);
}
.status-unsuccessful {
  background: rgba(199, 32, 38, 0.1); border-color: rgba(199, 32, 38, 0.35); color: var(--danger);
}

/* ------------------------------------------------------------------ tables */

table.grid {
  width: 100%; border-collapse: collapse; margin-top: 1rem;
  background: var(--panel-raised); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
table.grid th, table.grid td {
  text-align: left; padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--line); vertical-align: top;
}
table.grid tr:last-child td { border-bottom: 0; }
table.grid th {
  background: var(--panel); font-size: 0.78rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted);
}
td.expired { color: var(--danger); }

dl.detail {
  display: grid; grid-template-columns: minmax(10rem, 16rem) 1fr;
  gap: 0.45rem 1.25rem;
}
dl.detail dt { color: var(--muted); font-size: 0.875rem; }
dl.detail dd { margin: 0; white-space: pre-wrap; }
.restricted { border-left: 3px solid var(--warn); padding-left: 1rem; }

/* ------------------------------------------------------------------ forms */

.form { display: grid; gap: 1.1rem; max-width: 44rem; margin-top: 1.5rem; }
.form.narrow { max-width: 26rem; }
.form label { display: grid; gap: 0.3rem; font-size: 0.875rem; color: var(--muted); }
.form label.check {
  display: flex; gap: 0.6rem; align-items: start;
  color: var(--ink); font-size: 1rem;
}
.form input, .form select, .form textarea {
  font: inherit; color: var(--ink); padding: 0.5rem 0.6rem;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--bg); width: 100%;
}
.form input:focus, .form select:focus, .form textarea:focus {
  border-color: var(--accent-fill); outline: none;
  box-shadow: 0 0 0 3px rgba(218, 33, 40, 0.18);
}
.form label.check input { width: auto; accent-color: var(--brand-red); }
.form fieldset {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.1rem; display: grid; gap: 0.6rem; background: var(--panel);
}
.form fieldset legend {
  padding: 0 0.45rem; color: var(--muted); font-size: 0.78rem;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
}
.form .actions { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.button {
  display: inline-block; background: var(--accent-fill); color: var(--accent-contrast);
  border: 0; padding: 0.55rem 1.1rem; border-radius: var(--radius);
  font: inherit; font-weight: 500; cursor: pointer; text-decoration: none;
}
.button:hover { background: var(--brand-red-dark); color: var(--accent-contrast); }
.button.danger { background: var(--danger); }
.button.danger:hover { background: #8c2819; }

button.link {
  background: none; border: 0; padding: 0; font: inherit; color: var(--accent);
  cursor: pointer; text-decoration: underline;
}
button.link.danger, a.link.danger { color: var(--danger); }
.inline, .inline-form { display: inline; margin: 0; }

/* ------------------------------------------------------------------ admin */

.stats {
  list-style: none; padding: 0; display: grid; gap: 0.75rem;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
}
.stats li {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.9rem 1rem; background: var(--panel-raised); box-shadow: var(--shadow);
  font-size: 0.9rem; color: var(--muted);
}
.stats strong {
  font-size: 1.6rem; display: block; color: var(--ink);
  font-family: var(--font-display); font-weight: 700;
}

.admin-nav, .filters { display: flex; gap: 1.25rem; margin-top: 1.5rem; flex-wrap: wrap; }
.filters a { text-transform: capitalize; }
.filters a.current { font-weight: 700; color: var(--ink); }

.filter-bar {
  display: flex; gap: 1rem; align-items: end; flex-wrap: wrap;
  margin: 1.5rem 0 0.5rem; padding: 0.9rem 1rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.filter-bar label { display: grid; gap: 0.3rem; font-size: 0.85rem; color: var(--muted); }
.filter-bar select {
  font: inherit; color: var(--ink); padding: 0.45rem 0.55rem;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--bg); max-width: 28rem;
}

.credential-card {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.25rem; margin-bottom: 1.25rem;
  background: var(--panel-raised); box-shadow: var(--shadow);
}
.credential-card.unclassified { border-left: 3px solid var(--warn); }
.credential-card .warn-note { color: var(--warn); font-size: 0.875rem; margin: 0 0 0.75rem; }
.credential-card .form { margin-top: 0.5rem; }

ul.plain { margin: 0; padding-left: 1.1rem; }

@media (max-width: 40rem) {
  dl.detail { grid-template-columns: 1fr; gap: 0.1rem 0; }
  dl.detail dt { margin-top: 0.75rem; }
  .site-header { padding: 0.75rem 1rem; }
  main { padding: 1.5rem 1rem 3rem; }
}
