/* MapWise API Reference — hand-rolled styling (PROTOTYPE).
   Full control: this is ordinary vanilla CSS over spec-generated HTML. */

:root {
  --mw-green: #0b6e4f;
  --mw-green-dark: #08543c;
  --mw-navy: #0b2340;
  --mw-ink: #1a1f24;
  --mw-muted: #5b6670;
  --mw-line: #e3e8ec;
  --mw-surface: #ffffff;
  --mw-bg-soft: #f6f8f9;
  --mw-code: #0f5132;
  --mw-code-bg: #eef2f4;
  --mw-http-get: #198754;   /* matches the header's Free Trial (.btn-success) green */
  /* Type color-coding (light) — extends the original scheme
     (string=green, number=orange, boolean=blue) with object/array. */
  --t-string: #0f9d58;
  --t-number: #d9820b;
  --t-boolean: #2f7fe0;
  --t-object: #8b5cf6;
  --t-array: #0d9488;
  --t-other: var(--mw-muted);
}

/* Dark theme — applied when the toggle sets data-theme="dark" on .ref-layout.
   Every color above is redefined here; nothing else in the file hardcodes a
   color outside these tokens. */
.ref-layout[data-theme="dark"] {
  --mw-green: #2dd4a7;
  --mw-green-dark: #25b892;
  --mw-navy: #0a1626;
  --mw-ink: #e6edf3;
  --mw-muted: #9aa7b2;
  --mw-line: #263341;
  --mw-surface: #0f1926;
  --mw-bg-soft: #16222f;
  --mw-code: #7ee7c4;
  --mw-code-bg: #16222f;
  /* Type color-coding (dark) — brightened for contrast on the dark surface. */
  --t-string: #4ade80;
  --t-number: #fb9d3e;
  --t-boolean: #60a5fa;
  --t-object: #c4b5fd;
  --t-array: #5eead4;
  --t-other: var(--mw-muted);
}

.ref-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 0;
  width: 100%;          /* fill the page width (was capped at 1180px, centered) */
  margin: 0;
  font-family: 'Helvetica Neue', Arial, sans-serif;
  color: var(--mw-ink);
  background: var(--mw-surface);   /* theme-aware docs surface over the site body */
  min-height: 70vh;
}
.ref-content h1, .ref-content h2, .ref-content h3, .ref-content h4 { color: var(--mw-ink); }

/* Code chips — override the site's dark global <code> style so text stays
   readable (dark-on-light) everywhere in the reference. */
.ref-layout code {
  background: var(--mw-code-bg);
  color: var(--mw-code);
  padding: 0.08rem 0.34rem;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}
.ref-op-route code { color: var(--mw-ink); font-weight: 600; padding: 0.18rem 0.5rem; }

/* Type color-coding (params + schema). Base type drives the color. */
.ref-type { font-size: 0.82rem; }
.ref-t-string  { color: var(--t-string); }
.ref-t-integer,
.ref-t-number  { color: var(--t-number); }
.ref-t-boolean { color: var(--t-boolean); }
.ref-t-object  { color: var(--t-object); }
.ref-t-array   { color: var(--t-array); }
.ref-t-other   { color: var(--t-other); }
.ref-ftype { margin-left: 0.15rem; }

/* Curl / spend-cap dark terminal block. */
.ref-curl {
  background: var(--mw-navy);
  color: #e8eef5;
  border-radius: 8px;
  padding: 0.85rem 1rem;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.5;
  margin: 0.4rem 0 0;
}
.ref-curl code {
  background: none;
  color: inherit;
  padding: 0;
  white-space: pre;
  font-size: inherit;
}

/* Multi-language code samples — tab row + dark code panes. */
.ref-samples { margin: 0.4rem 0 0; }
.ref-tabs {
  display: flex; gap: 0.15rem; flex-wrap: wrap;
  border-bottom: 1px solid var(--mw-line); margin-bottom: -1px;
}
.ref-tab {
  border: none; background: none; cursor: pointer;
  padding: 0.35rem 0.7rem; font-size: 0.82rem; font-weight: 600;
  color: var(--mw-muted); border-bottom: 2px solid transparent;
}
.ref-tab:hover { color: var(--mw-ink); }
.ref-tab.active { color: var(--mw-green); border-bottom-color: var(--mw-green); }
.ref-code {
  background: var(--mw-navy);
  color: #e8eef5;
  border-radius: 0 8px 8px 8px;
  padding: 0.85rem 1rem;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.5;
  margin: 0;
}
.ref-code code {
  background: none; color: inherit; padding: 0;
  white-space: pre; font-size: inherit;
}
.ref-code[hidden] { display: none; }

