/* Panacea – components and the docs shell. Hand-written; builds only on the
   tokens in tokens.css, which must be linked first:

     <link rel="stylesheet" href="/design/tokens.css">
     <link rel="stylesheet" href="/design/components.css">
     <script src="/design/shell.js" defer></script>   (nav filter, optional)

   See README.md (Norwegian) for when to use what. */

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--surface-100);
  color: var(--ink);
  font: var(--type-body);
}
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--glacier); outline-offset: 2px; }
a { color: var(--glacier); text-underline-offset: 0.15em; }
/* No ligatures in monospace: readers copy what they see (->, !=, <!--). */
code, kbd, pre, samp, .mono, .code, .amount, .code-block, .endpoint, .method,
.field-name, .field-type, .input.mono, .textarea { font-variant-ligatures: none; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ------------------------------------------------------------- utilities */
.mono { font-family: var(--font-mono); }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--ink-muted); }
.note { font: var(--type-small); color: var(--ink-muted); }
.spacer { flex: 1; }
.truncate { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ----------------------------------------------------------------- shell
   body.shell
     header.topbar
     div.workspace
       nav.pane.pane-nav      (required)
       main.pane.pane-main    (required)
       aside.pane.pane-aside  (optional: examples, try-it, state)
     footer.shell-foot        (optional)

   The workspace fills the viewport and each pane scrolls on its own. Below
   1180px the aside moves under the content; below 760px everything stacks. */
.shell {
  min-height: 100vh;
  min-height: 100dvh;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 0 max(var(--space-4), env(safe-area-inset-right, 0px)) var(--space-3) max(var(--space-4), env(safe-area-inset-left, 0px));
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3) var(--space-6);
  padding-block: var(--space-3);
}
.brand { display: flex; align-items: baseline; gap: var(--space-2); text-decoration: none; color: inherit; }
.wordmark { margin: 0; font: var(--type-title); font-size: 24px; letter-spacing: -0.02em; color: var(--ink); }
/* The mark: base on the wordmark's baseline, 0.9 × its size. Inline it so it follows the theme. */
.brand-mark { flex: none; height: 22px; width: auto; aspect-ratio: 56 / 48; fill: var(--ink); }
.brand-mark .tip { fill: var(--glacier); }
.brand-tag {
  font: var(--type-label);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--glacier-tint);
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
}
.topbar-context { display: flex; gap: var(--space-2); align-items: baseline; font: var(--type-small); color: var(--ink-muted); min-width: 0; }
.topbar-context b { color: var(--ink); font-weight: 600; }
.topbar-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

.workspace {
  --nav-width: 260px;
  --aside-width: 460px;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--nav-width) minmax(0, 1fr) minmax(0, var(--aside-width));
  background: var(--surface-200);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.workspace:not(:has(> .pane-aside)) { grid-template-columns: var(--nav-width) minmax(0, 1fr); }
.pane { min-width: 0; min-height: 0; overflow: auto; }
.pane + .pane { border-left: 1px solid var(--line); }
.pane-main { padding: var(--space-6) var(--space-6) var(--space-8); }
.pane-main > * + * { margin-top: var(--space-6); }
.pane-aside { display: flex; flex-direction: column; }

.shell-foot { margin: var(--space-2) 2px 0; }

@media (max-width: 1180px) {
  .shell { height: auto; }
  .workspace { flex: none; grid-template-columns: 240px minmax(0, 1fr); }
  .pane { overflow: visible; }
  .pane-aside { grid-column: 1 / -1; border-left: 0 !important; border-top: 1px solid var(--line); }
  .pane-nav { position: sticky; top: 0; align-self: start; max-height: 100vh; overflow: auto; }
}
@media (max-width: 760px) {
  .workspace, .workspace:not(:has(> .pane-aside)) { grid-template-columns: minmax(0, 1fr); }
  .pane + .pane { border-left: 0; border-top: 1px solid var(--line); }
  .pane-nav { position: static; max-height: 320px; }
  .pane-main { padding: var(--space-4) var(--space-3) var(--space-6); }
}

/* ------------------------------------------------------------------- nav
   nav.pane.pane-nav
     div.nav-filter > input.input[type=search]
     details.nav-group[open] > summary + a.nav-item ...   (groups can nest)
     p.nav-empty[hidden]                                    (filter: no hits) */
.pane-nav { background: var(--surface-300); padding: 0 var(--space-2) var(--space-4); }
.nav-filter {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-300);
  padding: var(--space-3) 0 var(--space-2);
}
.nav-filter .input { width: 100%; }

