/* =========================================================================
   LIBRARY ITEM PAGE (ld) - 2026-11-11
   One layout for article, video, PDF, booklet, policy and media. The type sets the tone through
   data-tone on .ld, using the Command Centre tokens (activities-cc.css) the owner approved:
   article teal, video rose, PDF sky, booklet violet, media amber, policy emerald, featured gold.
   Comfort: no pure white on pure black (body #dbe4ee on #0a1328, 14.4:1), 0-9 digits, quiet motion.
   ========================================================================= */

.ld {
  --ld-surface: rgb(var(--t-c-0a1328));
  --ld-surface-2: rgb(var(--t-c-0d1832));
  --ld-inset: rgb(var(--t-c-071027));
  --ld-line: rgba(var(--t-c-94a3b8), 0.14);
  --ld-line-strong: rgba(var(--t-c-94a3b8), 0.26);
  --ld-text: rgb(var(--t-c-dbe4ee));
  --ld-text-strong: rgb(var(--t-c-eef3f8));
  --ld-muted: rgb(var(--t-c-9fb0c3));
  --ld-gold: rgb(var(--t-c-f5b83d));
  --tone: rgb(var(--t-c-2dd4bf));
  --tone-ink: rgb(var(--t-c-042f2e));
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem;
  color: var(--ld-text);
}
.ld[data-tone="teal"], .ld-card[data-tone="teal"] { --tone: rgb(var(--t-c-2dd4bf)); --tone-ink: rgb(var(--t-c-042f2e)); }
.ld[data-tone="rose"], .ld-card[data-tone="rose"] { --tone: rgb(var(--t-c-fb7185)); --tone-ink: rgb(var(--t-c-33060f)); }
.ld[data-tone="sky"], .ld-card[data-tone="sky"] { --tone: rgb(var(--t-c-38bdf8)); --tone-ink: rgb(var(--t-c-062236)); }
.ld[data-tone="violet"], .ld-card[data-tone="violet"] { --tone: rgb(var(--t-c-a78bfa)); --tone-ink: rgb(var(--t-c-1e1238)); }
.ld[data-tone="amber"], .ld-card[data-tone="amber"] { --tone: rgb(var(--t-c-fbbf24)); --tone-ink: rgb(var(--t-c-2a1a02)); }
.ld[data-tone="emerald"], .ld-card[data-tone="emerald"] { --tone: rgb(var(--t-c-34d399)); --tone-ink: rgb(var(--t-c-032a1c)); }
.ld svg { flex: none; width: 1.05em; height: 1.05em; }

/* Breadcrumb ------------------------------------------------------------- */
.ld-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; margin: 0; padding: 0; list-style: none; }
.ld-crumbs__sep { color: var(--ld-muted); }

/* Head ------------------------------------------------------------------- */
.ld-head { display: grid; gap: .75rem; }
.ld-badges { display: flex; flex-wrap: wrap; gap: .5rem; }
.ld-type, .ld-featured {
  display: inline-flex; align-items: center; gap: .4rem; width: fit-content; padding: .3rem .75rem; border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--tone) 40%, transparent); background: color-mix(in srgb, var(--tone) 14%, transparent);
  color: var(--tone); font-size: .8rem; font-weight: 800;
}
.ld-featured { --tone: var(--ld-gold); }
.ld-type--sm { padding: .15rem .55rem; font-size: .72rem; }
.ld-title { margin: 0; color: var(--ld-text-strong); font-size: clamp(1.6rem, 1.1rem + 2vw, 2.6rem); font-weight: 900; line-height: 1.45; text-wrap: balance; }
.ld-meta { display: flex; flex-wrap: wrap; gap: .25rem .9rem; margin: 0; color: var(--ld-muted); font-size: .9rem; }
.ld-meta span + span::before { content: "·"; margin-inline-end: .9rem; color: var(--ld-line-strong); }
.ld-meta time { direction: ltr; unicode-bidi: isolate; }

