/* =====================================================================
   CHCP Glossary — design system. Colours derive from the CHCP wordmark.
   ===================================================================== */

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

html, body {
    margin: 0;
    padding: 0;
}

button, input, select, textarea {
    font: inherit;
    color: inherit;
}

button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

a {
    color: inherit;
    text-decoration: none;
}

ul, ol {
    list-style: none;
    margin: 0;
    padding: 0;
}

img, svg {
    display: block;
    max-width: 100%;
}

[hidden] {
    display: none !important;
}

/* ---------- Tokens ---------- */
:root {
    /* CHCP brand palette */
    --chcp-pink: #E6007E;
    --chcp-green: #8DC63F;
    --chcp-teal: #00A19A;
    --chcp-orange: #F6891F;
    --chcp-red: #D71920;
    --chcp-blue: #00A6E2;
    --chcp-purple: #A4308C;
    --chcp-navy: #1B2456;
    --chcp-dgreen: #006837;

    /* Tints */
    --chcp-pink-50: #FCE5F1;
    --chcp-pink-100: #F6BEDC;
    --chcp-green-50: #F2F9E2;
    --chcp-green-100: #DAEEB1;
    --chcp-teal-50: #DFF5F3;
    --chcp-teal-100: #B0E4E0;
    --chcp-orange-50: #FEEEDA;
    --chcp-orange-100: #FDD2A1;
    --chcp-red-50: #FBE0E2;
    --chcp-red-100: #F4B6BB;
    --chcp-blue-50: #DEF3FB;
    --chcp-blue-100: #B2E2F4;
    --chcp-purple-50: #F2DDEC;
    --chcp-purple-100: #DDB4D1;
    --chcp-navy-50: #E5E7EE;
    --chcp-navy-100: #BFC3D4;

    /* Semantic surfaces */
    --bg-page: #F8F6F1;
    --bg-surface: #FFFFFF;
    --bg-surface-2: #F2EFE8;
    --bg-inverse: var(--chcp-navy);

    /* Text */
    --text-1: #1B2456;
    --text-2: #4C536A;
    --text-3: #6B7185;
    --text-4: #9DA3B5;
    --text-on-dark: #FFFFFF;
    --text-on-primary: #FFFFFF;

    /* Borders */
    --border-1: #ECE7DC;
    --border-2: #DAD3C3;
    --border-strong: #1B2456;

    /* The wordmark blue #00A6E2 is only 2.78:1 on white (fails WCAG AA);
       #0076A8 is 5.05:1. */
    --primary: #0076a8;
    --primary-hover: #00638f;
    --primary-press: #004f73;
    --primary-soft: var(--chcp-blue-50);
    --primary-on: #FFFFFF;

    /* Type */
    --font-display: 'Varela Round', ui-sans-serif, system-ui, -apple-system, sans-serif;
    --font-body: 'Varela Round', ui-sans-serif, system-ui, -apple-system, sans-serif;

    /* Sizes */
    --fs-h1: clamp(32px, 3.6vw, 44px);
    --fs-h2: 28px;
    --fs-h3: 22px;
    --fs-h4: 18px;
    --fs-body-lg: 18px;
    --fs-body: 16px;
    --fs-small: 14px;
    --fs-micro: 12px;

    --lh-tight: 1.1;
    --lh-snug: 1.25;
    --lh-base: 1.5;
    --lh-loose: 1.65;

    /* Spacing (4-px base) */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-7: 32px;
    --space-8: 40px;
    --space-9: 48px;
    --space-10: 64px;
    --space-11: 80px;
    --space-12: 96px;

    /* Radius */
    --radius-xs: 4px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-pill: 999px;

    /* Shadows */
    --shadow-xs: 0 1px 1px rgba(27, 36, 86, 0.04);
    --shadow-sm: 0 1px 3px rgba(27, 36, 86, 0.06), 0 1px 2px rgba(27, 36, 86, 0.04);
    --shadow-md: 0 4px 14px rgba(27, 36, 86, 0.08), 0 2px 4px rgba(27, 36, 86, 0.04);
    --shadow-lg: 0 14px 36px rgba(27, 36, 86, 0.10), 0 4px 10px rgba(27, 36, 86, 0.06);
    --shadow-focus: 0 0 0 3px rgba(0, 166, 226, 0.32);

    --backdrop: rgba(27, 36, 86, 0.45);

    /* Layout */
    --container-max: 1180px;
    --container-pad: clamp(20px, 4vw, 40px);
    --header-h: 72px;

    /* Decorative only (keylines), so the bright hues' contrast doesn't matter. */
    --rainbow: linear-gradient(
        90deg,
        var(--chcp-pink) 0%, var(--chcp-purple) 16%, var(--chcp-blue) 33%,
        var(--chcp-teal) 50%, var(--chcp-green) 66%, var(--chcp-orange) 83%,
        var(--chcp-red) 100%
    );
    --aurora: radial-gradient(60vw 50vh at 8% -8%, rgba(230, 0, 126, 0.10), transparent 60%),
    radial-gradient(55vw 50vh at 95% -4%, rgba(0, 166, 226, 0.11), transparent 60%),
    radial-gradient(50vw 55vh at 50% 6%, rgba(0, 161, 154, 0.08), transparent 62%),
    radial-gradient(45vw 45vh at 100% 40%, rgba(141, 198, 63, 0.08), transparent 60%),
    radial-gradient(45vw 45vh at 0% 55%, rgba(246, 137, 31, 0.07), transparent 60%);
}

