/* Roundabout brand styling for the MUTCD docs site.
   Palette (from the Brand & Marketing index):
     navy/purple #1B1B33 · red #BF252F · green #35954D · yellow #E8AB2E · brown #E2B088 */

:root {
  --ra-navy: #1b1b33;
  --ra-navy-light: #2a2a4d;
  --ra-red: #bf252f;
  --ra-green: #35954d;
  --ra-yellow: #e8ab2e;
  --ra-brown: #e2b088;
}

[data-md-color-scheme="default"] {
  --md-primary-fg-color: var(--ra-navy);
  --md-primary-fg-color--light: var(--ra-navy-light);
  --md-primary-fg-color--dark: #141426;
  --md-accent-fg-color: var(--ra-red);
  --md-typeset-a-color: var(--ra-red);
}

/* Thin traffic-light accent bar under the top header. */
.md-header {
  border-bottom: 3px solid var(--ra-green);
}

/* Section headings in brand navy (LIGHT mode only — navy on the dark scheme is invisible,
   so dark mode keeps Material's light heading color). */
[data-md-color-scheme="default"] .md-typeset h2,
[data-md-color-scheme="default"] .md-typeset h3 {
  color: var(--ra-navy);
}
.md-typeset h3[id] {
  border-left: 3px solid var(--ra-yellow);
  padding-left: 0.6rem;
}

/* Quoted MUTCD text (Standard/Guidance/etc.) stands out. */
.md-typeset blockquote {
  border-left: 4px solid var(--ra-green);
}