/* Actions ---------------------------------------------------------------- */
.ld-actions-card { padding: 0; border: 0; background: transparent; box-shadow: none; }
.ld-actions { display: flex; flex-wrap: wrap; gap: .6rem; }
.ld-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 2.75rem; padding: 0 1.1rem;
  border: 1px solid var(--ld-line-strong); border-radius: .85rem; background: var(--ld-inset); color: var(--ld-text);
  font: inherit; font-size: .88rem; font-weight: 800; text-decoration: none; cursor: pointer;
  transition: border-color .16s ease, background .16s ease, color .16s ease;
}
.ld-btn:hover { border-color: var(--tone); background: color-mix(in srgb, var(--tone) 10%, var(--ld-inset)); color: var(--ld-text-strong); }
.ld-btn--primary { border-color: transparent; background: var(--tone); color: var(--tone-ink); font-weight: 900; }
.ld-btn--primary:hover { background: color-mix(in srgb, var(--tone) 88%, rgb(var(--t-c-ffffff))); color: var(--tone-ink); }
.ld-btn--quiet { margin-inline-start: auto; }
.ld :is(a, button, summary, video, audio, [tabindex]):focus-visible { outline: 2px solid var(--tone); outline-offset: 3px; }

/* Stage (player, viewer, image) ----------------------------------------- */
.ld-stage { overflow: hidden; border: 1px solid var(--ld-line); border-radius: 1.25rem; background: var(--ld-inset); }
.ld-stage--doc { border: 0; background: transparent; }
.ld-video { display: block; width: 100%; aspect-ratio: 16 / 9; background: rgb(var(--t-c-000000)); }
.ld-embed { position: relative; aspect-ratio: 16 / 9; }
.ld-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.ld-zoom { display: block; width: 100%; padding: 0; border: 0; background: transparent; cursor: zoom-in; }
.ld-image { display: block; width: 100%; max-height: 78vh; object-fit: contain; background: rgb(var(--t-c-050b1c)); }
.ld-audio { display: grid; gap: 1rem; padding: 1.25rem; }
.ld-audio__cover { width: 100%; max-height: 360px; object-fit: cover; border-radius: 1rem; }
.ld-audio audio { width: 100%; }
.ld-empty { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 1rem; min-height: 14rem; padding: 2rem; color: var(--ld-muted); text-align: center; }
.ld-lightbox { position: fixed; inset: 0; width: min(96vw, 1400px); height: fit-content; max-height: 94vh; margin: auto; padding: 0; border: 0; background: transparent; }
.ld-lightbox::backdrop { background: rgba(var(--t-c-020612), 0.88); }
.ld-lightbox img { display: block; max-width: 100%; max-height: 94vh; margin: auto; border-radius: .75rem; }
.ld-lightbox__close { position: absolute; top: .5rem; inset-inline-end: .5rem; display: grid; width: 2.5rem; height: 2.5rem; place-items: center; border: 0; border-radius: 50%; background: rgba(var(--t-c-071027), 0.85); color: rgb(var(--t-c-ffffff)); font-size: 1.4rem; cursor: pointer; }

/* About + figures -------------------------------------------------------- */
.ld-about { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 300px); gap: 1.25rem; align-items: start; }
.ld-about__text { display: grid; gap: .75rem; padding: 1.25rem 1.4rem; border: 1px solid var(--ld-line); border-radius: 1.25rem; background: var(--ld-surface); }
.ld-lead { margin: 0; color: var(--ld-text-strong); font-size: 1.08rem; line-height: 1.9; }
.ld-desc { color: var(--ld-text); font-size: 1rem; line-height: 1.9; }
.ld-muted { margin: 0; color: var(--ld-muted); }
.ld-stats { display: grid; gap: .6rem; }
.ld-stat {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .65rem; padding: .8rem 1rem;
  border: 1px solid var(--ld-line); border-radius: 1rem; background: var(--ld-surface);
}
.ld-stat svg { width: 1.15rem; height: 1.15rem; color: var(--tone); }
.ld-stat__label { color: var(--ld-muted); font-size: .85rem; }
.ld-stat b { color: var(--ld-text-strong); font-size: 1rem; font-weight: 900; font-variant-numeric: tabular-nums; }