/* ---------- Base ---------- */
html {
    background: var(--bg-page);
    color: var(--text-1);
}

body {
    font-family: var(--font-body);
    font-size: var(--fs-body);
    line-height: var(--lh-base);
    color: var(--text-1);
    background-color: var(--bg-page);
    background-image: var(--aurora);
    background-attachment: fixed;
    background-repeat: no-repeat;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* Film grain sits behind content (z-index:-1) rather than blended over it,
   so text and contrast audits are unaffected. */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: 0.035;
    background-image: url('data:image/svg+xml,%3Csvg xmlns=\'http://www.w3.org/2000/svg\' width=\'160\' height=\'160\'%3E%3Cfilter id=\'n\'%3E%3CfeTurbulence type=\'fractalNoise\' baseFrequency=\'0.85\' numOctaves=\'2\' stitchTiles=\'stitch\'/%3E%3C/filter%3E%3Crect width=\'100%25\' height=\'100%25\' filter=\'url(%23n)\'/%3E%3C/svg%3E');
}

/* Sticky footer: <main> grows to fill short pages. */
.public-shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* `width: 100%` is needed: `.container`'s auto margins suppress the flex
   item's default stretch. */
.public-shell > main {
    flex: 1 0 auto;
    width: 100%;
}

h1, h2, h3, h4, h5 {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: var(--lh-tight);
    letter-spacing: -0.015em;
    margin: 0;
    color: var(--text-1);
}

p {
    margin: 0;
}

::selection {
    background: var(--chcp-blue-100);
    color: var(--text-1);
}

/* Skip link */
.skip-link {
    position: absolute;
    top: -100px;
    left: 16px;
    background: var(--chcp-navy);
    color: white;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    z-index: 100;
}

.skip-link:focus {
    top: 16px;
}

:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
    border-radius: var(--radius-sm);
}

/* ---------- Layout ---------- */
.container {
    max-width: var(--container-max);
    padding-left: var(--container-pad);
    padding-right: var(--container-pad);
    margin-left: auto;
    margin-right: auto;
}

.stack > * + * {
    margin-top: var(--stack-gap, var(--space-4));
}

.cluster {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
}

.cluster--center {
    justify-content: center;
}

/* ---------- Site header ---------- */
.site-header {
    position: relative;
    background: var(--bg-page);
}

.site-header::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background: var(--rainbow);
}

.site-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    min-height: var(--header-h);
    padding-top: var(--space-4);
    padding-bottom: var(--space-5);
}