/* JSON syntax highlighting in the example response — typed by value, matching
   the schema type palette. Fixed bright colors: the code block is always dark. */
.ref-json-key     { color: #cbd5e1; }
.ref-json-string  { color: #4ade80; }   /* green  — matches string */
.ref-json-number  { color: #fb9d3e; }   /* orange — matches integer/number */
.ref-json-boolean { color: #60a5fa; }   /* blue   — matches boolean */
.ref-json-null    { color: #9aa7b2; }   /* gray */

/* Light scrollbars on the dark code blocks (default black-on-dark is invisible).
   Applies to horizontal (code samples) and vertical (example response) scroll. */
.ref-code, .ref-curl {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.35) transparent;
}
.ref-code::-webkit-scrollbar,
.ref-curl::-webkit-scrollbar { width: 9px; height: 9px; }
.ref-code::-webkit-scrollbar-track,
.ref-curl::-webkit-scrollbar-track { background: transparent; }
.ref-code::-webkit-scrollbar-thumb,
.ref-curl::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3); border-radius: 5px;
  border: 2px solid transparent; background-clip: content-box;
}
.ref-code::-webkit-scrollbar-thumb:hover,
.ref-curl::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.5); background-clip: content-box; }

/* Collapsible example response */
.ref-example { margin: 0.6rem 0 0; }
.ref-example > summary {
  cursor: pointer; font-size: 0.82rem; font-weight: 600;
  color: var(--mw-green); padding: 0.3rem 0; list-style-position: inside;
}
.ref-example > summary:hover { color: var(--mw-green-dark); }
.ref-example .ref-code { border-radius: 8px; margin-top: 0.35rem; max-height: 420px; overflow: auto; }

/* Sidebar */
.ref-sidebar {
  border-right: 1px solid var(--mw-line);
  padding: 1.5rem 1rem;
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
}
.ref-sidebar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.85rem; }
.ref-brand { font-weight: 700; font-size: 1.05rem; }
.ref-brand .ref-ver { color: var(--mw-muted); font-weight: 400; font-size: 0.8rem; }

/* Nav search filter — matches the help-section search input (bi-search icon,
   left padding, >=16px font to stop iOS focus-zoom). */
.ref-search { position: relative; margin-bottom: 0.9rem; }
.ref-search-icon {
  position: absolute; left: 0.7rem; top: 50%; transform: translateY(-50%);
  color: var(--mw-muted); pointer-events: none;
}
.ref-search-input {
  width: 100%; box-sizing: border-box;
  padding: 0.45rem 0.6rem 0.45rem 2.1rem; font-size: 1rem;
  border: 1px solid var(--mw-line); border-radius: 6px;
  background: var(--mw-surface); color: var(--mw-ink);
}
.ref-search-input:focus { outline: none; border-color: var(--mw-green); }

/* Dark-mode toggle button */
.ref-theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0;
  border: 1px solid var(--mw-line); border-radius: 6px;
  background: var(--mw-surface); color: var(--mw-ink); cursor: pointer;
  font-size: 1rem; line-height: 1;
}
.ref-theme-toggle:hover { border-color: var(--mw-green); color: var(--mw-green); }
.ref-theme-icon-dark { display: none; }
.ref-layout[data-theme="dark"] .ref-theme-icon-light { display: none; }
.ref-layout[data-theme="dark"] .ref-theme-icon-dark { display: inline; }

/* Mobile top bar (hidden on desktop via .d-lg-none from the site's Bootstrap):
   title left, actions (theme + menu) right — matching help + the site header. */
.ref-mobilebar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.5rem; padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--mw-line);
  background: var(--mw-surface); position: sticky; top: 0; z-index: 20;
}
.ref-mobilebar-title { font-weight: 600; font-size: 0.95rem; color: var(--mw-ink); }
.ref-mobilebar-actions { display: inline-flex; align-items: center; gap: 0.4rem; }
.ref-nav-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0;
  border: none; background: none; cursor: pointer; color: var(--mw-ink);
}
/* Hamburger / X glyphs — same 30x30 stroke geometry as the site header +
   help toggle; the close (X) shows when the panel is open. currentColor via
   mask so it inherits ink and flips correctly in dark mode. */
