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

:root {
    /* ── Horizon Design System tokens ───────────────────────── */
    --color-primary:    #0170B9;
    --color-action:     #1c67e3;
    --color-hover:      #f64137;
    --color-dark:       #2e2e32;
    --color-text:       #3a3a3a;
    --color-text-meta:  #58585b;
    --color-bg:         #F5F5F5;
    --color-surface:    #FFFFFF;
    --color-border:     #dddddd;
    --color-focus:      #444447;
    --radius:           4px;
    --shadow-card:      0px 0px 4px 0 rgba(0,0,0,0.34);
    --shadow-menu:      0px 4px 10px -2px rgba(0,0,0,0.1);
    --container:        1200px;
    --font-body:        'Public Sans', sans-serif;
    --font-heading:     'Inter', sans-serif;

    /* ── Legacy aliases (CSS in templates uses these names) ─── */
    --nasa-blue:        var(--color-primary);
    --nasa-red:         var(--color-hover);
    --earth-teal:       var(--color-action);
    --earth-teal-light: #e8f0fc;
    --text-primary:     var(--color-text);
    --text-secondary:   var(--color-text-meta);
    --bg-page:          var(--color-bg);
    --border:           var(--color-border);

    /* ── Structural (layout) ────────────────────────────────── */
    --sidebar-width:    280px;
    --header-height:    64px;
}

body {
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.65;
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
}

h1 { font-size: 36px; font-weight: 700; }
h2 { font-size: 30px; font-weight: 500; }
h3 { font-size: 24px; font-weight: 500; }

/* ── Header ── */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--color-dark);
    color: #fff;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    z-index: 100;
    gap: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .3);
}

.site-header .hamburger {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 1.4rem;
    padding: 0.25rem 0.5rem;
    display: none;
}

.site-header .brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: #fff;
}

.site-header .brand-badge {
    padding: 0.2rem 0.5rem;
}

.site-header .brand-title {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.2;
}

.site-header .brand-subtitle {
    font-size: 0.7rem;
    opacity: 0.8;
    font-weight: 400;
}

.staff-header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.header-nav {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.header-nav a {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
    padding: 0.4rem 0.85rem;
    border-radius: 4px;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.header-nav a:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.header-nav a.active {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

/* ── Layout ── */
.layout {
    display: flex;
    padding-top: var(--header-height);
    min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: #fff;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    z-index: 90;
    transition: transform 0.25s ease;
}

.sidebar-inner {
    padding: 1rem 0 2rem;
}

.sidebar-label {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-secondary);
    padding: 0.75rem 1.25rem 0.4rem;
}

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 1.25rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    line-height: 1.35;
}

.sidebar nav a .step-num {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--border);
    color: var(--text-secondary);
    font-size: 0.65rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar nav a:hover {
    background: var(--earth-teal-light);
    color: var(--earth-teal);
    border-left-color: var(--earth-teal);
}

.sidebar nav a.active {
    background: var(--earth-teal-light);
    color: var(--nasa-blue);
    border-left-color: var(--nasa-blue);
    font-weight: 600;
}

.sidebar nav a.active .step-num {
    background: var(--nasa-blue);
    color: #fff;
}

/* ── Main content ── */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0;
    padding: 2.5rem 3rem;

}

.figure {
    width: 1000px;
    max-width: calc(100vw - 100px);
}

.page-header {
    border-bottom: 3px solid var(--earth-teal);
    padding-bottom: 1rem;
    margin-bottom: 2rem;
}

.page-header .section-tag {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #0170B9; /* 4.63:1 on white — WCAG AA (was #1c67e3 at 3.1:1) */
    margin-bottom: 0.4rem;
}

.page-header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--nasa-blue);
    line-height: 1.2;
}

.content-placeholder {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    color: var(--text-secondary);
}

.tk-body {
    font-size: 18px;
    line-height: 1.75;
    color: #3a3a3a;
}

.tk-body h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #0170B9;
    margin: 2.25rem 0 0.6rem;
}

.tk-body h3 {
    font-size: 1.15rem;
    font-weight: 600;
    color: #0170B9;
    margin: 1.75rem 0 0.5rem;
}

.tk-body h4 {
    font-size: 0.95rem;
    font-style: italic;
    font-weight: 600;
    color: #3a3a3a;
    margin: 1.4rem 0 0.4rem;
}

.tk-body p {
    margin-bottom: 1rem;
}

