/* ============================================================================
   DOCUMENT CARD (.doc list + .dc card) — shared single source of truth.
   EXTRACTED from comp-doc-card.html (Jun 2026, the _cover.css precedent) so the
   catalogue card is one file for the DS preview card AND the prototype's
   catalogue "Karty" view. Behaviour (wrap-aware meta fitter + render builder)
   lives in _doc-card.js.

   Consumes the shared chip components (_chips.css) and buttons (_buttons.css)
   — link those first. Dark is a co-located token revalue (notes/architecture).
   The chip-hover overrides beat the chip base by SPECIFICITY within the shared
   @layer components (`.dc:is(:hover,…) .vchip.v-valid` (0,4,0) > `.v-valid`).
   ============================================================================ */

@layer tokens { :root { --dc-surface: #ffffff; } }
@layer theme  { [data-theme="dark"] { --dc-surface: var(--color-bg-subtle); } }

@layer components {

.doc {
  display: flex; flex-direction: column; gap: 10px; max-width: 100%;
  /* Container queries on the LIST (not on each .dc) — a container element
     styles its descendants, never itself. All cards share the list's width. */
  container-type: inline-size;
  container-name: doc;
}

/* ── Card shell — block + floated achip so the TITLE FLOWS AROUND / UNDER the
   availability chip at ALL widths (a grid put the chip in its own column with
   dead space under it — the title couldn't use the full card width). ──────── */
.dc {
  background: var(--dc-surface);
  color: var(--color-fg-default);
  border: 1px solid var(--color-border-default);
  border-radius: 6px;
  padding: 16px 20px;
  box-shadow: var(--shadow-1);

  display: block;
}
.dc::after { content: ""; display: block; clear: both; }  /* contain the float */
.dc:hover,
.dc[data-state~="hover"] { background: var(--gov-color-primary-50); }

.dc .bottom   { margin-top: 8px; display: flex; align-items: center; gap: 16px; }
.dc .bottom .meta { flex: 1 1 0; min-width: 0; }
.dc .bottom .cta-wrap { flex: none; margin-left: auto; }
/* Availability chip floats top-right; the title flows around / under it. The
   negative bottom margin shrinks the float's wrap region to ~1 line so line 2+
   of the title flows directly beneath the chip. */
.dc > .achip { float: right; margin: 0 0 -4px 12px; white-space: nowrap; }

/* ── Heading — doc-type chip floats so title text wraps under it ──────── */
.dc .heading {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--color-fg-default);
}
.dc .heading::after { content: ""; display: block; clear: right; }
/* Doc-type chip is the shared .dc-chip component (see _chips.css) — only the
   in-heading layout is local: a right margin + baseline alignment so the title
   text wraps cleanly under it on line 2. */
.dc .heading .dc-chip { margin: 0 8px 0 0; vertical-align: 3px; }
.dc .title { font-weight: 600; }
/* English original title (when it differs) — muted secondary line. */
.dc .title-en { font-size: 12.5px; font-weight: 400; color: var(--color-fg-tertiary); line-height: 1.45; margin-top: 2px; }

/* ── Sub row ──────────────────────────────────────────────────────────── */
.dc .sub { margin-top: 8px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dc .code-cell { display: inline-flex; align-items: center; gap: 6px; line-height: 1; }
.dc .num { font-family: var(--font-mono); font-weight: 600; font-size: 14px; color: var(--color-fg-default); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.dc .pill { font-family: var(--font-mono); font-weight: 500; font-size: 11px; color: var(--color-fg-secondary); background: var(--gov-color-neutral-100); padding: 2px 6px; border-radius: 3px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dc .pill .abbr { color: var(--gov-color-neutral-500); font-weight: 400; }
.dc .pill--am { background: var(--gov-color-warning-50); color: var(--gov-color-warning-700); }
.dc .pill--am .abbr { color: var(--gov-color-warning-700); opacity: 0.65; }
.dc .sep { color: var(--gov-color-neutral-300); font-size: 12px; }

/* ── Meta — JS hides items per-card when wrap is detected (_doc-card.js) ── */
.dc .meta {
  font-size: 12.5px;
  color: var(--color-fg-secondary);
  display: flex; gap: 6px 20px;
  flex-wrap: wrap;
}
.dc .meta strong { color: var(--color-fg-default); font-weight: 500; }
.dc .meta__item { white-space: nowrap; }
.dc .meta__item[data-fit-hidden] { display: none; }

/* ── CTA — shared .btn component (_buttons.css) ──────────────────────────
   Číst = primary, Požádat = secondary; both small (.btn--sm). Only the
   narrow-mode collapse to icon-only is local (below). */
.dc .cta-wrap .btn { white-space: nowrap; }

/* ── Narrow mode — achip + doc-type chip collapse (float is already default) ── */
@container doc (max-width: 460px) {
  /* Doc-type chip uses short form (STANAG → NAG), matching the table
     step at the same threshold. ČOS / AP are already short. */
  .dc .dc-chip__full  { display: none; }
  .dc .dc-chip__short { display: inline; }

  /* Availability collapses to icon-only — it's the floated chip on the
     right and eats the most title width. Color + icon still encode the
     access category; tooltip preserves the verbal label. */
  .dc .achip { padding: 0; gap: 0; justify-content: center; width: 22px; height: 22px; box-sizing: border-box; }
  .dc .achip .chip-label { display: none; }
  .dc .achip i { font-size: 12px; width: 12px; height: 12px; top: 0; margin: 0; }
}

/* ── Very narrow — collapse CTA label + validity chip, keep icons ─────── */
@container doc (max-width: 340px) {
  .dc .cta-wrap .btn__label { display: none; }
  .dc .cta-wrap .btn { padding: 6px 9px; }

  /* Validity collapses to icon-only at the narrowest step. Tooltip
     preserves the label. cchip keeps its short letter form which fits. */
  .dc .vchip { padding: 0; gap: 0; justify-content: center; width: 22px; height: 22px; box-sizing: border-box; }
  .dc .vchip .chip-label { display: none; }
  .dc .vchip i { font-size: 12px; width: 12px; height: 12px; top: 0; margin: 0; }
  .dc .vchip:has(.bi-check-circle-fill),
  .dc .vchip:has(.bi-arrow-repeat),
  .dc .vchip:has(.bi-slash-circle) { padding: 0; }
  .dc .vchip:has(.bi-check-circle-fill) i,
  .dc .vchip:has(.bi-arrow-repeat) i,
  .dc .vchip:has(.bi-slash-circle) i { margin-left: 0; }
}

/* ── Chip hover state on the active (hovered) card ────────────────────── */
.dc:is(:hover, [data-state~="hover"]) .vchip.v-valid          { background: var(--gov-color-success-100);  border-style: solid;  border-color: var(--gov-color-success-500); }
.dc:is(:hover, [data-state~="hover"]) .vchip.v-replaced       { background: var(--gov-color-warning-100);  border-style: solid;  border-color: var(--gov-color-warning-500); }
.dc:is(:hover, [data-state~="hover"]) .vchip.v-invalid        { background: var(--gov-color-neutral-200);  border-style: solid;  border-color: var(--gov-color-neutral-400);  color: var(--gov-color-neutral-800); }
.dc:is(:hover, [data-state~="hover"]) .vchip.v-draft          { background: var(--gov-color-neutral-100);  border-style: dashed; border-color: var(--gov-color-neutral-400);  color: var(--gov-color-neutral-700); }
.dc:is(:hover, [data-state~="hover"]) .achip.a-public         { background: var(--gov-color-success-100);  border-style: solid;  border-color: var(--gov-color-success-500); }
.dc:is(:hover, [data-state~="hover"]) .achip.a-login          { background: var(--gov-color-info-100);     border-style: solid;  border-color: var(--gov-color-info-500); }
.dc:is(:hover, [data-state~="hover"]) .achip.a-controlled     { background: var(--gov-color-warning-100);  border-style: solid;  border-color: var(--gov-color-warning-500); }
.dc:is(:hover, [data-state~="hover"]) .achip.a-metadata       { background: var(--gov-color-neutral-200);  border-style: solid;  border-color: var(--gov-color-neutral-400); }
.dc:is(:hover, [data-state~="hover"]) .cchip.cchip--neozn     { background: var(--gov-color-neutral-100);  border-color: var(--gov-color-neutral-300);  color: var(--gov-color-neutral-800); }
.dc:is(:hover, [data-state~="hover"]) .cchip.cchip--nu        { background: var(--gov-color-warning-100);  border-color: var(--gov-color-warning-500); }
.dc:is(:hover, [data-state~="hover"]) .cchip.cchip--nr,
.dc:is(:hover, [data-state~="hover"]) .cchip.cchip--nc        { background: var(--gov-color-error-100);    border-color: var(--gov-color-error-500); }

/* When the card lifts to its primary-50 active surface, an inner secondary /
   ghost CTA would camouflage — its hover fill IS primary-50, the card colour —
   so re-point those buttons to the active-surface treatment (see _buttons.css
   ".on-active"): solid rest pops, hover / pressed deepen to primary-100 / -200
   so the feedback stays visible on the tinted card. gov refs resolve on the
   .btn → flip in dark. */
.dc:is(:hover, [data-state~="hover"]) .btn--secondary { --_bg: var(--color-bg-surface); }
.dc:is(:hover, [data-state~="hover"]) .btn--secondary:hover,
.dc:is(:hover, [data-state~="hover"]) .btn--secondary[data-state~="hover"] {
  --_bg: var(--gov-color-primary-100); --_fg: var(--gov-color-primary-700); --_bd: var(--gov-color-primary-600);
}
.dc:is(:hover, [data-state~="hover"]) .btn--secondary:active,
.dc:is(:hover, [data-state~="hover"]) .btn--secondary[data-state~="pressed"] {
  --_bg: var(--gov-color-primary-200); --_fg: var(--gov-color-primary-700); --_bd: var(--gov-color-primary-700);
}
.dc:is(:hover, [data-state~="hover"]) .btn--ghost:hover,
.dc:is(:hover, [data-state~="hover"]) .btn--ghost[data-state~="hover"] {
  --_bg: var(--gov-color-primary-100); --_fg: var(--gov-color-primary-700);
}
.dc:is(:hover, [data-state~="hover"]) .btn--ghost:active,
.dc:is(:hover, [data-state~="hover"]) .btn--ghost[data-state~="pressed"] {
  --_bg: var(--gov-color-primary-200); --_fg: var(--gov-color-primary-700);
}
} /* end @layer components — doc-card */

/* Doc-type (filled) chip adopts its ACTIVE treatment on card hover — a 1px
   inset border in the outlined-variant ink. Dark-only, matching the chip's own
   active state (the vivid light fills need no border). box-shadow only, so it
   coexists with _dark.css's unlayered dc-chip rules (dc-chip-dark exception). */
body[data-theme="dark"] .dc:is(:hover, [data-state~="hover"]) .dc-chip--cos     { box-shadow: inset 0 0 0 1px #98c0e8; }
body[data-theme="dark"] .dc:is(:hover, [data-state~="hover"]) .dc-chip--stanag  { box-shadow: inset 0 0 0 1px #cdd4dc; }
body[data-theme="dark"] .dc:is(:hover, [data-state~="hover"]) .dc-chip--stanrec { box-shadow: inset 0 0 0 1px #c8b9e0; }
body[data-theme="dark"] .dc:is(:hover, [data-state~="hover"]) .dc-chip--ap      { box-shadow: inset 0 0 0 1px #a8d2c4; }
