/* ==========================================================================
   AIT documentation theme
   --------------------------------------------------------------------------
   One set of semantic tokens is defined per colour scheme; everything below
   the token blocks is written against those names only. Nothing here hard
   codes a colour, so the light and dark builds cannot drift apart.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */

[data-md-color-scheme="default"] {
  --ait-page: #ffffff;
  --ait-surface: #f5f8fb;
  --ait-surface-raised: #eaf0f6;
  --ait-line: #d6e0e9;
  --ait-line-strong: #b9c8d5;
  --ait-ink: #0b1a26;
  --ait-body: #33495b;
  --ait-muted: #566b7c;
  --ait-accent: #0d6b63;
  --ait-accent-soft: rgba(13, 107, 99, 0.09);
  --ait-signal: #8a5300;
  --ait-signal-soft: rgba(138, 83, 0, 0.1);
  --ait-shadow: 0 1px 2px rgba(11, 26, 38, 0.05), 0 12px 28px -18px rgba(11, 26, 38, 0.35);
  --ait-shadow-lift: 0 2px 4px rgba(11, 26, 38, 0.06), 0 22px 40px -24px rgba(11, 26, 38, 0.45);

  --md-default-bg-color: #ffffff;
  --md-default-fg-color: #0b1a26;
  --md-default-fg-color--light: #4a6072;
  --md-default-fg-color--lighter: #8296a6;
  --md-default-fg-color--lightest: #dbe4ec;
  --md-typeset-color: #2a3f52;
  --md-typeset-a-color: #0d6b63;
  --md-code-bg-color: #f2f6fa;
  --md-code-fg-color: #1f3547;
  --md-primary-fg-color: #0b1a26;
  --md-primary-fg-color--light: #16293a;
  --md-primary-fg-color--dark: #050f18;
  --md-primary-bg-color: #ffffff;
  --md-primary-bg-color--light: rgba(255, 255, 255, 0.72);
  --md-accent-fg-color: #0d6b63;
  --md-accent-fg-color--transparent: rgba(13, 107, 99, 0.1);
  --md-accent-bg-color: #ffffff;
  --md-footer-bg-color: #0b1a26;
  --md-footer-bg-color--dark: #050f18;
  --md-footer-fg-color--light: rgba(255, 255, 255, 0.7);
}

[data-md-color-scheme="slate"] {
  --ait-page: #0b1520;
  --ait-surface: #111f2c;
  --ait-surface-raised: #182838;
  --ait-line: #26384a;
  --ait-line-strong: #375065;
  --ait-ink: #eef5fa;
  --ait-body: #c2d2de;
  --ait-muted: #8ea3b4;
  --ait-accent: #63d5c8;
  --ait-accent-soft: rgba(99, 213, 200, 0.1);
  --ait-signal: #f2b84b;
  --ait-signal-soft: rgba(242, 184, 75, 0.12);
  --ait-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 14px 30px -18px rgba(0, 0, 0, 0.8);
  --ait-shadow-lift: 0 2px 6px rgba(0, 0, 0, 0.5), 0 26px 46px -24px rgba(0, 0, 0, 0.95);

  --md-default-bg-color: #0b1520;
  --md-default-fg-color: #eef5fa;
  --md-default-fg-color--light: #a9bccb;
  --md-default-fg-color--lighter: #6f8899;
  --md-default-fg-color--lightest: #23364a;
  --md-typeset-color: #c5d5e1;
  --md-typeset-a-color: #63d5c8;
  --md-code-bg-color: #0f1c28;
  --md-code-fg-color: #dbe7f0;
  --md-primary-fg-color: #0b1520;
  --md-primary-fg-color--light: #142434;
  --md-primary-fg-color--dark: #060e16;
  --md-primary-bg-color: #eef5fa;
  --md-primary-bg-color--light: rgba(238, 245, 250, 0.72);
  --md-accent-fg-color: #63d5c8;
  --md-accent-fg-color--transparent: rgba(99, 213, 200, 0.12);
  --md-accent-bg-color: #06131b;
  --md-footer-bg-color: #081019;
  --md-footer-bg-color--dark: #050b12;
  --md-footer-fg-color--light: rgba(238, 245, 250, 0.68);
}

