/*
 * The organism: what a website's organism draws in the visitor's browser, in
 * the site's own manner. `components/frame.ts` draws the landing a link opens
 * and the screen around a lobe; `organism.ts`, `lobe.ts` and `data.ts` draw
 * what a lobe that has no draw of its own says of itself. They are the head
 * of the site, the reading column, hairlines in place of cards, the mono for
 * every label and every byte, and the one red for where a reader acts.
 *
 * Every selector names a class, since the lobes layer styles no element by
 * its name alone, and every value is a slot of the tokens, so both themes
 * follow. `.rubric-root` is the frame's root: it wears `.nv-viewport`, which
 * carries the base, so a page drawn of `frame` alone has the site's faces,
 * colours and ground without a sheet of its own. The home's own sheet
 * (`window.css`) is the other layer and dresses nothing a tree draws.
 */

/* ---- the ground ------------------------------------------------------ */

/*
 * A page whose body holds the frame's root is that page's whole ground: no
 * margin of the engine's, the site's paper under the root and behind an
 * overscroll. Inside a shadow root nothing matches, and `:host` paints its
 * own.
 */
body:has(> .rubric-root) {
  margin: 0;
}

:root:has(> body > .rubric-root) {
  background: var(--nv-color-bg);
  color-scheme: light dark;
}

:root[data-theme='light']:has(> body > .rubric-root) {
  color-scheme: light;
}

:root[data-theme='dark']:has(> body > .rubric-root) {
  color-scheme: dark;
}

/* ---- the frame ------------------------------------------------------- */

/*
 * `.rubric-root` is the frame's room: the column is the site's wide one, the head and the main at one edge, and
 * the gutter at its sides is the site's, a step wider once the room has it.
 * The header and the main share one left edge, and the header's hairline
 * runs the room's whole width.
 */
.rubric-root {
  --rubric-gutter: 1rem;
  --rubric-column: 75rem;

  display: block;
  min-width: 0;
}

@container qs-page (min-width: 48rem) {
  .rubric-frame,
  .rubric-root > main,
  .rubric-root > .qs-app-tools {
    --rubric-gutter: 1.5rem;
  }
}

.rubric-frame,
.rubric-root > main,
.rubric-root > .qs-app-tools {
  padding-inline: max(
    var(--rubric-gutter),
    calc((100% - var(--rubric-column)) / 2 + var(--rubric-gutter))
  );
}

.rubric-frame {
  padding-block: var(--nv-space-3, 0.75rem) var(--nv-space-6, 2rem);
  border-bottom: 1px solid var(--nv-color-border);
  background: var(--nv-color-bg);
}

/* The head's line: the mark home, then the route as quiet words after it. */
.rubric-bar {
  display: flex;
  gap: var(--nv-space-3, 0.75rem);
  align-items: center;
  min-width: 0;
}

.rubric-mark {
  display: flex;
  flex: none;
  align-items: center;
  color: var(--nv-color-fg);
}

.rubric-mark svg {
  display: block;
  width: auto;
  height: 1.75rem;
}

.rubric-route {
  display: flex;
  flex-wrap: wrap;
  gap: var(--nv-space-1, 0.25rem) var(--nv-space-3, 0.75rem);
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--nv-font-mono);
  font-size: var(--nv-text-xs, 0.75rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--nv-color-fg);
}

.rubric-route li::before {
  content: '/';
  margin-inline-end: var(--nv-space-3, 0.75rem);
  color: var(--nv-color-fg-subtle);
}

.rubric-route a {
  color: var(--nv-color-fg-muted);
  text-decoration: none;
}

.rubric-route a:hover {
  color: var(--nv-color-accent);
}

.rubric-back {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  margin-block-start: var(--nv-space-2, 0.5rem);
  font-family: var(--nv-font-mono);
  font-size: var(--nv-text-xs, 0.75rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--nv-color-fg-muted);
  text-decoration: none;
}

.rubric-back::before {
  content: '\2190';
  margin-inline-end: var(--nv-space-2, 0.5rem);
}

.rubric-back:hover {
  color: var(--nv-color-accent);
}

