/* ============================================
   DECK KIT
   Shared layouts for the dedicated research decks (MARIO, Seeing with the
   Hands, TacTex). Builds on the .present-deck--research palette and slide
   frame in project.css; nothing here applies to the reading page.
   ============================================ */

/* Figures drawn for the reading page read their colours from the site tokens.
   Inside a deck those tokens follow the deck palette instead, so a figure
   matches the day / night toggle of the presentation. */
.present-deck--research {
  --color-text: var(--deck-text);
  --color-text-muted: var(--deck-muted);
  --color-border: var(--deck-border);
  --color-surface: var(--deck-surface);
  --color-accent: var(--deck-accent);
  --color-bg: var(--deck-bg);
}

/* ---------- dense content slide ---------- */
body.present-mode .present-deck--research .present-slide--dk.slide-active {
  gap: clamp(1rem, 2.5vh, 1.7rem);
  padding-top: clamp(2.2rem, 5vh, 3.4rem);
  padding-bottom: clamp(5.2rem, 9vh, 6rem);
}

body.present-mode .present-deck--research .present-slide--dk .present-slide-heading {
  max-width: none;
  gap: 0.55rem;
}

body.present-mode .present-deck--research .present-slide--dk .present-slide-heading h2 {
  max-width: none;
  font-size: clamp(1.85rem, 3.15vw, 3.05rem);
  line-height: 1.2;
  text-wrap: balance;
}

.dk-body {
  display: grid;
  flex: 1 1 auto;
  align-content: center;
  gap: clamp(0.8rem, 2vh, 1.4rem);
  min-height: 0;
  min-width: 0;
}