.ref-nav-toggle-icon {
  width: 24px; height: 24px; display: inline-block; background: currentColor;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: center; mask-position: center;
  -webkit-mask-size: 100%; mask-size: 100%;
}
.ref-nav-icon-open {
  -webkit-mask-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='black' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
  mask-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='black' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}
.ref-nav-icon-close {
  display: none;
  -webkit-mask-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='black' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M8 8l14 14M22 8L8 22'/%3e%3c/svg%3e");
  mask-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='black' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M8 8l14 14M22 8L8 22'/%3e%3c/svg%3e");
}
/* Glyph swap driven by the button's aria-expanded state (help pattern). */
.ref-nav-toggle[aria-expanded="true"] .ref-nav-icon-open { display: none; }
.ref-nav-toggle[aria-expanded="true"] .ref-nav-icon-close { display: inline-block; }
.ref-nav { display: flex; flex-direction: column; gap: 0.15rem; }
.ref-nav a {
  color: var(--mw-ink); text-decoration: none; font-size: 0.9rem;
  padding: 0.3rem 0.5rem; border-radius: 5px;
}
.ref-nav a:hover { background: var(--mw-bg-soft); color: var(--mw-green); }
.ref-nav a.active {
  color: var(--mw-green); font-weight: 600;
  background: var(--mw-bg-soft);
  box-shadow: inset 2px 0 0 var(--mw-green);
}
.ref-navgroup {
  margin: 0.9rem 0 0.25rem; font-size: 0.72rem; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--mw-muted);
}
/* HTTP-method badge in the nav (Swagger-UI style: solid pill, white text). */
.ref-nav-method {
  display: inline-block; min-width: 34px; text-align: center;
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.03em;
  color: #fff; padding: 0.12rem 0.32rem; border-radius: 4px;
  margin-right: 0.35rem; vertical-align: middle;
}
.ref-nav-method-get { background: var(--mw-http-get); }
.ref-nav-method-post { background: #2563eb; }
.ref-nav a { display: flex; align-items: center; }

/* Content */
.ref-content { padding: 1.75rem 2rem 4rem; min-width: 0; }
/* Any fragment jump (click or refresh) lands the heading below the sticky bar,
   not flush at y=0 hidden under it. */
.ref-content [id] { scroll-margin-top: 5rem; }
/* Explicit text colors so the site's global p/li/strong colors don't win over
   inheritance — critical for legibility in dark mode. */
.ref-content p,
.ref-content li,
.ref-content td,
.ref-content ol,
.ref-content ul { color: var(--mw-ink); }
.ref-content strong { color: var(--mw-ink); }
.ref-content a:not(.ref-btn) { color: var(--mw-green); }
.ref-content h1 { font-size: 1.9rem; margin: 0 0 0.5rem; }
.ref-lead { color: var(--mw-muted); line-height: 1.55; }
.ref-links { margin: 1rem 0 0; }
.ref-btn {
  display: inline-block; background: var(--mw-green); color: #fff;
  text-decoration: none; padding: 0.45rem 0.85rem; border-radius: 6px;
  font-size: 0.85rem; font-weight: 600;
}
.ref-btn:hover { background: var(--mw-green-dark); }
.ref-btn-ghost { background: transparent; color: var(--mw-green); border: 1px solid var(--mw-green); }

.ref-block { margin: 2.25rem 0; }
.ref-block h2 { font-size: 1.35rem; margin-bottom: 0.5rem; }
.ref-block h3 { font-size: 1.02rem; margin: 1rem 0 0.4rem; }
.ref-block ul, .ref-block ol { line-height: 1.75; }
.ref-block p { line-height: 1.6; }   /* fill width — no code column beside these */

.ref-infobox {
  background: var(--mw-bg-soft); border: 1px solid var(--mw-line);
  border-radius: 8px; padding: 0.75rem 1rem; margin: 0.75rem 0;
}
.ref-infobox strong { display: block; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--mw-muted); }
.ref-infobox p { margin: 0.35rem 0 0; }
.ref-steps li { margin-bottom: 0.4rem; }
.ref-scope { border-left: 3px solid var(--mw-green); }

/* Errors table (global + per-endpoint) */
.ref-errors { width: 100%; border-collapse: collapse; font-size: 0.88rem; margin-top: 0.4rem; }
.ref-errors th {
  text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--mw-muted); border-bottom: 1px solid var(--mw-line); padding: 0.4rem 0.6rem;
}
.ref-errors td { padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--mw-line); vertical-align: top; }
.ref-errcode code, .ref-errors td:first-child code { font-weight: 700; }

