/* wiki — this screen owns this file. See the comment beside the <link> in index.html.
   Rules that two screens want belong in style.css, not duplicated here.

   The whole sheet is arranged around one rule from `12` §4b: the CONSEQUENCE is visible and the
   REASON folds. So a fact is large and a `why` under it is small and muted — never the other way
   round, which is the half that gets kept by accident and makes a page read as an essay.

   And around one constraint: this page is mostly lists of paths, and a path does not wrap at a
   convenient place. Everything that can hold one either wraps anywhere or scrolls inside its own
   box, so that the PAGE never scrolls sideways on a 375px phone. */

.wiki {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* ------------------------------------------------------------------ the head */

.wiki__name {
    margin: 0;
    overflow-wrap: anywhere;
}

/* The one sentence that is always on the screen rather than folded, because it changes how
   everything under it reads: nobody wrote this, and nobody can edit it. */
.wiki__lede {
    margin: 0.35rem 0 0.6rem;
    color: var(--text-muted);
    max-width: 46rem;
    overflow-wrap: anywhere;
}

/* ------------------------------------------------------------------ sections and facts */

.wiki__section {
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.wiki__title {
    margin: 0 0 0.5rem;
}

/* A wrapping row of facts, like the monitor's. A pair is a whole line when its `why` is under it. */
.wiki__facts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
}

.wiki__pair {
    display: flex;
    flex-direction: column;
    min-width: 0;
    /* Room to breathe on a wide screen, and a full line the moment the value is long enough to need
       it — which for a file path is most of the time. */
    flex: 1 1 14rem;
}

/* No `text-transform` here, and that is not an omission. Half the labels on this page are
   IDENTIFIERS taken from the application — a variable name, a package, a saved test — and the
   environment of a process is case sensitive. A sheet that lowercased them would print STRIPE_KEY as
   stripe_key: a name that looks like the one that is set, and is not. */
.wiki__key {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.wiki__val {
    font-weight: 600;
    overflow-wrap: anywhere;
}

/* The platform's own sentences, verbatim. Muted and narrow: they are there for the reader who
   stopped on this line, not for the one scanning the page. */
.wiki__why {
    margin: 0.2rem 0 0;
    color: var(--text-muted);
    font-size: 0.85rem;
    max-width: 46rem;
    overflow-wrap: anywhere;
    flex: 1 0 100%;
}

/* What a good-looking page does not establish: a walk that stopped, a link that leaves the zone, a
   reference that names nothing. Beside the good news, never instead of it. */
.wiki__caveat {
    margin: 0.5rem 0 0;
    color: var(--notice);
    font-size: 0.85rem;
    max-width: 46rem;
    overflow-wrap: anywhere;
}

.wiki__problem {
    margin: 0.5rem 0 0;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--danger);
    border-left-width: 5px;
    border-radius: var(--radius-sm);
    background: var(--danger-weak);
    color: var(--danger);
    max-width: 46rem;
    overflow-wrap: anywhere;
}

/* ------------------------------------------------------------------ folds */

.wiki__fold {
    margin-top: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-sunken);
}

/* A closed fold has to be worth reading closed — a count, a state. The cursor and the padding are
   what make it obvious it opens; a summary that looks like a paragraph gets read and not pressed. */
.wiki__foldhead {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.wiki__foldhead:hover,
.wiki__foldhead:focus-visible {
    color: var(--accent);
}

.wiki__fold > *:not(summary) {
    padding: 0 0.75rem;
}

.wiki__fold > *:last-child {
    padding-bottom: 0.6rem;
}

/* ------------------------------------------------------------------ lists */

.wiki__list {
    margin: 0.4rem 0 0;
    padding-left: 1.1rem;
    font-size: 0.9rem;
}

.wiki__list li {
    margin-bottom: 0.3rem;
    overflow-wrap: anywhere;
}

/* Languages and variable names: short tokens, so a row of pills reads faster than a list. */
.wiki__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin: 0.4rem 0 0;
    padding: 0;
    list-style: none;
}

.wiki__chips li {
    padding: 0.15rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    overflow-wrap: anywhere;
}

/* ------------------------------------------------------------------ the file tree */

.wiki__folder {
    margin-top: 0.6rem;
}

.wiki__foldername {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.wiki__files {
    margin: 0.2rem 0 0;
    padding: 0;
    list-style: none;
}

.wiki__files li {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.25rem 0.75rem;
    padding: 0.15rem 0 0.15rem 0.9rem;
    font-size: 0.85rem;
}

.wiki__filename {
    font-family: var(--font-mono);
    /* A file name is the application's and may be anything the filesystem allows. It wraps rather
       than truncating: the useful half of a long name is usually the end. */
    overflow-wrap: anywhere;
    min-width: 0;
}

.wiki__filemeta {
    color: var(--text-muted);
    white-space: nowrap;
}

/* ------------------------------------------------------------------ the graph */

.wiki__edges {
    margin: 0.3rem 0 0;
    padding: 0;
    list-style: none;
}

.wiki__edges li {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem;
    padding: 0.25rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

.wiki__edgefrom,
.wiki__edgeto {
    font-family: var(--font-mono);
    overflow-wrap: anywhere;
    min-width: 0;
}

.wiki__edgeto {
    font-weight: 600;
}

/* The verb between them, drawn as an arrow so the direction survives a monochrome screen: `import`
   and `require` mean the same direction and it must be readable without colour. */
.wiki__edgehow::before {
    content: "→ ";
}

.wiki__edgehow {
    color: var(--text-muted);
    font-size: 0.78rem;
    white-space: nowrap;
}

/* ------------------------------------------------------------------ the Mermaid fence

   Source, shown as source. It scrolls inside ITS OWN box: a diagram of forty file paths is wider
   than any phone, and the page must never be the thing that scrolls sideways. */
.wiki__fence {
    margin: 0.5rem 0 0;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    line-height: 1.45;
    overflow-x: auto;
    max-height: 22rem;
    overflow-y: auto;
    white-space: pre;
}

.wiki__fence:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}
