/* 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;
}
/* A footnote-marker tooltip lives INSIDE a horizontally-scrolling table wrap. An opacity:0 /
   visibility:hidden bubble still occupies its absolute ~340px box, which inflates the wrap's
   scrollWidth and forces a spurious horizontal scrollbar on otherwise-narrow tables (Table
   2N-1 was 836px in a 550px wrap). Take the HIDDEN bubble out of layout (display:none) so it
   adds no width until hovered; scoped to table wraps so the normative-badge tooltips keep
   their fade. (The footnote text is also printed below the table, so an occasionally-clipped
   hover bubble loses no information.) */
.md-typeset .mutcd-table-wrap .mutcd-tip::after { display: none; }
.md-typeset .mutcd-table-wrap .mutcd-tip:hover::after { display: block; }
/* 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;
  /* Size to content but at least fill the wrapper: a narrow table spans full width, while a
     wide/dense one grows past the wrapper so .mutcd-table-wrap scrolls horizontally — legible —
     instead of being crushed to fit the viewport. */
  width: auto;
  min-width: 100%;
  margin: 0;
  font-size: 0.72rem;
}
/* Dense tables (5+ columns, e.g. the sign-size matrices that run 15-27 columns) keep a slightly
   smaller font and give every cell a legible MINIMUM width, so the table overflows into the
   horizontal-scroll wrapper rather than squishing every column into an unreadable sliver.
   (Previously these were table-layout:fixed at width:100%, which defeated the scroll wrapper.) */
.md-typeset table.mutcd-table:has(tr > :nth-child(5)) {
  font-size: 0.66rem;
}
.md-typeset table.mutcd-table:has(tr > :nth-child(5)) th,
.md-typeset table.mutcd-table:has(tr > :nth-child(5)) td {
  min-width: 4em;
}
.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);
}

/* ---- Sign-code references -------------------------------------------------------------- */
/* The searchable "Signs shown:" list under a figure. The per-sign labels (R1-1, R1-3P, …) are
   baked into the artwork PNG, so site search can't see them; this line restores them as real,
   indexed, readable text. */
.md-typeset .mutcd-fig-signs {
  margin: 0.35rem 0 0;
  font-size: 0.72rem;
  color: var(--md-default-fg-color--light);
}
.md-typeset .mutcd-fig-signs-label { font-weight: 600; }

/* A sign-code mention in prose / a caption: a subtle dotted-underline link (not the loud brand
   orange — these are dense) that jumps to the defining section and, via signs.js, previews the
   sign's figure on hover. Override the global content-link colour rules, which force orange. */
[data-md-color-scheme="default"] .md-content a.mutcd-sign:not(.headerlink),
[data-md-color-scheme="default"] .md-content a.mutcd-sign:not(.headerlink):visited,
[data-md-color-scheme="slate"] .md-content a.mutcd-sign:not(.headerlink),
[data-md-color-scheme="slate"] .md-content a.mutcd-sign:not(.headerlink):visited {
  color: inherit;
}
.md-typeset a.mutcd-sign {
  text-decoration: none;
  border-bottom: 1px dotted var(--md-default-fg-color--light);
  cursor: help;
}
.md-typeset a.mutcd-sign:hover {
  color: var(--md-accent-fg-color);
  border-bottom-color: currentColor;
}
/* The Sign Code Index thumbnail wraps an image, so it carries no text underline. */
.md-typeset a.mutcd-sign:has(img) { border-bottom: none; cursor: zoom-in; }
.md-typeset img.mutcd-sign-thumb {
  height: 44px;
  width: auto;
  max-width: 150px;
  padding: 2px;
  background: #fff;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 3px;
  vertical-align: middle;
}
/* An individual per-sign image (not a wide figure crop) reads better a touch larger and
   contained, so the whole sign shows without cropping. */
.md-typeset img.mutcd-sign-thumb--single {
  height: 50px;
  max-width: 80px;
  object-fit: contain;
}

/* Floating preview card (built by signs.js) shown when hovering a sign code or a thumbnail. */
.mutcd-sign-card {
  position: absolute;
  z-index: 40;
  display: none;
  padding: 0.4rem;
  background: #fff;
  border: 1px solid var(--md-default-fg-color--lighter);
  border-radius: 0.3rem;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.28);
  max-width: min(360px, 84vw);
  pointer-events: none;
}
.mutcd-sign-card.is-visible { display: block; }
.mutcd-sign-card img {
  display: block;
  max-width: 340px;
  max-height: 300px;
  width: auto;
  height: auto;
  margin: 0 auto;
}
.mutcd-sign-card__name {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.7rem;
  text-align: center;
  color: #333;
}
[data-md-color-scheme="slate"] .mutcd-sign-card {
  background: var(--ra-navy-light);
  border-color: rgba(255, 255, 255, 0.14);
}
[data-md-color-scheme="slate"] .mutcd-sign-card__name { color: #e8e8f0; }

/* ---- State supplement: "<State>-modified" section flag (AZ/CO/WA editions) ---- */
:root { --md-admonition-icon--state-modified: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 2 2 7v10l10 5 10-5V7L12 2zm0 2.2 7 3.5v8.6l-7 3.5-7-3.5V7.7l7-3.5zM11 8v6h2V8h-2zm0 8v2h2v-2h-2z"/></svg>'); }
.md-typeset .admonition.state-modified,
.md-typeset details.state-modified { border-color: #e8772e; }
.md-typeset .state-modified > .admonition-title,
.md-typeset .state-modified > summary { background-color: rgba(232,119,46,.12); }
.md-typeset .state-modified > .admonition-title::before,
.md-typeset .state-modified > summary::before { background-color: #e8772e; -webkit-mask-image: var(--md-admonition-icon--state-modified); mask-image: var(--md-admonition-icon--state-modified); }