/* The title, in the display face at the measure the site's titles keep. */
.rubric-title {
  max-width: 20ch;
  margin: var(--nv-space-6, 2rem) 0 0;
  font-family: var(--nv-font-display);
  font-size: var(--nv-text-5xl, clamp(2rem, 1.5rem + 2.6vw, 3.5rem));
  font-weight: var(--nv-weight-normal, 400);
  line-height: var(--nv-leading-display, 1.05);
  letter-spacing: -0.01em;
  text-wrap: balance;
  color: var(--nv-color-fg);
}

/* What the home says that the person must read: a hairline box, a rule in the danger ink. */
.rubric-warnings {
  display: grid;
  gap: var(--nv-space-2, 0.5rem);
  margin: var(--nv-space-4, 1rem) 0 0;
  padding: 0;
  list-style: none;
}

.rubric-warning {
  padding: var(--nv-space-2, 0.5rem) var(--nv-space-3, 0.75rem);
  border: 1px solid var(--nv-color-border-strong);
  border-inline-start: 3px solid var(--nv-color-danger);
  border-radius: var(--nv-radius-md);
  background: var(--nv-color-bg-raised);
  font-size: var(--nv-text-sm, 0.875rem);
  color: var(--nv-color-fg);
}

/* The main: the reading column, the text at its measure, the first sentence the statement. */
.rubric-root > main {
  padding-block: var(--nv-space-7, 3rem) var(--nv-space-8, 4rem);
  min-width: 0;
}

.rubric-root > main p {
  max-width: 62ch;
}

.rubric-root > main > div > p:first-child {
  font-size: var(--nv-text-xl, 1.25rem);
  color: var(--nv-color-fg);
}

/* ---- what a lobe says of itself -------------------------------------- */

/*
 * `.rubric-page` is a page of the describe look: an organism's, a lobe's.
 * Its headings are the site's: the display face for the name, a mono kicker
 * over a hairline for each part.
 */
.rubric-page {
  display: block;
  min-width: 0;
}

.rubric-page h2 {
  margin: 0 0 var(--nv-space-3, 0.75rem);
  font-size: var(--nv-text-4xl, clamp(2rem, 1.55rem + 2vw, 2.625rem));
  font-weight: var(--nv-weight-normal, 400);
  line-height: var(--nv-leading-tight, 1.2);
  letter-spacing: -0.015em;
}

.rubric-page h3 {
  margin: var(--nv-space-7, 3rem) 0 0;
  padding-block-end: var(--nv-space-2, 0.5rem);
  border-bottom: 1px solid var(--nv-color-border-strong);
  font-family: var(--nv-font-mono);
  font-size: var(--nv-text-xs, 0.75rem);
  font-weight: var(--nv-weight-medium, 500);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--nv-color-fg-muted);
}

/* A method is a name, so it is set as a byte is. */
.rubric-page h4 {
  margin: 0 0 var(--nv-space-1, 0.25rem);
  font-family: var(--nv-font-mono);
  font-size: var(--nv-text-base, 1rem);
  font-weight: var(--nv-weight-medium, 500);
  letter-spacing: 0;
  color: var(--nv-color-fg);
}

.rubric-page p {
  margin: 0 0 var(--nv-space-3, 0.75rem);
}

.rubric-page small {
  font-family: var(--nv-font-mono);
  font-size: var(--nv-text-xs, 0.75rem);
}

.rubric-page + .rubric-page {
  margin-block-start: var(--nv-space-8, 4rem);
}

/* A row of presses, a page's turn: side by side. */
.rubric-page p:has(> .rubric-button) {
  display: flex;
  flex-wrap: wrap;
  gap: var(--nv-space-3, 0.75rem);
}

.rubric-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.rubric-item {
  padding-block: var(--nv-space-4, 1rem);
  border-bottom: 1px solid var(--nv-color-border);
}

.rubric-item > :last-child {
  margin-block-end: 0;
}

.rubric-link {
  color: var(--nv-color-fg);
  font-weight: var(--nv-weight-medium, 500);
  text-decoration: none;
}