.nav-group > summary {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  list-style: none;
  cursor: pointer;
  padding: var(--space-3) var(--space-2) var(--space-1);
  font: var(--type-label);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  border-radius: var(--radius-sm);
}
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary::before {
  content: "";
  width: 6px; height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  margin-right: 2px;
  transition: transform 120ms ease;
}
.nav-group[open] > summary::before { transform: rotate(45deg); }
.nav-group > summary:hover { color: var(--ink); }
.nav-group .nav-group { margin-left: var(--space-3); }
.nav-group .nav-group > summary { text-transform: none; letter-spacing: 0; font: var(--type-small); font-weight: 600; padding-top: var(--space-2); }

.nav-item {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 2px var(--space-2);
  align-items: baseline;
  width: 100%;
  padding: 6px var(--space-2);
  border: 0;
  border-radius: var(--radius-md);
  background: none;
  font: var(--type-small);
  font-weight: 500;
  color: var(--ink);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.nav-item.plain { grid-template-columns: minmax(0, 1fr); }
/* Hover is a lighter version of the current item, so the two never look the same. */
.nav-item:hover { background: color-mix(in srgb, var(--surface-200) 50%, transparent); }
.nav-item[aria-current="page"], .nav-item[aria-current="true"] {
  background: var(--surface-200);
  font-weight: 600;
}
.nav-empty { padding: var(--space-3) var(--space-2); font: var(--type-small); color: var(--ink-muted); }

/* ------------------------------------------------------- HTTP method tag */
.method { font-family: var(--font-mono); font-size: 10.5px; font-weight: 600; letter-spacing: 0.03em; }
.method-get { color: var(--glacier); }
.method-post { color: var(--positive); }
.method-put, .method-patch { color: var(--aurora); }
.method-delete { color: var(--negative); }

/* ------------------------------------------------------------- page head */
.crumbs { display: flex; flex-wrap: wrap; gap: var(--space-1); font: var(--type-small); color: var(--ink-muted); margin: 0 0 var(--space-2); padding: 0; list-style: none; }
.crumbs li + li::before { content: "/"; margin-right: var(--space-1); color: var(--line); }
.crumbs a { color: inherit; text-decoration: none; }
.crumbs a:hover { color: var(--glacier); }

.endpoint {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font: var(--type-code);
  padding: var(--space-2) var(--space-3);
  background: var(--surface-300);
  border-radius: var(--radius-md);
  overflow-x: auto;
  white-space: nowrap;
}
.endpoint .method { font-size: 12px; }

/* ----------------------------------------------------------------- prose */
.prose { max-width: 68ch; }
.prose h1 { margin: 0 0 var(--space-2); font: var(--type-heading); letter-spacing: -0.01em; text-wrap: balance; }
.prose h2 { margin: var(--space-6) 0 var(--space-2); font: var(--type-title); }
.prose p, .prose ul, .prose ol { margin: 0 0 var(--space-3); }
.prose code, .inline-code {
  font: var(--type-code);
  font-size: 12px;
  background: var(--surface-300);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
}
.prose .aside-note { font: var(--type-small); color: var(--ink-muted); }
.prose .aside-note b { color: var(--ink); font-weight: 600; }

/* Section label: the .label type style with room for a note beside it. */
.section-label {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  margin: 0 0 6px;
  font: var(--type-label);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.section-label .note { text-transform: none; letter-spacing: 0; font-weight: 400; }

/* ------------------------------------------------------- field reference
   dl.fields > div > dt(.field-name, .field-type, .chip) + dd             */
.fields { margin: 0; border-top: 1px solid var(--line); }
.fields > div { padding: var(--space-3) 0; border-bottom: 1px solid var(--line); }
.fields dt { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-2); }
.field-name { font: var(--type-code); font-weight: 600; }
.field-type { font: var(--type-code); font-size: 12px; color: var(--ink-muted); }
.fields dd { margin: var(--space-1) 0 0; font: var(--type-small); max-width: 68ch; }
.fields .fields { margin: var(--space-2) 0 0 var(--space-4); border-top: 0; border-left: 1px solid var(--line); padding-left: var(--space-3); }
.fields .fields > div:last-child { border-bottom: 0; }

/* --------------------------------------------------------------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-200);
  font: var(--type-small);
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { border-color: var(--ink-muted); }
.btn-primary { background: var(--glacier); border-color: var(--glacier); color: var(--on-glacier); font-weight: 600; }
.btn-primary:hover { border-color: var(--glacier); filter: brightness(1.08); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------------------------------------------------------------- fields */
.input, .textarea, .select {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-200);
  padding: 6px 10px;
  font: var(--type-small);
}
.input:hover, .textarea:hover, .select:hover { border-color: var(--ink-muted); }
.input::placeholder, .textarea::placeholder { color: var(--ink-muted); }
.input.mono, .textarea { font: var(--type-code); }
.textarea { width: 100%; min-height: 220px; resize: vertical; padding: 10px var(--space-3); tab-size: 2; }