.dk-grid {
  display: grid;
  align-items: center;
  gap: clamp(1.1rem, 2.4vw, 2.5rem);
  min-width: 0;
}
.dk-grid--48 { grid-template-columns: minmax(0, 4fr) minmax(0, 8fr); }
.dk-grid--57 { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
.dk-grid--66 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.dk-grid--75 { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
.dk-grid--84 { grid-template-columns: minmax(0, 8fr) minmax(0, 4fr); }
.dk-grid--top { align-items: start; }
.dk-grid--stretch { align-items: stretch; }

.dk-col {
  display: grid;
  align-content: center;
  gap: clamp(0.6rem, 1.5vh, 1rem);
  min-width: 0;
}

/* ---------- text ---------- */
.dk-text {
  display: grid;
  gap: 0.8em;
  min-width: 0;
}
.dk-text p {
  margin: 0;
  color: var(--deck-muted);
  font-size: clamp(1.05rem, 1.5vw, 1.45rem);
  line-height: 1.5;
  text-wrap: pretty;
}
.dk-text p strong { color: var(--deck-text); }

.dk-claim {
  margin: 0;
  color: var(--deck-text);
  font-size: clamp(1.35rem, 2.2vw, 2.1rem);
  font-weight: 620;
  line-height: 1.28;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.dk-cap {
  margin: 0;
  color: var(--deck-muted);
  font-size: clamp(0.95rem, 1.3vw, 1.2rem);
  line-height: 1.45;
}

/* ---------- cards ---------- */
.dk-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  padding: clamp(0.9rem, 1.7vw, 1.5rem);
  border: 1px solid var(--deck-border);
  border-radius: 4px;
  background: var(--deck-surface);
}
.dk-card > span {
  color: var(--deck-accent);
  font-size: 0.8em;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.dk-card h3 {
  margin: 0.3rem 0 0;
  color: var(--deck-text);
  font-size: clamp(1.2rem, 1.85vw, 1.8rem);
  line-height: 1.22;
}
.dk-card p {
  margin: 0.3rem 0 0;
  color: var(--deck-muted);
  font-size: clamp(1rem, 1.5vw, 1.4rem);
  line-height: 1.42;
}
.dk-card p strong { color: var(--deck-text); }

.dk-stack { display: grid; gap: 0.7rem; min-width: 0; }
.dk-row {
  display: grid;
  grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr));
  gap: 0.7rem;
  min-width: 0;
}

.dk-row--slim .dk-card,
.dk-stack--slim .dk-card { padding: clamp(0.6rem, 1vw, 0.9rem) clamp(0.75rem, 1.2vw, 1.1rem); }
.dk-row--slim .dk-card h3,
.dk-stack--slim .dk-card h3 { margin-top: 0.15rem; font-size: clamp(1.05rem, 1.5vw, 1.4rem); }
.dk-row--slim .dk-card p,
.dk-stack--slim .dk-card p { margin-top: 0.2rem; font-size: clamp(0.9rem, 1.2vw, 1.12rem); line-height: 1.36; }

/* ---------- big numbers ---------- */
.dk-stat {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  padding: clamp(0.85rem, 1.5vw, 1.25rem);
  border: 1px solid var(--deck-border);
  border-radius: 4px;
  background: var(--deck-surface);
}
.dk-stat strong {
  color: var(--deck-accent);
  font-family: var(--font-serif);
  font-size: clamp(2.3rem, 4.6vw, 4.4rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.dk-stat strong small {
  margin-left: 0.18em;
  color: var(--deck-muted);
  font-family: inherit;
  font-size: 0.42em;
  font-weight: 600;
  letter-spacing: 0;
}
.dk-stat span {
  margin-top: 0.5rem;
  color: var(--deck-muted);
  font-size: clamp(1rem, 1.45vw, 1.35rem);
  line-height: 1.35;
}

/* ---------- media ---------- */
.dk-fig {
  position: relative;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--deck-border);
  border-radius: 4px;
  background: var(--deck-surface);
}
.dk-fig img,
.dk-fig video {
  display: block;
  width: 100%;
  height: auto;
  max-height: var(--dk-h, 58vh);
  object-fit: contain;
}
.dk-fig > figcaption {
  padding: 0.5rem 0.8rem;
  border-top: 1px solid var(--deck-border);
  color: var(--deck-muted);
  font-size: clamp(0.9rem, 1.3vw, 1.2rem);
  line-height: 1.4;
}
.dk-fig--chip > figcaption {
  position: absolute;
  right: 0.8rem;
  bottom: 0.8rem;
  max-width: calc(100% - 1.6rem);
  padding: 0.42rem 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(10, 11, 15, 0.78);
  color: #f7f7f8;
  font-size: clamp(0.85rem, 1.1vw, 1.05rem);
  line-height: 1.2;
}

.dk-tiles {
  display: grid;
  grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr));
  gap: 0.6rem;
  min-width: 0;
}
.dk-tile {
  display: grid;
  gap: 0.4rem;
  margin: 0;
  justify-items: center;
  min-width: 0;
}
.dk-tile img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--deck-border);
  border-radius: 4px;
}
.dk-tile figcaption {
  color: var(--deck-muted);
  font-size: clamp(0.95rem, 1.35vw, 1.25rem);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.dk-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.dk-chips span {
  padding: 0.32rem 0.7rem;
  border: 1px solid var(--deck-border);
  border-radius: 999px;
  background: var(--deck-surface);
  color: var(--deck-muted);
  font-size: clamp(0.9rem, 1.3vw, 1.2rem);
  line-height: 1.2;
}
.dk-chips span strong { color: var(--deck-text); }

/* An animated figure on a slide takes the slide palette and a quieter frame. */
.present-deck--research .dk-figure {
  margin: 0;
  min-width: 0;
}
.present-deck--research .dk-figure > .tcf,
.present-deck--research .dk-figure > .mrf {
  border-radius: 4px;
  background: var(--deck-surface);
}

/* Takeaway line under a figure */
.dk-note {
  margin: 0;
  padding: 0.55rem 0.85rem;
  border-left: 3px solid var(--deck-accent);
  background: var(--deck-accent-soft);
  color: var(--deck-muted);
  font-size: clamp(1rem, 1.5vw, 1.4rem);
  line-height: 1.45;
}
.dk-note strong { color: var(--deck-text); }

/* Closing: contributor line */
.dk-with {
  margin: 0;
  max-width: 36rem;
  color: var(--deck-muted);
  font-size: 0.82em;
  line-height: 1.45;
}
.present-author-faces .dk-with strong {
  display: inline;
  color: var(--deck-text);
  font-size: 1em;
  font-weight: 600;
  line-height: inherit;
}

@media (max-width: 900px) {
  .dk-grid--48,
  .dk-grid--57,
  .dk-grid--66,
  .dk-grid--75,
  .dk-grid--84 { grid-template-columns: minmax(0, 1fr); }
  .dk-row { grid-template-columns: minmax(0, 1fr); }
}

/* Figure sized by the room the slide leaves for it. The fit box takes the
   spare row of the body; the drawing is as large as fits it, whatever the
   screen shape (container units, so no viewport arithmetic). */
.dk-body--fig {
  grid-template-rows: minmax(0, 1fr) auto;
  align-content: stretch;
}
.dk-body--fill {
  grid-template-rows: minmax(0, 1fr);
  align-content: stretch;
}
.dk-body--fill > .dk-grid {
  grid-template-rows: minmax(0, 1fr);
  align-items: stretch;
  height: 100%;
  min-height: 0;
}
.dk-figure--fit {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 0.4rem;
  min-height: 0;
  min-width: 0;
}
.dk-fitbox {
  display: block;
  min-height: 0;
  min-width: 0;
  container-type: size;
}
/* The card takes the whole cell so its edges line up with the cards, photos
   and headings around it; the drawing is as large as fits and sits centred. */
.dk-fitbox > .tcf,
.dk-fitbox > .mrf {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
}
.dk-fitbox > .tcf > svg,
.dk-fitbox > .mrf > svg {
  width: 100%;
  height: 100%;
}

/* Bars (backup results) */
.dk-bars {
  display: grid;
  grid-template-columns: repeat(var(--n, 10), minmax(0, 1fr));
  gap: clamp(0.2rem, 0.5vw, 0.5rem);
  align-items: end;
  height: clamp(9rem, 28vh, 17rem);
  margin-top: 0.7rem;
}
.dk-bar {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 0.28rem;
  height: 100%;
  min-width: 0;
}
.dk-bar b {
  color: var(--deck-text);
  font-size: clamp(0.62rem, 0.9vw, 0.86rem);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.dk-bar i {
  display: block;
  width: min(72%, 2.6rem);
  height: calc(var(--v) * 70%);
  border-radius: 2px 2px 0 0;
  background: var(--deck-accent);
  opacity: 0.4;
}
.dk-bar i.is-low { opacity: 1; }
.dk-bar span {
  color: var(--deck-muted);
  font-size: clamp(0.62rem, 0.9vw, 0.86rem);
  max-width: 100%;
  overflow: hidden;
  text-overflow: clip;
  white-space: nowrap;
}

/* more layouts */
.dk-grid--three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dk-body--fig > .dk-grid,
.dk-body--fill > .dk-grid {
  grid-template-rows: minmax(0, 1fr);
  align-items: stretch;
  min-height: 0;
}
.dk-grid > .dk-figure--fit,
.dk-grid > .dk-stack { align-self: stretch; }
.dk-grid > .dk-stack { align-content: center; }

.dk-stat strong small.pre {
  margin: 0 0.22em 0 0;
  font-size: 0.34em;
  letter-spacing: 0.02em;
}
.dk-row--stats .dk-stat strong { font-size: clamp(1.9rem, 3.4vw, 3.2rem); }
.dk-row--stats .dk-stat { padding: clamp(0.6rem, 1vw, 0.9rem) clamp(0.75rem, 1.2vw, 1.1rem); }
.dk-row--stats .dk-stat span { margin-top: 0.3rem; font-size: clamp(0.9rem, 1.25vw, 1.15rem); }

.present-deck-authors .dk-equal { color: var(--deck-dim); font-size: 0.82em; white-space: nowrap; }

/* ---------- closing slide: paper, identity, contributors, QR ---------- */
.dk-close {
  display: flex;
  flex: 1;
  align-items: stretch;
  gap: clamp(1.6rem, 3.4vw, 3.6rem);
  min-height: 0;
  margin-top: clamp(0.8rem, 2vh, 1.5rem);
}

.dk-close-side {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: space-between;
  gap: clamp(0.9rem, 2.2vh, 1.6rem);
  min-width: 0;
}

.dk-close-bio {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 1.8vw, 1.6rem);
}

.dk-close-photo {
  display: block;
  flex: none;
  width: clamp(5.4rem, 14vh, 8rem);
  height: clamp(5.4rem, 14vh, 8rem);
  overflow: hidden;
  border: 1px solid var(--deck-border);
  border-radius: 50%;
}
.dk-close-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 18%;
}

