/* /inside — the interactive "how it works" page. Builds on styles.css (same
   tokens, nav, sections, fonts); everything here is specific to its labs. */

body {
  /* Key material is gold everywhere on this page; file kinds get their own hues
     so a chunk can be traced back to its file through the pipeline. */
  --key: #F2C14E;
  --key-soft: color-mix(in oklab, var(--key) 14%, transparent);
  --k-text: #5EC8F2;
  --k-sheet: #6FDDB0;
  --k-photo: #B79CFF;
  --k-video: #FFB070;
  --k-pdf: #F28DB2;
  --sealed: #2A3542;
  --sealed-ink: #8494A3;
  --danger: #F2716B;
}
body.light {
  --key: #B5850A;
  --k-text: #1C8FC0;
  --k-sheet: #17946A;
  --k-photo: #7B5BE0;
  --k-video: #D2711E;
  --k-pdf: #C8467A;
  --sealed: #C9D3DA;
  --sealed-ink: #4E6070;
  --danger: #C2272D;
}

.mono, code { font-family: 'JetBrains Mono', monospace; }

/* ---------- Hero ---------- */

.in-hero { padding-bottom: 64px; }
.in-hero h1 { max-width: 760px; }
.in-chapters {
  animation: fadeUp .6s .24s ease both;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  width: 100%;
  max-width: 820px;
  margin-top: 14px;
  text-align: left;
}
.in-chapter {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg2);
  color: var(--text2);
  font-size: 14px;
  transition: border-color .2s;
}
.in-chapter:hover { text-decoration: none; border-color: var(--accent); }
.in-chapter-k {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 16px;
  color: var(--text);
}

.in-lede { max-width: 660px; }

/* ---------- Lab panels ---------- */

.lab {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
  margin-bottom: 22px;
}
.lab-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; margin-bottom: 22px; }
.lab-head h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 20px;
  font-weight: 600;
  margin: 0;
}
.lab-head p { margin: 0; color: var(--text3); font-size: 14px; }
.lab-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 8px;
}
.lab-hint { margin: 10px 0 0; color: var(--text3); font-size: 13px; line-height: 1.55; text-wrap: pretty; }
/* A written-out block between two labs keeps the labs' spacing. */
.written + .lab { margin-top: 22px; }

.lab-foot {
  margin: 22px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--line2);
  color: var(--text2);
  font-size: 14px;
  line-height: 1.65;
  max-width: 820px;
  text-wrap: pretty;
}

.linkish {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  color: var(--accent-ink);
  cursor: pointer;
}
.linkish:hover { text-decoration: underline; }

button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Passphrase → KEK ---------- */

.kdf {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px minmax(0, 1.1fr) 28px minmax(0, 1fr);
  align-items: start;
  gap: 8px;
}
.kdf-col { min-width: 0; }
.kdf-arrow {
  align-self: center;
  height: 2px;
  background: linear-gradient(90deg, var(--line), var(--accent));
  position: relative;
  margin-top: -40px;
}
.kdf-arrow::after {
  content: "";
  position: absolute;
  right: -2px;
  top: -4px;
  border: 5px solid transparent;
  border-left: 7px solid var(--accent);
  border-right: 0;
}

.pp-input {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px;
}

.mill {
  display: grid;
  grid-template-columns: repeat(24, minmax(0, 1fr));
  gap: 3px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}
.mill i {
  display: block;
  aspect-ratio: 1;
  border-radius: 2px;
  background: var(--line2);
  transition: background .25s;
}
.mill i[data-p="1"] { background: color-mix(in oklab, var(--accent) 35%, transparent); }
.mill i[data-p="2"] { background: color-mix(in oklab, var(--accent) 65%, transparent); }
.mill i[data-p="3"] { background: var(--accent); }
.mill i.hot { background: var(--key); }
.mill-status {
  margin-top: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text3);
  font-variant-numeric: tabular-nums;
}
.kv { display: flex; gap: 10px; align-items: baseline; margin-top: 10px; font-size: 13px; color: var(--text2); }
.kv code { font-size: 12px; color: var(--text2); overflow-wrap: anywhere; }

.hexkey {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--key-soft);
  border: 1px solid color-mix(in oklab, var(--key) 40%, transparent);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13.5px;
  color: var(--key);
  font-variant-numeric: tabular-nums;
}
.hexkey span { display: inline-flex; }
.hexkey b { font-weight: 500; transition: color .5s, background .5s; border-radius: 2px; }
.hexkey b.flip { color: var(--bg); background: var(--key); transition: none; }

