/* Casilla reference presentation. Owned by the casilla reference surface.
 *
 * The generated per-modelo pages (dev/docs/casilla_reference.py) are where a
 * search result lands, and there is no per-casilla prose to lean on, so each
 * entry is ranked by the question a filer actually has: what box is this, how
 * does it get filled, and what backs it.
 *
 * The ranking is carried by TYPE, not by containers. An earlier pass gave the
 * fill statement its own bordered panel and gave every fact a pill; the panel
 * fought the card it sat in and the pills flattened signal against noise. Here
 * one card is one box; inside it weight and colour do the ordering, and a pill
 * is reserved for a fact that is genuinely exceptional (required, a bounded
 * range, a segmento, absent from the official form).
 *
 * Tokens come from the Furo skeleton (--color-*) and the Cadrumo theme layer
 * (--cadrumo-radius-*), so light and dark both track the site.
 */

/* ── Modelo overview ──────────────────────────────────────────────────── */

.modelo-overview {
  margin: 0 0 1.5rem;
}

.modelo-overview__name {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--color-foreground-muted);
}

.modelo-overview__definition {
  margin: 0.5rem 0 0;
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--color-foreground-primary);
}

.modelo-overview__facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1rem;
  margin: 0.9rem 0 0;
  padding: 0;
  font-size: 0.82rem;
  color: var(--color-foreground-secondary);
  list-style: none;
}

.modelo-overview__facts .casilla-fact {
  padding: 0;
  background: none;
  border: 0;
  border-radius: 0;
}

/* The modelo's own grounding is the quietest thing in the header: it explains
 * the page, it is not the page. */
.modelo-overview .casilla-card__legal {
  margin-top: 0.8rem;
}

/* ── Jump index over every casilla ────────────────────────────────────── */

.casilla-index {
  margin: 0 0 2.25rem;
  border: 1px solid var(--color-background-border);
  border-radius: var(--cadrumo-radius-m, 10px);
  background: var(--color-background-secondary);
}

.casilla-index__lead {
  margin: 0;
  padding: 0.6rem 0.9rem;
  font-size: 0.8rem;
  border-bottom: 1px solid var(--color-background-border);
}

.casilla-index__title {
  font-weight: 600;
  color: var(--color-foreground-primary);
}

.casilla-index__hint {
  color: var(--color-foreground-muted);
}

/* Modelo 100 lists 2258 casillas. Bounding the height keeps the index a
 * lookup device instead of a wall the reader has to scroll past to reach the
 * first card. */
.casilla-index__scroll {
  max-height: 19rem;
  padding: 0.65rem 0.9rem 0.9rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.casilla-index__group + .casilla-index__group {
  margin-top: 0.7rem;
}

.casilla-index__section {
  display: block;
  margin: 0 0 0.3rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-foreground-muted);
  text-decoration: none;
}

.casilla-index__section:hover {
  color: var(--color-brand-content);
}

.casilla-index__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.casilla-index__chip {
  display: inline-block;
  min-width: 2.2rem;
  padding: 0.1rem 0.35rem;
  font-size: 0.76rem;
  line-height: 1.45;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  color: var(--color-foreground-secondary);
  background: var(--color-background-primary);
  border: 1px solid var(--color-background-border);
  border-radius: var(--cadrumo-radius-s, 6px);
}

/* A casilla whose record design prints no number falls back to its id, which
 * runs five times the width of a number. Clamping those into the number grid
 * tore its rhythm apart and truncated them mid-word, so they get their own
 * band below it: full text, free to wrap, no grid to break. */
.casilla-index__named {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.3rem;
}

.casilla-index__named .casilla-index__chip {
  min-width: 0;
  font-family: var(--font-stack--monospace);
  font-size: 0.7rem;
  text-align: left;
  white-space: normal;
  background: none;
  border-style: dashed;
  overflow-wrap: anywhere;
}

.casilla-index__chip:hover,
.casilla-index__chip:focus-visible {
  color: var(--color-brand-content);
  border-color: var(--color-brand-content);
}

/* ── The casilla card ─────────────────────────────────────────────────── */

.casilla-card {
  margin: 0 0 0.75rem;
  padding: 1rem 1.15rem;
  border: 1px solid var(--color-background-border);
  border-radius: var(--cadrumo-radius-m, 10px);
  background: light-dark(var(--color-background-primary), rgb(255 255 255 / 3%));
  scroll-margin-top: 5rem;
}

/* The target affordance is the whole card lifting, not a bar down its side:
 * a side rule read as a permanent category marker on every card it touched. */
.casilla-card:target {
  border-color: var(--color-brand-content);
  box-shadow: 0 0 0 3px light-dark(rgb(0 0 0 / 4%), rgb(255 255 255 / 6%));
}

.casilla-card__head {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
}

/* Same face as the title: a separate numeric font made the badge read as a
 * code token rather than as the box number printed on the form. */