.dk-close-id { min-width: 0; }
.dk-close-id strong {
  display: block;
  color: var(--deck-text);
  font-size: clamp(1.5rem, 2.5vw, 2.3rem);
  font-weight: 650;
  line-height: 1.1;
}
.dk-close-id em {
  display: block;
  margin-top: 0.2rem;
  color: var(--deck-accent);
  font-size: clamp(1.05rem, 1.6vw, 1.5rem);
  font-style: normal;
  font-weight: 650;
  line-height: 1.2;
}
body.present-mode .present-deck--research .dk-close-topics {
  display: grid;
  gap: 0.3rem;
  margin: 0.7rem 0 0;
  padding: 0;
  list-style: none;
  font-size: clamp(0.92rem, 1.3vw, 1.25rem);
  line-height: 1.3;
}
body.present-mode .present-deck--research .dk-close-topics li {
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.7rem;
  margin: 0;
  padding: 0;
}
.dk-close-topics span:first-child { color: var(--deck-text); font-weight: 650; }
.dk-close-topics span:last-child { color: var(--deck-muted); }

.dk-close-foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: clamp(1.2rem, 2.4vw, 2.4rem);
  padding-top: clamp(0.8rem, 1.8vh, 1.3rem);
  border-top: 1px solid var(--deck-border);
}

