/* plinth presentation (SPEC PRES area). Self-hosted, system fonts,
   zero external requests (PRIV-01). Mobile-first (PRES-01). */

:root {
  --bg: #101014;
  --fg: #f2f2f0;
  --muted: #b9b9b4;
  --scrim: linear-gradient(to top, rgba(8, 8, 10, 0.88) 0%,
                           rgba(8, 8, 10, 0.55) 55%, rgba(8, 8, 10, 0) 100%);
  --accent: #d8c9a3;
}

* { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0; min-height: 100%;
  background: var(--bg); color: var(--fg);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
img, video { max-width: 100%; height: auto; }

/* ---- full-viewport item presentation (PRES-01) ---- */
main.item { min-height: 100svh; position: relative; }
main.item > h1 { position: absolute; left: -9999px; } /* title lives on the card */
main.item figure {
  margin: 0; height: 100svh; display: grid; place-items: center;
  background: var(--bg);
}
/* PRES-01: :cover (default) fills the entire visible viewport;
   :contain letterboxes on the canvas — selectable per portfolio. */
main.m-cover figure img {
  width: 100vw; height: 100svh; object-fit: cover; display: block;
}
main.m-contain figure img {
  max-height: 100svh; max-width: 100vw; width: auto; height: auto;
  object-fit: contain; display: block;
}
main.item video, main.item audio { width: min(92vw, 60rem); }
main.item pre {
  width: min(92vw, 46rem); margin: 4rem auto; padding: 1.5rem;
  overflow-x: auto; background: #16161c; border-radius: 6px;
  font-size: 0.9rem;
}

/* ---- info card: native details/summary overlay (PRES-04/05).
   No JS: open by default, the summary is the unobtrusive toggle;
   scrim keeps WCAG AA contrast without hiding the media. ---- */
details.card {
  position: fixed; inset: auto 0 0 0; z-index: 2;
  padding: 1.1rem 1.25rem;
  /* distinct backdrop: AA-legible over ANY media (PRES-04) — solid
     enough alone; blur adds separation where supported */
  background: rgba(10, 10, 13, 0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
details.card summary {
  cursor: pointer; list-style: none; display: inline-block;
  font-size: 1.15rem; font-weight: 600; letter-spacing: 0.01em;
}
details.card summary::-webkit-details-marker { display: none; }
details.card summary::after {
  content: " ⌃"; color: var(--muted); font-size: 0.8em;
}
details.card:not([open]) summary::after { content: " ⌄"; }
details.card .text, details.card .phase-text { max-width: 46rem; }
details.card .text p, details.card .meta { color: var(--muted); }
details.card .meta { font-size: 0.85rem; margin: 0.5rem 0 0; }
details.card .meta a { color: var(--fg); }
p.cta { margin: 0.75rem 0 0; }
p.cta a {
  display: inline-block; padding: 0.45rem 1.1rem; border: 1px solid var(--accent);
  border-radius: 3px; color: var(--accent); text-decoration: none;
}
p.cta .price { margin-left: 0.75rem; color: var(--muted); }
p.cta .price s { opacity: 0.6; margin-right: 0.4rem; }
code.coupon {
  margin-left: 0.75rem; padding: 0.15rem 0.5rem;
  border: 1px dashed var(--muted); border-radius: 3px;
}
p.ended { color: var(--accent); font-size: 0.9rem; margin: 0.4rem 0 0; }
footer.rights { color: var(--muted); font-size: 0.75rem; margin-top: 0.6rem; }

/* ---- in-place slideshow home (PRES-10 :slideshow, ruled 2026-08-10):
   URL constant; first slide is the no-JS content; crossfade honours
   prefers-reduced-motion via the animation kill below ---- */
div.slides section.slide { display: none; }
div.slides section.slide.active { display: block; animation: 0.6s ease both slide-fade; }
@keyframes slide-fade { from { opacity: 0; } }
nav.slides-nav { display: none; } /* JS-only controls */
html.js nav.slides-nav { display: block; }
nav.slides-nav button {
  position: fixed; top: 50%; transform: translateY(-50%); z-index: 3;
  background: none; border: none; cursor: pointer;
  padding: 0.6rem 0.8rem; font-size: 1.4rem; color: var(--fg); opacity: 0.7;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.9), 0 0 2px rgba(0, 0, 0, 0.9);
}
nav.slides-nav button:hover, nav.slides-nav button:focus-visible { opacity: 1; }
nav.slides-nav .prev { left: 0.25rem; }
nav.slides-nav .next { right: 0.25rem; }
details.card summary a { text-decoration: none; }
details.card summary a:hover { text-decoration: underline; }
@media (prefers-reduced-motion: reduce) {
  div.slides section.slide.active { animation: none; }
}

/* ---- home affordance: minimal chrome back to the tree root ---- */
nav.home a {
  position: fixed; top: 0; left: 0; z-index: 3;
  padding: 0.8rem 1.1rem; text-decoration: none;
  font-size: 0.85rem; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--fg); opacity: 0.7;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.9), 0 0 2px rgba(0, 0, 0, 0.9);
}
nav.home a:hover, nav.home a:focus-visible { opacity: 1; }
nav.browse a {
  position: fixed; top: 0; right: 0; z-index: 3;
  padding: 0.8rem 1.1rem; text-decoration: none;
  font-size: 0.85rem; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--fg); opacity: 0.7;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.9), 0 0 2px rgba(0, 0, 0, 0.9);
}
nav.browse a:hover, nav.browse a:focus-visible { opacity: 1; }
main.browse nav.home a { position: static; padding: 0; text-shadow: none;
  color: var(--muted); }