/* Article ---------------------------------------------------------------- */
.ld-progress { position: fixed; top: 0; inset-inline: 0; z-index: 60; height: 3px; background: transparent; pointer-events: none; }
.ld-progress span { display: block; width: 100%; height: 100%; background: var(--tone, rgb(var(--t-c-2dd4bf))); transform: scaleX(0); transform-origin: right; }
[dir="ltr"] .ld-progress span { transform-origin: left; }
.ld-article-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 2rem; align-items: start; }
.ld-reading { min-width: 0; padding: clamp(1.25rem, 3vw, 2.5rem); border: 1px solid var(--ld-line); border-radius: 1.25rem; background: var(--ld-surface); }
.ld-reading > * { max-width: 70ch; margin-inline: auto; }
.ld-reading .ld-lead { margin-bottom: 1.75rem; padding-bottom: 1.25rem; border-bottom: 1px solid var(--ld-line); font-size: 1.15rem; }
.ld-prose { color: var(--ld-text); font-size: 1.125rem; line-height: 1.9; }
.ld-prose p { margin: 0 0 1.15em; color: var(--ld-text); font-size: inherit; line-height: inherit; }
.ld-prose :is(h2, h3, h4) { position: relative; scroll-margin-top: 160px; color: var(--ld-text-strong); line-height: 1.6; }
.ld-prose h2 { margin: 2em 0 .7em; padding-inline-start: .85rem; border-inline-start: 4px solid var(--tone); font-size: 1.45rem; }
.ld-prose h3 { margin: 1.6em 0 .5em; color: var(--tone); font-size: 1.2rem; }
.ld-prose h4 { margin: 1.4em 0 .4em; font-size: 1.08rem; }
.ld-anchor { margin-inline-start: .4rem; color: var(--ld-muted); font-size: .85em; text-decoration: none; opacity: 0; transition: opacity .15s ease; }
.ld-prose :is(h2, h3):hover .ld-anchor, .ld-anchor:focus-visible { opacity: 1; }
.ld-prose li::marker { color: var(--tone); }
.ld-prose a { color: color-mix(in srgb, var(--tone) 80%, rgb(var(--t-c-ffffff))); }
.ld-prose blockquote { margin: 1.5em 0; padding: 1rem 1.25rem; border: 0; border-inline-start: 4px solid var(--tone); border-radius: .75rem; background: color-mix(in srgb, var(--tone) 8%, var(--ld-inset)); color: var(--ld-text-strong); }
.ld-prose .callout { margin: 1.4em 0; padding: 1rem 1.2rem; border: 1px solid; border-radius: .9rem; line-height: 1.85; }
.ld-prose .callout__label { display: inline-block; margin-inline-end: .35rem; font-weight: 900; }
.ld-prose .callout--warn { border-color: rgba(var(--t-c-fbbf24), 0.4); background: rgba(var(--t-c-fbbf24), 0.08); }
.ld-prose .callout--warn .callout__label { color: rgb(var(--t-c-fbbf24)); }
.ld-prose .callout--tip { border-color: rgba(var(--t-c-34d399), 0.4); background: rgba(var(--t-c-34d399), 0.08); }
.ld-prose .callout--tip .callout__label { color: rgb(var(--t-c-34d399)); }
.ld-prose .callout--note { border-color: rgba(var(--t-c-38bdf8), 0.4); background: rgba(var(--t-c-38bdf8), 0.08); }
.ld-prose .callout--note .callout__label { color: rgb(var(--t-c-38bdf8)); }
.ld-prose table { display: block; overflow-x: auto; font-size: .95rem; }
.ld-prose th { background: color-mix(in srgb, var(--tone) 10%, var(--ld-inset)); }
.ld-aside { position: sticky; top: 160px; display: grid; gap: 1rem; }
.ld-toc { padding: 1rem 1.1rem; border: 1px solid var(--ld-line); border-radius: 1.1rem; background: var(--ld-surface); }
.ld-toc summary { color: var(--ld-text-strong); font-weight: 900; cursor: pointer; list-style: none; }
.ld-toc summary::-webkit-details-marker { display: none; }
.ld-toc ol { display: grid; gap: .15rem; max-height: 55vh; margin: .75rem 0 0; padding: 0; overflow: auto; list-style: none; }
.ld-toc a { display: block; padding: .35rem .6rem; border-inline-start: 2px solid transparent; border-radius: .4rem; color: var(--ld-muted); font-size: .88rem; line-height: 1.6; text-decoration: none; }
.ld-toc .is-h3 a { padding-inline-start: 1.4rem; font-size: .84rem; }
.ld-toc a:hover { color: var(--ld-text-strong); background: rgba(var(--t-c-94a3b8), 0.06); }
.ld-toc a[aria-current="true"] { border-inline-start-color: var(--tone); color: var(--tone); background: color-mix(in srgb, var(--tone) 8%, transparent); }

