/* Afsprakenregister
   Rustig en zakelijk; de enige expressieve noot is de handtekening in blauwe inkt. */

:root {
    --paper: #f3f4f6;
    --sheet: #ffffff;
    --ink: #17213a;
    --muted: #5a6475;
    --line: #d8dce3;
    --line-strong: #b9c0cb;
    --pen: #1f3fa6;
    --signed: #2b6a4e;
    --signed-bg: #e8f2ec;
    --open: #8f5400;
    --open-bg: #fbf1e1;
    --danger: #b42318;
    --focus: #1f3fa6;

    --font: "Instrument Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
    --font-hand: "Caveat", "Segoe Script", "Bradley Hand", cursive;
    --font-mono: ui-monospace, "Cascadia Mono", Consolas, monospace;

    --radius: 6px;
    --measure: 46rem;
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font);
    font-size: 1rem;
    line-height: 1.55;
}

a { color: var(--pen); text-underline-offset: 0.15em; }
a:hover { text-decoration-thickness: 2px; }

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

h1, h2 { line-height: 1.2; margin: 0; font-weight: 600; }
h1 { font-size: 1.75rem; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; }
p { margin: 0; }

.visually-hidden {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}

/* Kop en navigatie */
.site-header { background: var(--sheet); border-bottom: 1px solid var(--line); }
.site-header-inner {
    max-width: var(--measure); margin: 0 auto; padding: 0.85rem 1.25rem;
    display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.brand { font-weight: 700; color: var(--ink); text-decoration: none; }
.site-nav { display: flex; align-items: center; gap: 1.25rem; }
.site-nav a { color: var(--muted); text-decoration: none; }
.site-nav a[aria-current="page"] { color: var(--ink); font-weight: 600; }
.site-nav form { margin: 0; }
.site-nav .link-button { text-decoration: none; }
.site-nav .link-button:hover { color: var(--ink); }

.page { max-width: var(--measure); margin: 0 auto; padding: 1.75rem 1.25rem 4rem; }
.page > * + * { margin-top: 1.5rem; }

.breadcrumb { font-size: 0.9rem; color: var(--muted); }
.breadcrumb a { color: var(--muted); }
.breadcrumb a + a::before { content: "/"; margin: 0 0.5rem; color: var(--line-strong); }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.page-head > div { flex: 1 1 20rem; }
.page-head > .button { flex: none; }
.lead { color: var(--muted); margin-top: 0.4rem; max-width: 38rem; }
.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 1.5rem 0; }
.mono { font-family: var(--font-mono); font-size: 0.85rem; word-break: break-all; }

/* Knoppen */
.button {
    display: inline-flex; align-items: center; justify-content: center;
    font: inherit; font-weight: 600; font-size: 0.95rem;
    padding: 0.55rem 1rem; border-radius: var(--radius);
    background: var(--ink); color: #fff; border: 1px solid var(--ink);
    text-decoration: none; cursor: pointer; white-space: nowrap;
}
.button:hover { background: #26324f; text-decoration: none; }
.button-quiet { background: var(--sheet); color: var(--ink); border-color: var(--line-strong); }
.button-quiet:hover { background: var(--paper); }
.link-button {
    font: inherit; background: none; border: 0; padding: 0;
    color: var(--muted); cursor: pointer; text-decoration: underline; text-underline-offset: 0.15em;
}
.link-button.danger { color: var(--danger); }

/* Formulieren */
.stack > * + * { margin-top: 1rem; }
.field { display: block; }
.field > span { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.3rem; }
.field em { font-style: normal; font-weight: 400; color: var(--muted); }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], textarea, select {
    width: 100%; font: inherit; color: var(--ink);
    padding: 0.55rem 0.7rem; background: var(--sheet);
    border: 1px solid var(--line-strong); border-radius: var(--radius);
}
textarea { resize: vertical; }
.mono-input { font-family: var(--font-mono); font-size: 0.85rem; }
.form-actions { display: flex; align-items: center; gap: 1rem; }
.check { display: flex; gap: 0.6rem; align-items: flex-start; }
.check input { margin-top: 0.3rem; width: 1.05rem; height: 1.05rem; accent-color: var(--ink); }

.panel {
    background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 0.9rem 1.1rem;
}
.panel > summary { cursor: pointer; font-weight: 600; }
.panel[open] > summary { margin-bottom: 1rem; }

