/*
 * BEMGen site styling. It follows design/ui-design-spec.md: flat, square, rule-framed surfaces; Geist, Geist Mono, and
 * Cormorant Garamond; the EnergyAtlas palette with the contrast adjustments of its section 0.6. Sizes are in rem so
 * that they scale with Material's root font size (1rem = 20px at the base size, so 0.8rem = 16px).
 */

/* ---------------------------------------------------------------------------------------------------------------------
 * Tokens
 * ------------------------------------------------------------------------------------------------------------------ */

:root {
  --font-sans: "Geist", "Inter", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Geist Mono", "IBM Plex Mono", Consolas, monospace;
  --font-serif: "Cormorant Garamond", "Cormorant", Georgia, serif;

  --md-text-font: "Geist";
  --md-code-font: "Geist Mono";

  --ea-primary: #003978;
  --ea-transition: 150ms ease;

  /* Horizontal margin of the article inside the content column; full-bleed strips and grids cancel it. */
  --ea-gutter: 0.8rem;
}

@media screen and (min-width: 76.25em) {
  :root {
    --ea-gutter: 1.2rem;
  }
}

[data-md-color-scheme="slate"] {
  --ea-accent: #4da3ff;
  --ea-accent-tint: rgba(77, 163, 255, 0.08);
  --ea-text-primary: #e5e5e5;
  --ea-text-secondary: #b0b0b0;
  --ea-text-muted: #999999;
  --ea-bg-base: #000000;
  --ea-bg-surface-1: #1a1a1a;
  --ea-bg-surface-2: #2a2a2a;
  --ea-bg-surface-3: #3a3a3a;
  --ea-border-subtle: #404040;
  --ea-border-interactive: #6b6b6b;
  --ea-success: #28a745;
  --ea-warning: #ffc107;
  --ea-error: #f44336;
  --ea-code-bg: var(--ea-bg-surface-1);
}

[data-md-color-scheme="default"] {
  --ea-accent: #125dae;
  --ea-accent-tint: rgba(18, 93, 174, 0.08);
  --ea-text-primary: #18202c;
  --ea-text-secondary: #3f4b5b;
  --ea-text-muted: #5f6b7a;
  --ea-bg-base: #ffffff;
  --ea-bg-surface-1: #f8fafc;
  --ea-bg-surface-2: #f4f7fb;
  --ea-bg-surface-3: #e7edf5;
  --ea-border-subtle: #cfd8e5;
  --ea-border-interactive: #768599;
  --ea-success: #188038;
  --ea-warning: #9a6700;
  --ea-error: #c5221f;
  --ea-code-bg: var(--ea-bg-surface-2);
}

/* Material's own variables, mapped onto the tokens for both schemes. */
[data-md-color-scheme="slate"],
[data-md-color-scheme="default"] {
  --md-default-bg-color: var(--ea-bg-base);
  --md-default-fg-color: var(--ea-text-primary);
  --md-default-fg-color--light: var(--ea-text-secondary);
  --md-default-fg-color--lighter: var(--ea-text-muted);
  --md-default-fg-color--lightest: var(--ea-border-subtle);

  --md-primary-fg-color: var(--ea-bg-base);
  --md-primary-fg-color--light: var(--ea-bg-surface-1);
  --md-primary-fg-color--dark: var(--ea-bg-base);
  --md-primary-bg-color: var(--ea-text-primary);
  --md-primary-bg-color--light: var(--ea-text-secondary);

  --md-accent-fg-color: var(--ea-accent);
  --md-accent-fg-color--transparent: var(--ea-accent-tint);
  --md-accent-bg-color: var(--ea-bg-base);
  --md-accent-bg-color--light: var(--ea-bg-surface-1);

  --md-typeset-color: var(--ea-text-secondary);
  --md-typeset-a-color: var(--ea-accent);
  --md-typeset-table-color: var(--ea-border-subtle);
  --md-typeset-table-color--light: var(--ea-accent-tint);

  --md-code-bg-color: var(--ea-code-bg);
  --md-code-fg-color: var(--ea-text-primary);

  --md-admonition-bg-color: transparent;
  --md-admonition-fg-color: var(--ea-text-secondary);

  --md-footer-bg-color: var(--ea-bg-base);
  --md-footer-bg-color--dark: var(--ea-bg-base);
  --md-footer-fg-color: var(--ea-text-primary);
  --md-footer-fg-color--light: var(--ea-text-secondary);
  --md-footer-fg-color--lighter: var(--ea-text-muted);

  --md-shadow-z1: none;
  --md-shadow-z2: none;
  --md-shadow-z3: none;

  background-color: var(--ea-bg-base);
}