/* ---------- Keyring ---------- */

.ring {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.ring-seals { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.seal {
  display: flex;
  gap: 12px;
  align-items: center;
  text-align: left;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  min-width: 0;
  transition: border-color .25s, background .25s;
}
.seal:hover { border-color: var(--text3); }
.seal.open { border-color: color-mix(in oklab, var(--key) 60%, transparent); background: var(--key-soft); }
.seal.bad { border-color: color-mix(in oklab, var(--danger) 60%, transparent); }
.seal-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.seal-title { font-weight: 600; font-size: 14.5px; }
.seal-state { font-size: 12.5px; color: var(--text3); overflow-wrap: anywhere; }
.seal-state code { font-size: 11px; line-height: 1.5; }
.seal.open .seal-state { color: var(--key); }
.seal.bad .seal-state { color: var(--danger); }

/* A padlock drawn in CSS: shackle lifts when the seal opens. */
.seal-lock { position: relative; flex: 0 0 22px; height: 24px; }
.seal-lock::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 0;
  width: 10px;
  height: 12px;
  border: 2.5px solid var(--text3);
  border-bottom: 0;
  border-radius: 7px 7px 0 0;
  transition: transform .35s ease, border-color .25s;
  transform-origin: 100% 100%;
}
.seal-lock::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 22px;
  height: 13px;
  border-radius: 3px;
  background: var(--text3);
  transition: background .25s;
}
.seal.open .seal-lock::before { transform: translateY(-4px) rotate(-18deg); border-color: var(--key); }
.seal.open .seal-lock::after { background: var(--key); }
.seal.bad .seal-lock::after, .seal.bad .seal-lock::before { border-color: var(--danger); background: var(--danger); }
.seal.bad .seal-lock::before { background: none; }

.ring-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.btn-small {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--btn-ink);
  cursor: pointer;
}
.btn-small:hover { filter: brightness(1.08); }
.btn-small.ghost { background: none; border-color: var(--line); color: var(--text2); }
.btn-small.ghost:hover { color: var(--text); border-color: var(--text3); }

.ring-box {
  min-width: 0;
  border-radius: 14px;
  border: 1.5px dashed var(--line);
  padding: 16px;
  background-image: radial-gradient(circle, var(--dot) 1px, transparent 1px);
  background-size: 18px 18px;
  transition: border-color .3s;
}
.ring-box[data-state="open"] { border-style: solid; border-color: color-mix(in oklab, var(--key) 55%, transparent); }
.ring-box-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.ring-box-title { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 16px; }
.ring-box-state { font-size: 12.5px; color: var(--text3); }
.ring-box[data-state="open"] .ring-box-state { color: var(--key); }

.ring-keys { display: grid; gap: 8px; }
.key-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  text-align: left;
  min-width: 0;
}
.key-name { font-weight: 600; font-size: 14px; white-space: nowrap; }
.key-val {
  font-size: 12px;
  color: var(--sealed-ink);
  letter-spacing: .02em;
  overflow: hidden;
  text-overflow: clip;
  white-space: nowrap;
  min-width: 0;
}
.ring-box[data-state="open"] .key-val { color: var(--key); }

.ring-derived { margin-top: 14px; }
.ring-derived-label { font-size: 12.5px; color: var(--text3); margin-bottom: 8px; }
.ring-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-key {
  font: inherit;
  font-size: 12.5px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--text3);
  cursor: pointer;
  transition: color .3s, border-color .3s, background .3s;
}
.ring-box[data-state="open"] .chip-key { color: var(--text); border-color: color-mix(in oklab, var(--key) 35%, var(--line)); }

.key-card.sel, .chip-key.sel, .seal.sel { box-shadow: 0 0 0 2px var(--accent); }

.ring-detail {
  min-width: 0;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 18px;
  font-size: 14px;
}
.ring-detail-name { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 17px; margin-bottom: 8px; }
.ring-detail p { margin: 0 0 14px; color: var(--text2); line-height: 1.6; text-wrap: pretty; }
.ring-detail dl { margin: 0; display: grid; gap: 4px; }
.ring-detail dt { font-size: 12px; font-weight: 600; color: var(--text3); margin-top: 6px; }
.ring-detail dd { margin: 0; color: var(--text); line-height: 1.5; }
.kd-how {
  display: block;
  margin-top: 14px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg3);
  font-size: 11.5px;
  color: var(--text2);
  overflow-wrap: anywhere;
}
.kd-how:empty { display: none; }

