/* UATH Suite operations manual. Colours follow the app (app/globals.css): sage primary on
   near-white, warm near-black in dark mode. */

:root {
  --bg: #fdfdfd;
  --bg-soft: #f5f6f2;
  --bg-sunk: #eef0ea;
  --fg: #1d1f1b;
  --fg-muted: #5c6157;
  --border: #e2e5dc;
  --primary: #7d9460;
  --primary-strong: #5d7343;
  --primary-soft: #eef3e7;
  --on-primary: #fbfbf8;
  --link: #4f6a33;
  --note: #2f6fb0;
  --note-soft: #eaf2fb;
  --tip: #4d7a2e;
  --tip-soft: #edf5e6;
  --warn: #a15c07;
  --warn-soft: #fdf3e2;
  --badge: #d9480f;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 4px 16px rgb(0 0 0 / 0.05);
  --header-h: 60px;
  --sidebar-w: 280px;
  --font: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #14120f;
    --bg-soft: #1c1a16;
    --bg-sunk: #23211c;
    --fg: #ecebe6;
    --fg-muted: #a7a69d;
    --border: #312e27;
    --primary: #aebd99;
    --primary-strong: #c4d1b1;
    --primary-soft: #232a1b;
    --on-primary: #14120f;
    --link: #b8cc9c;
    --note: #7fb1e6;
    --note-soft: #172331;
    --tip: #9fcb7c;
    --tip-soft: #1a2615;
    --warn: #e9b163;
    --warn-soft: #2d2212;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #14120f;
  --bg-soft: #1c1a16;
  --bg-sunk: #23211c;
  --fg: #ecebe6;
  --fg-muted: #a7a69d;
  --border: #312e27;
  --primary: #aebd99;
  --primary-strong: #c4d1b1;
  --primary-soft: #232a1b;
  --on-primary: #14120f;
  --link: #b8cc9c;
  --note: #7fb1e6;
  --note-soft: #172331;
  --tip: #9fcb7c;
  --tip-soft: #1a2615;
  --warn: #e9b163;
  --warn-soft: #2d2212;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.4);
  color-scheme: dark;
}

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

html { scroll-padding-top: calc(var(--header-h) + 16px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.65 var(--font);
}
img { max-width: 100%; height: auto; }
a { color: var(--link); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
code, kbd { font-family: var(--mono); font-size: 0.88em; }
code { background: var(--bg-sunk); padding: 0.1em 0.35em; border-radius: 5px; }
kbd {
  border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px;
  padding: 0.05em 0.4em; background: var(--bg-soft);
}
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; }
.skip-link:focus { left: 16px; background: var(--bg); padding: 8px 12px; border-radius: 6px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  height: var(--header-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--fg); text-decoration: none; min-width: 0; }
.brand img { width: 32px; height: 32px; object-fit: contain; }
.brand strong { font-size: 15px; line-height: 1.2; white-space: nowrap; }
.brand span { display: block; font-size: 12px; color: var(--fg-muted); font-weight: 400; }
.header-spacer { flex: 1; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--fg); cursor: pointer;
}
.icon-btn:hover { background: var(--bg-soft); }
.icon-btn svg { width: 18px; height: 18px; }
.menu-btn { display: none; }
.open-app {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px;
  background: var(--primary); color: var(--on-primary); text-decoration: none; font-weight: 600; font-size: 14px;
  white-space: nowrap;
}
.open-app:hover { background: var(--primary-strong); }
.open-app svg { width: 16px; height: 16px; flex: none; }

/* ---------- Search ---------- */
.search { position: relative; width: min(360px, 40vw); }
.search input {
  width: 100%; height: 38px; padding: 0 12px 0 34px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg-soft); color: var(--fg); font: inherit; font-size: 14px;
}
.search svg { position: absolute; left: 10px; top: 10px; width: 18px; height: 18px; color: var(--fg-muted); }
.search-results {
  position: absolute; top: 44px; left: 0; right: 0; z-index: 60;
  max-height: 60vh; overflow: auto;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 6px; margin: 0; list-style: none;
}
.search-results[hidden] { display: none; }
.search-results a { display: block; padding: 8px 10px; border-radius: 6px; color: var(--fg); text-decoration: none; }
.search-results a:hover, .search-results a[aria-selected='true'] { background: var(--primary-soft); }
.search-results small { display: block; color: var(--fg-muted); font-size: 12.5px; line-height: 1.4; }
.search-results .empty { padding: 10px; color: var(--fg-muted); font-size: 14px; }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) 220px;
  max-width: 1440px; margin: 0 auto;
}
.layout.no-toc { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
.sidebar {
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h)); overflow-y: auto;
  padding: 20px 12px 40px 16px;
  border-right: 1px solid var(--border);
  font-size: 14.5px;
}
.sidebar details { margin-bottom: 6px; }
.sidebar summary {
  cursor: pointer; list-style: none;
  padding: 6px 8px; border-radius: 6px;
  font-weight: 600; font-size: 13px; letter-spacing: 0.02em; text-transform: uppercase; color: var(--fg-muted);
}
.sidebar summary::-webkit-details-marker { display: none; }
.sidebar summary::after { content: '›'; float: right; transition: transform 0.15s; }
.sidebar details[open] summary::after { transform: rotate(90deg); }
.sidebar ul { list-style: none; margin: 2px 0 8px; padding: 0; }
.sidebar li a {
  display: block; padding: 5px 10px; border-radius: 6px;
  color: var(--fg); text-decoration: none; line-height: 1.4;
}
.sidebar li a:hover { background: var(--bg-soft); }
.sidebar li a[aria-current='page'] { background: var(--primary-soft); color: var(--primary-strong); font-weight: 600; }

