/* Text-mode interaction uses colour and inverse video rather than web-style underlines. */
a,
.text-button,
u {
  text-decoration: none !important;
}

/* Leave one terminal row between the blue title bar and page output. */
.document {
  padding-top: var(--cell-h);
}

/*
 * Command-origin navigation focuses the hidden home heading for accessibility.
 * Do not project that focus state onto the visible ASCII banner as an inversion.
 */
.home-name-heading:focus-visible + .home-name-banner-shell {
  filter: none !important;
}

/* The command row is terminal chrome: blue field, yellow input text, and no separator rule. */
.prompt-line {
  background: var(--blue);
  color: var(--white);
}

.prompt-line::before {
  content: none;
}

.prompt-prefix {
  background: var(--blue);
  color: var(--white);
}

.command-input,
.command-input:focus,
.command-input:focus-visible {
  --pair-foreground: var(--yellow);
  --pair-background: var(--blue);
  background: var(--blue) !important;
  color: var(--yellow) !important;
  caret-color: var(--white) !important;
  outline: 0 !important;
}

.command-input::placeholder {
  color: var(--yellow);
  opacity: 1;
}

/*
 * Status telemetry occupies four integer character-grid tracks. Line position is
 * anchored left, grid and cell telemetry are centred, and Colophon is anchored
 * right. Hidden tiers retain the same four-track geometry rather than clustering.
 */
.status-line {
  display: grid;
  grid-template-columns:
    var(--status-track-1, 1fr)
    var(--status-track-2, 1fr)
    var(--status-track-3, 1fr)
    var(--status-track-4, 1fr);
  align-items: center;
  justify-content: stretch;
  gap: 0;
}

.status-left,
.status-centre,
.status-right {
  display: none !important;
}

.status-data {
  min-width: 0;
  overflow: visible;
  white-space: nowrap;
}

.status-data-line {
  grid-column: 1;
  justify-self: start;
  text-align: left;
}

.status-data-grid {
  grid-column: 2;
  justify-self: center;
  text-align: center;
}

.status-data-cell {
  grid-column: 3;
  justify-self: center;
  text-align: center;
}

.status-colophon {
  grid-column: 4;
  justify-self: end;
  min-width: max-content;
  margin-left: 0;
  overflow: visible;
  white-space: nowrap;
  text-align: right;
}

.status-line[data-status-tier="no-cell"] .status-data-grid {
  grid-column: 2 / 4;
}

.status-line[data-status-tier="no-grid"] .status-data-line {
  grid-column: 1 / 4;
}

/* Route context lives in the title-bar breadcrumb, not as a duplicate page-body line. */
.location-line {
  display: none !important;
}

/*
 * Primary navigation uses fixed terminal fields rather than variable-width web links.
 * Each link occupies exactly 12 EGA columns and the single-column gap is preserved
 * when rows wrap. terminal-chrome.js pads the command inside the literal brackets.
 */
.primary-menu {
  gap: 0 var(--cell-w);
  align-items: flex-start;
}

.primary-menu::before {
  content: none;
}

.primary-menu a {
  display: inline-flex;
  flex: 0 0 calc(12 * var(--cell-w));
  width: calc(12 * var(--cell-w));
  min-width: calc(12 * var(--cell-w));
  max-width: calc(12 * var(--cell-w));
  align-items: flex-start;
  padding: 0;
  overflow: hidden;
  white-space: pre;
}

.primary-menu a[aria-current="page"] {
  --pair-foreground: var(--black);
  --pair-background: var(--cyan);
  background: var(--pair-background);
  color: var(--pair-foreground);
}

/*
 * On the six primary top-level pages, the breadcrumb plus active primary-menu
 * field are the visible page heading. Keep the semantic H1 focusable for route
 * accessibility, but give it no visible box or terminal-grid footprint.
 * Sub-pages have no active primary-menu field and retain their visible H1.
 */
.primary-menu:has(a[aria-current="page"]) + article > #page-title {
  position: absolute !important;
  width: 0 !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.top-breadcrumbs {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  overflow: hidden;
  white-space: nowrap;
  background: var(--blue);
}

.top-breadcrumbs .top-title,
.top-breadcrumbs .top-route,
.top-breadcrumbs .top-breadcrumb-link,
.top-breadcrumbs .top-breadcrumb-current,
.top-breadcrumbs .top-breadcrumb-separator {
  min-width: 0;
  line-height: var(--cell-h);
}

.top-breadcrumbs .top-title {
  flex: 0 0 auto;
  color: var(--yellow);
}

.top-breadcrumbs .top-route {
  flex: 0 1 auto;
  display: flex;
  align-items: center;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: clip;
}

.top-breadcrumb-separator,
.top-breadcrumb-current {
  color: var(--white);
}

.top-title.top-breadcrumb-current {
  color: var(--yellow);
}

.top-breadcrumb-link {
  --pair-foreground: var(--white);
  --pair-background: var(--blue);
  display: inline-block;
  color: var(--pair-foreground);
  background: var(--pair-background);
}

.top-title.top-breadcrumb-link {
  --pair-foreground: var(--yellow);
  --pair-background: var(--blue);
}

.top-breadcrumb-link:hover,
.top-breadcrumb-link:focus-visible {
  outline: 0;
  color: var(--pair-background);
  background: var(--pair-foreground);
}

.top-mode:empty {
  display: none;
}

/* Utility commands keep the core diagnostic markup for validation, but render as a shell transcript. */
.transient-output,
.transient-output[data-kind="error"] {
  color: var(--white);
}

.terminal-core-utility .row-reveal-mask {
  visibility: hidden !important;
}

.terminal-core-utility .transient-output > :not(.terminal-log):not(.terminal-compat-data) {
  visibility: hidden !important;
}

.terminal-log,
.terminal-entry,
.terminal-echo,
.terminal-result {
  margin: 0;
  padding: 0;
}

.terminal-echo {
  color: var(--green);
  white-space: pre-wrap;
}

.terminal-result {
  color: var(--white);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.terminal-entry[data-kind="error"] .terminal-result {
  color: var(--red);
}

.terminal-entry[data-kind="completion"] .terminal-result {
  color: var(--cyan);
}

.terminal-compat-data {
  display: none !important;
}

/*
 * Narrow layouts remove the stage padding. Preserve the accepted 1px inset
 * outline contract and add a second inset frame overlay above the terminal
 * children, so the left/right edge remains visibly continuous around the
 * two-row command area without changing cell geometry.
 */
@media (max-width: 720px) {
  .terminal {
    outline: 1px solid var(--white);
    outline-offset: -1px;
  }

  .terminal::after {
    content: "";
    position: absolute;
    z-index: 40;
    inset: 0;
    border: 1px solid var(--white);
    pointer-events: none;
  }
}
