/* ==========================================================================
   nlco.ca design system — single stylesheet, light + dark themes.
   Brand blue #336699; system font stack; WCAG AA contrast throughout.
   ========================================================================== */

/* ---- Tokens ------------------------------------------------------------ */

:root {
    --brand: #336699;
    --brand-dark: #27527b;
    --brand-deep: #1d3e5e;
    --accent: #1e88c7;
    --bg: #ffffff;
    --surface: #f4f7fa;
    --surface-2: #e8eef5;
    --text: #1f2933;
    --text-muted: #52606d;
    --border: #d9e2ec;
    --link: #27527b;
    --focus: #1e88c7;
    --on-brand: #ffffff;
    --header-bg: rgba(255, 255, 255, 0.92);
    --shadow: 0 1px 3px rgba(31, 41, 51, 0.08), 0 4px 16px rgba(31, 41, 51, 0.06);
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --brand: #4d84b8;
        --brand-dark: #6ea3d0;
        --brand-deep: #16283c;
        --accent: #63b3e4;
        --bg: #11181f;
        --surface: #1a232c;
        --surface-2: #22303d;
        --text: #e5ebf1;
        --text-muted: #9fb0c0;
        --border: #2c3a48;
        --link: #8bbde4;
        --focus: #63b3e4;
        --on-brand: #0b1218;
        --header-bg: rgba(17, 24, 31, 0.92);
        --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.3);
    }
}
:root[data-theme="dark"] {
    --brand: #4d84b8;
    --brand-dark: #6ea3d0;
    --brand-deep: #16283c;
    --accent: #63b3e4;
    --bg: #11181f;
    --surface: #1a232c;
    --surface-2: #22303d;
    --text: #e5ebf1;
    --text-muted: #9fb0c0;
    --border: #2c3a48;
    --link: #8bbde4;
    --focus: #63b3e4;
    --on-brand: #0b1218;
    --header-bg: rgba(17, 24, 31, 0.92);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.3);
}

/* ---- Accessibility preferences ------------------------------------------
   Set as attributes on <html> by js/theme.js (persisted in localStorage):
   data-textsize="large|xlarge", data-contrast="high". Everything is
   rem-based, so scaling the root font-size scales the whole UI. */

html[data-textsize="large"] { font-size: 112.5%; }
html[data-textsize="xlarge"] { font-size: 125%; }

/* High contrast, light */
:root[data-contrast="high"] {
    --brand: #1d3e5e;
    --brand-dark: #14293d;
    --brand-deep: #14293d;
    --accent: #0000c7;
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-2: #ffffff;
    --text: #000000;
    --text-muted: #1a1a1a;
    --border: #000000;
    --link: #0000c7;
    --focus: #0000c7;
    --on-brand: #ffffff;
    --header-bg: #ffffff;
    --shadow: none;
}

/* High contrast, dark */
:root[data-contrast="high"][data-theme="dark"] {
    --brand: #99ccff;
    --brand-dark: #c2e0ff;
    --brand-deep: #000000;
    --accent: #99ccff;
    --bg: #000000;
    --surface: #000000;
    --surface-2: #000000;
    --text: #ffffff;
    --text-muted: #e6e6e6;
    --border: #ffffff;
    --link: #99ccff;
    --focus: #ffff00;
    --on-brand: #000000;
    --header-bg: #000000;
    --shadow: none;
}
@media (prefers-color-scheme: dark) {
    :root[data-contrast="high"]:not([data-theme="light"]) {
        --brand: #99ccff;
        --brand-dark: #c2e0ff;
        --brand-deep: #000000;
        --accent: #99ccff;
        --bg: #000000;
        --surface: #000000;
        --surface-2: #000000;
        --text: #ffffff;
        --text-muted: #e6e6e6;
        --border: #ffffff;
        --link: #99ccff;
        --focus: #ffff00;
        --on-brand: #000000;
        --header-bg: #000000;
        --shadow: none;
    }
}

/* High contrast: every link underlined, stronger borders/outlines, no
   gradients or translucency. */
[data-contrast="high"] a { text-decoration: underline; }
[data-contrast="high"] :focus-visible { outline-width: 3px; }
[data-contrast="high"] .btn { border-width: 2px; }
[data-contrast="high"] .site-header { backdrop-filter: none; }
[data-contrast="high"] .hero,
[data-contrast="high"] .page-title {
    background: var(--brand-deep);
    border-bottom: 2px solid var(--border);
}
[data-contrast="high"] .card,
[data-contrast="high"] details,
[data-contrast="high"] .notice,
[data-contrast="high"] .callout,
[data-contrast="high"] .bulletin { border-width: 2px; }
:root[data-contrast="high"][data-theme="dark"] .hero,
:root[data-contrast="high"][data-theme="dark"] .page-title { color: #fff; }
[data-contrast="high"] .site-footer {
    /* footer background is dark in both HC palettes, so text stays white */
    background: var(--brand-deep);
    border-top: 2px solid var(--border);
    color: #fff;
}

/* ---- Base -------------------------------------------------------------- */

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    /* sticky footer: main stretches so the footer never floats mid-screen */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main { flex: 1 0 auto; }
.site-footer { flex-shrink: 0; }

img { max-width: 100%; height: auto; }

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

h1, h2, h3, h4 {
    line-height: 1.25;
    color: var(--text);
    margin: 0 0 0.6em;
    font-weight: 650;
    text-wrap: balance;
}
h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); }
h2 { font-size: clamp(1.35rem, 3vw, 1.75rem); }
h3 { font-size: 1.15rem; }