/* ---------------------------------------------------------------------------------------------------------------------
 * Page frame
 * ------------------------------------------------------------------------------------------------------------------ */

/* Reserve the scrollbar's width on every page, so that moving between short and long pages does not shift the layout. */
html {
  scrollbar-gutter: stable;
}

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

.md-main__inner {
  margin-top: 0;
}

/* The content column is bounded by two thin vertical rules, like the frame of a drawing sheet. */
@media screen and (min-width: 60em) {
  .md-content {
    border-left: 1px solid var(--ea-border-subtle);
    border-right: 1px solid var(--ea-border-subtle);
    min-height: calc(100vh - 4.8rem);
  }
}

.md-sidebar {
  padding-top: 1.6rem;
}

.md-content__inner {
  padding-top: 1.2rem;
}

/*
 * A page that hides a sidebar (the landing page hides both) keeps the sidebar's width as an empty margin, without its
 * rule, so its text lines up with the text of every other page. Only the content moves: strips and grids still run
 * from frame to frame. --ea-inset-left and --ea-inset-right hold the empty margins.
 */
.md-content {
  --ea-inset-left: 0rem;
  --ea-inset-right: 0rem;
}

@media screen and (min-width: 76.25em) {
  .md-sidebar--primary[hidden] ~ .md-content {
    --ea-inset-left: 12.1rem;
  }

  .md-sidebar--secondary[hidden] ~ .md-content {
    --ea-inset-right: 12.1rem;
  }
}

[dir] .md-main__inner > .md-content > .md-content__inner.md-typeset,
[dir] .md-main__inner > .md-content > .md-path {
  margin-left: calc(var(--ea-gutter) + var(--ea-inset-left));
  margin-right: calc(var(--ea-gutter) + var(--ea-inset-right));
}

/* ---------------------------------------------------------------------------------------------------------------------
 * Header and tabs
 * ------------------------------------------------------------------------------------------------------------------ */

.md-header,
.md-header--shadow {
  border-bottom: 1px solid var(--ea-border-subtle);
  box-shadow: none;
}

.md-header__title {
  font-weight: 650;
  letter-spacing: -0.01em;
}

.md-header__button.md-logo {
  opacity: 0.9;
}

.md-source {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  letter-spacing: 0.06em;
}

.md-tabs {
  border-bottom: 1px solid var(--ea-border-subtle);
}

/* The loading bar of instant navigation: a thin accent rule along the top edge. */
.md-progress {
  background-color: var(--ea-accent);
}

.md-tabs__item {
  height: 2.2rem;
  padding-left: 0.4rem;
  padding-right: 0.4rem;
}

.md-tabs__link {
  align-items: center;
  color: var(--ea-text-muted);
  font-family: var(--font-mono);
  font-size: 0.575rem;
  font-weight: 600;
  height: 1.2rem;
  letter-spacing: 0.14em;
  margin-top: 0.5rem;
  opacity: 1;
  padding: 0 0.4rem;
  text-transform: uppercase;
  transition: color var(--ea-transition), background-color var(--ea-transition);
}

.md-tabs__link:focus,
.md-tabs__link:hover {
  color: var(--ea-text-primary);
}

/* The active tab is a small inverted block inside a thin accent outline, as in the reference header. */
.md-tabs__item--active .md-tabs__link {
  background-color: var(--ea-text-primary);
  color: var(--ea-bg-base);
  outline: 1px solid var(--ea-accent);
  outline-offset: 0.15rem;
}

.md-tabs__item--active .md-tabs__link:focus,
.md-tabs__item--active .md-tabs__link:hover {
  color: var(--ea-bg-base);
}