.dk-close-with { flex: 1; min-width: 0; }
.dk-close-label {
  margin: 0 0 0.45rem;
  color: var(--deck-accent);
  font-size: clamp(0.78rem, 1vw, 0.95rem);
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.dk-close-names {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem clamp(0.9rem, 1.5vw, 1.4rem);
  margin: 0;
  color: var(--deck-text);
  font-size: clamp(1.1rem, 1.75vw, 1.65rem);
  font-weight: 500;
  line-height: 1.3;
}
.dk-close-names span { white-space: nowrap; }
.dk-close-names .dk-first { font-weight: 700; }
.dk-close-names sup { margin-left: 0.08em; color: var(--deck-accent); font-size: 0.7em; line-height: 0; }
.dk-close-note {
  margin: 0.45rem 0 0;
  color: var(--deck-muted);
  font-size: clamp(0.85rem, 1.1vw, 1.05rem);
}
.dk-close-note sup { color: var(--deck-accent); font-size: 0.8em; line-height: 0; }

.dk-close-qr {
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
}
.dk-close-qr img {
  display: block;
  width: clamp(7.2rem, 19vh, 11rem);
  height: auto;
  padding: 0.4rem;
  background: #fff;
  border: 1px solid var(--deck-border);
  border-radius: 2px;
}
.dk-close-qr p {
  margin: 0;
  color: var(--deck-muted);
  font-size: clamp(0.85rem, 1.15vw, 1.1rem);
  line-height: 1.3;
}

@media (max-width: 900px) {
  .dk-close { flex-direction: column; }
  .dk-close-foot { flex-wrap: wrap; align-items: flex-start; }
}


/* ---------- equal-height columns, photos that fill their row ---------- */
.dk-grid--stretch { align-items: stretch; }
.dk-stack--even { align-content: stretch; grid-auto-rows: 1fr; }
.dk-grid > .dk-stack--even { align-content: stretch; }
.dk-stack--even > .dk-card,
.dk-stack--even > .dk-stat { height: 100%; }

.dk-fig--fill {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: 0;
}
.dk-fig-media {
  position: relative;
  min-height: clamp(9rem, var(--dk-min, 32vh), 26rem);
  background: var(--dk-media-bg, var(--deck-surface));
}
.dk-fig--fill .dk-fig-media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: var(--dk-fit, cover);
  object-position: var(--dk-pos, 50% 50%);
}

/* Cards in a row start at the same line, whatever their text length. */
.dk-row > .dk-card { justify-content: flex-start; }

/* Slimmer cards stay readable. */
.dk-row--slim .dk-card h3,
.dk-stack--slim .dk-card h3 { font-size: clamp(1.1rem, 1.6vw, 1.5rem); }
.dk-row--slim .dk-card p,
.dk-stack--slim .dk-card p { font-size: clamp(0.95rem, 1.3vw, 1.2rem); }