p { margin: 0 0 1em; }

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

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---- Layout ------------------------------------------------------------ */

.container {
    max-width: 72rem;
    margin-inline: auto;
    padding-inline: 1.25rem;
}
.container-narrow { max-width: 50rem; }

.section { padding-block: 2.75rem; }
.section-alt { background: var(--surface); }
.section h2 { margin-top: 0; }

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--brand);
    color: var(--on-brand);
    padding: 0.6rem 1rem;
    z-index: 100;
}
.skip-link:focus { left: 0; }

/* Visually hidden, available to screen readers */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* Announce links that open a new tab (covers Markdown-rendered links too) */
main a[target="_blank"]::after {
    content: " \2197" / " (opens in new tab)";
    font-size: 0.85em;
}

main:focus { outline: none; } /* skip-link target; keyboard focus ring not needed on the region */

/* ---- Header / navigation ------------------------------------------------ */

.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--header-bg);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}

.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding-block: 0.6rem;
}

.site-logo { display: inline-flex; align-items: center; }
.site-logo img { width: 280px; height: auto; }

:root[data-theme="dark"] .site-logo img { filter: brightness(1.7) saturate(0.8); }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .site-logo img { filter: brightness(1.7) saturate(0.8); }
}

.site-nav ul {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    list-style: none;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
}

.site-nav a:not(.btn) {
    display: block;
    padding: 0.45rem 0.7rem;
    border-radius: 6px;
    text-decoration: none;
    color: var(--text);
    font-weight: 500;
}
.site-nav a:not(.btn):hover { background: var(--surface-2); color: var(--text); }
.site-nav a[aria-current="page"] { color: var(--brand); box-shadow: inset 0 -2px 0 var(--brand); border-radius: 6px 6px 0 0; }

/* breathing room around the Login button and theme toggle */
@media (min-width: 900px) {
    .site-nav li:has(> .btn) { margin-inline-start: 1rem; }
    .site-nav li:has(> .theme-toggle) { margin-inline-start: 0.75rem; }
}

.nav-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    padding: 0.4rem 0.55rem;
    cursor: pointer;
}

.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-muted);
    padding: 0.35rem 0.55rem;
    cursor: pointer;
    line-height: 0;
}
.theme-toggle:hover { color: var(--text); border-color: var(--text-muted); }
.theme-toggle .icon-moon { display: inline; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: inline; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
    :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: inline; }
}

/* Accessibility options dropdown */
.a11y-menu { position: relative; }
.a11y-toggle {
    line-height: 1.1;
    font-size: 0.95rem;
    font-weight: 650;
    padding: 0.32rem 0.55rem;
}
.a11y-panel {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    z-index: 60;
    min-width: 15rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
    padding: 0.9rem 1rem;
}
.a11y-panel-label { font-weight: 650; margin: 0 0 0.4rem; }
.a11y-sizes { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.a11y-sizes button {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    padding: 0.35rem 0.7rem;
    font: inherit;
    font-size: 0.92rem;
    cursor: pointer;
}
.a11y-sizes button[aria-pressed="true"] {
    background: var(--brand);
    border-color: var(--brand);
    color: var(--on-brand);
    font-weight: 600;
}
.a11y-check { display: flex; align-items: center; gap: 0.45rem; font-weight: 500; cursor: pointer; }

@media (max-width: 899px) {
    .nav-toggle { display: inline-flex; }
    .site-nav { display: none; width: 100%; }
    .site-nav.open { display: block; }
    .site-nav ul { flex-direction: column; align-items: stretch; gap: 0.15rem; padding-block: 0.5rem; }
    .site-nav a:not(.btn) { padding: 0.6rem 0.75rem; }
    .site-nav a[aria-current="page"] { box-shadow: inset 3px 0 0 var(--brand); border-radius: 6px; }
    .site-nav li:has(.theme-toggle) { padding: 0.4rem 0.75rem; }
    .a11y-panel { position: static; margin-top: 0.5rem; }
}

/* ---- Buttons ------------------------------------------------------------ */

.btn {
    display: inline-block;
    background: var(--brand);
    color: var(--on-brand);
    border: 1px solid var(--brand);
    border-radius: 8px;
    padding: 0.55rem 1.2rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.15s ease, color 0.15s ease;
}
.btn:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: var(--on-brand); }

