/* ============================================================
   RedBook Direct — docs theme (overrides `modern` template)
   The `modern` template is built on Bootstrap 5 and is driven by
   CSS custom properties, so most theming is overriding vars.
   Brand values taken from https://api.redbookdirect.com
   ============================================================ */

:root {
  /* --- RedBook brand color ---------------------------------- */
  --brand:      #E9161D;
  --brand-rgb:  233, 22, 29;

  /* Bootstrap-level overrides driven by the brand color */
  --bs-primary:          #E9161D;
  --bs-primary-rgb:      233, 22, 29;
  --bs-link-color:       var(--brand);
  --bs-link-color-rgb:   var(--brand-rgb);
  --bs-link-hover-color: #b8121a;   /* slightly darkened brand */
}

/* Buttons / active states that use the primary color */
.btn-primary {
  --bs-btn-bg: var(--brand);
  --bs-btn-border-color: var(--brand);
  --bs-btn-hover-bg: #b8121a;
  --bs-btn-hover-border-color: #b8121a;
  --bs-btn-active-bg: #b8121a;
  --bs-btn-active-border-color: #b8121a;
}

.btn-outline-primary {
  --bs-btn-color: var(--brand);
  --bs-btn-border-color: var(--brand);
  --bs-btn-hover-bg: var(--brand);
  --bs-btn-hover-border-color: var(--brand);
  --bs-btn-active-bg: var(--brand);
  --bs-btn-active-border-color: var(--brand);
}
/* Dark mode: the light-red link color reads better than brand red on a dark
   bg, but its hover fill is then too light for white button text to pass
   AA contrast — swap to a dark hover-text color instead of the default white. */
[data-bs-theme="dark"] .btn-outline-primary {
  --bs-btn-color: #ff5a5f;
  --bs-btn-border-color: #ff5a5f;
  --bs-btn-hover-bg: #ff5a5f;
  --bs-btn-hover-border-color: #ff5a5f;
  --bs-btn-hover-color: #1a1a1a;
  --bs-btn-active-bg: #ff5a5f;
  --bs-btn-active-border-color: #ff5a5f;
  --bs-btn-active-color: #1a1a1a;
}

/* --- Inline code --------------------------------------------- */
/* Bootstrap's default `code` color is `--bs-code-color` (its brand pink), with no
   background — reads poorly and clashes with our red brand links. Give it the same
   grey-chip treatment GitHub-style docs use, on tokens that already flip for dark mode.
   `pre code` (fenced blocks) is excluded: those are already styled via highlight.js's
   `.hljs` class and get their own background. */
code:not(pre code) {
  background: var(--bs-tertiary-bg);
  color: var(--bs-body-color);
  padding: .15em .4em;
  border-radius: .3rem;
}

/* Bootstrap normally makes code inside a link inherit the link color (`a>code{color:
   inherit}`) so it still reads as clickable; our rule above is more specific and would
   otherwise override that back to body text color. Restore it explicitly. */
a > code:not(pre code) {
  color: inherit;
}

/* --- Light mode ------------------------------------------- */
[data-bs-theme="light"] {
  --bs-link-color:     var(--brand);
  --bs-link-color-rgb: var(--brand-rgb);
}

/* --- Dark mode -------------------------------------------- */
/* Brand red is quite dark on a dark bg; lighten links a touch */
[data-bs-theme="dark"] {
  --bs-link-color:       #ff5a5f;
  --bs-link-color-rgb:   255, 90, 95;
  --bs-link-hover-color: #ff8085;
}