/* Meldingen */
.notice { border-radius: var(--radius); padding: 0.75rem 1rem; border: 1px solid; }
.notice ul { margin: 0; padding-left: 1.2rem; }
.notice-success { background: var(--signed-bg); border-color: #b9d8c6; }
.notice-info { background: #eef1fa; border-color: #c8d1ec; }
.notice-error { background: #fdeceb; border-color: #f2c0bb; color: #7a1a12; }

/* Lijsten met projecten, containers, personen */
.row-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.row { padding: 1rem 0; border-bottom: 1px solid var(--line); }
.row > * + * { margin-top: 0.3rem; }
.row-title { font-weight: 600; font-size: 1.05rem; color: var(--ink); }
a.row-title { text-decoration: none; }
a.row-title:hover { color: var(--pen); text-decoration: underline; }
.row-text { color: var(--muted); }
.row-meta { font-size: 0.9rem; color: var(--muted); }
.row-actions { display: flex; gap: 1rem; font-size: 0.9rem; }
.row-actions form { margin: 0; }
.state-signed { color: var(--signed); font-weight: 600; }
.state-open { color: var(--open); font-weight: 600; }

.signer-chips { list-style: none; margin: 0.5rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip { font-size: 0.85rem; padding: 0.15rem 0.6rem; border-radius: 999px; border: 1px solid; }
.chip-role { color: var(--muted); }
.chip-signed { background: var(--signed-bg); border-color: #b9d8c6; }
.chip-signed .chip-state { color: var(--signed); font-weight: 600; }
.chip-open { background: var(--open-bg); border-color: #ecd3a8; }
.chip-open .chip-state { color: var(--open); font-weight: 600; }

/* Het afsprakenvel */
.document {
    background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 2rem 2.25rem;
}
.document-head { padding-bottom: 1.25rem; border-bottom: 1px solid var(--line); }
.document-project { color: var(--muted); font-size: 0.95rem; margin-bottom: 0.25rem; }
.document-meta { color: var(--muted); font-size: 0.9rem; margin-top: 0.35rem; }

.agreement-list { list-style: none; counter-reset: agreement; margin: 0; padding: 0; }
.agreement {
    counter-increment: agreement; position: relative;
    padding: 1.1rem 0 1.1rem 2.5rem; border-bottom: 1px solid var(--line);
}
.agreement:last-child { border-bottom: 0; }
.agreement::before {
    content: counter(agreement);
    position: absolute; left: 0; top: 1.1rem; width: 1.75rem;
    font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums;
}
.agreement-body { max-width: 38rem; }
.doc-links { list-style: none; margin: 0.6rem 0 0; padding: 0; font-size: 0.92rem; }
.doc-links li + li { margin-top: 0.2rem; }
.doc-links a { word-break: break-word; }
.doc-label { color: var(--muted); }

/* Bijlagen */
.doc-files { list-style: none; margin: 0.7rem 0 0; padding: 0; display: grid; gap: 0.35rem; }
.doc-files li, .file-edit-list li {
    display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap; font-size: 0.92rem;
}
.doc-files a { word-break: break-word; }
.file-type {
    flex: none; min-width: 2.9rem; text-align: center;
    font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em;
    padding: 0.1rem 0.35rem; border-radius: 4px;
    background: var(--paper); border: 1px solid var(--line-strong); color: var(--muted);
}
.file-edit-list { list-style: none; margin: 0 0 0.6rem; padding: 0; display: grid; gap: 0.4rem; }
.file-name { word-break: break-word; }
.file-remove { margin-left: auto; color: var(--danger); font-size: 0.88rem; display: inline-flex; gap: 0.3rem; align-items: center; cursor: pointer; }
.file-remove input { accent-color: var(--danger); }
.file-edit-list li:has(.file-remove input:checked) .file-name { text-decoration: line-through; color: var(--muted); }
.file-input { font: inherit; font-size: 0.92rem; max-width: 100%; }
.file-input::file-selector-button {
    font: inherit; font-weight: 600; margin-right: 0.75rem; cursor: pointer;
    padding: 0.4rem 0.8rem; border-radius: var(--radius);
    background: var(--sheet); color: var(--ink); border: 1px solid var(--line-strong);
}

.document-actions { display: flex; gap: 0.6rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }

/* Handtekeningen */
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: 0.75rem; }
.signers > * + * { margin-top: 1rem; }
.signer-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.signer { padding: 1.1rem 0; border-bottom: 1px solid var(--line); }
.signer > * + * { margin-top: 0.7rem; }
.signer-who strong { display: block; }
.signer-role { color: var(--muted); font-size: 0.92rem; }
.signer-comment { color: var(--muted); font-size: 0.92rem; }
.signer-link { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.signer-link input { flex: 1 1 18rem; min-width: 0; }
.signer-link form { margin: 0; }

.signature { margin: 0; max-width: 22rem; }
.signature-name {
    font-family: var(--font-hand); font-size: 2.3rem; line-height: 1.1;
    color: var(--pen); padding: 0 0.25rem 0.1rem;
    border-bottom: 1.5px solid var(--ink);
    transform: rotate(-1.5deg); transform-origin: left bottom;
}
.signature figcaption { font-size: 0.85rem; color: var(--muted); margin-top: 0.35rem; }

.audit { font-size: 0.85rem; }
.audit summary { cursor: pointer; color: var(--muted); }
.audit dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 1rem; margin: 0.5rem 0 0; }
.audit dt { color: var(--muted); }
.audit dd { margin: 0; word-break: break-word; }

.inline-form {
    display: grid; grid-template-columns: 1fr 1fr auto; gap: 0.75rem; align-items: end;
    background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem;
}

/* Versiegeschiedenis */
.versions h2 { margin-bottom: 0.75rem; }
.version-list { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); }
.version-list li { padding: 0.35rem 0 0.35rem 1rem; }
.version-list li.is-current { border-left: 2px solid var(--ink); margin-left: -2px; }
.version-list li.is-current a { font-weight: 600; color: var(--ink); }
.version-note { font-size: 0.92rem; color: var(--muted); }

/* Bewerkformulier */
.agreement-editor > * + * { margin-top: 0.9rem; }
.agreement-fields {
    border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--sheet); padding: 1rem 1.1rem; margin: 0;
}
.agreement-fields > * + * { margin-top: 0.8rem; }
.agreement-fields legend { font-weight: 600; padding: 0 0.35rem; }

/* Tekenpagina */
.sign-box {
    background: var(--sheet); border: 1px solid var(--line-strong); border-radius: var(--radius);
    padding: 1.5rem 1.75rem;
}
.sign-box > * + * { margin-top: 1rem; }
.signature-input { font-family: var(--font-hand); font-size: 1.8rem; color: var(--pen); padding: 0.2rem 0.7rem; }
.others h2 { font-size: 1rem; }

.login { max-width: 22rem; margin: 3rem auto 0; }
.login > * + * { margin-top: 1.25rem; }

@media (max-width: 640px) {
    h1 { font-size: 1.45rem; }
    .document { padding: 1.25rem 1.1rem; }
    .agreement { padding-left: 2rem; }
    .inline-form { grid-template-columns: 1fr; }
    .sign-box { padding: 1.25rem 1.1rem; }
}

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

@media print {
    body { background: #fff; }
    .site-header, .no-print, .breadcrumb, .notice, .audit summary { display: none !important; }
    .page { max-width: none; padding: 0; }
    .document, .sign-box { border: 0; padding: 0; }
    .audit[open] dl, .audit dl { display: grid; }
    .doc-links a::after { content: " (" attr(href) ")"; color: var(--muted); }
}

/* ---------- Projectoverzicht ---------- */

/* Nieuw project: eigen vlak, los van de lijst */
.create-block {
    background: var(--sheet);
    border: 1px solid var(--line-strong);
    border-top: 4px solid var(--ink);
    border-radius: var(--radius);
    padding: 1.25rem 1.4rem 1.4rem;
}
.create-block h2 { margin-bottom: 1rem; }

/* Duidelijke scheiding tussen kop/aanmaken en de lijst */
.project-section { padding-top: 1.75rem; border-top: 2px solid var(--line-strong); }
.section-bar {
    display: flex; justify-content: space-between; align-items: center;
    gap: 0.75rem 1.25rem; flex-wrap: wrap; margin-bottom: 1rem;
}
.section-bar h2 { display: flex; align-items: center; gap: 0.5rem; }
.count {
    font-size: 0.85rem; font-weight: 600; color: var(--muted);
    background: var(--sheet); border: 1px solid var(--line); border-radius: 999px;
    padding: 0.05rem 0.55rem; font-variant-numeric: tabular-nums;
}

.filter-bar { flex: 1 1 100%; display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.filter-bar input[type="search"] { flex: 1 1 14rem; width: auto; min-width: 0; }
.filter-bar select { width: auto; flex: 0 1 auto; }
.filter-bar .button { padding-block: 0.5rem; }

/* Projectkaarten */
.project-cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
.project-card {
    background: var(--sheet); border: 1px solid var(--line);
    border-radius: var(--radius); overflow: hidden;
}

.project-card-head {
    display: flex; align-items: center; gap: 1rem;
    padding: 1.1rem 1.25rem; color: var(--ink); text-decoration: none;
}
.project-card-head:hover { background: #f7f8fb; }
.project-card-head:hover .project-card-title { color: var(--pen); text-decoration: underline; text-underline-offset: 0.15em; }
.project-card-head:hover .chevron { color: var(--pen); transform: translateX(2px); }
.project-card-head:focus-visible { outline-offset: -3px; }
.project-card-text { flex: 1; min-width: 0; display: grid; gap: 0.2rem; }
.project-card-title { font-size: 1.15rem; font-weight: 600; }
.project-card-description { color: var(--muted); }
.project-card-meta { font-size: 0.88rem; color: var(--muted); }

.chevron { flex: none; color: var(--line-strong); transition: transform 120ms ease, color 120ms ease; }

/* Statuslabels */
.pill {
    flex: none; white-space: nowrap; font-size: 0.82rem; font-weight: 600;
    padding: 0.15rem 0.6rem; border-radius: 999px; border: 1px solid;
}
.pill-open { color: var(--open); background: var(--open-bg); border-color: #ecd3a8; }
.pill-signed { color: var(--signed); background: var(--signed-bg); border-color: #b9d8c6; }
.pill-none { color: var(--muted); background: var(--paper); border-color: var(--line); }

/* Containers onder een project: ingesprongen, met boomlijn */
.container-rows {
    list-style: none; margin: 0; padding: 0.35rem 0 0.5rem;
    border-top: 1px solid var(--line); background: #fafbfc;
}
.container-rows li { position: relative; padding-left: 2.6rem; }
.container-rows li::before {
    content: ""; position: absolute; left: 1.4rem; top: 0; bottom: 0;
    border-left: 1.5px solid var(--line-strong);
}
.container-rows li:last-child::before { bottom: 50%; }
.container-rows li::after {
    content: ""; position: absolute; left: 1.4rem; top: 50%; width: 0.8rem;
    border-top: 1.5px solid var(--line-strong);
}
.container-row {
    display: flex; align-items: center; gap: 0.9rem;
    padding: 0.6rem 1.25rem 0.6rem 0.4rem; color: var(--ink); text-decoration: none;
    border-radius: var(--radius);
}
.container-row:hover { background: #eef1f6; }
.container-row:hover .container-row-title { color: var(--pen); text-decoration: underline; text-underline-offset: 0.15em; }
.container-row:hover .chevron { color: var(--pen); }
.container-row-main { flex: 1; min-width: 0; display: grid; gap: 0.05rem; }
.container-row-title { font-weight: 600; }
.container-row-meta { font-size: 0.85rem; color: var(--muted); }
.container-row .chevron { width: 16px; height: 16px; }

.container-more, .container-empty {
    display: block; padding: 0.55rem 1.25rem 0.75rem 2.6rem;
    font-size: 0.9rem; background: #fafbfc;
}
.container-empty { color: var(--muted); border-top: 1px solid var(--line); margin: 0; }
.container-more { margin-top: -0.4rem; }

/* Op de projectpagina staan de containers zonder kaartkop */
.project-section > .project-card .container-rows { border-top: 0; background: var(--sheet); }

.pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1.5rem; }

@media (max-width: 640px) {
    .project-card-head { flex-wrap: wrap; padding: 1rem; }
    .project-card-text { flex-basis: 100%; }
    .container-row-main { flex-basis: 100%; }
    .container-rows li { padding-left: 2.1rem; }
    .container-rows li::before, .container-rows li::after { left: 1rem; }
    .project-card-head .chevron { display: none; }
    .container-row { flex-wrap: wrap; gap: 0.35rem 0.75rem; }
    .container-row .chevron { display: none; }
    .filter-bar input[type="search"] { flex-basis: 100%; }
    .filter-bar select { flex: 1; }
}