/* Request bar: method + path + send */
.field-row { display: flex; gap: var(--space-2); align-items: stretch; flex-wrap: wrap; }
.field-row > .input { flex: 1; min-width: 200px; }
.field-row > .method {
  display: flex; align-items: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-300);
  font-size: 12px;
}

/* ----------------------------------------------------------------- chips
   Small status labels. Variants carry state, never decoration. */
.chip {
  display: inline-block;
  padding: 1px 7px;
  border-radius: var(--radius-sm);
  background: var(--surface-300);
  color: var(--ink-muted);
  font: var(--type-label);
  font-size: 11px;
  line-height: 18px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  vertical-align: baseline;
}
.chip.mono { font-family: var(--font-mono); letter-spacing: 0; }
.chip-positive { background: var(--positive-tint); color: var(--positive); }
.chip-negative { background: var(--negative-tint); color: var(--negative); }
.chip-aurora { background: var(--aurora-tint); color: var(--aurora); }
.chip-glacier { background: var(--glacier-tint); color: var(--ink); }

/* ------------------------------------------------------- panel and code
   div.panel > div.panel-head + pre.code-block                            */
.panel { border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface-300); overflow: hidden; }
.panel-head {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--line);
  font: var(--type-small);
  font-size: 12px;
  color: var(--ink-muted);
}
.code-block {
  margin: 0;
  padding: var(--space-3);
  font: var(--type-code);
  font-size: 12px;
  line-height: 1.55;
  overflow: auto;
  white-space: pre;
  tab-size: 2;
}
.panel > .code-block { max-height: 520px; }
.code-block:not(.panel > .code-block) { background: var(--surface-300); border-radius: var(--radius-md); }
.tok-key { color: var(--glacier); }
.tok-str { color: var(--positive); }
.tok-num { color: var(--aurora); }
.tok-lit { color: var(--negative); }
.tok-com { color: var(--ink-muted); font-style: italic; }

/* ------------------------------------------------------------------ tabs */
.tabs {
  display: flex;
  gap: 2px;
  padding: var(--space-2) 10px 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface-200);
  overflow-x: auto;
}
.pane-aside > .tabs { position: sticky; top: 0; z-index: 1; }
.tab {
  padding: 7px 10px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  font: var(--type-small);
  font-weight: 500;
  color: var(--ink-muted);
  white-space: nowrap;
  cursor: pointer;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--glacier); }
.tab-body { padding: var(--space-3) 14px var(--space-6); }
.tab-body > * + * { margin-top: var(--space-3); }

/* ---------------------------------------------------------------- tables
   Wrap in .table-scroll when a table can be wider than its pane. */
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font: var(--type-small); font-size: 12.5px; }
.table th {
  padding: 6px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font: var(--type-label);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.table th.num { text-align: right; }
.table td { padding: 5px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table td.num { font-family: var(--font-mono); font-size: 12px; }
.table tfoot td { font-weight: 600; border-bottom: 0; border-top: 2px solid var(--line); }
.table tr.group td {
  background: var(--surface-300);
  font: var(--type-label);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.table tbody tr[aria-selected="true"] td { background: var(--glacier-tint); }

/* ---------------------------------------------------- card and key/value */
.card { border: 1px solid var(--line); border-radius: var(--radius-md); padding: 10px var(--space-3); background: var(--surface-200); }
.card-head { display: flex; justify-content: space-between; gap: var(--space-2); align-items: baseline; margin: 0 0 var(--space-1); font: var(--type-small); font-weight: 600; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; margin: var(--space-1) 0 0; font: var(--type-small); font-size: 12.5px; }
.kv dt { color: var(--ink-muted); }
.kv dd { margin: 0; }

/* ----------------------------------------------------------- empty state */
.empty { padding: var(--space-6) var(--space-1); font: var(--type-small); color: var(--ink-muted); }