.brand {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    color: var(--text-1);
}

.brand__logo {
    height: 80px;
    width: auto;
}

.brand__divider {
    width: 1px;
    height: 22px;
    background: var(--border-2);
}

.brand__name {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 18px;
    letter-spacing: -0.01em;
    color: var(--text-1);
}

.link-muted {
    font-size: var(--fs-small);
    font-weight: 500;
    color: var(--text-2);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
}

.link-muted:hover {
    background: var(--bg-surface-2);
    color: var(--text-1);
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--chcp-navy);
    color: white;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* ---------- Search ---------- */
.search {
    position: relative;
    background: var(--bg-surface);
    border: 1px solid var(--border-1);
    border-radius: var(--radius-md);
    padding: var(--space-2);
    box-shadow: var(--shadow-xs);
}

.search:focus-within {
    border-color: var(--chcp-blue);
    box-shadow: 0 0 0 3px rgba(0, 166, 226, 0.18);
}

.search__input {
    width: 100%;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    padding: 8px 40px 8px 32px;
    font-size: var(--fs-body);
    font-family: var(--font-body);
    color: var(--text-1);
}

.search__input::placeholder {
    color: var(--text-4);
}

.search__input:focus {
    outline: none;
}

.search__icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-3);
    pointer-events: none;
}

.search__kbd {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    gap: 2px;
    align-items: center;
}

.kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    border: 1px solid var(--border-2);
    border-bottom-width: 2px;
    border-radius: var(--radius-xs);
    font-size: var(--fs-micro);
    font-family: var(--font-body);
    font-weight: 600;
    color: var(--text-3);
    background: var(--bg-surface);
}

/* ---------- Eyebrow / section labels ---------- */
.eyebrow {
    font-family: var(--font-body);
    font-size: var(--fs-micro);
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-3);
    margin: 0 0 var(--space-3);
}

/* ---------- Entries list ---------- */
.entries-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin: var(--space-6) 0 var(--space-3);
    gap: var(--space-4);
    flex-wrap: wrap;
}

.entries-count {
    font-size: var(--fs-small);
    color: var(--text-3);
}

.entries-count strong {
    color: var(--text-1);
    font-weight: 600;
}

.sort {
    font-size: var(--fs-small);
    color: var(--text-3);
}

.entries-list {
    background: var(--bg-surface);
    border: 1px solid var(--border-1);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.entry {
    display: grid;
    grid-template-columns: 56px 1fr auto;
    gap: var(--space-4);
    padding: var(--space-5) var(--space-6);
    border-top: 1px solid var(--border-1);
    align-items: start;
}

.entry:first-child {
    border-top: none;
}

.entry:hover {
    background: rgba(255, 255, 255, 0.6);
}

/* Decorative (the term has its own column), so colour costs no legibility. */
.entry__letter {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 28px;
    line-height: 1;
    letter-spacing: -0.02em;
    margin-top: 2px;
    opacity: 0.9;
}

/* Darkened hues so each initial meets WCAG large-text contrast (≥3:1). */
.entries-list .entry:nth-of-type(7n+1) .entry__letter {
    color: #a40058;
}

.entries-list .entry:nth-of-type(7n+2) .entry__letter {
    color: #006b91;
}

.entries-list .entry:nth-of-type(7n+3) .entry__letter {
    color: #006c68;
}

.entries-list .entry:nth-of-type(7n+4) .entry__letter {
    color: #5b8a22;
}

.entries-list .entry:nth-of-type(7n+5) .entry__letter {
    color: #b85f00;
}

.entries-list .entry:nth-of-type(7n+6) .entry__letter {
    color: #7a1f66;
}

.entries-list .entry:nth-of-type(7n+7) .entry__letter {
    color: #97121a;
}

.entry__body {
    min-width: 0;
}

.entry__head {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-3);
    margin-bottom: var(--space-1);
}

.entry__term {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 20px;
    letter-spacing: -0.01em;
    color: var(--text-1);
}