/* ---------- title slide: authors and hook ---------- */
.present-deck--research .present-slide--title .dk-authors {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.15rem 0;
  max-width: 34rem;
  font-size: clamp(1rem, 1.4vw, 1.28rem);
  line-height: 1.4;
}
.present-deck--research .present-slide--title .dk-authors .dk-au {
  display: inline-block;
  margin: 0;
  color: var(--deck-muted);
  font-size: inherit;
  white-space: nowrap;
}
.present-deck--research .present-slide--title .dk-authors .dk-au strong { color: var(--deck-text); }
.present-deck--research .present-slide--title .dk-authors .dk-au i {
  margin: 0 0.5em;
  color: var(--deck-dim);
  font-style: normal;
}
.present-deck--research .present-slide--title .dk-authors .dk-equal {
  flex: 0 0 100%;
  display: block;
  margin: 0.2rem 0 0;
  color: var(--deck-dim);
  font-size: 0.82em;
  white-space: normal;
}
.present-deck--research .present-slide--title .present-deck-hook {
  max-width: 20ch;
  margin-top: clamp(0.5rem, 2vh, 1.4rem);
  padding-top: clamp(0.9rem, 2.2vh, 1.5rem);
  border-top: 1px solid var(--deck-border);
}

/* ---------- a stat laid out as a band under a row of figures ---------- */
.dk-stat--band {
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: clamp(1rem, 2.2vw, 2.2rem);
  padding: clamp(0.6rem, 1vw, 0.9rem) clamp(1rem, 2vw, 1.8rem);
}
.dk-stat--band strong { flex: none; font-size: clamp(2rem, 3.6vw, 3.4rem); }
.dk-stat--band span { margin-top: 0; font-size: clamp(1rem, 1.45vw, 1.35rem); }

/* Figures side by side share their caption row, so the cards line up even when
   one caption runs to two lines. */
.dk-grid.dk-grid--twins {
  grid-template-rows: minmax(0, 1fr) auto;
  row-gap: 0.4rem;
}
.dk-grid--twins > .dk-figure--fit {
  grid-row: span 2;
  grid-template-rows: subgrid;
}

/* Cards that follow the drawing's own shape instead of filling the slide. */
.dk-grid--natural .dk-fitbox { aspect-ratio: var(--dk-ar); }

/* A text column beside captioned figures stops where the cards stop. */
.dk-grid--twins > .dk-stack { grid-row: 1; grid-column: 2; }
.dk-grid--twins > .dk-figure--fit:first-child { grid-column: 1; }

/* Stats in a row all start on the same line. */
.dk-row > .dk-stat { justify-content: flex-start; }

/* ---------- qualities table: photo, pixel layout, electrode distance, base frequency ---------- */
.dk-qtab {
  display: grid;
  grid-template-columns: 5.4rem repeat(4, minmax(0, 1fr));
  align-items: stretch;
  min-width: 0;
}
.dk-qtab > * { min-width: 0; }
.dk-qdefs { position: absolute; width: 0; height: 0; overflow: hidden; }
.dk-qtab .dk-tile { padding: 0 0.3rem; }
.dk-qh,
.dk-qc {
  display: flex;
  align-items: center;
  border-top: 1px solid var(--deck-border);
  padding-block: clamp(0.3rem, 0.8vh, 0.55rem);
}
.dk-qh {
  padding-right: 0.5rem;
  color: var(--deck-accent);
  font-size: clamp(0.85rem, 1.1vw, 1.02rem);
  font-weight: 600;
  line-height: 1.25;
}
.dk-qc {
  justify-content: center;
  padding-inline: 0.3rem;
  color: var(--deck-text);
  font-size: clamp(1rem, 1.45vw, 1.35rem);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.dk-qc svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: clamp(4rem, 12vh, 7rem);
}
/* the first table row (photos) carries no rule */
.dk-qtab .dk-tile { margin-bottom: clamp(0.3rem, 0.8vh, 0.55rem); }

/* ---------- a single picture centred over a row of cards ---------- */
.dk-solo {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 0.4rem;
  justify-items: center;
  min-height: 0;
  min-width: 0;
  margin: 0;
}
.dk-fitbox--center {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
}
.dk-fitbox--center > img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100cqw;
  max-height: 100cqh;
}
.dk-solo > .dk-cap { text-align: center; }