a.rubric-link:hover {
  color: var(--nv-color-accent);
  text-decoration: underline;
}

.rubric-muted {
  color: var(--nv-color-fg-muted);
}

.rubric-item > small.rubric-muted {
  margin-inline-start: var(--nv-space-2, 0.5rem);
  font-family: var(--nv-font-mono);
}

.rubric-worn {
  font-family: var(--nv-font-mono);
  font-size: var(--nv-text-xs, 0.75rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--nv-color-fg-muted);
}

/* The About fold and a writing method's summary: a mono word, with a thumb's height. */
.rubric-item summary {
  display: flex;
  align-items: center;
  min-height: 2.75rem;
  font-family: var(--nv-font-mono);
  font-size: var(--nv-text-sm, 0.875rem);
  color: var(--nv-color-fg);
  cursor: pointer;
}

.rubric-item summary:hover {
  color: var(--nv-color-accent);
}

.rubric-item details > p {
  margin-block-start: var(--nv-space-2, 0.5rem);
}

/* ---- a form, and its press ------------------------------------------- */

.rubric-write {
  display: grid;
  gap: var(--nv-space-4, 1rem);
  margin: var(--nv-space-3, 0.75rem) 0 0;
  padding: var(--nv-space-4, 1rem);
  border: 1px solid var(--nv-color-border);
  border-radius: var(--nv-radius-md);
  background: var(--nv-color-bg-raised);
}

.rubric-write legend {
  padding-inline: var(--nv-space-2, 0.5rem);
  font-family: var(--nv-font-mono);
  font-size: var(--nv-text-xs, 0.75rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--nv-color-fg-muted);
}

.rubric-field {
  display: grid;
  gap: var(--nv-space-1, 0.25rem);
}

.rubric-field label {
  font-family: var(--nv-font-mono);
  font-size: var(--nv-text-sm, 0.875rem);
  color: var(--nv-color-fg);
}

.rubric-field input,
.rubric-field select,
.rubric-field textarea {
  width: 100%;
  max-width: 28rem;
  min-height: 2.75rem;
  padding: var(--nv-space-2, 0.5rem) var(--nv-space-3, 0.75rem);
  border: 1px solid var(--nv-color-border-strong);
  border-radius: var(--nv-radius-md);
  background: var(--nv-color-bg);
  font-family: var(--nv-font-mono);
  font-size: max(var(--nv-text-input, 1rem), 16px);
  color: var(--nv-color-fg);
}

.rubric-field input[type='checkbox'] {
  width: 1.25rem;
  min-height: 1.25rem;
  height: 1.25rem;
  accent-color: var(--nv-color-accent);
}

.rubric-field input:focus,
.rubric-field select:focus,
.rubric-field textarea:focus {
  border-color: var(--nv-color-accent);
}

.rubric-field small {
  color: var(--nv-color-fg-muted);
}

/* At home, where the person holds no place: the home's words for how one comes, in the body's face, a little larger, the
   first thing read under the heading. */
.rubric-lead {
  max-width: 40rem;
  margin: var(--nv-space-3, 0.75rem) 0 0;
  font-size: var(--nv-text-lg, 1.125rem);
  line-height: 1.5;
  color: var(--nv-color-fg);
}

/* The link a move gave, to copy: no card, the field under its label and the press beside it, the two of one height on one
   line, wrapping on a phone; the field mono and broken nowhere, its text scrolled within it. */
.rubric-copy {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: var(--nv-space-2, 0.5rem);
  align-items: flex-end;
  max-width: 40rem;
  margin: var(--nv-space-3, 0.75rem) 0 0;
  padding: 0;
  border: 0;
  min-inline-size: 0;
}

.rubric-copy .rubric-field {
  flex: 1 1 14rem;
}

.rubric-copy .rubric-field input {
  max-width: none;
  height: 2.75rem;
  font-family: var(--nv-font-mono);
}

.rubric-copy .rubric-button {
  margin-block-start: 0;
}

/* A link taken by hand at home lays as the moved link does, its label across the row above the field and the press, so it
   is never cut short beside them on a phone; its press the red one, since it is where the person acts. */