/* --- Navbar brand (logo) ---------------------------------- */
/* The brand logo is the full "RedBook — Driving Confidence" wordmark lockup
   (a wide SVG, ~5.7:1). Two things need handling:

   1. Size it from a definite height. The SVG ships with only a viewBox (no
      intrinsic width/height), so `width:auto` alone leaves it unsized; pin
      the height and let width follow the aspect ratio. We match both `img`
      and `svg` because the `modern` template inlines any <img class="svg">,
      swapping the <img> for a raw <svg> that a rule targeting only `img`
      would miss.
   2. Hide the redundant app-name text. docfx renders `_appName` as text
      beside the logo, but the logo already spells out the RedBook wordmark —
      the duplicate text overflowed the (flex-shrunk) brand box and collided
      with the nav links. `font-size:0` collapses that text to zero width
      while leaving the logo untouched; `_appName` is kept so the logo's
      alt="RedBook Direct API" still gives the home link an accessible name. */
.navbar-brand {
  font-size: 0;
}
.navbar-brand img,
.navbar-brand svg {
  height: 32px;
  width: auto;
}

/* ============================================================
   Landing-page components — shared by the site root (index.md)
   and the docs hub (docs/index.md) so both read as one system.
   ============================================================ */

/* `main.container-xxl` caps out at 1768px (a modern-template override), which
   reads as uncontained on large monitors. Constrain the landing page itself
   to a normal reading width instead of touching the shared container rule. */
.rbd-landing-container {
  max-width: 1200px;
  margin-inline: auto;
  /* Inset the hero/cards from the container edge, scaling from ~1rem on
     mobile up to 4rem (Tailwind's p-16) once there's room for it. */
  padding-inline: clamp(1rem, 4vw, 4rem);
}

.rbd-hero {
  padding: 2.5rem 0 3rem;
  text-align: center;
}
.rbd-hero .rbd-eyebrow {
  display: inline-block;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--brand);
  margin-bottom: .75rem;
}
[data-bs-theme="dark"] .rbd-hero .rbd-eyebrow {
  color: #ff5a5f;
}
.rbd-hero h1 {
  font-weight: 700;
}
.rbd-hero .lead {
  max-width: 42rem;
  margin: 0 auto;
}

/* Card grid used for feature/section callouts. Each card's action is a
   Bootstrap `stretched-link`, so the whole card is clickable while still
   exposing exactly one accessible link per card. */
.rbd-card {
  height: 100%;
  transition: transform .15s ease, box-shadow .15s ease;
}
.rbd-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 .5rem 1.25rem rgba(0, 0, 0, .08);
}
.rbd-card-icon {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: .75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(var(--brand-rgb), .12);
  color: var(--brand);
  font-size: 1.25rem;
  margin-bottom: .75rem;
}
[data-bs-theme="dark"] .rbd-card-icon {
  color: #ff5a5f;
}

.rbd-cta-band {
  border-radius: 1rem;
  padding: 2.5rem 2rem;
  background: linear-gradient(135deg, rgba(var(--brand-rgb), .08), rgba(var(--brand-rgb), .02));
  border: 1px solid rgba(var(--brand-rgb), .15);
}

/* ============================================================
   Scalar endpoint embed — the per-endpoint API reference iframe
   on each page under docs/endpoints/. Wired up (src + height) by
   the shared wireEndpointEmbeds() in main.js.
   ============================================================ */

/* Lets the embed use the full content width without disturbing the rest of the
   page, which keeps DocFX's normal TOC/affix (unlike the full api-reference
   page). min-height is only a placeholder while the embed loads: it reports its
   content height and main.js then sets an explicit height and clears this
   floor, so the iframe fits its content instead of scrolling internally. */
