/* The stylesheet of every page gherkin-glass writes. Colour and emphasis never
   carry meaning alone: every state is also said in words or in the markup. */

/* The colours are the themes' tokens, --ghg-*, which every page defines in
   its head, since the accent colours are set for each site. */

body {
  margin: 0;
  background: var(--ghg-background);
  color: var(--ghg-text);
  font-family: system-ui, sans-serif;
  line-height: 1.5;
}

main {
  max-width: 60rem;
  margin: 0 auto;
  padding: 1rem;
}

/* A link is underlined, so that colour is not all that tells it apart. */
a {
  color: var(--ghg-accent);
  text-decoration: underline;
}

:focus-visible {
  outline: 3px solid var(--ghg-accent);
  outline-offset: 2px;
}

h1, h2, h3, h4, h5 {
  line-height: 1.25;
  margin: 1.5rem 0 0.5rem;
}

/* The disclosure button reads as its heading, with a marker that shows its state. */
.ghg-toggle {
  all: inherit;
  margin: 0;
  cursor: pointer;
}

.ghg-toggle::before {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  margin-right: 0.5em;
  vertical-align: middle;
  border-style: solid;
  border-width: 0.4em 0 0.4em 0.6em;
  border-color: transparent transparent transparent currentColor;
  transition: transform 0.1s;
}

.ghg-toggle[aria-expanded="true"]::before {
  transform: rotate(90deg);
}

/* After `all: inherit`, which would take the heading's outline. */
.ghg-toggle:focus-visible {
  outline: 3px solid var(--ghg-accent);
  outline-offset: 2px;
}

/* Forced colours would make every border of the marker opaque, a box in either state. */
@media (forced-colors: active) {
  .ghg-toggle::before {
    forced-color-adjust: none;
    border-color: transparent transparent transparent ButtonText;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ghg-toggle::before {
    transition: none;
  }
}

.ghg-block {
  border-left: 1px solid var(--ghg-border);
  padding-left: 1rem;
}

.ghg-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  list-style: none;
  margin: 0.25rem 0;
  padding: 0;
  color: var(--ghg-muted);
}

.ghg-description p {
  margin: 0.5rem 0;
}

.ghg-steps {
  padding-left: 1.5rem;
}

/* Highlighting only colours text that already says what it is. */
.ghg-keyword {
  font-weight: bold;
  color: var(--ghg-keyword);
}

.ghg-parameter {
  color: var(--ghg-parameter);
}

.ghg-number {
  color: var(--ghg-number);
}

.ghg-placeholder {
  color: var(--ghg-placeholder);
}

.ghg-table {
  border-collapse: collapse;
  margin: 0.5rem 0;
}

.ghg-table th,
.ghg-table td {
  border: 1px solid var(--ghg-border);
  padding: 0.25rem 0.5rem;
  text-align: left;
}

.ghg-doc-string {
  margin: 0.5rem 0;
}

pre {
  background: var(--ghg-surface);
  padding: 0.5rem;
  overflow-x: auto;
}

figcaption {
  color: var(--ghg-muted);
  font-family: monospace;
}

.ghg-controls {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0;
}

.ghg-controls button,
.ghg-from-disk button {
  font: inherit;
  padding: 0.25rem 0.75rem;
  background: var(--ghg-surface);
  color: var(--ghg-text);
  border: 1px solid var(--ghg-border);
  border-radius: 0.25rem;
  cursor: pointer;
}

/* The breadcrumb's separators are drawn, not written, so that a screen reader
   says only the links, as the WAI-ARIA breadcrumb example does. */
.ghg-breadcrumb {
  max-width: 60rem;
  margin: 0 auto;
  padding: 1rem 1rem 0;
}

.ghg-breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  list-style: none;
  margin: 0;
  padding: 0;
}

.ghg-breadcrumb li + li::before {
  content: "";
  display: inline-block;
  height: 0.8em;
  margin: 0 0.5em;
  border-right: 0.1em solid currentColor;
  transform: rotate(15deg);
}