/* ---- prev/next (PRES-03 static half; keyboard/swipe arrive with the viewer) */
nav.seq a {
  position: fixed; top: 50%; transform: translateY(-50%); z-index: 3;
  padding: 0.6rem 0.8rem; text-decoration: none; font-size: 1.4rem;
  color: var(--fg); opacity: 0.7; transition: opacity 0.2s;
  /* legible over any media, including pure white (PRES-04 spirit) */
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.9), 0 0 2px rgba(0, 0, 0, 0.9);
}
nav.seq a:hover, nav.seq a:focus-visible { opacity: 1; }
nav.seq a[rel="prev"] { left: 0.25rem; }
nav.seq a[rel="next"] { right: 0.25rem; }

/* ---- index & category: media-first grid ---- */
main.browse { padding: 1.25rem; max-width: 80rem; margin: 0 auto; }
main.browse h1 { font-weight: 600; letter-spacing: 0.01em; }
ul.grid {
  list-style: none; margin: 1.5rem 0; padding: 0;
  display: grid; gap: 0.75rem;
  grid-template-columns: repeat(auto-fill, minmax(min(46vw, 15rem), 1fr));
}
ul.grid a { text-decoration: none; display: block; }
ul.grid img {
  width: 100%; aspect-ratio: 1; object-fit: cover; display: block;
  border-radius: 4px; background: #16161c;
}
ul.grid .label { display: block; padding: 0.4rem 0.1rem; color: var(--muted); font-size: 0.85rem; }
ul.categories { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
ul.categories a {
  display: inline-block; padding: 0.25rem 0.9rem; border: 1px solid #33333c;
  border-radius: 999px; text-decoration: none; color: var(--muted); font-size: 0.9rem;
}
ul.categories a:hover { color: var(--fg); border-color: var(--muted); }
div.definition { max-width: 46rem; color: var(--muted); }
p.hero a { color: var(--accent); }

/* ---- cross-document view transitions (PRES-02 registry, static half).
   Progressive: browsers without the API navigate normally. ---- */
@view-transition { navigation: auto; }
html.t-slide-h::view-transition-old(root) {
  animation: 0.28s ease both slide-out-l;
}
html.t-slide-h::view-transition-new(root) {
  animation: 0.28s ease both slide-in-r;
}
html.t-zoom::view-transition-old(root) { animation: 0.3s ease both fade-out; }
html.t-zoom::view-transition-new(root) { animation: 0.3s ease both zoom-in; }
/* t-crossfade: the API's default cross-fade — no extra rules needed */
@keyframes slide-out-l { to { transform: translateX(-6%); opacity: 0; } }
@keyframes slide-in-r { from { transform: translateX(6%); opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes zoom-in { from { transform: scale(1.03); opacity: 0; } }

/* ---- accessibility: motion (PRES-03, TEST-09) ---- */
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) { animation: none !important; }
  nav.seq a { transition: none; }
}

/* ---- print (PRES-12): ink-legible, flattened, no chrome ---- */
@media print {
  body { background: #fff; color: #000; font-size: 11pt; }
  main.item { min-height: 0; }
  main.item figure { height: auto; }
  main.item figure img { max-height: 60vh; }
  details.card { position: static; background: none; padding: 0.5rem 0;
                 backdrop-filter: none; border-top: none; }
  details.card:not([open]) { display: block; }
  details.card .text p, details.card .meta { color: #222; }
  nav.seq, nav.home, ul.categories { display: none; }
  p.cta a { border: none; padding: 0; color: #000; text-decoration: underline; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.8em; }
  footer.rights { color: #444; }
}

/* ---- dictionary-entry category header (CON-05) ---- */
header.dict h1 { display: inline-block; margin-bottom: 0.2rem; }
header.dict .phon {
  margin-left: 0.8rem; color: var(--muted); font-size: 1.05rem;
}
header.dict .def { max-width: 46rem; color: var(--fg); margin: 0.3rem 0 0.4rem; }
header.dict .related { color: var(--muted); font-size: 0.9rem; }
header.dict .related a { color: var(--fg); }

/* ---- deck mode (PRES-14): slides application ---- */
main.deck figure.bg { position: absolute; inset: 0; z-index: 0; height: 100svh; }
main.deck figure.bg figure { height: 100svh; }
/* :background {:scrim true} — dim an image backdrop for legibility */
main.deck figure.bg.scrimmed::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(rgba(8, 8, 10, 0.55), rgba(8, 8, 10, 0.4));
}
main.deck .slide-content {
  position: relative; z-index: 1; min-height: 100svh;
  display: flex; flex-direction: column; justify-content: center;
  max-width: 58rem; margin: 0 auto; padding: 8vh 8vw;
  text-shadow: 0 0 10px rgba(8, 8, 10, 0.7);
}
main.deck > h1 { position: static; left: auto; }
main.deck .slide-content h1 {
  position: static; font-size: clamp(1.8rem, 5vw, 3.4rem);
  line-height: 1.12; margin: 0.2em 0 0.4em;
}
main.deck .slide-content .text { max-width: none; font-size: 1.15rem; }
main.deck .slide-content .text li { margin: 0.35em 0; }
/* inline media on a slide: contained, never the full-bleed treatment */
main.deck .slide-content figure {
  height: auto; margin: 1.2rem 0; background: transparent;
  justify-items: start;
}
main.m-cover .slide-content figure img, main.m-contain .slide-content figure img {
  width: auto; height: auto; max-width: 100%; max-height: 52svh;
  object-fit: contain; border-radius: 6px;
}
p.kicker {
  color: var(--accent); text-transform: uppercase; font-size: 0.8rem;
  letter-spacing: 0.12em; margin: 0 0 0.2em;
}
aside.notes { display: none; }
html.show-notes aside.notes {
  display: block; position: fixed; inset: 0 0 auto 0; z-index: 6;
  background: rgba(10, 10, 13, 0.93); color: var(--muted);
  padding: 1rem 1.4rem; font-size: 0.95rem; border-bottom: 1px solid #33333c;
}
div.progress { position: fixed; bottom: 0.55rem; right: 0.9rem; z-index: 3; }
div.progress a {
  color: var(--muted); font-size: 0.8rem; text-decoration: none;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.9);
}
div.progress a:hover { color: var(--fg); }
nav.vert a {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 3;
  padding: 0.4rem 0.9rem; text-decoration: none; font-size: 1.3rem;
  color: var(--fg); opacity: 0.7;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.9), 0 0 2px rgba(0, 0, 0, 0.9);
}
nav.vert a:hover, nav.vert a:focus-visible { opacity: 1; }
nav.vert a.up { top: 0.15rem; }
nav.vert a.down { bottom: 0.15rem; }
/* fragments: stepwise reveal, JS only; full content without JS/print */
html.js main.deck[data-fragments] .slide-content li {
  opacity: 0.15; transition: opacity 0.25s;
}
html.js main.deck[data-fragments] .slide-content li.revealed { opacity: 1; }
/* overview: spatial map whose axes MATCH the keys — sections as
   columns (←/→), slides stacked within a column (↑/↓). Shared by the
   browse/ page and the in-slide popup. */
div.ov-map {
  display: flex; gap: 1.1rem; align-items: flex-start;
  /* horizontal padding ≥ outline width + offset (2px + 3px): the
     scroll box clips at its content edge, which was cutting the
     selection outline off the leftmost column (Andrew's screenshot) */
  overflow-x: auto; padding: 0.5rem 6px 1rem;
  /* keep the outline visible when the viewer scrolls a tile to the
     edge (scrollIntoView would otherwise consume the padding) */
  scroll-padding: 8px;
}
div.ov-map section.ov {
  flex: 0 0 clamp(9rem, 20vw, 13rem);
  /* flex items floor at min-content by default (min-width: auto) — a
     long nowrap label was widening its whole column past the basis,
     so the ellipsis never engaged (Andrew's catch, F-002) */
  min-width: 0; width: clamp(9rem, 20vw, 13rem);
}
div.ov-map section.ov h2 {
  font-size: 0.95rem; color: var(--muted); margin: 0 0 0.5rem;
}
div.ov-map ul.col {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 0.6rem;
}
div.ov-map ul.col li {
  background: #1b1b22; border-radius: 6px; overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
div.ov-map ul.col a { display: block; text-decoration: none; }
/* every tile the same size: image thumb or placeholder glyph */
div.ov-map ul.col img, div.ov-map ul.col .ph {
  width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block;
}
div.ov-map ul.col .ph {
  display: flex; align-items: center; justify-content: center;
  background: #22222b; color: var(--muted); font-size: 1.9rem;
}
div.ov-map ul.col .label {
  display: block; padding: 0.45rem 0.6rem;
  color: var(--fg); font-size: 0.85rem;
  /* one line, clipped with an ellipsis — tiles stay aligned; the
     full title is the anchor's :title hover pop-over */
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
div.ov-map ul.col a:hover li, div.ov-map ul.col a:hover .label { color: var(--accent); }
div.ov-map li:target, div.ov-map li.selected {
  outline: 2px solid var(--accent); outline-offset: 3px;
}
/* 2D spatial indicator: bottom edge = sections (←/→), right edge =
   slides within the current section (↑/↓). Subtle but clear. */
div.pos { pointer-events: none; --pos-size: 3px; }
div.pos-h {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 4;
  display: flex; gap: 4px; height: var(--pos-size);
}
div.pos-v {
  position: fixed; top: 0; bottom: var(--pos-size); right: 0; z-index: 4;
  display: flex; flex-direction: column; gap: 4px; width: var(--pos-size);
}
div.pos-h span, div.pos-v span { flex: 1; background: rgba(255, 255, 255, 0.14); }
div.pos-h span.on, div.pos-v span.on { background: var(--accent); }
/* :contrast :strong — a light bar with a dark halo, legible over any
   slide background (light or dark) */
div.pos.strong span { background: rgba(255, 255, 255, 0.35); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55); }
div.pos.strong span.on { background: #ffffff; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.75); }

/* PRES-17 (evaluation): body-prose justification. Scoped to direct
   paragraphs of .text blocks — lists, verse blockquotes and headings
   stay ragged by design. The CSS is the no-JS/native fallback; the
   vendored justif module upgrades exactly these paragraphs. */
html[data-justify] .text > p { text-align: justify; }
html[data-justify="native"] .text > p { hyphens: auto; }

/* handout: the whole deck as one printable document (PRES-14) */
main.handout { padding: 1.25rem; max-width: 46rem; margin: 0 auto; }
main.handout nav.home a {
  position: static; padding: 0; text-shadow: none; color: var(--muted);
}
main.handout h2 { color: var(--muted); font-size: 1.1rem; margin: 2.2rem 0 0.4rem; }
main.handout article.handout-slide {
  border-top: 1px solid #26262e; padding: 1rem 0 0.5rem; margin-top: 1rem;
}
main.handout h3 { margin: 0 0 0.5rem; }
main.handout figure { margin: 1rem 0; }
main.handout img {
  width: auto; height: auto; max-width: 100%; max-height: 40svh;
  border-radius: 6px;
}
main.handout aside.notes {
  display: block; position: static; inset: auto; background: none;
  border: none; border-left: 3px solid var(--accent);
  padding: 0.25rem 0.9rem; margin-top: 0.8rem;
  color: var(--muted); font-size: 0.95rem;
}
main.handout aside.notes::before { content: "Notes: "; font-weight: 600; }
p.tools a { color: var(--accent); font-size: 0.9rem; }
@media print {
  /* one ⌘P → one page per slide (Andrew's ruling): the h1 is the
     cover page; each section opens a fresh page with its heading on
     its first slide's page; every further slide breaks to a new page */
  main.handout section.handout-section { break-before: page; }
  main.handout article.handout-slide + article.handout-slide { break-before: page; }
  main.handout article.handout-slide { break-inside: avoid; border-top: none; }
  main.handout h2 { break-after: avoid; }
  main.handout aside.notes { color: #333; border-left-color: #999; }
}

/* popup overview on slide pages (JS-only; browse/ stays the no-JS path) */
div.ov-popup {
  display: none; position: fixed; inset: 0; z-index: 7;
  /* legibility over any slide: near-opaque scrim + blur separation,
     congruent with the info card's backdrop treatment */
  background: rgba(10, 10, 13, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  overflow: auto; padding: 1.75rem;
}
html.show-ov div.ov-popup { display: block; }
div.ov-popup p.tools { margin: 0 0 1rem; }
html.show-ov { overflow: hidden; }
@media print {
  /* the background is stage dressing, not handout content — printing
     it produced a page of image before the slide (Andrew's report).
     :background {:print true} opts a slide's backdrop back in, flowed
     as a contained image above the content, never its own page. */
  main.deck figure.bg { display: none; }
  main.deck figure.bg.print-keep { display: block; position: static; height: auto; }
  main.deck figure.bg.print-keep figure { height: auto; }
  main.deck figure.bg.print-keep img {
    width: auto; height: auto; max-width: 100%; max-height: 9cm;
    object-fit: contain;
  }
  main.deck figure.bg.print-keep::after { content: none; }
  main.deck .slide-content { min-height: 0; text-shadow: none; padding: 0.5rem 0; }
  aside.notes { display: block; border-top: 1px solid #999; color: #333;
                margin-top: 0.8rem; padding-top: 0.4rem; }
  aside.notes::before { content: "Notes: "; font-weight: 600; }
  div.progress, nav.vert, div.pos { display: none; }
  html.js main.deck[data-fragments] .slide-content li { opacity: 1; }
}
