/* ==========================================================================
   Customer Things — stylesheet
   No framework: plain modern CSS. Sections:
   1. Design tokens   2. Base   3. App shell, background & sidebar   4. Sections & headings
   5. Fields & values 6. Buttons, badges, notices                  7. Loading
   ========================================================================== */

/* 1. Design tokens ------------------------------------------------------- */
:root {
    /* Fonts: loaded from Google Fonts in index.html */
    --font-sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, Consolas, monospace;

    /* Brand colours (from the original palette) */
    --brand: #005F8A;
    --brand-strong: #004766;
    --brand-soft: #e7f1f6;
    --accent: #008eaa;
    --success: #3d8f50;
    --success-soft: #e8f4eb;
    --danger: #b42318;
    --danger-soft: #fdecea;

    /* Neutrals */
    --ink: #17212b;
    --ink-2: #3f4b57;
    --muted: #66727e;
    --line: #e1e6eb;
    --bg: #f4f6f8;
    --surface: #ffffff;

    /* Shape and spacing */
    --sidebar-width: 296px;
    --radius: 12px;
    --radius-small: 8px;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
}

/* 2. Base ---------------------------------------------------------------- */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, ul, dl, dd {
    margin: 0;
}

a {
    color: var(--brand);
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--brand) 35%, transparent);
    text-underline-offset: 3px;
}

a:hover {
    color: var(--brand-strong);
    text-decoration-color: currentColor;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

::selection {
    background: var(--brand-soft);
}

.mono {
    font-family: var(--font-mono);
    font-size: 0.94em;
    letter-spacing: -0.01em;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition: none !important;
        animation: none !important;
    }

    /* Keep the loading spinner turning (slower), so it is clear the app has not frozen */
    .loading-spinner {
        animation: spin 1.6s linear infinite !important;
    }
}

/* 3. App shell, background & sidebar ------------------------------------- */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    padding: 28px 16px 20px;
    background: var(--surface);
    border-right: 1px solid var(--line);
    z-index: 2;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 12px;
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--ink);
    text-decoration: none;
}

.sidebar-brand:hover {
    color: var(--ink);
}

.sidebar-brand-mark {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--brand), var(--accent));
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.tracker {
    flex: 1;
    /* Padding (and matching negative margin) gives the highlights room so they are not clipped */
    margin: 36px -6px 0;
    padding: 2px 6px;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: thin;
}