.tk-body ul, .tk-body ol {
    margin: 0.5rem 0 1rem 1.5rem;
}

.tk-body li {
    margin-bottom: 0.4rem;
}

.tk-body hr {
    border: none;
    border-top: 1px solid #dddddd;
    margin: 2rem 0;
}

/* ── Footer ── */
.site-footer {
    margin-left: var(--sidebar-width);
    background: var(--color-dark);
    color: rgba(255, 255, 255, 0.75);
    font-size: 0.8rem;
    padding: 1.1rem 3rem;
    display: flex;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.site-footer a, .hero-links a {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    transition: color 0.15s;
    white-space: nowrap;
}

.site-footer a:hover, .hero-links a:hover {
    color: #fff;
    text-decoration: underline;
}

.footer-divider {
    color: rgba(255, 255, 255, 0.3);
}

/* ── Review button ── */
.review-btn {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    writing-mode: vertical-lr;
    text-orientation: mixed;
    padding: 1.1rem 0.75rem;
    background: #c0392b; /* 5.1:1 with #fff — WCAG AA ✓ */
    color: #fff;
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    text-decoration: none;
    border-radius: var(--radius) 0 0 var(--radius);
    box-shadow: -3px 0 14px rgba(0, 0, 0, 0.18);
    z-index: 150;
    transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
    white-space: nowrap;
}

.review-btn:hover {
    background: #c9291e;
    transform: translateY(-50%) translateX(-4px);
    box-shadow: -5px 0 18px rgba(0, 0, 0, 0.22);
}

.watermark-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* This allows clicks to pass through */
    z-index: 9999; /* High z-index to stay on top */
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0.1; /* Adjust transparency */
}

.watermark-text {
    font-size: 5rem;
    font-weight: bold;
    color: #000;
    transform: rotate(-45deg);
    user-select: none; /* Prevents text selection */
    text-shadow: -2px -2px 0 #fff,
    2px -2px 0 #fff,
    -2px 2px 0 #fff,
    2px 2px 0 #fff,
    -2px 0 0 #fff,
    2px 0 0 #fff,
    0 -2px 0 #fff,
    0 2px 0 #fff;
}

.brand {
    min-width: 0;
}

.brand-title,
.brand-subtitle {
    white-space: nowrap;
}

.site-footer {
    margin-left: var(--sidebar-width);
    background: var(--color-dark);
    color: rgba(255, 255, 255, 0.75);
    padding: 1.5rem 3rem;

    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.footer-left {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.footer-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
}

.footer-sub {
    font-size: 0.7rem;
    opacity: 0.7;
}

.footer-links {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.site-footer {
    border-top: 3px solid var(--earth-teal);
}

.site-footer a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    border-bottom: 1px dashed transparent;
    padding-bottom: 2px;
    transition: border-color 0.15s ease, color 0.15s ease;
}

.site-footer a:hover {
    text-decoration: none;
    color: #fff;
    border-bottom-color: rgba(255, 255, 255, 0.6);
}

/* =============================================================
   toolkit.css  —  Shared styles for all toolkit section pages
   Individual pages override or extend these where needed.
   ============================================================= */

/* ── Phase grid ───────────────────────────────────────────── */
.phases-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin: 1.5rem 0;
}

/* ── Phase cards (standard variant used by most pages) ────── */
.phase-card {
    border-radius: var(--radius);
    padding: 1rem;
    font-size: 0.88rem;
}

.phase-card h4 {
    margin: 0 0 0.6rem 0;
    font-size: 0.9rem;
    color: #0170B9;
}

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

.phase-card ul li {
    margin-bottom: 0.3rem;
    line-height: 1.5;
}

/* Base phase colours (per-page outlines stay in each template) */
.phase-1 {
    background: #cce0f5;
}

.phase-2 {
    background: #c8dff5;
}

.phase-3 {
    background: #d4edda;
}

.phase-4 {
    background: #d5eddf;
}

/* Numbered plan sections */
.plan-section {
    margin-top: 2.2rem;
    padding-top: 0.5rem;
    border-top: 1px solid #dddddd;
}

.plan-section > h2 {
    color: #0170B9;
    font-size: 1.2rem;
    margin-bottom: 0.7rem;
}

.plan-section p {
    margin-bottom: 0.8rem;
    line-height: 1.7;
}

/* Sub-sections */
.plan-subsection {
    margin-top: 1.4rem;
}

.plan-subsection > h3 {
    color: #0170B9;
    font-size: 1rem;
    margin-bottom: 0.6rem;
}