.casilla-card__number {
  flex: none;
  min-width: 2.2rem;
  padding: 0.05rem 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.5;
  text-align: center;
  color: var(--color-foreground-secondary);
  background: var(--color-background-secondary);
  border-radius: var(--cadrumo-radius-s, 6px);
  overflow-wrap: anywhere;
}

.casilla-card__title {
  flex: 1 1 18rem;
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.45;
  color: var(--color-foreground-primary);
}

/* The description is prose and reads as prose: indented under the title, in
 * the body measure, not dressed as another field. */
.casilla-card__help {
  margin: 0.45rem 0 0 2.8rem;
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--color-foreground-secondary);
}

/* ── How the box gets filled: the answer, carried by weight alone ─────── */

.casilla-fill {
  margin: 0.55rem 0 0 2.8rem;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--color-foreground-secondary);
}

.casilla-fill__kind {
  font-weight: 600;
  color: var(--color-foreground-primary);
}

.casilla-fill__shape::before {
  margin: 0 0.4rem;
  color: var(--color-foreground-border);
  content: "\00b7";
}

/* The derivation is part of the sentence, so it takes the sentence's colour and
 * is marked by weight and a rule. In link colour it became the loudest thing on
 * a card whose point is the sentence around it. */
.casilla-derives-from__ref {
  font-weight: 600;
  color: var(--color-foreground-primary);
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 1px solid var(--color-foreground-border);
}

.casilla-derives-from__ref:hover,
.casilla-derives-from__ref:focus-visible {
  color: var(--color-brand-content);
  border-bottom-color: currentcolor;
}

/* ── Exceptional facts only ───────────────────────────────────────────── */

.casilla-card__facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 0.5rem 0 0 2.8rem;
  padding: 0;
  list-style: none;
}

.casilla-fact {
  margin: 0;
  padding: 0.05rem 0.45rem;
  font-size: 0.74rem;
  line-height: 1.55;
  color: var(--color-foreground-secondary);
  background: var(--color-background-secondary);
  border-radius: 999px;
}

.casilla-fact--required {
  color: light-dark(#8a3d33, #e0a79f);
  background: light-dark(#f6e7e4, rgb(224 131 118 / 12%));
}

.casilla-fact--internal {
  font-style: italic;
}

/* ── Legal basis: grounding, so it recedes ────────────────────────────── */

.casilla-card__legal {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.5rem;
  align-items: baseline;
  margin: 0.6rem 0 0 2.8rem;
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--color-foreground-muted);
}

.casilla-card__legal-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-foreground-border);
}

.casilla-card__legal-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.1rem 0.9rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.casilla-card__legal-list li {
  margin: 0;
}

.casilla-legal-name {
  color: var(--color-foreground-muted);
}

/* Quiet by default: the citation is checkable, not clickbait. It only takes
 * link colour when the reader reaches for it. */
.casilla-legal-ref {
  color: var(--color-foreground-muted);
  text-decoration: none;
  border-bottom: 1px dotted var(--color-foreground-border);
}

.casilla-legal-ref:hover,
.casilla-legal-ref:focus-visible {
  color: var(--color-brand-content);
  border-bottom-color: currentcolor;
}

.casilla-legal-ref--raw {
  font-family: var(--font-stack--monospace);
  font-size: 0.72rem;
  border-bottom: 0;
}

/* ── Registry identifiers (demoted) ───────────────────────────────────── */

.casilla-card__internals {
  margin: 0.55rem 0 0 2.8rem;
}

.casilla-card__internals > summary {
  font-size: 0.72rem;
  color: var(--color-foreground-border);
  cursor: pointer;
}

.casilla-card__internals > summary:hover {
  color: var(--color-brand-content);
}

.casilla-internals {
  display: grid;
  grid-template-columns: minmax(7rem, max-content) 1fr;
  gap: 0.2rem 0.9rem;
  margin: 0.5rem 0 0;
  padding: 0.6rem 0.75rem;
  background: light-dark(var(--color-background-secondary), rgb(0 0 0 / 22%));
  border-radius: var(--cadrumo-radius-s, 6px);
}

.casilla-internals dt {
  margin: 0;
  font-size: 0.74rem;
  color: var(--color-foreground-muted);
}

.casilla-internals dd {
  margin: 0;
  font-size: 0.74rem;
  overflow-wrap: anywhere;
}

.casilla-internals code {
  padding: 0 0.2rem;
  font-size: 0.71rem;
  background: var(--color-background-primary);
}

.casilla-section-anchor {
  display: block;
  height: 0;
}

@media (max-width: 46rem) {
  .casilla-card__help,
  .casilla-fill,
  .casilla-card__facts,
  .casilla-card__legal,
  .casilla-card__internals {
    margin-left: 0;
  }

  .casilla-internals {
    grid-template-columns: 1fr;
    gap: 0.05rem;
  }

  .casilla-internals dt {
    margin-top: 0.4rem;
  }
}