.endpoint-embed {
  width: 100%;
  min-height: 480px;
  border: 1px solid var(--bs-border-color, #d0d7de);
  border-radius: 6px;
  display: block;
  overflow: hidden;
}

/* ============================================================
   Segment × endpoint availability matrix — docs/endpoints/availability.md
   Wide tables of endpoint groups against segments. They fit on a
   desktop but cannot reflow onto a phone, so they scroll
   horizontally inside their own region rather than forcing the
   whole page to scroll sideways.
   ============================================================ */

/* The scroll container is focusable (tabindex="0" in the markup) so keyboard-only
   users can reach and scroll it — a scrollable region that only responds to a
   mouse fails WCAG 2.1 SC 2.1.1. Being focusable, it must also show a focus ring;
   `:focus-visible` keeps it off for pointer users. */
.rbd-matrix-scroll {
  overflow-x: auto;
  /* The table inside sets `margin-bottom: 0` so Bootstrap's table margin cannot
     open a gap above the horizontal scrollbar. Carry that separation on the
     wrapper instead: headings get no top margin, so without it each matrix runs
     straight into the heading that follows it. */
  margin-bottom: 1.5rem;
}

/* The modern template's JS wraps every article table in its own
   `div.table-responsive` at runtime. That injected div would otherwise become
   the scroll container — and it carries no tabindex, role or accessible name,
   so the table would only scroll with a mouse. Neutralise its overflow so the
   scrolling happens on our labelled, focusable wrapper instead. */
.rbd-matrix-scroll > .table-responsive {
  overflow: visible;
}

.rbd-matrix-scroll:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
[data-bs-theme="dark"] .rbd-matrix-scroll:focus-visible {
  outline-color: #ff5a5f;
}

.rbd-matrix {
  /* Segment codes (`campertrailer`, `marineengine`) set the column width, so let
     the table run past the container and scroll rather than crushing the cells. */
  min-width: max-content;
  margin-bottom: 0;
}

/* Bootstrap puts captions below the table; read as a table title above it
   instead. The caption is each table's accessible name, so it stays visible
   rather than being hidden from sighted readers. */
.rbd-matrix caption {
  caption-side: top;
  padding-top: 0;
  font-size: .875rem;
}

.rbd-matrix td {
  /* 12 data columns: trim the horizontal padding, and centre the marks under
     their headers (`text-center` in the markup handles alignment). */
  padding-inline: .5rem;
  white-space: nowrap;
  font-size: 1.05rem;      /* emoji render small at body size */
  line-height: 1.4;
}

.rbd-matrix th[scope="col"] {
  white-space: nowrap;
  vertical-align: bottom;
}

/* Each availability mark links to its endpoint page, but the link's only
   content is an emoji — an underline under it reads as a stray line rather than
   as a link affordance. Row-header links keep theirs; only the marks lose it.
   The marks aren't distinguished by colour either, so no contrast cue is lost.
   Keyboard focus stays visible via an explicit ring. */
.rbd-matrix td a {
  text-decoration: none;
}
.rbd-matrix td a:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 2px;
}
[data-bs-theme="dark"] .rbd-matrix td a:focus-visible {
  outline-color: #ff5a5f;
}

/* Pin the endpoint-group column while the segment columns scroll under it —
   without it you lose track of which row you're reading by column four.
   The background must be opaque, otherwise scrolled cells show through. */
.rbd-matrix th[scope="row"],
.rbd-matrix thead th:first-child {
  position: sticky;
  left: 0;
  background: var(--bs-body-bg);
  white-space: nowrap;
}
.rbd-matrix th[scope="row"] {
  z-index: 2;
  font-weight: 400;
}
/* The column header outranks the body cells so it stays clear of them. */
.rbd-matrix thead th:first-child {
  z-index: 3;
}

/* Group banners (RedBook Data / Pricing / …) span the full width. The cell
   itself can't be sticky — a colspan cell that wide keeps its background on
   screen but scrolls its text off — so the label is pinned instead. */
.rbd-matrix .rbd-matrix-group th {
  background: var(--bs-tertiary-bg, rgba(var(--brand-rgb), .06));
  font-weight: 600;
  text-align: left;
}
.rbd-matrix-group-label {
  position: sticky;
  left: 0;
  display: inline-block;
}

/* Footnote references and their return arrows. Kept as real links (not
   `title` attributes) so they work with a keyboard and a screen reader. */
.rbd-fn-ref {
  text-decoration: none;
  padding-inline: .15rem;
}
.rbd-fn-back {
  margin-left: .35rem;
  text-decoration: none;
}
.rbd-footnotes li {
  margin-bottom: .5rem;
}