.plan-subsection p {
    margin-bottom: 0.8rem;
    line-height: 1.7;
}

/* ── Section intro ────────────────────────────────────────── */
.section-intro p {
    margin-bottom: 0.9rem;
    line-height: 1.7;
}

/* ── Content list ─────────────────────────────────────────── */
.content-list {
    margin: 0.4rem 0 1rem 1.5rem;
}

.content-list li {
    margin-bottom: 0.4rem;
    line-height: 1.6;
    font-size: 0.93rem;
}

/* ── Subsection headings ──────────────────────────────────── */
.subsection {
    margin-top: 2.5rem;
}

.subsection > h2 {
    color: #0170B9;
    border-bottom: 2px solid #1c67e3;
    padding-bottom: 0.4rem;
    margin-bottom: 1rem;
}

.subsection > h3 {
    color: #0170B9;
    margin: 1.5rem 0 0.6rem 0;
}

.subsection p {
    margin-bottom: 0.9rem;
    line-height: 1.7;
}

/* ── Step header / body ───────────────────────────────────── */
.step-header {
    background: #0170B9;
    color: #fff;
    padding: 0.7rem 1.1rem;
    border-radius: 4px 4px 0 0;
    font-size: 1rem;
    font-weight: 700;
    margin-top: 2rem;
    margin-bottom: 0;
}

.step-body {
    border: 1px solid #dddddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    padding: 1.2rem 1.4rem;
    background: #fff;
}

.step-body p {
    margin-bottom: 0.8rem;
    line-height: 1.7;
}

.step-body p:last-child {
    margin-bottom: 0;
}

.step-body h4 {
    color: #0170B9;
    margin: 1rem 0 0.4rem 0;
    font-size: 0.95rem;
}

.step-body ul, .step-body ol {
    margin: 0.3rem 0 0.8rem 1.4rem;
}

.step-body ul li, .step-body ol li {
    margin-bottom: 0.35rem;
    line-height: 1.6;
}

.step-purpose {
    font-size: 0.82rem;
    color: #555;
    font-style: italic;
    margin: 0 0 0.8rem 0;
    border-left: 3px solid #1c67e3;
    padding-left: 0.7rem;
}

/* ── Example box ──────────────────────────────────────────── */
.example-box {
    background: #eef4fc;
    border: 1px solid #1c67e3;
    border-left: 5px solid #1c67e3;
    border-radius: 4px;
    padding: 1rem 1.2rem;
    margin: 1rem 0 1.5rem 0;
    font-size: 0.92rem;
}

.example-box h5 {
    margin: 0 0 0.6rem 0;
    color: #0170B9;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.example-box p {
    margin-bottom: 0.5rem;
    line-height: 1.65;
}

.example-box ul {
    margin: 0.3rem 0 0.5rem 1.2rem;
    padding: 0;
}

.example-box ul li {
    margin-bottom: 0.35rem;
    line-height: 1.6;
}

/* ── Ref note (dashed teal callout) ──────────────────────── */
.ref-note {
    background: #eef4fc;
    border: 1px dashed #1c67e3;
    border-radius: 4px;
    padding: 0.6rem 1rem;
    margin: 0.5rem 0 1rem 0;
    font-size: 0.9rem;
    font-style: italic;
    color: #0170B9;
}

/* ── Related / callout boxes ─────────────────────────────── */
.related-box {
    background: #F5F5F5;
    border-left: 4px solid #1c67e3;
    padding: 0.9rem 1.2rem;
    margin: 1rem 0 1.5rem 0;
    border-radius: 0 4px 4px 0;
    font-size: 0.93rem;
    line-height: 1.7;
}

.related-box strong {
    color: #0170B9;
}

.related-box ul {
    margin: 0.4rem 0 0 1.3rem;
}

.related-box ul li {
    margin-bottom: 0.3rem;
}

/* ── Phase usage list ─────────────────────────────────────── */
.phase-usage {
    margin: 0.5rem 0 1rem 0;
    padding: 0;
    list-style: none;
}

.phase-usage li {
    display: flex;
    gap: 0.7rem;
    margin-bottom: 0.55rem;
    line-height: 1.6;
    font-size: 0.93rem;
}

.phase-usage li::before {
    content: "▸";
    color: #1c67e3;
    flex-shrink: 0;
    font-size: 0.85rem;
    margin-top: 2px;
}