.entry__def {
    color: var(--text-2);
    font-size: var(--fs-body);
    line-height: var(--lh-base);
    margin-top: var(--space-2);
}

.entry__tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-top: var(--space-3);
    padding-top: var(--space-3);
    border-top: 1px dashed var(--border-1);
}

.entry__actions {
    display: inline-flex;
    gap: var(--space-4);
    font-size: var(--fs-small);
    color: var(--text-3);
}

.entry__actions a {
    text-decoration: underline;
    text-decoration-color: var(--border-2);
    text-underline-offset: 3px;
}

.entry__actions a:hover {
    color: var(--text-1);
    text-decoration-color: var(--text-2);
}

.entry__right {
    display: flex;
    justify-content: flex-end;
}

/* ---------- Tag (area label on entries) ---------- */
.tag {
    --tag-color: var(--text-2);
    --tag-soft: var(--bg-surface-2);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    background: var(--tag-soft);
    color: var(--tag-color);
    font-size: var(--fs-micro);
    font-weight: 700;
    letter-spacing: 0.02em;
    border: 1px solid transparent;
}

.tag__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--tag-color);
}

.tag--clinical {
    --tag-color: #006B91;
    --tag-soft: var(--chcp-blue-50);
}

.tag--operational {
    --tag-color: #5B8A22;
    --tag-soft: var(--chcp-green-50);
}

.tag--it,
.tag--it-systems {
    --tag-color: #006C68;
    --tag-soft: var(--chcp-teal-50);
}

.tag--hr,
.tag--hr-people {
    --tag-color: #B85F00;
    --tag-soft: var(--chcp-orange-50);
}

.tag--governance {
    --tag-color: #7A1F66;
    --tag-soft: var(--chcp-purple-50);
}

.tag--safeguarding {
    --tag-color: #97121A;
    --tag-soft: var(--chcp-red-50);
}

.tag--acronyms {
    --tag-color: #A40058;
    --tag-soft: var(--chcp-pink-50);
}

/* ---------- Empty state ---------- */
.empty {
    background: var(--bg-surface);
    border: 1px dashed var(--border-2);
    border-radius: var(--radius-lg);
    padding: var(--space-9) var(--space-6);
    text-align: center;
    margin-top: var(--space-6);
}

.empty__icon {
    width: 56px;
    height: 56px;
    margin: 0 auto var(--space-4);
    border-radius: 50%;
    background: var(--bg-surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-3);
}

.empty__title {
    font-size: var(--fs-h3);
    margin-bottom: var(--space-2);
}

.empty__msg {
    color: var(--text-3);
    max-width: 50ch;
    margin: 0 auto var(--space-5);
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 10px 18px;
    font-weight: 600;
    font-size: var(--fs-small);
    border-radius: var(--radius-md);
    border: 1.5px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
}

/* Navy, not blue: white on #00A6E2 fails WCAG AA. */
.btn--primary {
    background: var(--chcp-navy);
    color: #ffffff;
    box-shadow: var(--shadow-sm);
}

.btn--primary:hover {
    background: #2a3570;
    box-shadow: var(--shadow-md);
}

.btn--primary:active {
    background: #141b45;
}

.btn--secondary {
    background: var(--bg-surface);
    color: var(--text-1);
    border-color: var(--border-2);
}

.btn--secondary:hover {
    background: var(--bg-surface-2);
    border-color: var(--chcp-navy-100);
}

.btn--ghost {
    background: transparent;
    color: var(--text-2);
}

.btn--ghost:hover {
    background: var(--bg-surface-2);
    color: var(--text-1);
}

.btn--danger {
    background: var(--bg-surface);
    color: var(--chcp-red);
    border-color: var(--chcp-red-100);
}

.btn--danger:hover {
    background: var(--chcp-red-50);
    border-color: var(--chcp-red);
}

.btn--sm {
    padding: 6px 12px;
    font-size: var(--fs-micro);
}