/* ---------- Who sees what ---------- */

.seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--bg3);
  margin-bottom: 18px;
}
.seg button {
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 9px;
  border: 0;
  background: none;
  color: var(--text2);
  cursor: pointer;
}
.seg button[aria-checked="true"] { background: var(--bg2); color: var(--text); box-shadow: 0 1px 0 var(--line), 0 2px 10px -4px rgba(0,0,0,.35); }
.seg-sm { margin-bottom: 0; }
.seg-sm button { font-size: 13.5px; padding: 7px 12px; }

.sees { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 18px; }
.sees li {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 4px 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line2);
  min-width: 0;
}
.sees .mark {
  grid-row: span 2;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  margin-top: 1px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--bg);
  background: var(--ok);
  transition: background .3s;
}
.sees li.hidden .mark { background: var(--sealed); color: var(--sealed-ink); }
.sees .what { font-size: 13px; color: var(--text3); }
.sees .val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--text);
  overflow-wrap: anywhere;
  min-height: 1.4em;
}
.sees li.hidden .val { color: var(--sealed-ink); }
.sees li.never .val { font-family: 'Instrument Sans', sans-serif; font-style: italic; color: var(--text3); }

/* ---------- Backup pipeline ---------- */

.pipe { padding-bottom: 22px; }
.pipe-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; }
.pipe-ctrl { display: flex; gap: 6px; }
.icon-btn {
  width: 40px;
  height: 36px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text2);
  font-size: 13px;
  cursor: pointer;
}
.icon-btn:hover { color: var(--text); border-color: var(--text3); }
.icon-btn.play { width: 56px; background: var(--accent); color: var(--btn-ink); border-color: transparent; font-size: 14px; }

.steps {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 4px;
  counter-reset: step;
}
.steps button {
  width: 100%;
  font: inherit;
  font-size: 12.5px;
  text-align: left;
  padding: 8px 8px 9px;
  border: 0;
  border-top: 3px solid var(--line);
  background: none;
  color: var(--text3);
  cursor: pointer;
  transition: color .25s, border-color .25s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.steps button .n { font-family: 'JetBrains Mono', monospace; font-size: 11px; margin-right: 6px; }
.steps button.done { border-top-color: color-mix(in oklab, var(--accent) 45%, transparent); color: var(--text2); }
.steps button.cur { border-top-color: var(--accent); color: var(--text); font-weight: 600; }

.stage-wrap { overflow: hidden; border-radius: 12px; border: 1px solid var(--line2); background: var(--bg); }
.stage {
  position: relative;
  min-height: 300px;
  background-image: radial-gradient(circle, var(--dot) 1px, transparent 1px);
  background-size: 22px 22px;
  transition: height .4s ease;
}
.stage .flabel, .stage .note, .stage .zone, .stage .chunk, .stage .tag {
  position: absolute;
  left: 0;
  top: 0;
  transition: transform .7s cubic-bezier(.6,.05,.25,1), width .7s cubic-bezier(.6,.05,.25,1),
              height .7s cubic-bezier(.6,.05,.25,1), opacity .5s, background-color .5s, border-color .5s;
}
.stage .flabel {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}
.stage .flabel small { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--text3); }
.stage.narrow .flabel { flex-direction: row; align-items: baseline; gap: 8px; }
.stage .flabel.dim { opacity: .38; }

.stage .chunk {
  box-sizing: border-box;
  border-radius: 4px;
  background: var(--c);
  border: 1px solid color-mix(in oklab, var(--c) 70%, #000);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  color: color-mix(in oklab, var(--c) 25%, #000);
  font-weight: 600;
}
body.light .stage .chunk { color: #fff; border-color: color-mix(in oklab, var(--c) 80%, #000); }
.stage .chunk .id { opacity: 0; transition: opacity .4s; white-space: nowrap; }
.stage .chunk.show-id .id { opacity: 1; }
.stage .chunk.reused { opacity: .45; }
.stage .chunk.sealed {
  background-color: var(--sealed);
  background-image: var(--noise);
  background-size: 64px 64px;
  border-color: color-mix(in oklab, var(--c) 55%, var(--sealed));
  color: var(--sealed-ink);
}
.stage .chunk.sealed::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--c);
}
.stage .chunk.gone { opacity: 0; }