:root {
  --md-text-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --md-code-font: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --ait-mono: var(--md-code-font);
}

/* --------------------------------------------------------------------------
   2. Shell: announcement, header, tabs
   -------------------------------------------------------------------------- */

.md-banner {
  background: var(--md-primary-fg-color--dark);
  color: var(--md-primary-bg-color);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.ait-announce {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.7rem;
  font-size: 0.68rem;
}

.ait-announce__tag {
  padding: 0.12rem 0.45rem;
  border: 1px solid var(--ait-signal);
  border-radius: 0.2rem;
  color: var(--ait-signal);
  font-family: var(--ait-mono);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  white-space: nowrap;
}

.ait-announce__body {
  opacity: 0.82;
}

.ait-announce__link {
  color: var(--md-primary-bg-color);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.18em;
  white-space: nowrap;
}

.md-header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: none;
}

.md-header--shadow {
  box-shadow: 0 0 0.2rem rgba(0, 0, 0, 0.3), 0 0.2rem 0.5rem rgba(0, 0, 0, 0.22);
}

.md-header__title {
  font-weight: 600;
  letter-spacing: -0.012em;
}

.md-header__topic:first-child {
  font-weight: 650;
}

.md-header__button.md-logo :is(img, svg) {
  width: 1.5rem;
  height: 1.5rem;
}

.md-tabs {
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.md-tabs__link {
  margin-top: 0.5rem;
  opacity: 0.72;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.005em;
  transition: opacity 140ms ease;
}

.md-tabs__link:is(:hover, :focus-visible) {
  opacity: 1;
}

.md-tabs__item--active .md-tabs__link {
  position: relative;
  opacity: 1;
}

.md-tabs__item--active .md-tabs__link::after {
  position: absolute;
  right: 0;
  bottom: -0.52rem;
  left: 0;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--ait-signal);
  content: "";
}

.md-search__form {
  border-radius: 0.25rem;
  background: rgba(255, 255, 255, 0.09);
}

.md-search__form:hover {
  background: rgba(255, 255, 255, 0.14);
}

[dir="ltr"] .md-search__output {
  border-radius: 0.25rem;
}

/* --------------------------------------------------------------------------
   3. Layout and navigation
   -------------------------------------------------------------------------- */

.md-grid {
  max-width: 70rem;
}

.md-main__inner {
  margin-top: 1.6rem;
}

.md-nav {
  font-size: 0.68rem;
}