/* The active tab already wears the accent outline, so keyboard focus thickens it to stay visible. */
.md-tabs__item--active .md-tabs__link:focus-visible {
  outline-width: 2px;
}

/* ---------------------------------------------------------------------------------------------------------------------
 * Search
 * ------------------------------------------------------------------------------------------------------------------ */

@media screen and (min-width: 60em) {
  .md-search__form {
    background-color: transparent;
    border: 1px solid var(--ea-border-interactive);
    border-radius: 0;
    transition: border-color var(--ea-transition);
  }

  .md-search__form:hover {
    background-color: transparent;
    border-color: var(--ea-text-muted);
  }

  [data-md-toggle="search"]:checked ~ .md-header .md-search__form {
    background-color: var(--ea-bg-base);
    border-color: var(--ea-accent);
    border-radius: 0;
    box-shadow: none;
  }

  .md-search__output {
    border: 1px solid var(--ea-border-interactive);
    border-top: 0;
    border-radius: 0;
    box-shadow: none;
  }
}

.md-search__input {
  font-family: var(--font-sans);
}

.md-search__input::placeholder {
  color: var(--ea-text-muted);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.md-search-result__meta {
  background-color: var(--ea-bg-surface-1);
  color: var(--ea-text-muted);
  font-family: var(--font-mono);
  font-size: 0.55rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.md-search-result__link:focus,
.md-search-result__link:hover,
.md-search-result__more > summary:focus > div,
.md-search-result__more > summary:hover > div {
  background-color: var(--ea-accent-tint);
}

/* ---------------------------------------------------------------------------------------------------------------------
 * Breadcrumbs
 * ------------------------------------------------------------------------------------------------------------------ */

.md-path {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  letter-spacing: 0.1em;
  margin-left: var(--ea-gutter);
  margin-right: var(--ea-gutter);
  padding-top: 1.2rem;
  text-transform: uppercase;
}

.md-path__list {
  gap: 0.4rem;
}

.md-path__item:not(:first-child) {
  gap: 0.4rem;
}

.md-path__item:not(:first-child)::before {
  background: none;
  color: var(--ea-text-muted);
  content: "/";
  height: auto;
  -webkit-mask-image: none;
  mask-image: none;
  width: auto;
}

.md-path__link {
  color: var(--ea-text-muted);
}

.md-path ~ .md-content__inner {
  padding-top: 0.4rem;
}

/* ---------------------------------------------------------------------------------------------------------------------
 * Sidebars: navigation and table of contents
 * ------------------------------------------------------------------------------------------------------------------ */

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

.md-nav__link {
  color: var(--ea-text-secondary);
  transition: color var(--ea-transition);
}

.md-nav__link:is(:focus, :hover),
.md-nav__item .md-nav__link--active:is(:focus, :hover) {
  color: var(--ea-text-primary);
}

.md-nav__item .md-nav__link--active,
.md-nav__item .md-nav__link--active code {
  color: var(--ea-accent);
}

/* Section labels and the "Table of contents" title read as technical labels, not as links. */
.md-nav__title,
.md-nav__item--section > .md-nav__link,
.md-nav__item--section > .md-nav__link[for] {
  color: var(--ea-text-muted);
  font-family: var(--font-mono);
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

@media screen and (min-width: 76.25em) {
  .md-nav__item--section > .md-nav__link {
    margin-bottom: 0.4rem;
  }

  /* Nested pages hang from a thin rule; the active page marks it with an accent edge. */
  .md-nav--primary .md-nav__item--nested:not(.md-nav__item--section) > .md-nav > .md-nav__list {
    border-left: 1px solid var(--ea-border-subtle);
    margin-left: 0.6rem;
  }

  .md-nav--primary .md-nav__item--nested:not(.md-nav__item--section) > .md-nav > .md-nav__list > .md-nav__item {
    padding-left: 0.4rem;
  }

  .md-nav--primary .md-nav__link--active:not(.md-nav__container) {
    box-shadow: -0.45rem 0 0 -0.4rem var(--ea-accent);
  }

  .md-nav--secondary {
    border-left: 1px solid var(--ea-border-subtle);
    padding-left: 0.6rem;
  }
}

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

/* ---------------------------------------------------------------------------------------------------------------------
 * Typography
 * ------------------------------------------------------------------------------------------------------------------ */

.md-typeset {
  font-feature-settings: "ss01" off;
  line-height: 1.6;
}

.md-typeset :is(h1, h2, h3, h4, h5, h6) {
  color: var(--ea-text-primary);
  font-family: var(--font-sans);
}

.md-typeset h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0 0 1.2rem;
}

.md-typeset h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 3.2rem 0 0.8rem;
}

.md-typeset h3 {
  font-size: 1.1rem;
  font-weight: 650;
  letter-spacing: -0.015em;
  line-height: 1.25;
  margin: 2rem 0 0.6rem;
}

.md-typeset h4 {
  font-size: 0.9rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.3;
  margin: 1.6rem 0 0.4rem;
}

.md-typeset :is(h5, h6) {
  color: var(--ea-text-muted);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.12em;
}

@media screen and (max-width: 44.984375em) {
  .md-typeset h1 {
    font-size: 1.6rem;
  }

  .md-typeset h2 {
    font-size: 1.25rem;
    margin-top: 2.4rem;
  }

  .md-typeset h3 {
    font-size: 1rem;
  }
}

.md-typeset p {
  margin: 0 0 1.25em;
}

.md-typeset :is(strong, b) {
  color: var(--ea-text-primary);
}

.md-typeset a {
  text-decoration-color: transparent;
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color var(--ea-transition), text-decoration-color var(--ea-transition);
}

.md-typeset a:is(:focus, :hover) {
  color: var(--ea-accent);
  text-decoration-color: currentcolor;
}

.md-typeset .headerlink {
  color: var(--ea-text-muted);
  font-family: var(--font-mono);
  font-weight: 400;
}

.md-typeset hr {
  border-bottom: 1px solid var(--ea-border-subtle);
}

.md-typeset img {
  border-radius: 0;
}

/* Long-form prose keeps a readable measure; tables, code, figures, and grids use the full column (spec section 0.9). */
.md-typeset > :is(p, ul, ol, dl, blockquote, .admonition, details, h1, h2, h3, h4) {
  max-width: 46rem;
}

/* ---------------------------------------------------------------------------------------------------------------------
 * Code
 * ------------------------------------------------------------------------------------------------------------------ */

.md-typeset code {
  border-radius: 0;
  padding: 0.1em 0.3em;
}

.md-typeset pre > code {
  border: 1px solid var(--ea-border-subtle);
}

.md-typeset .highlight {
  border-radius: 0;
}

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

/* ---------------------------------------------------------------------------------------------------------------------
 * Tables: technical data sheets
 * ------------------------------------------------------------------------------------------------------------------ */

.md-typeset table:not([class]) {
  border: 1px solid var(--ea-border-subtle);
  border-radius: 0;
  font-size: 0.72rem;
}

.md-typeset table:not([class]) th {
  border-bottom: 1px solid var(--ea-border-subtle);
  color: var(--ea-text-muted);
  font-family: var(--font-mono);
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  min-width: 3rem;
  text-transform: uppercase;
  vertical-align: bottom;
  white-space: nowrap;
}

.md-typeset table:not([class]) :is(th, td) {
  padding: 0.6em 1em;
}

.md-typeset table:not([class]) :is(th, td) + :is(th, td) {
  border-left: 1px solid var(--ea-border-subtle);
}

.md-typeset table:not([class]) td {
  border-top: 1px solid var(--ea-border-subtle);
}

.md-typeset table:not([class]) tbody tr {
  transition: background-color var(--ea-transition);
}

.md-typeset table:not([class]) tbody tr:hover {
  background-color: var(--ea-accent-tint);
  box-shadow: none;
}

.md-typeset table:not([class]) code {
  white-space: nowrap;
}

/* ---------------------------------------------------------------------------------------------------------------------
 * Admonitions: technical panels with a semantic edge (spec section 0.5)
 * ------------------------------------------------------------------------------------------------------------------ */

.md-typeset :is(.admonition, details)[class] {
  --ea-state: var(--ea-accent);

  background-color: transparent;
  border: 1px solid var(--ea-border-subtle);
  border-left: 2px solid var(--ea-state);
  border-radius: 0;
  box-shadow: none;
  font-size: 0.72rem;
}

.md-typeset :is(.admonition, details):is(.success, .check, .done)[class] {
  --ea-state: var(--ea-success);
}

.md-typeset :is(.admonition, details):is(.warning, .caution, .attention)[class] {
  --ea-state: var(--ea-warning);
}

.md-typeset :is(.admonition, details):is(.danger, .error, .failure, .fail, .missing, .bug)[class] {
  --ea-state: var(--ea-error);
}

.md-typeset :is(.admonition, details):is(.example, .quote, .cite)[class] {
  --ea-state: var(--ea-text-muted);
}

.md-typeset :is(.admonition, details)[class] > :is(.admonition-title, summary) {
  background-color: transparent;
  border-bottom: 1px solid var(--ea-border-subtle);
  color: var(--ea-state);
  font-family: var(--font-mono);
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  margin: 0 -0.6rem;
  padding-bottom: 0.5rem;
  padding-top: 0.5rem;
  text-transform: uppercase;
}

.md-typeset :is(.admonition, details)[class] > :is(.admonition-title, summary)::before {
  background-color: var(--ea-state);
  height: 0.8rem;
  top: 0.55rem;
  width: 0.8rem;
}

.md-typeset :is(.admonition, details)[class] > :is(.admonition-title, summary)::after {
  color: var(--ea-state);
}

/* ---------------------------------------------------------------------------------------------------------------------
 * Buttons and the back-to-top control
 * ------------------------------------------------------------------------------------------------------------------ */

.md-typeset .md-button {
  background-color: transparent;
  border: 1px solid var(--ea-border-interactive);
  border-radius: 0;
  color: var(--ea-text-primary);
  font-family: var(--font-mono);
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  padding: 0.6rem 0.8rem;
  text-decoration: none;
  text-transform: uppercase;
  transition: color var(--ea-transition), background-color var(--ea-transition), border-color var(--ea-transition);
}

.md-typeset .md-button:is(:focus, :hover) {
  background-color: transparent;
  border-color: var(--ea-accent);
  color: var(--ea-accent);
}

.md-typeset .md-button--primary {
  background-color: var(--ea-text-primary);
  border-color: var(--ea-text-primary);
  color: var(--ea-bg-base);
}

.md-typeset .md-button--primary:is(:focus, :hover) {
  background-color: var(--ea-accent);
  border-color: var(--ea-accent);
  color: var(--ea-bg-base);
}

.md-top {
  border: 1px solid var(--ea-border-interactive);
  border-radius: 0;
  box-shadow: none;
  color: var(--ea-text-secondary);
  font-family: var(--font-mono);
  font-size: 0.55rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.md-top:is(:focus, :hover) {
  background-color: var(--ea-bg-base);
  border-color: var(--ea-accent);
  color: var(--ea-accent);
}

/* ---------------------------------------------------------------------------------------------------------------------
 * Content tabs
 * ------------------------------------------------------------------------------------------------------------------ */

.md-typeset .tabbed-labels {
  border-bottom: 1px solid var(--ea-border-subtle);
  box-shadow: none;
}

.md-typeset .tabbed-labels > label {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ---------------------------------------------------------------------------------------------------------------------
 * Footer: previous and next pages, then the meta line
 * ------------------------------------------------------------------------------------------------------------------ */

.md-footer {
  border-top: 1px solid var(--ea-border-subtle);
}

.md-footer__direction {
  color: var(--ea-text-muted);
  font-family: var(--font-mono);
  font-size: 0.55rem;
  letter-spacing: 0.14em;
  opacity: 1;
  text-transform: uppercase;
}

.md-footer__title {
  font-weight: 650;
}

.md-footer-meta {
  border-top: 1px solid var(--ea-border-subtle);
}

.md-copyright {
  color: var(--ea-text-muted);
  font-family: var(--font-mono);
  font-size: 0.55rem;
  letter-spacing: 0.06em;
}

/* ---------------------------------------------------------------------------------------------------------------------
 * Section strips (spec sections 7 and 0.8). Only on overview pages, set per heading with attr_list:
 *   ## Where to start { .ea-strip data-index="01" data-note="Six entry points" }
 * ------------------------------------------------------------------------------------------------------------------ */

.md-typeset h2.ea-strip {
  align-items: center;
  border-bottom: 1px solid var(--ea-border-subtle);
  border-top: 1px solid var(--ea-border-subtle);
  color: var(--ea-text-muted);
  display: flex;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 600;
  gap: 0.5rem;
  letter-spacing: 0.14em;
  line-height: 1.3;
  margin: 3.2rem calc(-1 * (var(--ea-gutter) + var(--ea-inset-right))) 1.6rem
    calc(-1 * (var(--ea-gutter) + var(--ea-inset-left)));
  max-width: none;
  min-height: 2.2rem;
  padding: 0.5rem calc(var(--ea-gutter) + var(--ea-inset-right)) 0.5rem calc(var(--ea-gutter) + var(--ea-inset-left));
  position: relative;
  text-transform: uppercase;
}

.md-typeset h2.ea-strip[data-index]::before {
  content: attr(data-index) "\00a0/";
}

.md-typeset h2.ea-strip[data-note]::after {
  content: attr(data-note);
  margin-left: auto;
  text-align: right;
}

.md-typeset h2.ea-strip .headerlink {
  margin-left: 0;
}

/* A strip followed directly by a grid shares its bottom rule with the grid. */
.md-typeset h2.ea-strip + .grid {
  border-top: 0;
  margin-top: -1.6rem;
}

@media screen and (max-width: 44.984375em) {
  .md-typeset h2.ea-strip[data-note]::after {
    display: none;
  }
}

/* ---------------------------------------------------------------------------------------------------------------------
 * Grids of cells (spec sections 6 and 8). Material's `grid cards` markup becomes one continuous grid with shared
 * borders. The outer block draws the top and bottom rules from frame to frame; the list inside it is the grid, inset
 * like the text, and each cell draws its right and bottom rule, which the list clips at its outer edge. Cells pad
 * their text by the gutter, so it lines up with the prose above and below.
 * ------------------------------------------------------------------------------------------------------------------ */

.md-typeset .grid.cards {
  border-bottom: 1px solid var(--ea-border-subtle);
  border-top: 1px solid var(--ea-border-subtle);
  display: block;
  margin: 1.6rem calc(-1 * (var(--ea-gutter) + var(--ea-inset-right))) 1.6rem
    calc(-1 * (var(--ea-gutter) + var(--ea-inset-left)));
  max-width: none;
  padding: 0 var(--ea-inset-right) 0 var(--ea-inset-left);
}

.md-typeset .grid.cards > :is(ul, ol) {
  counter-reset: ea-cell;
  display: grid;
  gap: 0;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
  list-style: none;
  margin: 0;
  overflow: hidden;
  padding: 0;
}

/*
 * Where an empty sidebar margin moves the grid in from the frame, the grid closes its outer edge with its own rule,
 * drawn just outside the margin so that the cells' text keeps its alignment.
 */
@media screen and (min-width: 76.25em) {
  .md-sidebar--primary[hidden] ~ .md-content .md-typeset .grid.cards > :is(ul, ol) {
    border-left: 1px solid var(--ea-border-subtle);
    margin-left: -1px;
  }

  .md-sidebar--secondary[hidden] ~ .md-content .md-typeset .grid.cards > :is(ul, ol) {
    border-right: 1px solid var(--ea-border-subtle);
    margin-right: -1px;
  }
}

.md-typeset .grid.cards > :is(ul, ol) > li {
  border: 0;
  border-radius: 0;
  box-shadow: 1px 0 0 var(--ea-border-subtle), 0 1px 0 var(--ea-border-subtle);
  counter-increment: ea-cell;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 1.4rem var(--ea-gutter) 1.6rem;
  position: relative;
  transition: background-color var(--ea-transition);
}

.md-typeset .grid.cards > :is(ul, ol) > li:is(:hover, :focus-within) {
  background-color: var(--ea-bg-surface-1);
  border-color: transparent;
  box-shadow: 1px 0 0 var(--ea-border-subtle), 0 1px 0 var(--ea-border-subtle);
}

/*
 * A cell whose title is a link is a link as a whole: the title link stretches over the cell. Other links in the cell
 * (a button, a link in the description) stay above it and keep their own targets.
 */
.md-typeset .grid.cards > :is(ul, ol) > li > p:first-of-type > a:only-child::after {
  content: "";
  inset: 0;
  position: absolute;
}

.md-typeset .grid.cards > :is(ul, ol) > li a:not(p:first-of-type > a:only-child) {
  position: relative;
  z-index: 1;
}

.md-typeset .grid.cards > :is(ul, ol) > li:has(> p:first-of-type > a:only-child):hover > p:first-of-type > a {
  color: var(--ea-accent);
}

/* The stretched link gives the cell its focus ring, so a keyboard user sees the whole cell selected. */
.md-typeset .grid.cards > :is(ul, ol) > li > p:first-of-type > a:only-child:focus-visible {
  outline: none;
}

.md-typeset .grid.cards > :is(ul, ol) > li > p:first-of-type > a:only-child:focus-visible::after {
  outline: 1px solid var(--ea-accent);
  outline-offset: -2px;
}

/* The cell index: A, B, C in a list; 01, 02, 03 in a numbered list. */
.md-typeset .grid.cards > :is(ul, ol) > li::before {
  color: var(--ea-text-muted);
  content: counter(ea-cell, upper-alpha);
  font-family: var(--font-mono);
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  margin-bottom: 1.2rem;
}

.md-typeset .grid.cards > ol > li::before {
  content: counter(ea-cell, decimal-leading-zero);
}

.md-typeset .grid.cards > :is(ul, ol) > li > :first-child {
  margin-top: 0;
}

.md-typeset .grid.cards > :is(ul, ol) > li > p {
  max-width: 34rem;
}

/* The first line of a cell is its title. */
.md-typeset .grid.cards > :is(ul, ol) > li > p:first-of-type {
  color: var(--ea-text-primary);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 0.6rem;
}

.md-typeset .grid.cards > :is(ul, ol) > li > p:first-of-type a {
  color: inherit;
}

.md-typeset .grid.cards > :is(ul, ol) > li > p:first-of-type a:is(:focus, :hover) {
  color: var(--ea-accent);
}

/* A cell's button sits at its bottom edge, so the buttons of a row line up. */
.md-typeset .grid.cards > :is(ul, ol) > li > p:last-child:has(> .md-button) {
  margin-bottom: 0;
  margin-top: auto;
  padding-top: 0.6rem;
}

/* Compact cells: the numbered reading lists of the section index pages. */
.md-typeset .grid.cards.compact > :is(ul, ol) > li {
  padding: 1.1rem var(--ea-gutter) 1.2rem;
}

.md-typeset .grid.cards.compact > :is(ul, ol) > li::before {
  margin-bottom: 0.8rem;
}

.md-typeset .grid.cards.compact > :is(ul, ol) > li > p:first-of-type {
  font-size: 0.9rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin-bottom: 0.4rem;
}

.md-typeset .grid.cards.compact > :is(ul, ol) > li > p {
  font-size: 0.72rem;
  margin-bottom: 0;
}

/* ---------------------------------------------------------------------------------------------------------------------
 * Landing hero (spec sections 17 and 0.7)
 * ------------------------------------------------------------------------------------------------------------------ */

.md-typeset .ea-hero {
  container-type: inline-size;
  padding: 2.4rem 0 3.2rem;
}

/* Sized to the hero's own width: "Generate building energy models" is about 15.2 em wide, so 6.2cqi keeps it on one line. */
.md-typeset .ea-hero h1 {
  font-size: clamp(1.6rem, 6.2cqi, 3.2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.02;
  margin: 0 0 1.6rem;
}

.md-typeset .ea-hero h1 em {
  font-family: var(--font-serif);
  font-size: 1.1em;
  font-style: italic;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.md-typeset .ea-hero h1 .headerlink {
  display: none;
}

.md-typeset .ea-hero p {
  color: var(--ea-text-secondary);
  font-size: 0.9rem;
  line-height: 1.6;
  margin: 0;
  max-width: 32rem;
}

/* ---------------------------------------------------------------------------------------------------------------------
 * Motion: none for visitors who ask for less
 * ------------------------------------------------------------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
