/*
 * Governance: policies, risks and incidents (public/js/areas/policies.js, risks.js, incidents.js).
 * Only what the UI kit does not already give.
 */

/* ---------- policy library ---------- */
.pol-grid, .pol-tpls { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--gap); }
.pol-tpls { margin-top: var(--gap); }
.pol-card, .pol-tpl { display: flex; flex-direction: column; gap: 8px; min-width: 0; color: inherit; text-decoration: none; }
.pol-card h3, .pol-tpl h3 { font-size: 17px; line-height: 1.25; overflow-wrap: anywhere; }
.pol-tpl p { font-size: 13px; flex: 1 1 auto; }
.pol-tpl .btn { align-self: flex-start; }
.pol-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pol-top .pill { margin-left: auto; flex: none; }
.pol-ic { width: 30px; height: 30px; border-radius: 9px; flex: none; display: grid; place-items: center; background: var(--glass-2); border: 1px solid var(--stroke); color: var(--accent-t); }
.pol-kind { font: 600 10.5px/1.2 var(--f-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--faint); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pol-meta { font-size: 12.8px; color: var(--muted); margin: 0; overflow-wrap: anywhere; }
.pol-flags { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12.3px; }
.pol-due, .pol-next { display: inline-flex; align-items: center; gap: 5px; color: var(--text-2); }
.pol-due.warn { color: var(--t-med); font-weight: 600; }
.pol-due.bad { color: var(--t-crit); font-weight: 700; }
.pol-acks { margin-top: auto; padding-top: 6px; font-size: 12.5px; color: var(--muted); }
.pol-acks .row { margin-bottom: 6px; gap: 8px; }
.pol-acks b { color: var(--text); font-size: 12.5px; }
.pol-note { margin: auto 0 0; padding-top: 6px; font-size: 12.5px; color: var(--faint); }
.pol-li .li-t, .pol-li .li-s, .rk-li .li-t { white-space: normal; }
.pol-quote { font-style: italic; margin-top: 2px; }

/* ---------- one policy ---------- */
.pol-decide { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; margin-bottom: var(--gap); }
.pol-decide > .ic { flex: none; margin-top: 2px; }
.pol-decide .grow { flex: 1 1 260px; min-width: 0; }
.pol-switch { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; margin-bottom: var(--gap); font-size: 12.5px; }
.seg a { display: inline-flex; align-items: center; height: 32px; padding: 0 12px; border-radius: 9px; font-size: 13px; font-weight: 500; color: var(--muted); white-space: nowrap; text-decoration: none; }
.seg a.on { background: var(--glass-3); color: var(--text); box-shadow: var(--hl), 0 2px 8px -3px rgba(0, 0, 0, .4); }
[data-theme="light"] .seg a.on { background: #fff; box-shadow: 0 1px 4px rgba(64, 48, 32, .12); }
.pol-side { align-content: start; }
.pol-doc { min-width: 0; }
.pol-doc-h { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12.5px; padding-bottom: 12px; margin-bottom: 4px; border-bottom: 1px solid var(--stroke); }
.pol-change { margin: 12px 0 0; }
.pol-doc-h + .md, .pol-change + .md { margin-top: 16px; }
.pol-read { max-width: 860px; }
.pol-kv { grid-template-columns: 110px minmax(0, 1fr); }
.pol-people { max-height: 360px; overflow-y: auto; margin-top: 6px; }
.pol-person { gap: 10px; padding: 8px 0; }
.pol-person .li-r .pill { white-space: nowrap; }
.pol-remind { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; margin-top: 12px; font-size: 12.5px; }
.pol-ack { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 22px; padding: 14px 16px; border-radius: var(--r-md); border: 1px dashed var(--stroke-2); background: var(--glass); font-size: 13.5px; }
.pol-ack span { flex: 1 1 240px; }
.pol-ack.done { border-style: solid; border-color: rgba(39, 116, 46, .35); background: rgba(39, 116, 46, .08); justify-content: flex-start; color: var(--text); }
.pol-ack.done .ic { color: var(--t-low); flex: none; }

/* Policy text, rendered from the safe markdown subset. */
.md { font-size: 15px; line-height: 1.65; color: var(--text-2); overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md h2, .md h3, .md h4, .md h5 { color: var(--text); margin: 1.5em 0 .5em; line-height: 1.25; }
.md h2 { font-size: 24px; }
.md h3 { font-size: 19px; }
.md h4 { font-size: 16px; font-family: var(--f-ui); font-weight: 700; }
.md h5 { font-size: 14px; font-family: var(--f-ui); font-weight: 700; }
.md p, .md ul, .md ol { margin: 0 0 .85em; }
.md ul, .md ol { padding-left: 1.35em; }
.md li { margin: .3em 0; }
.md li::marker { color: var(--accent-t); }
.md strong { color: var(--text); }
.md a { color: var(--accent-t); text-decoration: underline; text-underline-offset: 2px; }

/* ---------- the editor ---------- */
.pol-edit { min-width: 0; }
.pol-editor { margin-top: 4px; }
.pol-tabs { display: none; margin-bottom: 10px; }
.pol-panes { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--gap); align-items: start; }
.pol-pane { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.pol-pane > label, .pol-pane > .lbl { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.pol-write textarea { min-height: 460px; font-size: 13.5px; line-height: 1.6; }
.pol-write .hint { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.pol-preview .md { max-height: 560px; overflow-y: auto; padding: 12px 14px; border-radius: var(--r-md); border: 1px solid var(--stroke); background: var(--glass); font-size: 14px; }
.pol-edit-f { margin-top: 14px; }
@media (max-width: 1100px) {
	.pol-tabs { display: inline-flex; }
	.pol-panes { grid-template-columns: minmax(0, 1fr); }
	.pol-editor[data-tab="write"] .pol-preview, .pol-editor[data-tab="preview"] .pol-write { display: none; }
	.pol-preview .md { max-height: none; }
	.pol-write textarea { min-height: 360px; }
}

/* ---------- risks ---------- */
.rk-axes { font-size: 11.5px; margin-top: 4px; gap: 4px 12px; flex-wrap: wrap; }
.rk-score { width: 36px; height: 36px; border-radius: 11px; flex: none; display: grid; place-items: center; font: 700 14px/1 var(--f-mono); color: #fff; background: var(--bc, #7C8A93); }
.rk-score.lg { width: 46px; height: 46px; border-radius: 14px; font-size: 18px; }
.rk-li .li-r .sev { white-space: nowrap; }
.rk-rate { display: inline-flex; align-items: center; gap: 8px; }
.rk-rate b { font-size: 14px; min-width: 18px; }
.rk-late { color: var(--t-crit); font-weight: 700; }
.rk-clip { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 320px; font-size: 12.8px; color: var(--text-2); }
.rk-rating { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rk-detail { margin: 8px 0 0; font-size: 12.8px; color: var(--text-2); }
.rk-hist { margin-top: 10px; }
.rk-hist .li-s, .inc-log .li-s, .inc-steps .li-s { white-space: normal; }

/* ---------- incidents ---------- */
.inc-note { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; margin-bottom: 8px; }
.inc-note textarea { width: 100%; }
.inc-log .li-t.inc-text { white-space: pre-wrap; font-weight: 500; overflow-wrap: anywhere; }

@media (max-width: 720px) {
	.pol-grid, .pol-tpls { grid-template-columns: minmax(0, 1fr); }
	.pol-kv { grid-template-columns: 1fr; }
	.pol-ack .btn { width: 100%; justify-content: center; }
	.md { font-size: 14.5px; }
	.md h2 { font-size: 21px; }
	.md h3 { font-size: 17.5px; }
	.pol-people { max-height: none; }
	.rk-clip { max-width: none; }
}