.ref-tag {
  font-size: 1.5rem; margin: 2.5rem 0 0.5rem;
  padding-bottom: 0.4rem; border-bottom: 2px solid var(--mw-green);
}

/* Endpoint block — two columns: prose left, sticky code panel right (Stripe
   pattern). Stacks to one column on mobile (see the mobile media query). */
.ref-endpoint {
  display: grid;
  /* Prose flexes; the code rail takes ~45% (Stripe-like), scaling with the
     full page width, clamped so it's never cramped nor absurdly wide. */
  grid-template-columns: minmax(0, 1fr) clamp(380px, 45%, 680px);
  gap: 2rem;
  padding: 1.75rem 0; border-bottom: 1px solid var(--mw-line);
}
.ref-endpoint-main { min-width: 0; }
.ref-endpoint-aside {
  min-width: 0;
  position: sticky;
  top: 1.5rem;
  align-self: start;
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
}
.ref-op-title { font-size: 1.25rem; margin: 0 0 0.4rem; }
.ref-op-route { margin-bottom: 0.75rem; }
.ref-method {
  display: inline-block; font-weight: 700; font-size: 0.72rem;
  padding: 0.15rem 0.5rem; border-radius: 4px; color: #fff; letter-spacing: 0.04em;
}
.ref-method-get { background: var(--mw-http-get); }
.ref-method-post { background: #2563eb; }
.ref-op-route code { font-size: 0.95rem; color: var(--mw-ink); }
.ref-op-desc { color: var(--mw-muted); line-height: 1.55; max-width: 70ch; }
.ref-subhead {
  font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--mw-muted); margin: 1.4rem 0 0.5rem;
}
.ref-status { color: var(--mw-green); font-weight: 700; }