.btn-outline {
    background: transparent;
    color: var(--link);
    border-color: var(--brand);
}
.btn-outline:hover { background: var(--brand); color: var(--on-brand); }

.btn-small { padding: 0.35rem 0.9rem; font-size: 0.95rem; }

.btn-light { background: #fff; border-color: #fff; color: var(--brand-deep); }
.btn-light:hover { background: #e8eef5; border-color: #e8eef5; color: var(--brand-deep); }
.btn-outline-light { background: transparent; border: 1px solid rgba(255,255,255,0.85); color: #fff; }
.btn-outline-light:hover { background: rgba(255,255,255,0.15); color: #fff; }

.btn-link {
    background: none;
    border: none;
    padding: 0;
    color: var(--link);
    text-decoration: underline;
    cursor: pointer;
    font: inherit;
}

/* ---- Hero --------------------------------------------------------------- */

.hero {
    background:
        radial-gradient(ellipse at 20% -20%, rgba(30, 136, 199, 0.35), transparent 55%),
        linear-gradient(135deg, #1d3e5e, #336699 70%, #3d7ab5);
    color: #fff;
    padding-block: clamp(3.5rem, 9vw, 6.5rem);
    text-align: center;
}
.hero h1 { color: #fff; margin-bottom: 0.4em; }
.hero-tagline {
    font-size: clamp(1.05rem, 2.2vw, 1.3rem);
    color: rgba(255, 255, 255, 0.92);
    max-width: 40rem;
    margin: 0 auto 1.6em;
}
.hero-actions { display: flex; gap: 0.8rem; justify-content: center; flex-wrap: wrap; margin: 0; }

/* ---- Page-title band ----------------------------------------------------- */

.page-title {
    background: linear-gradient(135deg, var(--brand-deep), var(--brand-dark));
    color: #fff;
    padding-block: 2.2rem;
}
.page-title h1 { color: #fff; margin: 0; }
.page-title .subtitle { color: rgba(255, 255, 255, 0.85); margin: 0.3em 0 0; }

/* ---- Cards --------------------------------------------------------------- */

.card-grid {
    display: grid;
    gap: 1.75rem;
    grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
}
.card > img { display: block; width: 100%; aspect-ratio: 3 / 2; object-fit: cover; }
.card-body { padding: 1.25rem 1.4rem 1.4rem; }
.card-body h2 { font-size: 1.2rem; margin-bottom: 0.15em; }
.card-subtitle { color: var(--text-muted); font-size: 0.95rem; margin-bottom: 0.9em; }
.card-body p:last-child { margin-bottom: 0; }

.contact-card { padding: 1.4rem; text-align: center; }
.contact-card h2 { font-size: 1.05rem; color: var(--brand); margin-bottom: 0.4em; }
.contact-card p, .contact-card address { margin: 0; font-style: normal; }

/* ---- News ----------------------------------------------------------------- */

.news-list { display: grid; gap: 1.5rem; margin-bottom: 1.5rem; }
.news-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem 1.4rem;
}
.section-alt .news-item { background: var(--bg); }
.news-item h2, .news-item h3 { margin-bottom: 0.15em; font-size: 1.2rem; }
.news-item a { text-decoration: none; }
.news-item a:hover { text-decoration: underline; }
.news-item p:last-child { margin-bottom: 0; }
.news-date { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 0.7em; }

.post-header { margin-bottom: 1.5rem; }
.post-header .news-date { margin-bottom: 0; }
.post-source { color: var(--text-muted); font-size: 0.95rem; }

.pagination { display: flex; gap: 1rem; align-items: center; justify-content: center; }
.pagination span { color: var(--text-muted); }

/* ---- Bulletins ------------------------------------------------------------ */

.bulletins { background: var(--surface); border-bottom: 1px solid var(--border); }
.bulletin {
    border-left: 4px solid var(--brand);
    background: var(--surface-2);
    border-radius: 0 8px 8px 0;
    padding: 0.9rem 1.2rem;
    margin-block: 1rem;
}
.bulletin-title { font-weight: 650; margin-bottom: 0.25em; }
.bulletin .prose p:last-child { margin-bottom: 0; }

/* ---- Long-form content ------------------------------------------------------ */

.prose { max-width: 70ch; }
.prose blockquote,
blockquote.quote {
    margin: 1.5em 0;
    padding: 0.4em 0 0.4em 1.2em;
    border-left: 4px solid var(--brand);
    color: var(--text-muted);
    font-style: italic;
}
.prose blockquote cite, blockquote footer { font-style: normal; font-size: 0.92rem; }

.callout {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--brand);
    border-radius: 0 8px 8px 0;
    padding: 0.9rem 1.2rem;
    font-weight: 500;
}

.notice {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 0 8px 8px 0;
    padding: 0.9rem 1.2rem;
}
.notice p:last-child { margin-bottom: 0; }
.notice-error { border-left-color: #c0392b; }
.notice-success { border-left-color: #2e7d4f; }

/* Numbered process steps */
.steps {
    list-style: none;
    counter-reset: step;
    margin: 1.5em 0;
    padding: 0;
    display: grid;
    gap: 0.9rem;
}
.steps li {
    counter-increment: step;
    position: relative;
    padding: 0.35rem 0 0.35rem 3.2rem;
    min-height: 2.4rem;
}
.steps li::before {
    content: counter(step);
    position: absolute;
    left: 0;
    top: 0.15rem;
    width: 2.3rem;
    height: 2.3rem;
    border-radius: 50%;
    background: var(--brand);
    color: var(--on-brand);
    display: grid;
    place-items: center;
    font-weight: 700;
}
.steps:not(.steps-detailed) { grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); }
.steps:not(.steps-detailed) li { display: flex; align-items: center; }

/* FAQ disclosure */
details {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    margin-bottom: 0.9rem;
    padding: 0;
}
summary {
    cursor: pointer;
    font-weight: 600;
    padding: 1rem 1.25rem;
    list-style-position: outside;
}
summary:hover { color: var(--brand); }
details[open] summary { border-bottom: 1px solid var(--border); }
details .prose { padding: 1rem 1.25rem 0.25rem; max-width: none; }

/* Link lists */
.doc-links { list-style: none; padding: 0; display: grid; gap: 0.5rem; }
.doc-links a { font-weight: 500; }

/* Definition list (staff roster) */
.staff-list { margin: 0; display: grid; gap: 0.4rem; }
.staff-list > div {
    display: grid;
    grid-template-columns: 11rem 1fr;
    gap: 1rem;
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--border);
}
.staff-list dt { font-weight: 650; }
.staff-list dd { margin: 0; }
@media (max-width: 540px) {
    .staff-list > div { grid-template-columns: 1fr; gap: 0.1rem; }
}

/* ---- Tables ------------------------------------------------------------------ */

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 0.55rem 0.8rem; border-bottom: 1px solid var(--border); }
thead th { background: var(--surface); border-bottom: 2px solid var(--border); }
tbody tr:nth-child(even) { background: var(--surface); }
.table-footnote { color: var(--text-muted); font-size: 0.92rem; margin-top: 0.8em; }

/* ---- Footer -------------------------------------------------------------------- */

.site-footer {
    background: var(--brand-deep);
    color: #cdd9e5;
    margin-top: 3rem;
    padding-block: 2.5rem 0;
}
.site-footer a { color: #ffffff; }
.footer-grid {
    display: grid;
    gap: 2rem;
    grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
    padding-bottom: 2rem;
}
.footer-heading { font-weight: 650; color: #fff; }
.footer-links { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; }
.footer-copyright {
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    padding-block: 1.1rem;
    font-size: 0.92rem;
}
.footer-copyright p { margin: 0; }

/* ---- 404 -------------------------------------------------------------------------- */

.error-page { text-align: center; }
.error-code { font-size: clamp(4rem, 14vw, 7rem); font-weight: 800; color: var(--surface-2); line-height: 1; margin: 0; }
.error-page .doc-links { justify-items: center; }

/* ---- Admin -------------------------------------------------------------------------- */

.admin-main { padding-block: 2rem; }
.admin-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.admin-toolbar h1, .admin-toolbar p { margin: 0; }
.admin-main .notice { margin-block: 1rem; }

.admin-login { max-width: 24rem; margin: 3rem auto; }

.admin form label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
.admin form .hint { font-weight: 400; color: var(--text-muted); font-size: 0.9rem; }
.admin input[type="text"],
.admin input[type="password"],
.admin input[type="url"],
.admin select,
.admin textarea {
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font: inherit;
}
.admin textarea { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92rem; line-height: 1.5; resize: vertical; }
.admin .check { font-weight: 600; }
.admin .check input { margin-right: 0.4rem; }

.form-row { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }

.editor-grid { display: grid; gap: 1.25rem; grid-template-columns: 1fr; }
@media (min-width: 1000px) {
    .editor-grid { grid-template-columns: 1fr 1fr; align-items: start; }
}
.editor-preview .label { font-weight: 600; margin-bottom: 0.25rem; }
.preview-pane {
    border: 1px dashed var(--border);
    border-radius: 8px;
    background: var(--surface);
    padding: 1rem 1.2rem;
    min-height: 10rem;
}

.admin .actions { white-space: nowrap; }
.admin form.inline { display: inline; }