/* ── Fig caption ──────────────────────────────────────────── */
.fig-caption {
    font-style: italic;
    font-size: 0.82rem;
    color: #58585b;
    margin-top: 0.4rem;
}

/* ── Section rule ─────────────────────────────────────────── */
hr.section-rule {
    border: none;
    border-top: 1px solid #dddddd;
    margin: 2rem 0;
}

/* ── Page note ────────────────────────────────────────────── */
.page-note {
    font-size: 0.8rem;
    color: #696969; /* 4.58:1 on #F5F5F5 bg — WCAG AA ✓ */
    text-align: right;
    margin-top: 0.5rem;
    font-style: italic;
}

/* ── Shared table base ────────────────────────────────────── */
/* Applied to any .tk-table; specific table classes in each page
   override width, font-size, column weights as needed.         */
.tk-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0 1.5rem 0;
    font-size: 0.88rem;
}

.tk-table th {
    background: #0170B9;
    color: #fff;
    padding: 0.65rem 1rem;
    text-align: left;
    font-weight: 600;
    vertical-align: top;
}

.tk-table td {
    padding: 0.7rem 1rem;
    border: 1px solid #dddddd;
    vertical-align: top;
    line-height: 1.6;
}

.tk-table tr:nth-child(odd) td {
    background: #F5F5F5;
}

.tk-table tr:nth-child(even) td {
    background: #fff;
}


@media (min-width: 1500px) {
    .main-content {
        flex: none;
        width: 1200px;
        margin-left: calc(var(--sidebar-width) + (100vw - var(--sidebar-width) - 1200px) / 2);
    }
}

@media (max-width: 1400px) {
    .figure {
        width: 600px;
        max-width: calc(100vw - 380px);
    }
}

@media (max-width: 900px) {
    .phases-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ── Responsive ── */

/*
 * When the staff action bar is present, bump --header-height so the
 * sidebar top and content padding-top still clear the now-taller header.
 * Uses :has() which is supported in all modern browsers (Chrome 105+,
 * Safari 15.4+, Firefox 121+).  Falls back gracefully — older browsers
 * just see a slightly shorter header offset.
 */
@media (max-width: 768px) {
    :root:has(.staff-header-actions) {
        --header-height: 108px;
    }
}

@media (max-width: 768px) {
    .site-header .hamburger {
        display: block;
    }

    /* Allow the header to grow to two rows when staff buttons are present */
    .site-header {
        flex-wrap: wrap;
        height: auto;
        min-height: var(--header-height);
        padding: 0.3rem 0.75rem;
        align-content: center;
        row-gap: 0;
    }

    /* Hide subtitle to keep the brand compact on the first row */
    .site-header .brand-subtitle {
        display: none;
    }

    /* Staff buttons move to their own full-width second row */
    .staff-header-actions {
        width: 100%;
        margin-left: 0;
        justify-content: flex-end;
        flex-wrap: wrap;
        gap: 0.35rem;
        border-top: 1px solid rgba(255, 255, 255, 0.12);
        padding-top: 0.3rem;
        padding-bottom: 0.2rem;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        padding: 1.5rem 1.25rem;
    }

    .figure {
        width: 600px;
        max-width: calc(100vw - 100px);
    }

    .site-footer {
        margin-left: 0;
        padding: 1.25rem;
        flex-direction: column;
    }

    .footer-links {
        gap: 0.75rem;
    }
}

@media (max-width: 500px) {
    .phases-grid {
        grid-template-columns: 1fr;
    }
}

/* ── Accessibility utilities ──────────────────────────────── */

/* Visually hidden but available to screen readers */
.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;
}

/* Skip navigation link */
.skip-link {
    position: absolute;
    top: -999px;
    left: 1rem;
    background: #0170B9;
    color: #fff;
    padding: 0.5rem 1rem;
    border-radius: 0 0 4px 4px;
    font-weight: 700;
    font-size: 0.9rem;
    text-decoration: none;
    z-index: 9999;
}

.skip-link:focus {
    top: 0;
}

/* Global keyboard focus indicator — Horizon: 1px dotted #444447 */
:focus-visible {
    outline: 1px dotted var(--color-focus);
    outline-offset: 2px;
}

/* Focus on dark backgrounds */
.hamburger:focus-visible,
.review-btn:focus-visible,
.chat-fab:focus-visible,
.chat-hbtn:focus-visible {
    outline: 2px dotted #fff;
    outline-offset: 3px;
}
