/* Ketendo developer documentation
   Design tokens ported from the Portal (Portal/src/styles.scss + the saga-blue PrimeNG theme)
   so the docs read as part of the product rather than a generic reference page. */

@font-face {
  font-family: "Fira Code";
  src: url("fonts/FiraCode-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Fira Code";
  src: url("fonts/FiraCode-Medium.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

:root {
  /* Brand */
  --brand-navy: #25518e;
  --brand-navy-dark: #1d4276;
  --brand-navy-tint: #e8eef7;
  /* Accent only. #94cc5b is ~1.8:1 on white, so it never carries text. */
  --brand-green: #94cc5b;
  --brand-green-tint: #eef7e4;
  --brand-green-ink: #4a7c1f;

  /* Surfaces */
  --surface-ground: #f8f9fa;
  --surface-card: #ffffff;
  --surface-hover: #e9ecef;
  --border: #dee2e6;
  --border-subtle: #eef1f2;

  /* Text */
  --text: #495057;
  --text-muted: #6c757d;

  /* Semantic, kept distinct so readers can still scan for them */
  --req-bg: #fde8e8;      --req-ink: #a51818;
  --cond-bg: #fdf1e0;     --cond-ink: #96590a;
  --info-bg: var(--brand-navy-tint);
  --info-ink: var(--brand-navy);

  --code-bg: #14243d;     /* navy-tinted rather than neutral black */
  --code-ink: #dbe5f2;

  --radius: 4px;
  --radius-lg: 6px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  --sidebar-w: 280px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--surface-ground);
  line-height: 1.55;
  /* The pages are designed light; stop browsers force-inverting them into something unreadable. */
  color-scheme: light;
}

a { color: var(--brand-navy); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4, h5 { color: var(--brand-navy); font-weight: 500; }

code, pre { font-family: "Fira Code", Consolas, "SFMono-Regular", Menlo, monospace; }
code {
  background: var(--surface-hover);
  padding: 1px 6px;
  border-radius: var(--radius);
  font-size: 0.88em;
}
pre {
  background: var(--code-bg);
  color: var(--code-ink);
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  overflow-x: auto;
  font-size: 0.85em;
  line-height: 1.55;
}
pre code { background: none; padding: 0; color: inherit; }

/* ---------- Site chrome ---------- */

header.top {
  background: linear-gradient(120deg, var(--brand-navy-dark), var(--brand-navy));
  color: #fff;
  padding: 18px 32px;
  position: sticky;
  top: 0;
  z-index: 20;
}
header.top .brand { display: flex; align-items: center; gap: 12px; }
header.top .brand img { height: 30px; width: auto; display: block; }
header.top .brand-home { display: inline-flex; border-radius: var(--radius); padding: 4px; margin: -4px; }
header.top .brand-home:hover { background: rgba(255, 255, 255, 0.12); text-decoration: none; }
header.top .brand-home:focus-visible { outline: 2px solid var(--brand-green); outline-offset: 2px; }
header.top h1 { margin: 0; font-size: 1.35rem; color: #fff; font-weight: 500; }
header.top p { margin: 4px 0 0; opacity: 0.9; font-size: 0.92rem; }
header.top .meta { margin-top: 8px; font-size: 0.78rem; opacity: 0.85; }
header.top a { color: #fff; }
/* The default code chip is a light background with muted text - invisible on the navy header. */
header.top code {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  padding: 1px 6px;
}

nav.site {
  display: flex;
  gap: 4px;
  margin-top: 12px;
  flex-wrap: wrap;
}
nav.site a {
  padding: 5px 12px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  opacity: 0.85;
  border-bottom: 2px solid transparent;
}
nav.site a:hover { background: rgba(255, 255, 255, 0.12); text-decoration: none; opacity: 1; }
nav.site a[aria-current="page"] {
  opacity: 1;
  font-weight: 500;
  border-bottom-color: var(--brand-green);
}

.layout {
  display: flex;
  align-items: flex-start;
  max-width: 1400px;
  margin: 0 auto;
  background: var(--surface-card);
  min-height: 60vh;
}

nav.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  position: sticky;
  top: var(--header-h, 96px);
  max-height: calc(100vh - var(--header-h, 96px));
  overflow-y: auto;
  padding: 20px 14px 40px;
  border-right: 1px solid var(--border);
}
nav.sidebar h4 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 18px 0 6px 8px;
  font-weight: 600;
}
nav.sidebar h4:first-child { margin-top: 0; }
nav.sidebar a {
  display: block;
  padding: 5px 8px;
  border-radius: var(--radius);
  font-size: 0.86rem;
  color: var(--text);
  border-left: 2px solid transparent;
}
nav.sidebar a:hover {
  background: var(--surface-ground);
  border-left-color: var(--brand-green);
  text-decoration: none;
}
/* Links that leave the current page, so a reader can tell them apart from the anchors above -
   clicking one navigates rather than scrolling. */
nav.sidebar a.offsite {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
nav.sidebar a.offsite::after {
  content: "\2192";
  opacity: 0.45;
  font-size: 0.9em;
}
nav.sidebar a.offsite:hover { color: var(--brand-navy); }
nav.sidebar a.offsite:hover::after { opacity: 1; }

/* Sections of the page you are on, nested under it in the tree. */
nav.sidebar a.subsection {
  padding-left: 22px;
  font-size: 0.83rem;
  color: var(--text);
}
nav.sidebar h5.subgroup {
  margin: 10px 0 4px 22px;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
}
/* The page you are on. Styled as a label for the sections beneath it, deliberately without a
   highlight - only the section you are actually reading gets that, or the two compete. */
nav.sidebar a.here {
  color: var(--brand-navy);
  font-weight: 600;
  cursor: default;
}
nav.sidebar a.here:hover { background: none; border-left-color: transparent; text-decoration: none; }

/* The section currently in view. Set by the scrollspy in ketendo-docs.js. */
nav.sidebar a.active {
  background: var(--brand-navy-tint);
  border-left-color: var(--brand-green);
  color: var(--brand-navy);
  font-weight: 500;
}
/* The way back out of a sub-page. Sits above the filter, set apart from the section list. */
nav.sidebar .sidebar-back {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  margin-bottom: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
  border-left: 2px solid transparent;
  border-radius: var(--radius);
}
nav.sidebar .sidebar-back::before { content: "\2190"; font-size: 1em; }
nav.sidebar .sidebar-back:hover {
  color: var(--brand-navy);
  background: var(--surface-ground);
  border-left-color: var(--brand-green);
  text-decoration: none;
}

nav.sidebar input[type="search"] {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  margin-bottom: 4px;
  font-family: inherit;
}
nav.sidebar input[type="search"]:focus {
  outline: none;
  border-color: var(--brand-navy);
  box-shadow: 0 0 0 3px var(--brand-green-tint);
}

main {
  flex: 1;
  min-width: 0;
  padding: 28px 36px 80px;
  overflow-x: auto;
}

footer.page {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 30px 0 60px;
}

/* ---------- Content ---------- */

.toolbar { display: flex; gap: 10px; margin-bottom: 18px; }
.toolbar button {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 12px;
  font-size: 0.82rem;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
}
.toolbar button:hover { background: var(--surface-ground); }

section.group { margin-bottom: 34px; }
section.group > h2 {
  font-size: 1.15rem;
  border-bottom: 2px solid var(--border);
  padding-bottom: 8px;
  margin-bottom: 14px;
}

details.endpoint {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 10px;
  background: var(--surface-card);
  box-shadow: var(--shadow);
}
details.endpoint > summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
}
details.endpoint > summary::-webkit-details-marker { display: none; }
details.endpoint > summary::after {
  content: "\25B8";
  margin-left: auto;
  color: var(--text-muted);
  transition: transform 0.15s;
}
details.endpoint[open] > summary::after { transform: rotate(90deg); }
details.endpoint[open] > summary { border-left: 3px solid var(--brand-green); }
details.endpoint > summary .path { font-weight: 600; color: var(--brand-navy); }
details.endpoint > summary .purpose { color: var(--text-muted); font-weight: 400; font-size: 0.85rem; }
.endpoint-body { padding: 4px 16px 18px; border-top: 1px solid var(--border); }

/* A prose section, not a call. Same collapsible behaviour, deliberately different chrome, so a
   page is not read as a list of endpoints when half its rows are explanation. */
details.endpoint.section {
  border: none;
  border-left: 3px solid var(--brand-navy);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--surface-ground);
  box-shadow: none;
  margin-bottom: 18px;
}
details.endpoint.section[open] > summary { border-left: none; }
details.endpoint.section > summary { padding: 10px 16px; }
details.endpoint.section .section-title {
  font-size: 1rem;
  font-weight: 500;
  color: var(--brand-navy);
}
details.endpoint.section > summary .purpose { color: var(--text-muted); }
details.endpoint.section .endpoint-body {
  border-top: 1px solid var(--border);
  background: var(--surface-card);
}

.method {
  display: inline-block;
  background: var(--brand-navy);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius);
  letter-spacing: 0.03em;
}

.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge.req  { background: var(--req-bg);  color: var(--req-ink); }
.badge.opt  { background: var(--surface-hover); color: var(--text-muted); }
.badge.cond { background: var(--cond-bg); color: var(--cond-ink); }
.badge.auto { background: var(--info-bg); color: var(--info-ink); }
.badge.new  { background: var(--brand-green-tint); color: var(--brand-green-ink); }

table.fields { width: 100%; border-collapse: collapse; margin: 10px 0 16px; font-size: 0.86rem; }
table.fields th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding: 6px 8px;
}
table.fields td { padding: 7px 8px; border-bottom: 1px solid var(--border-subtle); vertical-align: top; overflow-wrap: anywhere; }
table.fields tr.nested  td:first-child { padding-left: 26px; }
table.fields tr.nested2 td:first-child { padding-left: 44px; }
table.fields tr.nested3 td:first-child { padding-left: 62px; }
table.fields tr.nested td:first-child,
table.fields tr.nested2 td:first-child,
table.fields tr.nested3 td:first-child { color: var(--text-muted); }
table.fields tr:last-child td { border-bottom: none; }