.content { padding: 28px 40px 80px; min-width: 0; }
.content > main { max-width: 780px; }
.toc {
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h)); overflow-y: auto;
  padding: 28px 16px; font-size: 13.5px;
}
.toc strong { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--fg-muted); margin-bottom: 8px; }
.toc ul { list-style: none; padding: 0; margin: 0; }
.toc li { margin: 4px 0; }
.toc li.lvl-3 { padding-left: 12px; }
.toc a { color: var(--fg-muted); text-decoration: none; }
.toc a:hover, .toc a.active { color: var(--primary-strong); }

.scrim { display: none; }

@media (max-width: 1180px) {
  .layout, .layout.no-toc { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 860px) {
  .layout, .layout.no-toc { grid-template-columns: minmax(0, 1fr); }
  .menu-btn { display: inline-grid; }
  .sidebar {
    position: fixed; left: 0; top: var(--header-h); z-index: 50;
    width: min(320px, 86vw); background: var(--bg);
    transform: translateX(-102%); transition: transform 0.2s ease;
    box-shadow: var(--shadow);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim {
    display: block; position: fixed; inset: var(--header-h) 0 0 0; z-index: 45; background: rgb(0 0 0 / 0.35);
  }
  .content { padding: 20px 16px 64px; }
  .search { width: auto; flex: 1; }
  .brand span, .open-app .label { display: none; }
  .header-spacer { display: none; }
}
@media (max-width: 520px) {
  .brand strong { display: none; }
}

/* ---------- Typography ---------- */
main h1 { font-size: 2rem; line-height: 1.2; margin: 6px 0 10px; letter-spacing: -0.01em; }
main h2 { font-size: 1.4rem; line-height: 1.3; margin: 2.2em 0 0.6em; padding-top: 0.4em; border-top: 1px solid var(--border); }
main h3 { font-size: 1.12rem; margin: 1.8em 0 0.5em; }
main h2 + h3 { margin-top: 0.8em; }
main p, main li { max-width: 72ch; }
main ul, main ol { padding-left: 1.4em; }
main li + li { margin-top: 0.3em; }
.lead { font-size: 1.12rem; color: var(--fg-muted); margin-top: 0; }
.heading-anchor { margin-left: 6px; color: var(--fg-muted); text-decoration: none; opacity: 0; font-weight: 400; }
h2:hover .heading-anchor, h3:hover .heading-anchor { opacity: 1; }
hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }

.breadcrumbs { font-size: 13.5px; color: var(--fg-muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.breadcrumbs a { color: var(--fg-muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--link); }
.audience { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 18px; }
.audience .pill {
  font-size: 12.5px; padding: 2px 10px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary-strong); font-weight: 600;
}

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 1em 0 1.5em; border: 1px solid var(--border); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--bg-soft); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.yes { color: var(--tip); font-weight: 700; text-align: center; }
td.no { color: var(--fg-muted); text-align: center; }
table.matrix th:not(:first-child), table.matrix td:not(:first-child) { text-align: center; }
table.matrix th { position: sticky; top: 0; }

/* ---------- Callouts ---------- */
.note, .tip, .warn {
  margin: 1.2em 0; padding: 12px 16px 12px 44px; border-radius: var(--radius);
  position: relative; border: 1px solid transparent;
}
.note > :first-child, .tip > :first-child, .warn > :first-child { margin-top: 0; }
.note > :last-child, .tip > :last-child, .warn > :last-child { margin-bottom: 0; }
.note::before, .tip::before, .warn::before {
  position: absolute; left: 14px; top: 11px; font-weight: 700; font-size: 16px;
  width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; font-size: 13px; color: var(--bg);
}
.note { background: var(--note-soft); border-color: color-mix(in srgb, var(--note) 25%, transparent); }
.note::before { content: 'i'; background: var(--note); }
.tip { background: var(--tip-soft); border-color: color-mix(in srgb, var(--tip) 25%, transparent); }
.tip::before { content: '✓'; background: var(--tip); }
.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.warn::before { content: '!'; background: var(--warn); }

/* ---------- Steps ---------- */
ol.steps { list-style: none; counter-reset: step; padding-left: 0; }
ol.steps > li {
  counter-increment: step; position: relative;
  padding: 0 0 18px 48px; margin: 0; max-width: none;
}
ol.steps > li::before {
  content: counter(step);
  position: absolute; left: 0; top: -2px;
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--primary); color: var(--on-primary); font-weight: 700; font-size: 15px;
}
ol.steps > li:not(:last-child)::after {
  content: ''; position: absolute; left: 15px; top: 34px; bottom: 2px; width: 2px; background: var(--border);
}
ol.steps > li > strong:first-child { display: block; }