.rubric-take .rubric-field {
  display: contents;
}

.rubric-take .rubric-field label {
  flex: 1 1 100%;
}

.rubric-take .rubric-field input {
  flex: 1 1 14rem;
  min-width: 0;
}

.rubric-take .rubric-button {
  border-color: var(--nv-color-accent);
  background: var(--nv-color-accent);
  color: var(--nv-color-fg-on-accent);
}

.rubric-take .rubric-button:hover {
  border-color: var(--nv-color-accent-hover);
  background: var(--nv-color-accent-hover);
  color: var(--nv-color-fg-on-accent);
}

/*
 * A button is an action, as the site's are: a mono word in a hairline box,
 * and the one that writes filled in the accent, because red is where a
 * reader acts.
 */
.rubric-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  margin-block-start: var(--nv-space-2, 0.5rem);
  padding: 0 var(--nv-space-5, 1.5rem);
  border: 1px solid var(--nv-color-border-strong);
  border-radius: var(--nv-radius-md);
  background: transparent;
  font-family: var(--nv-font-mono);
  font-size: var(--nv-text-sm, 0.875rem);
  color: var(--nv-color-fg);
  cursor: pointer;
}

.rubric-button:hover {
  border-color: var(--nv-color-accent);
  color: var(--nv-color-accent);
}

.rubric-link + .rubric-button {
  margin-block-start: 0;
  margin-inline-start: var(--nv-space-3, 0.75rem);
}

.rubric-write .rubric-button {
  justify-self: start;
  margin-block-start: 0;
  border-color: var(--nv-color-accent);
  background: var(--nv-color-accent);
  color: var(--nv-color-fg-on-accent);
}

.rubric-write .rubric-button:hover {
  border-color: var(--nv-color-accent-hover);
  background: var(--nv-color-accent-hover);
  color: var(--nv-color-fg-on-accent);
}

/* ---- data ------------------------------------------------------------ */

/*
 * `.rubric-data` is any data as a tree to read: the mono, on the sunken
 * paper in a hairline, a key above its value and a nest indented under it.
 */
.rubric-data {
  margin: var(--nv-space-2, 0.5rem) 0 var(--nv-space-3, 0.75rem);
  padding: var(--nv-space-3, 0.75rem) var(--nv-space-4, 1rem);
  border: 1px solid var(--nv-color-border);
  border-radius: var(--nv-radius-md);
  background: var(--nv-color-bg-sunken);
  font-family: var(--nv-font-mono);
  font-size: var(--nv-text-sm, 0.875rem);
  line-height: var(--nv-leading-normal, 1.5);
  color: var(--nv-color-fg);
  overflow-wrap: anywhere;
}

.rubric-data dl,
.rubric-data ol {
  margin: 0;
}

.rubric-data ol {
  padding-inline-start: var(--nv-space-5, 1.5rem);
}

.rubric-data dt {
  margin-block-start: var(--nv-space-2, 0.5rem);
  font-size: var(--nv-text-xs, 0.75rem);
  font-weight: var(--nv-weight-normal, 400);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--nv-color-fg-muted);
}

.rubric-data dt:first-child {
  margin-block-start: 0;
}

.rubric-data dd {
  margin: 0 0 0 var(--nv-space-4, 1rem);
}

.rubric-data dd > dl,
.rubric-data dd > ol,
.rubric-data li > dl,
.rubric-data li > ol {
  padding-block-start: var(--nv-space-1, 0.25rem);
}

/* A link's consent is the home's page: the home's name over it, the mark and the mono kicker, then the consent, the home's own
   page folded under it. */
.rubric-root > main > .rubric-bar {
  display: flex;
  gap: var(--nv-space-2, 0.5rem);
  align-items: center;
  margin-block-end: var(--nv-space-4, 1rem);
}

.rubric-root > main > .qs-ui-ask {
  margin-block-start: 0;
}

/* A page that asks a consent holds one reading column, centred, so the choices above end where the consent ends. */
.rubric-root:has(> main > .qs-ui-ask) {
  --rubric-column: 44rem;
}