/* ---------- Data status (header, top right) ---------- */
.data-status {
    margin-left: auto;
    max-width: 46ch;
    text-align: right;
    font-size: var(--fs-small);
    line-height: 1.4;
    color: var(--text-2);
}

.data-status p {
    margin: 0;
}

.data-status__date {
    font-weight: 600;
    color: var(--text-1);
}

/* The dot repeats what the text says, so the state never relies on colour. */
.data-status__dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 6px;
    border-radius: 50%;
    background: var(--text-4);
}

.data-status__source[data-state='current'] .data-status__dot {
    background: #5b8a22;
}

.data-status__source[data-state='offline'] .data-status__dot {
    background: #b85f00;
}

.data-status__source[data-state='update'] .data-status__dot {
    background: var(--primary);
}

.data-status__reload {
    font-weight: 700;
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.data-status__reload:hover {
    color: var(--primary-hover);
}

/* ---------- Footer ---------- */
.site-footer {
    position: relative;
    margin-top: var(--space-12);
    padding: var(--space-8) 0;
    background: var(--bg-surface);
    color: var(--text-3);
    font-size: var(--fs-small);
}

.site-footer::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 2px;
    background: var(--rainbow);
    opacity: 0.7;
}

.site-footer__inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-4);
    flex-wrap: wrap;
}

.site-footer__links {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.site-footer__logo {
    height: 28px;
    opacity: 0.6;
}

.static-page {
    padding-top: clamp(32px, 4vw, 48px);
    padding-bottom: clamp(48px, 6vw, 80px);
}

/* ---------- Prose ---------- */
.prose {
    max-width: 720px;
    font-size: var(--fs-body-lg);
    line-height: var(--lh-loose);
    color: var(--text-1);
}

.prose h1 {
    font-size: var(--fs-h1);
    line-height: var(--lh-tight);
    margin: 0 0 var(--space-7);
}

.prose h2 {
    font-size: var(--fs-h2);
    line-height: var(--lh-snug);
    margin: var(--space-9) 0 var(--space-4);
}

.prose h3 {
    font-size: var(--fs-h3);
    line-height: var(--lh-snug);
    margin: var(--space-7) 0 var(--space-3);
}

.prose h4 {
    font-size: var(--fs-h4);
    line-height: var(--lh-snug);
    margin: var(--space-6) 0 var(--space-2);
}

.prose p {
    margin: 0 0 var(--space-5);
}

.prose ul,
.prose ol {
    list-style: disc;
    margin: 0 0 var(--space-5);
    padding-left: var(--space-7);
}

.prose ol {
    list-style: decimal;
}

.prose li {
    margin-bottom: var(--space-2);
}

.prose a {
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.prose a:hover {
    color: var(--primary-hover);
}

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

.muted {
    color: var(--text-3);
}

.spacer-7 {
    height: var(--space-7);
}

.spacer-12 {
    height: var(--space-7);
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
    :root {
        --container-pad: 16px;
    }

    .site-header__inner {
        flex-wrap: wrap;
    }

    .data-status {
        flex-basis: 100%;
        margin-left: 0;
        max-width: none;
        text-align: left;
    }

    .brand__logo {
        height: 52px;
    }

    /* Entries: reclaim horizontal space for the definition */
    .entry {
        grid-template-columns: 28px 1fr;
        gap: var(--space-2) var(--space-3);
        padding: var(--space-4);
    }

    .entry__letter {
        font-size: 20px;
    }

    .entry__right {
        grid-column: 2;
        justify-content: flex-start;
    }
}

@media (hover: none) and (pointer: coarse) {
    /* Touch devices have no keyboard: hide the ⌘K / Ctrl+K hint. */
    .search__kbd {
        display: none;
    }

    .search__input {
        padding-right: 8px;
    }
}

/* ---------- Print ---------- */
@media print {
    .site-header, .site-footer, .chips {
        display: none !important;
    }

    body {
        background: white;
    }

    .entry {
        break-inside: avoid;
    }
}