/* Related ---------------------------------------------------------------- */
.ld-section-title { margin: 0 0 1rem; color: var(--ld-text-strong); font-size: 1.2rem; font-weight: 900; }
.ld-related__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.ld-card { display: grid; overflow: hidden; border: 1px solid var(--ld-line); border-radius: 1.1rem; background: var(--ld-surface); color: inherit; text-decoration: none; transition: border-color .18s ease, transform .18s ease; }
.ld-card:hover { border-color: color-mix(in srgb, var(--tone) 55%, transparent); transform: translateY(-2px); }
.ld-card__media { display: block; aspect-ratio: 16 / 9; overflow: hidden; background: rgb(var(--t-c-050b1c)); }
.ld-card__media img { display: block; width: 100%; height: 100%; object-fit: cover; }
.ld-card__fallback { display: grid; width: 100%; height: 100%; place-items: center; background: radial-gradient(120% 120% at 100% 0%, color-mix(in srgb, var(--tone) 32%, transparent), transparent 60%), color-mix(in srgb, var(--tone) 10%, #050b1c); color: var(--tone); }
.ld-card__fallback svg { width: 2.6rem; height: 2.6rem; }
.ld-card__body { display: grid; gap: .45rem; padding: .9rem 1rem 1.1rem; }
.ld-card__title { color: var(--ld-text-strong); font-size: .98rem; font-weight: 800; line-height: 1.6; }
.ld-card__text { color: var(--ld-muted); font-size: .84rem; line-height: 1.7; }

/* Loading: images sit on a quiet block until they arrive ---------------- */
.ld-card__media img, .ld-image { background: linear-gradient(90deg, rgb(var(--t-c-0b1630)), rgb(var(--t-c-101d3b)), rgb(var(--t-c-0b1630))); background-size: 200% 100%; }

/* Entry motion ----------------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  .ld-enter { animation: ld-rise .45s cubic-bezier(.2, .7, .2, 1) both; }
  .ld-enter:nth-of-type(2) { animation-delay: .05s; }
  .ld-enter:nth-of-type(3) { animation-delay: .1s; }
  .ld-enter:nth-of-type(4) { animation-delay: .15s; }
}
@keyframes ld-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Widths ----------------------------------------------------------------- */
@media (max-width: 1023px) {
  .ld-article-grid { grid-template-columns: minmax(0, 1fr); }
  .ld-aside { position: static; order: -1; }
  .ld-toc:not([open]) { padding-block: .8rem; }
  .ld-about { grid-template-columns: minmax(0, 1fr); }
  .ld-stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
}
@media (max-width: 640px) {
  .ld { gap: 1.1rem; }
  .ld-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .ld-btn--primary { grid-column: 1 / -1; }
  .ld-btn--quiet { margin-inline-start: 0; }
  .ld-reading { padding: 1.1rem; border-radius: 1rem; }
  .ld-prose { font-size: 1.06rem; }
  .ld-stat { padding: .7rem .8rem; }
}

/* Codes such as ECC-2:2024 stay whole inside right-to-left titles. */
.ld-nowrap { white-space: nowrap; }
/* Large but not taller than the screen. */
.ld-video { max-height: 74vh; }
/* Long descriptions fold under the summary so the player or viewer stays near the top. */
.ld-more summary { width: fit-content; color: var(--tone); font-weight: 800; cursor: pointer; }
.ld-more[open] summary { margin-bottom: .6rem; }

/* The share menu opens under the action bar, but the video (or picture) below was painted over it:
   both carry the .ld-enter animation, which gives each its own layer. Lift the action bar above the
   stage so the menu shows and can be clicked (2026-11-12). */
.ld-actions-card { position: relative; z-index: 20; }

/* Step 12: the breadcrumb pills come from app.css (legacy dark literals). Restated here with the same dark
   values so they follow the theme on this page only; app.css is not touched. */
.ld .library-subnav { border-color: rgba(var(--t-c-ffffff), 0.08); } /* background and shadow: library-share.css */
.ld .library-subnav__link { color: rgb(var(--t-c-dbe4ee)); background: rgba(var(--t-c-ffffff), 0.03); border-color: rgba(var(--t-c-ffffff), 0.08); }
.ld .library-subnav__link:hover { background: rgba(var(--t-c-ffffff), 0.06); color: rgb(var(--t-c-ffffff)); }
