/* system/apps/api/styles.css
 *
 * This app's own layout only -- text-field treatment comes from the
 * shared tier-2 .text-input-base/.text-input-bordered classes (see
 * start-here.md's "Three CSS tiers" section), nothing else here is
 * meant to be reused by another app.
 *
 * Mobile overflow fix (Sept 2026, Ron: "does not fit on the phone at
 * all -- multiple scrollable sections nested inside each other...at
 * least twice as wide as the screen"): the root cause was the same
 * flex min-width:auto trap documented in apps/notes and apps/manage-
 * repo-files' own styles.css -- flex ITEMS default to min-width:auto,
 * not 0, so a single long unbroken mono string (a used-by chip like
 * "system/apps/manage-repo-files/app.js", a source path, a param
 * name/type) refused to shrink below its own intrinsic width and
 * pushed .api-entry-head/.api-used-by/.api-group-head (and everything
 * above them, up through #appMainContent) wider than the viewport.
 * Only .api-example (the actual code block) had a *deliberate*
 * contained horizontal scroll region; every other overflow was the
 * whole page shifting sideways, which is what read as "multiple
 * scrollable sections nested" -- the page's own accidental horizontal
 * scroll plus the code block's real one. Fixed by giving every flex
 * row `min-width: 0` and every element that can hold a long unbroken
 * string `overflow-wrap: anywhere` (same pattern .api-entry-name
 * already had), so text wraps inside the existing single-column
 * layout instead of forcing horizontal growth anywhere but the one
 * genuinely-wide code example, which keeps its own explicit
 * overflow-x: auto scroller.
 *
 * Font sizes (Sept 2026, Ron: "make also all the fonts the standard
 * hundred percent font size, or close"): body/description/label text
 * below was running one to two steps smaller than the rest of the
 * studio's own roles for the same kind of content (see index.html's
 * --fs-* scale comment) -- some of it on --fs-4xs, a fallback-only
 * value this app invented that isn't part of the shell's defined type
 * scale at all. Retuned every non-code text role to the nearest
 * matching shell-defined step (--fs-sm for description/body copy,
 * --fs-xs for mono identifier labels -- the shell's own "buttons /
 * mono labels" role --, --fs-2xs for small meta/caption labels).
 * .api-example (the actual code block) is explicitly left at its
 * original size/family -- Ron likes the current syntax-coloring and
 * monospace treatment there and asked only that non-code text change.
 */

.api-app {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
  min-height: 0;
  min-width: 0;
  max-width: 100%;
}

.api-search-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.api-search-input {
  width: 100%;
  box-sizing: border-box;
}

.api-count {
  color: var(--slate-light);
  font-family: var(--font-sans);
  font-size: var(--fs-2xs);
  margin: 0;
}