.tracker-heading {
    padding: 0 12px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.tracker-item {
    position: relative;
    display: block;
    width: 100%;
    padding: 8px 12px 8px 16px;
    border: 0;
    border-radius: var(--radius-small);
    background: none;
    font: inherit;
    font-size: 0.9375rem;
    text-align: left;
    color: var(--ink-2);
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.tracker-item::before {
    content: "";
    position: absolute;
    left: 4px;
    top: 9px;
    bottom: 9px;
    width: 3px;
    border-radius: 2px;
    background: var(--brand);
    opacity: 0;
    transform: scaleY(0.4);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.tracker-item + .tracker-item {
    margin-top: 2px;
}

.tracker-item:focus-visible {
    outline-offset: -2px;
}

.tracker-item:hover {
    background: var(--bg);
    color: var(--ink);
}

.tracker-item.is-active {
    background: var(--brand-soft);
    color: var(--brand-strong);
    font-weight: 600;
}

.tracker-item.is-active::before {
    opacity: 1;
    transform: scaleY(1);
}

.sidebar-footer {
    margin-top: auto;
    padding: 16px 12px 0;
    border-top: 1px solid var(--line);
    display: grid;
    gap: 12px;
}

.sidebar-user {
    display: grid;
    min-width: 0;
}

.sidebar-user-label {
    font-size: 0.75rem;
    color: var(--muted);
}

.sidebar-user-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--ink-2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.main {
    position: relative;
    z-index: 1;
    margin-left: var(--sidebar-width);
}

/* Background behind the content: a soft brand glow and a faint dot grid, fading out from the top right */
.backdrop {
    position: fixed;
    inset: 0 0 0 var(--sidebar-width);
    pointer-events: none;
    z-index: 0;
    background:
        radial-gradient(900px 520px at 100% 0%, rgba(0, 142, 170, 0.11), transparent 65%),
        radial-gradient(760px 560px at 0% 100%, rgba(0, 95, 138, 0.06), transparent 65%);
}

.backdrop::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(0, 95, 138, 0.16) 1px, transparent 1.2px);
    background-size: 22px 22px;
    -webkit-mask-image: radial-gradient(1100px 700px at 100% 0%, #000 0%, transparent 70%);
    mask-image: radial-gradient(1100px 700px at 100% 0%, #000 0%, transparent 70%);
}

/* Brand shape in the top right corner: two layered wedges in the brand gradient */
.backdrop::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: min(560px, 45vw);
    aspect-ratio: 640 / 150;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 640 150'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='0' x2='1' y2='1'%3E%3Cstop offset='0' stop-color='%23005F8A'/%3E%3Cstop offset='1' stop-color='%23008eaa'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cpath d='M70 0H640V96L396 150Z' fill='%23008eaa' opacity='.16'/%3E%3Cpath d='M170 0H640V58L430 106Z' fill='url(%23g)' opacity='.95'/%3E%3Cpath d='M430 106L640 58V76Z' fill='%23ffffff' opacity='.18'/%3E%3C/svg%3E") no-repeat top right / contain;
}

/* 4. Sections & headings ------------------------------------------------- */
.section {
    max-width: 1180px;
    min-height: calc(100vh - 72px);
    padding: 24px 72px 56px;
    display: flex;
    flex-direction: column;
}

/* Only the selected section is shown */
.section[hidden] {
    display: none;
}

/* Space between a heading and what follows it (works whether or not they are wrapped in a <div>) */
.section-header + *,
.field-grid + .section-actions {
    margin-top: 32px;
}

/* Single-message pages: Loading, Not found, Forbidden */
.section--message {
    max-width: 880px;
    padding-top: 96px;
}

/* "Consent / Data policy  dp-123  [copy]" bar above the sections */
.page-context {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    max-width: 1180px;
    min-height: 72px;
    padding: 24px 72px 0;
    font-size: 0.875rem;
    color: var(--muted);
}

.page-context-parent {
    font-weight: 500;
}

.page-context-sep {
    color: var(--line);
    font-size: 1.1em;
}

.page-context-kind {
    font-weight: 600;
    color: var(--ink-2);
}

.page-context-id {
    padding: 2px 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    color: var(--ink-2);
    overflow-wrap: anywhere;
}

.copy-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 28px;
    padding: 0 6px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: none;
    font: inherit;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.copy-button:hover {
    background: var(--surface);
    border-color: var(--line);
    color: var(--brand);
}

.copy-button.is-copied {
    color: var(--success);
}

.copy-button svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
}

.section-header {
    display: grid;
    gap: 12px;
}

/* Short brand bar under the title, as a spacer before the rest of the heading */
.section-header::after {
    content: "";
    order: 1;
    width: 40px;
    height: 4px;
    margin: 2px 0 4px;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--brand), var(--accent));
}

.section-header > * {
    order: 2;
}

.section-header > .section-title {
    order: 0;
}

.section-title {
    font-size: clamp(2rem, 1.4rem + 1.4vw, 2.625rem);
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -0.02em;
    color: var(--ink);
}

.section-subtitle {
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--brand);
    overflow-wrap: anywhere;
}

.section-lead {
    max-width: 70ch;
    font-size: 1.125rem;
    color: var(--ink-2);
}

.section-note {
    max-width: 75ch;
    padding-left: 14px;
    border-left: 3px solid var(--line);
    font-size: 0.9375rem;
    color: var(--muted);
}

.section-actions {
    display: flex;
    gap: 12px;
}

/* Previous / Next buttons at the bottom of each section */
.section-pager {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-top: auto;
    padding-top: 48px;
}