/* Params table */
.ref-params { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.ref-params th {
  text-align: left; font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--mw-muted);
  border-bottom: 1px solid var(--mw-line); padding: 0.4rem 0.6rem;
}
.ref-params td { padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--mw-line); vertical-align: top; }
.ref-pname code { color: var(--mw-code); font-weight: 600; }
.ref-ptype { color: var(--mw-muted); white-space: nowrap; }
.ref-pdesc { color: var(--mw-ink); }
.ref-req { color: #b42318; font-size: 0.68rem; font-weight: 700; text-transform: uppercase; }
.ref-enum { color: var(--mw-muted); font-size: 0.8rem; margin-top: 0.15rem; }
.ref-ex { color: var(--mw-muted); font-size: 0.8rem; }

/* Response schema tree */
.ref-schema {
  background: var(--mw-bg-soft); border: 1px solid var(--mw-line);
  border-radius: 8px; padding: 0.5rem 0.75rem; font-size: 0.88rem;
}
.ref-field {
  padding: 0.28rem 0; border-bottom: 1px dashed var(--mw-line);
  line-height: 1.4;
}
.ref-field:last-child { border-bottom: none; }
.ref-fname { color: var(--mw-code); font-weight: 600; margin-right: 0.5rem; }
.ref-ftype { font-size: 0.82rem; }   /* color comes from .ref-t-* */
.ref-nullable { color: #9aa4ad; font-size: 0.72rem; font-style: italic; }
.ref-fdesc { display: block; color: var(--mw-muted); font-size: 0.82rem; margin-top: 0.1rem; }

/* Nesting depth — indentation + a left rule for hierarchy */
.ref-depth-1 { margin-left: 1rem; border-left: 2px solid var(--mw-line); padding-left: 0.75rem; }
.ref-depth-2 { margin-left: 2rem; border-left: 2px solid var(--mw-line); padding-left: 0.75rem; }
.ref-depth-3 { margin-left: 3rem; border-left: 2px solid var(--mw-line); padding-left: 0.75rem; }
.ref-depth-4 { margin-left: 4rem; border-left: 2px solid var(--mw-line); padding-left: 0.75rem; }
.ref-depth-5 { margin-left: 5rem; border-left: 2px solid var(--mw-line); padding-left: 0.75rem; }
.ref-depth-6 { margin-left: 6rem; border-left: 2px solid var(--mw-line); padding-left: 0.75rem; }

/* Desktop: the mobile bar is hidden (belt-and-suspenders with .d-lg-none). */
@media (min-width: 992px) {
  .ref-mobilebar { display: none; }
}

/* Mobile: single column; the sidebar collapses into a toggled panel. */
@media (max-width: 991.98px) {
  .ref-layout { grid-template-columns: 1fr; }
  /* Nav panel: hidden until opened, then a fixed dropdown flush under the
     sticky mobile bar (drops down at the current scroll position — not page
     top). --ref-panel-top is the bar's live bottom edge, set in JS. */
  /* Full-height opaque overlay from the bar's bottom to the viewport bottom —
     fully covers (and so hides) the page content behind it. No overflow:hidden
     scroll-lock: on iOS that causes a scroll-jump that desyncs the panel from
     the sticky bar (and hid the bar). The opaque full cover makes any
     background scroll invisible instead. */
  .ref-sidebar {
    display: none; border-right: none;
    position: fixed; left: 0; right: 0;
    top: var(--ref-panel-top, 3rem);
    /* Explicit full-remaining-height (overrides the desktop height:100vh):
       fills bar-bottom → viewport-bottom so it fully, opaquely covers the
       content behind it. Using height (not top+bottom+height) avoids the
       over-constraint that mispositioned the fixed panel. */
    height: calc(100dvh - var(--ref-panel-top, 3rem));
    overflow-y: auto; overscroll-behavior: contain; z-index: 19;
    background: var(--mw-surface);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    padding: 1rem 1.25rem 1.5rem;
  }
  .ref-sidebar.ref-sidebar-open { display: block; }
  .ref-sidebar-head { display: none; }   /* brand/theme live in the mobile bar */

  /* Comfortable edge padding; fit content to the page (no h-overflow). */
  .ref-content { padding: 1.25rem 1.25rem 3rem; }
  /* Right padding matches the site header so the menu toggle lines up on the
     x-axis with the header's hamburger above it; left stays comfortable. */
  .ref-mobilebar { padding: 0.65rem 0.75rem 0.65rem 1.25rem; }
  .ref-sidebar { padding: 1rem 1.25rem; }
  .ref-content p, .ref-block li, .ref-field { overflow-wrap: anywhere; }

  /* Params table → compact, fixed-layout so columns wrap and fit the width
     (same look as the errors table, which already fits). */
  .ref-params { table-layout: fixed; }
  .ref-params th, .ref-params td { padding: 0.5rem 0.5rem 0.5rem 0; }
  .ref-params th:nth-child(1), .ref-params td:nth-child(1) { width: 38%; }
  .ref-params th:nth-child(2), .ref-params td:nth-child(2) { width: 20%; }
  .ref-params th:nth-child(3), .ref-params td:nth-child(3) { width: 42%; }
  .ref-ptype { white-space: normal; }        /* allow the type column to wrap */
  .ref-pname code, .ref-fname { overflow-wrap: anywhere; }

  /* Errors table: also fixed-layout so long causes wrap in-cell. */
  .ref-errors { table-layout: fixed; }
  .ref-errors th, .ref-errors td { padding: 0.5rem 0.5rem 0.5rem 0; }
  .ref-errors th:nth-child(1), .ref-errors td:nth-child(1) { width: 18%; }
  .ref-errors th:nth-child(2), .ref-errors td:nth-child(2) { width: 32%; }
  .ref-errors th:nth-child(3), .ref-errors td:nth-child(3) { width: 50%; }

  /* Schema tree: shrink the deep indents so nested fields still fit. */
  .ref-depth-1 { margin-left: 0.6rem; padding-left: 0.5rem; }
  .ref-depth-2 { margin-left: 1.2rem; padding-left: 0.5rem; }
  .ref-depth-3 { margin-left: 1.8rem; padding-left: 0.5rem; }
  .ref-depth-4 { margin-left: 2.4rem; padding-left: 0.5rem; }
  .ref-depth-5 { margin-left: 3.0rem; padding-left: 0.5rem; }
  .ref-depth-6 { margin-left: 3.6rem; padding-left: 0.5rem; }

  /* Curl block scrolls within its own box rather than widening the page. */
  .ref-curl { max-width: 100%; }

  /* Endpoint: stack to one column; the code panel flows below the prose and
     is no longer sticky. */
  .ref-endpoint { grid-template-columns: 1fr; gap: 1rem; }
  .ref-endpoint-aside { position: static; max-height: none; overflow: visible; }
}