.ghg-breadcrumb [aria-current="page"] {
  font-weight: bold;
}

.ghg-features > li {
  margin: 0.25rem 0;
}

.ghg-feature > .ghg-toggle,
.ghg-count {
  display: inline;
  margin-left: 0.5em;
}

.ghg-count {
  color: var(--ghg-muted);
}

/* The skip link is out of sight until it has the focus. */
.ghg-skip {
  position: absolute;
  left: 0.5rem;
  top: -100rem;
  z-index: 1;
  padding: 0.5rem 1rem;
  background: var(--ghg-background);
  color: var(--ghg-accent);
}

.ghg-skip:focus {
  top: 0.5rem;
}

.ghg-from-disk {
  max-width: 36rem;
  padding: 1rem 1.5rem;
  border: 2px solid var(--ghg-border);
  background: var(--ghg-background);
  color: var(--ghg-text);
}

.ghg-from-disk::backdrop {
  background: rgb(0 0 0 / 50%);
}

.ghg-from-disk-title {
  font-weight: bold;
}

.ghg-options {
  padding: 0.5rem 1rem 0;
}

.ghg-theme {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  margin: 0 0 0 1rem;
  border: 1px solid var(--ghg-border);
}

.ghg-theme input {
  accent-color: var(--ghg-accent);
}

/* The folder tree beside the content, or above it on a window narrower than
   48em, the width script/src/policies/tree_state.ts's NARROW names too. */
.ghg-layout {
  display: flex;
  align-items: flex-start;
}

.ghg-tree {
  flex: 0 0 18rem;
  box-sizing: border-box;
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow: auto;
  padding: 1rem;
  border-right: 1px solid var(--ghg-border);
}

.ghg-tree[hidden] {
  display: none;
}

.ghg-page {
  flex: 1 1 auto;
  min-width: 0;
}

@media not all and (min-width: 48em) {
  .ghg-layout {
    display: block;
  }

  .ghg-tree {
    position: static;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--ghg-border);
  }
}

.ghg-treeview,
.ghg-treeview ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ghg-treeview ul {
  padding-left: 1rem;
}

/* An item without a marker starts where the text of one with a marker does. */
.ghg-treeview [role="treeitem"] {
  display: block;
  padding: 0.125rem 0.25rem 0.125rem 1.75rem;
  text-decoration: none;
}

.ghg-treeview [role="treeitem"]:hover {
  text-decoration: underline;
}

.ghg-treeview [role="treeitem"][aria-owns] {
  padding-left: 0.25rem;
}

.ghg-treeview [aria-current="page"] {
  font-weight: bold;
}

.ghg-marker {
  display: inline-block;
  /* At least 24 by 24 pixels, as WCAG 2.2's target size asks. */
  width: 1.5rem;
  min-height: 1.5rem;
  text-align: center;
  cursor: pointer;
}

.ghg-marker::before {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  vertical-align: middle;
  border-style: solid;
  border-width: 0.4em 0 0.4em 0.6em;
  border-color: transparent transparent transparent currentColor;
  transition: transform 0.1s;
}

[aria-expanded="true"] > .ghg-marker::before {
  transform: rotate(90deg);
}

@media (forced-colors: active) {
  .ghg-marker::before {
    forced-color-adjust: none;
    border-color: transparent transparent transparent LinkText;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ghg-marker::before {
    transition: none;
  }
}

.ghg-option {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

/* The steps a scenario takes from a background, set apart by a tint; the words before them say where they come from. */
.ghg-from-background {
  margin: 0.5rem 0;
  padding: 0.25rem 0.75rem;
  background: var(--ghg-surface);
}

.ghg-from-background p {
  margin: 0.25rem 0;
  color: var(--ghg-muted);
}

.ghg-from-background .ghg-steps {
  margin: 0.25rem 0;
}

/* A doc string keeps its box inside the tint. */
.ghg-from-background pre {
  background: var(--ghg-background);
}