.stage .zone {
  box-sizing: border-box;
  border: 1.5px dashed var(--line);
  border-radius: 10px;
  pointer-events: none;
}
.stage .zone.pack { border-style: solid; border-color: var(--text3); background: color-mix(in oklab, var(--bg2) 70%, transparent); }
.stage .zone.dest { border-color: color-mix(in oklab, var(--accent) 50%, transparent); background: var(--accent-soft); }
.stage .zone.tray { border-color: var(--line2); }
.stage .zone .zl {
  position: absolute;
  left: 10px;
  top: -9px;
  padding: 0 6px;
  background: var(--bg);
  font-size: 11.5px;
  color: var(--text3);
  white-space: nowrap;
}
.stage .zone.pack .zl { font-family: 'JetBrains Mono', monospace; font-size: 10.5px; }
.stage .zone.dest .zl { color: var(--accent-ink); }

.stage .tag {
  font-size: 11.5px;
  color: var(--text3);
  white-space: nowrap;
  font-family: 'JetBrains Mono', monospace;
}
.stage .tag.good { color: var(--ok); }
.stage .tag.key { color: var(--key); }

.stage .note {
  font-size: 12px;
  color: var(--text2);
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--bg2);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.stage .note.ok { color: var(--ok); border-color: color-mix(in oklab, var(--ok) 40%, transparent); }

.pipe-caption { margin-top: 18px; min-height: 108px; max-width: 760px; }
.pipe-caption h3 { font-family: 'Space Grotesk', sans-serif; font-size: 20px; font-weight: 600; margin: 0 0 8px; }
.pipe-caption p { margin: 0; color: var(--text2); font-size: 15px; line-height: 1.65; text-wrap: pretty; }

.meters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}
.meter {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line2);
  background: var(--bg);
  transition: opacity .3s, border-color .3s;
}
.meter.off { opacity: .4; }
.meter.hl { border-color: color-mix(in oklab, var(--accent) 50%, transparent); }
.meter .ml { font-size: 12px; color: var(--text3); }
.meter .mv {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

/* ---------- Repository ---------- */

.repo {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.repo-tree { display: flex; flex-direction: column; font-family: 'JetBrains Mono', monospace; font-size: 13px; min-width: 0; }
.repo-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  min-width: 0;
}
.repo-row:hover { background: var(--bg3); }
.repo-row[aria-selected="true"] { background: var(--accent-soft); color: var(--accent-ink); }
.repo-row .rn { white-space: pre; overflow: hidden; text-overflow: ellipsis; }
.repo-row .rs { color: var(--text3); white-space: nowrap; font-size: 12px; }
.repo-row.child .rn { color: var(--text2); }
.repo-row[aria-selected="true"] .rn { color: var(--accent-ink); }

.repo-detail {
  position: sticky;
  top: 84px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  padding: 20px;
  min-width: 0;
}
.repo-detail-name { font-family: 'JetBrains Mono', monospace; font-weight: 600; font-size: 15px; margin-bottom: 10px; }
.repo-detail p { margin: 0 0 16px; color: var(--text2); font-size: 14.5px; line-height: 1.65; text-wrap: pretty; }
.repo-sees code {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bg3);
  font-size: 12px;
  line-height: 1.7;
  color: var(--text2);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ---------- Narrow screens ---------- */

@media (max-width: 900px) {
  .kdf { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .kdf-arrow { width: 2px; height: 22px; margin: 0 auto; background: linear-gradient(180deg, var(--line), var(--accent)); }
  .kdf-arrow::after { right: auto; left: -4px; top: auto; bottom: -4px; border: 5px solid transparent; border-top: 7px solid var(--accent); border-bottom: 0; }
  .ring { grid-template-columns: minmax(0, 1fr); }
  .repo { grid-template-columns: minmax(0, 1fr); }
  .repo-detail { position: static; }
  .steps { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .in-chapters { grid-template-columns: minmax(0, 1fr); }
  .lab { padding: 20px 16px; }
  .sees { grid-template-columns: minmax(0, 1fr); }
  .meters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .steps button .t { display: none; }
  .steps button { text-align: center; }
  .steps button .n { margin: 0; }
  .steps { grid-template-columns: repeat(8, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .stage .flabel, .stage .note, .stage .zone, .stage .chunk, .stage .tag,
  .mill i, .hexkey b, .seal-lock::before { transition: none !important; }
  .in-chapters { animation: none; }
}