.api-groups {
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.api-empty {
  color: var(--slate-light);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
}

.api-group {
  border: 1px solid var(--hairline, #e2e2e2);
  border-radius: 10px;
  padding: 10px 12px;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.api-group--collapsed .api-group-desc,
.api-group--collapsed .api-entry-list {
  display: none;
}

.api-group--collapsed .api-group-chevron {
  transform: rotate(-90deg);
}

.api-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.api-group-title {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: var(--fs-sm);
  color: var(--ink);
  min-width: 0;
  overflow-wrap: anywhere;
}

.api-group-count {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  color: var(--slate-light);
  background: var(--hairline, #eee);
  border-radius: 999px;
  padding: 1px 7px;
  flex: 0 0 auto;
}

.api-group-chevron {
  margin-left: auto;
  color: var(--slate-light);
  transition: transform 0.15s ease;
  flex: 0 0 auto;
}

.api-group-desc {
  margin: 6px 0 8px;
  color: var(--slate-light);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  overflow-wrap: anywhere;
}

.api-entry-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.api-entry {
  border-top: 1px solid var(--hairline, #eee);
  padding: 6px 0;
  min-width: 0;
}

.api-entry:first-child {
  border-top: none;
}

.api-entry-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  width: 100%;
  min-width: 0;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.api-entry-kind {
  font-family: var(--font-sans);
  font-size: var(--fs-2xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--slate-light);
  flex: 0 0 auto;
}

.api-entry-name {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--ink);
  overflow-wrap: anywhere;
  min-width: 0;
  flex: 1 1 auto;
}

.api-direction {
  flex: 0 0 auto;
  font-family: var(--font-sans);
  font-size: var(--fs-2xs);
  border-radius: 999px;
  padding: 1px 6px;
}

.api-direction--client-to-server {
  background: #e6f0ff;
  color: #234a8f;
}

.api-direction--server-to-client {
  background: #eaf7ec;
  color: #226a3a;
}

.api-entry-chevron {
  margin-left: auto;
  color: var(--slate-light);
  transition: transform 0.15s ease;
  flex: 0 0 auto;
}

.api-entry--open .api-entry-chevron {
  transform: rotate(90deg);
}

.api-entry-desc {
  margin: 4px 0 0;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  overflow-wrap: anywhere;
}

.api-entry-detail {
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--paper-alt, #f7f7f7);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  box-sizing: border-box;
}

.api-detail-block {
  min-width: 0;
}

.api-detail-label {
  font-family: var(--font-sans);
  font-size: var(--fs-2xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--slate-light);
  margin-bottom: 2px;
}

.api-param-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.api-param-list li {
  min-width: 0;
}

.api-param-name {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--ink);
  margin-right: 6px;
  overflow-wrap: anywhere;
}

.api-param-type {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  color: #7a4fbf;
  margin-right: 6px;
  overflow-wrap: anywhere;
}

.api-param-desc {
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  color: var(--ink);
  overflow-wrap: anywhere;
}

.api-returns {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  color: var(--ink);
  overflow-wrap: anywhere;
}

/* The one deliberate exception to the font-size pass above: this is
 * the actual code example, and Ron explicitly asked to keep its
 * current syntax-coloring/monospace treatment as-is, size included.
 * Its own overflow-x: auto is the single legitimate horizontal-scroll
 * region left in this app -- everything else now wraps in place. */
.api-example {
  margin: 0;
  background: #1e1e2a;
  color: #e6e6f0;
  border-radius: 6px;
  padding: 8px 10px;
  overflow-x: auto;
  max-width: 100%;
  box-sizing: border-box;
  font-family: var(--font-mono);
  font-size: var(--fs-4xs, 10px);
}

.api-example code {
  white-space: pre;
}

.api-used-by {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 0;
}

.api-used-by--none {
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  color: var(--slate-light);
  font-style: italic;
  overflow-wrap: anywhere;
}

.api-used-by-chip {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  background: var(--hairline, #eee);
  color: var(--ink);
  border-radius: 999px;
  padding: 1px 7px;
  max-width: 100%;
  overflow-wrap: anywhere;
  box-sizing: border-box;
}

.api-since {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-2xs);
  color: var(--slate-light);
  font-style: italic;
  overflow-wrap: anywhere;
}

.api-source {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--slate-light);
  overflow-wrap: anywhere;
}

/* ------------------------------------------------------------------
 * New-style entry (main.js, Oct 14 2026; current best guess, open to
 * revision). Reuses every rule above; only what main.js adds is here:
 * the status badge (built / planned / unverified), the group tags and
 * the NewShell content-area fit. The old app.js never emits these
 * classes, so the old shell's look is unchanged.
 * ------------------------------------------------------------------ */
.api-app--shell {
  box-sizing: border-box;
  padding: 10px;
}

.api-status {
  flex: 0 0 auto;
  font-family: var(--font-sans);
  font-size: var(--fs-3xs, 10px);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 1px 7px;
  border: 1px solid currentColor;
}
.api-status--built { color: #1c7a4a; }
.api-status--planned { color: #b4540a; background: rgba(255, 168, 60, 0.16); }
.api-status--unverified { color: #7a5c00; border-style: dashed; }

.api-group--planned {
  border-style: dashed;
  border-color: #b4540a;
}

.api-group-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0 0;
  min-width: 0;
}

.api-origin {
  font-family: var(--font-sans);
  font-size: var(--fs-3xs, 10px);
  color: var(--slate-light);
  border: 1px solid var(--hairline, #e2e2e2);
  border-radius: 999px;
  padding: 1px 7px;
}

/* The `hidden` attribute alone does not hide .api-entry-detail (the display: flex
   rule above beats the browser's own [hidden] rule), which main.js relies on to
   expand / collapse. Scoped to the new entry so the old app.js keeps the look it
   has today (current best guess; folding this into the rule above would change
   the old shell's API app and is Ron's call). */
.api-app--shell .api-entry-detail[hidden] {
  display: none;
}

/* ---- 'See also' links between entries (slice 5, Oct 15 2026) ---- */
.api-see-list { margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.api-see-link {
  font: inherit; font-size: 0.8125rem; text-align: left;
  padding: 6px 10px; min-height: 36px;
  border: 1px solid var(--line, rgba(128,128,128,0.4)); border-radius: 999px;
  background: var(--card, transparent); color: inherit; cursor: pointer;
}
.api-see-link:active { background: rgba(128,128,128,0.18); }
.api-entry--flash { animation: api-flash 1.4s ease-out; }
@keyframes api-flash { from { background: rgba(80,140,255,0.28); } to { background: transparent; } }