table.simple { border-collapse: collapse; width: 100%; margin: 10px 0 18px; font-size: 0.88rem; }
table.simple th, table.simple td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: top; }
table.simple th { background: var(--surface-ground); color: var(--brand-navy); font-weight: 600; }

.callout {
  border-left: 4px solid var(--brand-navy);
  background: var(--info-bg);
  padding: 10px 14px;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 14px 0;
  font-size: 0.9rem;
}
.callout.warn { border-left-color: #b96e00; background: var(--cond-bg); }
.callout.ok   { border-left-color: var(--brand-green); background: var(--brand-green-tint); }

h3.sub { font-size: 0.95rem; margin: 18px 0 4px; }
h3.sub:first-child { margin-top: 4px; }

ol.steps, ul.checklist { padding-left: 22px; }
ol.steps li, ul.checklist li { margin-bottom: 6px; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; margin: 10px 0 20px; font-size: 0.85rem; align-items: center; }
.legend span.badge { margin-right: 4px; }

/* Tabs */
.tabs { display: flex; gap: 18px; border-bottom: 1px solid var(--border); margin: 8px 0 14px; }
.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 2px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  margin-bottom: -1px;
  font-family: inherit;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--brand-navy); border-bottom-color: var(--brand-green); }
.tab-panel[hidden] { display: none; }

[id] { scroll-margin-top: calc(var(--header-h, 96px) + 14px); }

/* ---------- Landing page ---------- */

.guide-cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); margin: 18px 0 30px; }
.guide-card {
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  background: var(--surface-card);
  box-shadow: var(--shadow);
  border-top: 3px solid var(--brand-green);
}
.guide-card:hover { text-decoration: none; border-color: var(--brand-navy); }
.guide-card h3 { margin: 0 0 6px; font-size: 1rem; }
.guide-card p { margin: 0; color: var(--text); font-size: 0.88rem; }
.guide-card .meta { margin-top: 10px; font-size: 0.76rem; color: var(--text-muted); }

@media (max-width: 900px) {
  .layout { flex-direction: column; align-items: stretch; }
  nav.sidebar {
    position: static;
    width: 100%;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  main { padding: 22px 18px 60px; }
}