/* Search + nav active state pick up the brand. */
.md-nav__link--active,
.md-nav__item .md-nav__link--active {
  color: var(--ra-green);
}
/* Selected text highlight in the brand green too. */
::selection { background: var(--ra-green); color: #fff; }

/* Normative category labels (Standard / Guidance / Option / Support / Legend). */
/* Hover/tap tooltips: a styled bubble driven by data-tip, working on desktop hover AND
   touch (the elements are focusable). Used for the normative-heading badges (MUTCD §1C.01
   definition) and table footnote markers (the footnote text). */
.md-typeset .mutcd-tip {
  position: relative;
  cursor: help;
}
.md-typeset .mutcd-tip::after {
  content: attr(data-tip);
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  z-index: 30;
  width: max-content;
  max-width: min(340px, 80vw);
  padding: 0.5em 0.7em;
  border-radius: 0.2rem;
  background: var(--md-default-fg-color);
  color: var(--md-default-bg-color);
  font-size: 0.7rem;
  font-weight: 400;
  line-height: 1.45;
  white-space: normal;
  text-align: left;
  text-transform: none;          /* badges are ALL-CAPS; the tooltip text must not inherit it */
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease;
  pointer-events: none;
}
/* Hover only (desktop). On touch there's no hover, so nothing sticks — the footnote text
   is also listed below each table and the badge meaning is in §1C.01. */
.md-typeset .mutcd-tip:hover::after {
  opacity: 1;
  visibility: visible;
}
/* Dark mode: Material's --md-default-fg-color is translucent (~0.82 alpha) in the slate
   scheme, so the tooltip bubble showed the text behind it. Force an opaque on-brand bubble. */
[data-md-color-scheme="slate"] .md-typeset .mutcd-tip::after {
  background: var(--ra-navy-light);
  color: #f5f5fa;
  border: 1px solid rgba(255, 255, 255, 0.14);
}
/* table footnote marker (e.g. the * in "W*") */
.md-typeset sup.mutcd-fn {
  font-weight: 700;
  color: var(--ra-brown);
  cursor: help;
}
.md-typeset .mutcd-label {
  display: inline-block;
  margin: 1.2em 0 0.2em;
  padding: 0.12rem 0.6rem;
  border-radius: 0.25rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
}
.md-typeset .mutcd-standard { background: var(--ra-red); }      /* shall — mandatory */
.md-typeset .mutcd-guidance { background: var(--ra-yellow); color: #1b1b33; } /* should */
.md-typeset .mutcd-option   { background: var(--ra-green); }    /* may */
.md-typeset .mutcd-support  { background: #6b7280; }            /* informational */
.md-typeset .mutcd-legend   { background: var(--ra-navy); }

/* Link-only fallback caption (a figure we couldn't embed) — a small cited box. */
.md-typeset p.mutcd-figure {
  margin: 1em 0;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-left: 3px solid var(--ra-brown);
  border-radius: 0.25rem;
  background: var(--md-default-fg-color--lightest);
  font-size: 0.78rem;
  font-style: italic;
}

/* Embedded figure / diagram (rasterized from the source PDF). */
.md-typeset figure.mutcd-figure {
  margin: 1.5em auto;
  text-align: center;
}
.md-typeset figure.mutcd-figure img {
  max-width: 100%;
  height: auto;
  padding: 0.5rem;
  background: #fff;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 0.25rem;
}
.md-typeset figure.mutcd-figure figcaption {
  margin-top: 0.5rem;
  font-size: 0.78rem;
  font-style: italic;
  color: var(--md-default-fg-color--light);
}

/* Caption sitting above a reconstructed Markdown table. */
.md-typeset .mutcd-caption {
  margin: 1.5em 0 0.4em;
  padding-left: 0.6rem;
  border-left: 3px solid var(--ra-brown);
  font-size: 0.8rem;
  font-weight: 600;
}

/* MUTCD tables are dense and wide — shrink the type a touch. */
.md-typeset table:not([class]) {
  font-size: 0.72rem;
}

/* Reconstructed MUTCD tables: the source tables are fully ruled, so show the whole cell
   grid; real rowspan/colspan reproduce merged header/category cells. Raw HTML tables don't
   get Material's scroll wrapper, so we wrap them ourselves to keep wide tables from
   overflowing into the right-hand table-of-contents. */
.md-typeset .mutcd-table-wrap {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  margin: 0.4em 0 1.2em;
  -webkit-overflow-scrolling: touch;
}
.md-typeset table.mutcd-table {
  border-collapse: collapse;
  display: table;
  /* Fill the wrapper and wrap cells to fit, instead of growing to max-content and forcing a
     horizontal scrollbar. The wrapper keeps overflow-x:auto only as a safety net on tiny screens. */
  width: 100%;
  margin: 0;
  font-size: 0.72rem;
}
/* Dense tables (5+ columns, e.g. Table 2H-1's sign-size matrix) get a smaller font + fixed
   layout so the columns wrap to fit the page width instead of spilling into a horizontal scroll.
   Narrow tables (2-4 cols, e.g. Table 2D-5) keep the larger content-sized layout. */
.md-typeset table.mutcd-table:has(tr > :nth-child(5)) {
  table-layout: fixed;
  font-size: 0.62rem;
}
.md-typeset table.mutcd-table th,
.md-typeset table.mutcd-table td {
  border: 1px solid #9aa0a6;            /* clearly visible ruled grid, like the source */
  padding: 0.3em 0.5em;
  text-align: left;
  vertical-align: top;
  overflow-wrap: break-word;            /* break long tokens so dense cells wrap to fit, not scroll */
}
[data-md-color-scheme="slate"] .md-typeset table.mutcd-table th,
[data-md-color-scheme="slate"] .md-typeset table.mutcd-table td {
  border-color: var(--md-default-fg-color--light);
}
.md-typeset table.mutcd-table th {
  background-color: var(--md-default-fg-color--lighter);
  font-weight: 600;
  text-align: center;
}
/* Single-value / numeric tables (dimensions, metric conversions, warrant counts, arrow heights)
   read better centered; text-heavy tables (e.g. Table 2A-1's sign-name lists) keep left align. */
.md-typeset table.mutcd-table.mutcd-table--center td {
  text-align: center;
}
/* Zebra striping: alternate row shading so the eye tracks across these wide, dense tables
   (works in light and dark via the theme variable). Adapts automatically to the scheme. */
.md-typeset table.mutcd-table tr:nth-child(even) td {
  background-color: var(--md-default-fg-color--lightest);
}

/* A table's footnotes, rendered below it with stable ids that the cell markers link to. */
.md-typeset .mutcd-tablenote {
  font-size: 0.7rem;
  margin: 0.15em 0;
  color: var(--md-default-fg-color--light);
}
.md-typeset .mutcd-tablenote strong {
  color: var(--md-default-fg-color);
}
.md-typeset table.mutcd-table sup a {
  text-decoration: none;
  font-weight: 600;
}

/* Header logo: the square Roundabout ring mark (theme.logo = logo-mark.png) which links to the
   docs home; sized for the navy header bar. */
.md-header__button.md-logo { padding: 2px 10px 2px 0; }
.md-header__button.md-logo img { height: 30px; width: auto; max-height: none; }

/* ---- Brand palette: the purply navy as the primary surface (not pure black), and the
   Roundabout tan/orange as the accent (not red). ---- */
[data-md-color-scheme="default"],
[data-md-color-scheme="slate"] {
  --md-primary-fg-color: #1b1b33;          /* header bar: brand purply navy, both schemes */
  --md-primary-fg-color--light: #2a2a48;
  --md-primary-fg-color--dark: #14141f;
}
/* Light mode: the tan reads too light on white, so links/accents use a deeper orange. */
[data-md-color-scheme="default"] {
  --md-accent-fg-color: #b5651d;
  --md-typeset-a-color: #b5651d;
}
/* Dark mode: the brand tan/orange pops against the dark surface. */
[data-md-color-scheme="slate"] {
  --md-accent-fg-color: #e2b088;
  --md-typeset-a-color: #e2b088;
}

/* "Copied link" confirmation when a heading's ¶ permalink is clicked (see copylink.js). */
a.headerlink.ra-copied { position: relative; }
a.headerlink.ra-copied::after {
  content: "Copied link";
  position: absolute; left: 1.5em; top: 50%; transform: translateY(-50%);
  white-space: nowrap; font-size: 0.62rem; font-weight: 600;
  color: var(--md-accent-fg-color);
}

/* Content links: force the brand orange per scheme. Material's slate scheme otherwise derives
   the link color from the primary (now indigo → reads blue). Exclude the ¶ permalink. */
[data-md-color-scheme="default"] .md-content a:not(.headerlink),
[data-md-color-scheme="default"] .md-content a:not(.headerlink):visited { color: #b5651d; }
[data-md-color-scheme="slate"] .md-content a:not(.headerlink),
[data-md-color-scheme="slate"] .md-content a:not(.headerlink):visited { color: #e2b088; }

/* Roundabout footer (mirrors roundabout.tech): logo + nav links + social icons on a navy band. */
.md-footer-meta { background-color: #14141f; }
.md-footer-meta__inner.md-grid {
  max-width: 1220px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 1rem 2rem; padding: 1.6rem 1rem;
}
.ra-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 1rem 2rem; }
.ra-footer__logo img { height: 32px; width: auto; display: block; }
.ra-footer__links { display: flex; flex-wrap: wrap; align-items: center; gap: 0.9rem 1.6rem; }
.ra-footer__links a {
  color: rgba(255, 255, 255, 0.6); font-size: 0.8rem; text-decoration: none; transition: color 0.15s ease;
}
.ra-footer__links a:hover { color: #fff; }
.ra-footer__socials { display: flex; flex-wrap: wrap; align-items: center; gap: 1.1rem; }
.ra-footer__socials a { color: rgba(255, 255, 255, 0.6); display: inline-flex; transition: color 0.15s ease; }
.ra-footer__socials a:hover { color: #fff; }
.ra-footer__socials svg { width: 22px; height: 22px; display: block; }

/* Home-page "last updated <date>" subtitle injected under the H1 by hooks.py. */
.md-typeset .ra-updated {
  margin: -0.5rem 0 1.3rem;
  font-size: 0.72rem; font-weight: 500;
  color: var(--md-default-fg-color--light);
}