/* ---------- App links ---------- */
a.app-link {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 1px 9px 1px 8px; border-radius: 6px;
  background: var(--primary-soft); color: var(--primary-strong);
  font-weight: 600; text-decoration: none; font-size: 0.95em; white-space: nowrap;
}
a.app-link:hover { background: color-mix(in srgb, var(--primary) 25%, var(--primary-soft)); }
a.app-link svg { width: 14px; height: 14px; flex: none; }
.app-path { font-family: var(--mono); font-size: 0.86em; }

/* ---------- Screenshots ---------- */
figure.shot { margin: 1.4em 0 1.6em; }
.shot-frame {
  /* Shrink-wraps the image: wide captures scale down to the column, narrow clips (a sidebar,
     a dialog) keep their natural size instead of being blown up and blurred. */
  position: relative; display: block; width: fit-content; max-width: 100%;
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); background: var(--bg-soft); cursor: zoom-in;
}
.shot-frame img { display: block; width: auto; max-width: 100%; height: auto; }
.shot.mobile .shot-frame { max-width: 360px; margin: 0 auto; }
.shot-marker {
  position: absolute; transform: translate(-50%, -50%);
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--badge); color: #fff; font-weight: 700; font-size: 13.5px;
  display: grid; place-items: center;
  box-shadow: 0 0 0 3px rgb(255 255 255 / 0.9), 0 2px 6px rgb(0 0 0 / 0.35);
  pointer-events: none;
}
.shot-box {
  position: absolute; border: 2px solid var(--badge); border-radius: 6px;
  box-shadow: 0 0 0 9999px rgb(0 0 0 / 0);
  pointer-events: none;
}
figure.shot figcaption { font-size: 14px; color: var(--fg-muted); margin-top: 8px; }
.shot-missing {
  padding: 28px 16px; text-align: center; color: var(--fg-muted); font-size: 14px;
  border: 1px dashed var(--border); border-radius: var(--radius);
}
ol.callouts { list-style: none; counter-reset: co; padding-left: 0; margin-top: 0.6em; }
ol.callouts > li { counter-increment: co; position: relative; padding-left: 34px; margin: 6px 0; }
ol.callouts > li::before {
  content: counter(co); position: absolute; left: 0; top: 1px;
  width: 22px; height: 22px; border-radius: 50%; background: var(--badge); color: #fff;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
}

.lightbox {
  position: fixed; inset: 0; z-index: 100; background: rgb(0 0 0 / 0.82);
  display: grid; place-items: center; padding: 24px; cursor: zoom-out;
}
.lightbox .shot-frame { max-width: min(1400px, 96vw); max-height: 92vh; overflow: auto; cursor: zoom-out; }

/* ---------- Cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin: 1.2em 0 2em; }
.card {
  display: block; padding: 16px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg); color: var(--fg); text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.card:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.card strong { display: block; font-size: 16px; margin-bottom: 4px; }
.card span { display: block; color: var(--fg-muted); font-size: 14px; line-height: 1.5; }
.card .card-icon { font-size: 22px; margin-bottom: 6px; display: block; }

.hero {
  padding: 28px; border-radius: 16px; margin-bottom: 8px;
  background: linear-gradient(135deg, var(--primary-soft), var(--bg-soft));
  border: 1px solid var(--border);
}
.hero h1 { margin-top: 0; }
.hero .search { width: 100%; max-width: 520px; margin-top: 14px; }
.hero .search input { height: 46px; font-size: 16px; background: var(--bg); }
.hero .search svg { top: 14px; }

/* ---------- Page footer ---------- */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 56px; max-width: 780px; }
.pager a {
  display: block; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius);
  text-decoration: none; color: var(--fg);
}
.pager a:hover { border-color: var(--primary); }
.pager small { display: block; color: var(--fg-muted); font-size: 12.5px; }
.pager .next { text-align: right; grid-column: 2; }
.site-footer { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--border); font-size: 13px; color: var(--fg-muted); max-width: 780px; }

dl.fields { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; }
dl.fields dt { font-weight: 600; }
dl.fields dd { margin: 0; color: var(--fg-muted); }
@media (max-width: 600px) { dl.fields { grid-template-columns: 1fr; } dl.fields dd { margin-bottom: 8px; } }

/* ---------- Print ---------- */
@media print {
  :root { --bg: #fff; --fg: #000; }
  .site-header, .sidebar, .toc, .pager, .scrim, .heading-anchor, .search { display: none !important; }
  .layout, .layout.no-toc { display: block; }
  .content { padding: 0; }
  main h2 { break-after: avoid; }
  figure.shot, table, .note, .tip, .warn, ol.steps > li { break-inside: avoid; }
  a.app-link { background: none; padding: 0; }
  a.app-link::after { content: ' (' attr(data-app) ')'; font-family: var(--mono); font-weight: 400; font-size: 0.85em; }
  .shot-frame { box-shadow: none; }
}

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