.pager-link {
    display: grid;
    gap: 2px;
    min-width: 200px;
    padding: 12px 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.pager-link:hover {
    border-color: var(--brand);
    box-shadow: var(--shadow);
}

.pager-link--next {
    margin-left: auto;
    text-align: right;
}

.pager-label {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.pager-link--previous .pager-label::before {
    content: "\2190  ";
}

.pager-link--next .pager-label::after {
    content: "  \2192";
}

.pager-title {
    font-weight: 600;
    color: var(--brand);
}

/* 5. Fields & values ----------------------------------------------------- */
.field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 20px 22px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.field--wide {
    grid-column: 1 / -1;
}

.field-label {
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}

.field-help {
    font-size: 0.875rem;
    color: var(--muted);
}

.field-value {
    margin-top: 6px;
    font-size: 1.0625rem;
    font-weight: 500;
    color: var(--ink);
    overflow-wrap: anywhere;
}

.value-sep {
    margin: 0 8px;
    font-weight: 400;
    color: var(--muted);
}

/* Description shown under a value, from Descriptions.json */
.value-description {
    display: block;
    margin-top: 2px;
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--muted);
}

/* Lists of values */
.value-list {
    list-style: none;
    padding: 0;
    display: grid;
    gap: 10px;
}

.value-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}

.value-row:last-child {
    border-bottom: 0;
}

/* One object in a list, e.g. an organisation */
.value-card {
    padding: 14px 16px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius-small);
}

/* Label / value pairs */
.kv {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 6px 24px;
    font-size: 0.9375rem;
}

.kv dt {
    font-weight: 400;
    color: var(--muted);
}

.kv dd {
    font-weight: 500;
    color: var(--ink);
    overflow-wrap: anywhere;
}

.kv .kv-note {
    grid-column: 1 / -1;
    margin: -2px 0 8px;
    font-size: 0.8125rem;
    font-weight: 400;
    color: var(--muted);
}

/* All available options with the included ones ticked (OptionChecklist) */
.checklist-summary {
    margin-bottom: 14px;
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--muted);
}

.checklist-summary strong {
    color: var(--brand);
}

.checklist {
    list-style: none;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 10px;
}

.checklist-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-small);
    background: var(--surface);
}

.checklist-item.is-included {
    border-color: color-mix(in srgb, var(--brand) 35%, transparent);
    background: var(--brand-soft);
}

.checklist-mark {
    position: relative;
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    margin-top: 2px;
    border: 1.5px solid #c5ced6;
    border-radius: 50%;
    background: var(--surface);
}

.checklist-item.is-included .checklist-mark {
    border-color: var(--brand);
    background: var(--brand);
}

/* The tick */
.checklist-item.is-included .checklist-mark::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 2px;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checklist-text {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.checklist-name {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.checklist-item.is-included .checklist-name {
    font-weight: 600;
    color: var(--brand-strong);
}

.checklist-description {
    font-size: 0.8125rem;
    font-weight: 400;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* 6. Buttons, badges, notices -------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-small);
    font: inherit;
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-primary {
    background: var(--brand);
    color: #fff;
}

.btn-primary:hover {
    background: var(--brand-strong);
    color: #fff;
}

.btn-outline {
    background: var(--surface);
    border-color: var(--line);
    color: var(--ink-2);
}

.btn-outline:hover {
    border-color: var(--brand);
    color: var(--brand);
}

.btn-block {
    width: 100%;
}

.badge {
    display: inline-block;
    flex-shrink: 0;
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--brand-soft);
    color: var(--brand-strong);
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.5;
}

.badge--success {
    background: var(--success-soft);
    color: var(--success);
}

.badge--danger {
    background: var(--danger-soft);
    color: var(--danger);
}

.badge--muted {
    background: #eef1f4;
    color: var(--muted);
}

/* Yes / No: different fill, outline and symbol, so they are easy to tell apart (not by colour alone) */
.badge--yes {
    background: #d4efdc;
    color: #17663a;
}

.badge--yes::before {
    content: "\2713";
    margin-right: 5px;
    font-weight: 700;
}

.badge--no {
    background: transparent;
    color: #6f7a85;
    box-shadow: inset 0 0 0 1px #d5dce3;
}

.badge--no::before {
    content: "\2013";
    margin-right: 5px;
}

.badge--info {
    background: #e6f5f8;
    color: var(--accent);
}

.notice {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.notice--danger {
    color: var(--danger);
}

.notice-icon {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
}

/* 7. Loading ------------------------------------------------------------- */
.loading {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 1.125rem;
    color: var(--muted);
}

.loading-spinner {
    display: inline-block;
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border: 3px solid var(--line);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Shown by index.html until the app has started */
.boot-loading {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    font-size: 1.125rem;
    color: var(--muted);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