.md-nav__title {
  color: var(--ait-muted);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.md-nav--secondary .md-nav__title {
  box-shadow: none;
}

.md-nav__item--section > .md-nav__link {
  color: var(--ait-muted);
  font-family: var(--ait-mono);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.md-nav__link {
  border-radius: 0.2rem;
  transition: color 120ms ease, background 120ms ease;
}

.md-sidebar--primary .md-nav__list .md-nav__link {
  padding: 0.18rem 0.4rem;
  margin-left: -0.4rem;
}

.md-sidebar--primary .md-nav__link:is(:hover, :focus-visible) {
  background: var(--ait-accent-soft);
}

.md-nav__link--active,
.md-nav__link--active:is(:hover, :focus-visible) {
  color: var(--md-accent-fg-color);
  font-weight: 650;
}

.md-sidebar--secondary .md-nav__link--active {
  border-left: 2px solid var(--ait-signal);
  margin-left: -2px;
  padding-left: calc(0.4rem + 2px);
}

/* --------------------------------------------------------------------------
   4. Typography
   -------------------------------------------------------------------------- */

.md-typeset {
  font-size: 0.775rem;
  line-height: 1.72;
}

.md-typeset :is(h1, h2, h3, h4) {
  color: var(--ait-ink);
  font-weight: 660;
  letter-spacing: -0.021em;
}

.md-typeset h1 {
  max-width: 22ch;
  margin-bottom: 1.1rem;
  font-size: clamp(1.85rem, 3.4vw, 2.5rem);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.032em;
}

.md-typeset h2 {
  margin-top: 3rem;
  padding-top: 1.35rem;
  border-top: 1px solid var(--ait-line);
  font-size: 1.32rem;
  line-height: 1.24;
}

.md-typeset h3 {
  margin-top: 2rem;
  font-size: 1.02rem;
}

.md-typeset h4 {
  font-size: 0.85rem;
}

.md-typeset h1 + h2 {
  margin-top: 1.6rem;
}

.md-typeset :is(h2, h3, h4) > code {
  font-size: 0.86em;
}

.md-typeset :is(p, li) {
  max-width: 46rem;
}

.md-typeset a {
  text-underline-offset: 0.16em;
  transition: color 120ms ease;
}

.md-typeset hr {
  border-bottom-color: var(--ait-line);
}

.md-typeset blockquote {
  border-left: 2px solid var(--ait-signal);
  color: var(--ait-muted);
}

/* --------------------------------------------------------------------------
   5. Code, tables, admonitions
   -------------------------------------------------------------------------- */

.md-typeset code {
  padding: 0.1em 0.34em;
  border: 1px solid var(--ait-line);
  border-radius: 0.2rem;
  font-size: 0.82em;
}

.md-typeset pre > code {
  padding: 0.85rem 1rem;
  border: 1px solid var(--ait-line);
  font-size: 0.72rem;
  line-height: 1.62;
}

.md-typeset .highlight :is(.filename, .highlighttable) {
  border-radius: 0.25rem;
}

.md-typeset .md-code__content {
  border-radius: 0.25rem;
}

.md-clipboard {
  color: var(--ait-muted);
}

.md-typeset table:not([class]) {
  display: table;
  width: 100%;
  border: 1px solid var(--ait-line);
  border-radius: 0.3rem;
  background: var(--ait-page);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.md-typeset table:not([class]) th {
  padding: 0.62rem 0.9rem;
  border-bottom: 1px solid var(--ait-line-strong);
  background: var(--ait-surface);
  color: var(--ait-muted);
  font-family: var(--ait-mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  vertical-align: bottom;
}

.md-typeset table:not([class]) td {
  padding: 0.62rem 0.9rem;
  border-top: 1px solid var(--ait-line);
  vertical-align: top;
}

.md-typeset table:not([class]) tr:hover {
  background: var(--ait-surface);
}

.md-typeset table:not([class]) td:first-child strong {
  color: var(--ait-ink);
  font-family: var(--ait-mono);
  font-size: 0.94em;
  font-weight: 600;
}

.md-typeset .admonition,
.md-typeset details {
  border: 1px solid var(--ait-line);
  border-left: 3px solid var(--ait-line-strong);
  border-radius: 0.3rem;
  background: var(--ait-surface);
  box-shadow: none;
  font-size: 0.74rem;
}

.md-typeset :is(.admonition-title, summary) {
  padding: 0.55rem 0.7rem 0.55rem 2.2rem;
  background: transparent;
  font-weight: 650;
}

.md-typeset :is(.admonition-title, summary)::before {
  top: 0.62rem;
  left: 0.7rem;
}

.md-typeset .admonition.warning,
.md-typeset details.warning {
  border-left-color: var(--ait-signal);
  background: var(--ait-signal-soft);
}

.md-typeset .admonition.info,
.md-typeset details.info,
.md-typeset .admonition.note,
.md-typeset details.note {
  border-left-color: var(--ait-accent);
  background: var(--ait-accent-soft);
}

/* --------------------------------------------------------------------------
   6. Page furniture
   -------------------------------------------------------------------------- */

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.ait-chip {
  display: inline-block;
  margin: 0 0.3rem 0.35rem 0;
  padding: 0.16rem 0.5rem;
  border: 1px solid var(--ait-line);
  border-radius: 999px;
  background: var(--ait-surface);
  color: var(--ait-muted);
  font-family: var(--ait-mono);
  font-size: 0.6rem;
  letter-spacing: 0.03em;
}

/* --------------------------------------------------------------------------
   7. Cards
   -------------------------------------------------------------------------- */

.ait-path-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 0.7rem;
  margin: 1.4rem 0 2.2rem;
}

.ait-path {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1.05rem 1.1rem 1.15rem;
  border: 1px solid var(--ait-line);
  border-radius: 0.35rem;
  background: var(--ait-page);
  box-shadow: var(--ait-shadow);
  transition: border-color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

.ait-path::before {
  position: absolute;
  top: -1px;
  left: 1.05rem;
  width: 2.2rem;
  height: 2px;
  background: var(--ait-accent);
  content: "";
}

.ait-path:nth-child(2n)::before {
  background: var(--ait-signal);
}

.ait-path:hover {
  transform: translateY(-2px);
  border-color: var(--ait-line-strong);
  box-shadow: var(--ait-shadow-lift);
}

.ait-path strong {
  color: var(--ait-ink);
  font-size: 0.84rem;
  font-weight: 650;
  letter-spacing: -0.012em;
}

.ait-path span:not(.visually-hidden) {
  color: var(--ait-body);
  font-size: 0.73rem;
  line-height: 1.6;
}

.ait-path a::after {
  position: absolute;
  inset: 0;
  border-radius: 0.35rem;
  content: "";
}

.ait-path:focus-within {
  border-color: var(--ait-accent);
}

/* Material's own card grid, aligned with the panels above. */
.md-typeset .grid.cards > :is(ul, ol) > li,
.md-typeset .grid > .card {
  border: 1px solid var(--ait-line);
  border-radius: 0.35rem;
  background: var(--ait-page);
  box-shadow: var(--ait-shadow);
  transition: border-color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

.md-typeset .grid.cards > :is(ul, ol) > li:is(:hover, :focus-within) {
  transform: translateY(-2px);
  border-color: var(--ait-line-strong);
  box-shadow: var(--ait-shadow-lift);
}

/* --------------------------------------------------------------------------
   8. Figures and diagrams
   -------------------------------------------------------------------------- */

.ait-figure,
.ait-architecture-plate {
  margin: 1.6rem 0 2.2rem;
  padding: clamp(0.5rem, 1.4vw, 0.85rem);
  border: 1px solid var(--ait-line);
  border-radius: 0.4rem;
  background: var(--ait-surface);
}

.ait-architecture-plate {
  margin-top: 0;
}

.md-typeset .ait-figure img,
.md-typeset .ait-architecture-plate img {
  display: block;
  width: 100%;
  margin: 0;
  border-radius: 0.25rem;
  background: var(--ait-page);
}

.md-typeset .ait-caption {
  margin: 0.75rem 0.25rem 0.15rem !important;
  max-width: 44rem;
  color: var(--ait-muted);
  font-size: 0.68rem;
  line-height: 1.6;
}

.ait-architecture-key {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.1rem;
  padding: 0.75rem 0.25rem 0;
  color: var(--ait-muted);
  font-family: var(--ait-mono);
  font-size: 0.6rem;
  letter-spacing: 0.02em;
}

.ait-architecture-key span {
  display: inline-flex;
  align-items: center;
  gap: 0.36rem;
}

.ait-architecture-key i {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--ait-line-strong);
}

.ait-architecture-key .control { background: var(--ait-signal); }
.ait-architecture-key .evidence { background: var(--ait-accent); }

.md-typeset img.ait-diagram-mobile {
  display: none;
  /* The narrow drawing is laid out on a 700 unit canvas. Letting it stretch
     past that on a mid-width screen scales its type above the page's own
     headings, so it is capped at its natural size and centred instead.
     The cap is in px on purpose: Material scales the rem unit, and this
     number has to stay pinned to the canvas the figure was drawn on. */
  max-width: 700px;
  margin-inline: auto;
}

/* A wide figure is allowed past the prose measure; the diagrams are drawn to
   be read at full width, not at 46rem. */
.ait-figure-wide {
  max-width: none;
}

.md-typeset .ait-figure-wide > p:not(.ait-caption) {
  max-width: none;
}

.ait-reading-list {
  margin: 1rem 0 2rem !important;
  padding: 0 !important;
  list-style: none !important;
  counter-reset: reading-path;
}

.ait-reading-list li {
  display: grid;
  grid-template-columns: 2rem minmax(11rem, 15rem) 1fr;
  gap: 0.8rem;
  align-items: baseline;
  padding: 0.9rem 0;
  border-top: 1px solid var(--ait-line);
  counter-increment: reading-path;
}

.ait-reading-list li::before {
  color: var(--ait-signal);
  content: counter(reading-path, decimal-leading-zero);
  font-family: var(--ait-mono);
  font-size: 0.65rem;
  font-weight: 700;
}

.ait-reading-list a {
  text-decoration: none;
}

.ait-reading-list span {
  color: var(--ait-body);
  font-size: 0.76rem;
  line-height: 1.55;
}

.ait-flow {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr));
  gap: 0.35rem;
  margin: 1.3rem 0 1.9rem;
}

.ait-flow > span {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 4rem;
  padding: 0.7rem 0.5rem;
  border: 1px solid var(--ait-line);
  border-radius: 0.3rem;
  background: var(--ait-surface);
  color: var(--ait-body);
  text-align: center;
  font-family: var(--ait-mono);
  font-size: 0.62rem;
  line-height: 1.45;
}

.ait-flow > span:not(:last-child)::after {
  position: absolute;
  z-index: 2;
  right: -0.42rem;
  color: var(--ait-signal);
  font-size: 0.7rem;
  content: "\203A";
}

.ait-flow > .signal {
  border-color: var(--ait-signal);
  background: var(--ait-signal-soft);
  color: var(--ait-ink);
}

.mermaid {
  margin: 1.5rem 0 2rem;
  padding: 1rem;
  border: 1px solid var(--ait-line);
  border-radius: 0.4rem;
  background: var(--ait-surface);
}

/* --------------------------------------------------------------------------
   9. Footer
   -------------------------------------------------------------------------- */

.md-footer-meta {
  font-size: 0.66rem;
}

.md-copyright {
  max-width: 42rem;
  line-height: 1.55;
}

.md-footer__link {
  opacity: 0.72;
  transition: opacity 140ms ease;
}

.md-footer__link:is(:hover, :focus-visible) {
  opacity: 1;
}

.md-footer__direction {
  font-size: 0.58rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

/* --------------------------------------------------------------------------
   10. Responsive, motion, print
   -------------------------------------------------------------------------- */

@media screen and (max-width: 76.1875em) {
  .md-nav--primary .md-nav__title {
    background: var(--md-primary-fg-color);
    color: var(--md-primary-bg-color);
  }
}

@media screen and (max-width: 60em) {
  .md-typeset img.ait-diagram-desktop {
    display: none !important;
  }

  .md-typeset img.ait-diagram-mobile {
    display: block !important;
  }

  [data-md-color-scheme="default"] .md-typeset img.ait-diagram-mobile[src$="#only-dark"],
  [data-md-color-scheme="slate"] .md-typeset img.ait-diagram-mobile[src$="#only-light"] {
    display: none !important;
  }
}

@media screen and (max-width: 44.9375em) {
  .ait-announce__body {
    display: none;
  }

  .md-typeset h2 {
    margin-top: 2.2rem;
  }

  .ait-flow > span:not(:last-child)::after {
    right: 50%;
    bottom: -0.55rem;
    transform: translateX(50%) rotate(90deg);
  }

  .ait-reading-list li {
    grid-template-columns: 2rem 1fr;
  }

  .ait-reading-list span {
    grid-column: 2;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ait-path,
  .md-typeset .grid.cards > :is(ul, ol) > li {
    transition: none;
  }

  .ait-path:hover,
  .md-typeset .grid.cards > :is(ul, ol) > li:is(:hover, :focus-within) {
    transform: none;
  }
}

@media print {
  .md-banner,
  .ait-path::before {
    display: none;
  }

  .ait-architecture-plate,
  .ait-figure,
  .ait-path,
  .ait-flow > span,
  .md-typeset .admonition {
    border-color: #9aa7b1;
    background: transparent;
    box-shadow: none;
  }

  .md-typeset .ait-diagram-desktop,
  [data-md-color-scheme="slate"] .md-typeset img[src$="#only-light"] {
    display: block !important;
  }

  .md-typeset .ait-diagram-mobile,
  .md-typeset img[src$="#only-dark"] {
    display: none !important;
  }
}

/* --------------------------------------------------------------------------
   11. Diagram variant selection
   --------------------------------------------------------------------------
   Two independent switches write `display` on the same images: viewport width
   picks the wide or narrow drawing, and colour scheme picks the light or dark
   file. Width is settled above; the scheme rules are last and one specificity
   step higher, so they always have the final say.
   -------------------------------------------------------------------------- */

[data-md-color-scheme="default"] .md-typeset img[src$="#only-dark"],
[data-md-color-scheme="slate"] .md-typeset img[src$="#only-light"] {
  display: none;
}
