/* --------------------------------------------------------
   binary-plus, essay layout
   Reuses tokens, fonts, scroll-reveal and dark mode from styles.css.
   Aesthetic: calm reading column (nohello-clean), one live matrix.
   -------------------------------------------------------- */

.doc-body {
  line-height: 1.7;
}

/* --- Back link --- */

.topbar__back {
  position: absolute;
  top: 1.5rem;
  left: 1.5rem;
  font-size: 0.8rem;
  font-weight: 500;
  font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', ui-monospace, monospace;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s ease;
  z-index: 2;
}

.topbar__back:hover { color: var(--blue); }

/* --- Reading column --- */

.doc {
  max-width: 720px;
  margin: 0 auto;
  padding: 7rem 1.5rem 5rem;
}

/* --- Header --- */

.doc__header { margin-bottom: 2.5rem; }

.doc__title {
  font-size: clamp(2.6rem, 9vw, 4.5rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.0;
  font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', ui-monospace, monospace;
  color: var(--fg);
}

.doc__bang {
  color: var(--violet);
  font-weight: 700;
  margin-left: 0.04em;
}

.doc__lede {
  margin-top: 1.4rem;
  font-size: 1.12rem;
  color: var(--slate);
  max-width: 38rem;
}

/* --- Rule --- */

.rule {
  height: 1px;
  background: linear-gradient(to right,
    transparent, var(--blue) 18%, var(--teal) 50%, var(--coral) 82%, transparent);
  opacity: 0.32;
  margin: 0 0 3.5rem;
}

/* --- Sections --- */

.section { margin-bottom: 4rem; }

.kicker {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', ui-monospace, monospace;
  color: var(--teal);
  margin-bottom: 0.6rem;
}

.section h2 {
  font-size: clamp(1.4rem, 3.6vw, 1.85rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--fg);
  margin-bottom: 1.1rem;
}

.section p { margin-bottom: 1.1rem; }
.section p:last-child { margin-bottom: 0; }

code {
  font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.88em;
  background: var(--faint);
  padding: 0.08em 0.34em;
  border-radius: 4px;
}

/* --- Inline prose links --- */

.section a {
  color: var(--blue);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--blue) 40%, transparent);
  text-underline-offset: 2px;
  transition: text-decoration-color 0.2s ease;
}
.section a:hover { text-decoration-color: var(--blue); }

/* --- First-order move cards --- */

.moves {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-top: 1.6rem;
}

@media (min-width: 620px) {
  .moves { grid-template-columns: 1fr 1fr; }
}

.move {
  border: 1px solid var(--faint);
  border-radius: 10px;
  padding: 1.25rem 1.35rem;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
}

.move--pick {
  border-color: color-mix(in srgb, var(--violet) 55%, var(--faint));
  box-shadow: 0 4px 24px color-mix(in srgb, var(--violet) 14%, transparent);
}

.move__name {
  font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', ui-monospace, monospace;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--blue);
  margin-bottom: 0.15rem;
}

.move--pick .move__name { color: var(--violet); }

.move__gloss {
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 0.9rem !important;
}

.move__row {
  font-size: 0.86rem;
  line-height: 1.55;
  margin-bottom: 0.55rem !important;
  padding-left: 1.3rem;
  position: relative;
  color: var(--slate);
}
.move__row:last-child { margin-bottom: 0 !important; }

.move__row span {
  position: absolute;
  left: 0;
  font-weight: 700;
  font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', ui-monospace, monospace;
}

.move__row--up span   { color: var(--teal); }
.move__row--down span { color: var(--coral); }

.move code { background: color-mix(in srgb, var(--faint) 70%, transparent); }

/* --- Payoff matrix --- */

.matrix-wrap {
  overflow-x: auto;
  margin: 1.8rem 0 1.2rem;
  -webkit-overflow-scrolling: touch;
}

.matrix {
  border-collapse: separate;
  border-spacing: 4px;
  width: 100%;
  min-width: 460px;
  font-size: 0.9rem;
}

.matrix th {
  font-weight: 600;
  color: var(--muted);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.4rem 0.3rem;
  text-align: center;
}

.matrix thead th abbr {
  text-decoration: none;
  border-bottom: 1px dotted var(--faint);
  cursor: help;
}

.matrix tbody th[scope="row"] {
  text-align: left;
  font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.82rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--fg);
  white-space: nowrap;
  padding-right: 0.6rem;
}

.matrix__corner { text-align: left !important; }

.col--sum, .col--min { color: var(--slate) !important; }

/* Cells */

.cell {
  position: relative;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  padding: 0.6rem 0.4rem;
  border-radius: 7px;
  cursor: default;
  min-width: 2.6rem;
  outline: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.cell:hover, .cell:focus, .cell.is-pinned {
  transform: translateY(-1px);
  box-shadow: 0 3px 14px rgba(0,0,0,0.10);
  z-index: 5;
}

.cell--pos  { background: color-mix(in srgb, var(--teal) 16%, var(--bg)); color: var(--teal); }
.cell--pos-strong { background: color-mix(in srgb, var(--teal) 30%, var(--bg)); }
.cell--neg  { background: color-mix(in srgb, var(--coral) 18%, var(--bg)); color: var(--coral); }
.cell--zero { background: var(--faint); color: var(--muted); }

.cell--sum { background: color-mix(in srgb, var(--slate) 12%, var(--bg)); color: var(--slate); }
.cell--sum-win { background: color-mix(in srgb, var(--violet) 22%, var(--bg)); color: var(--violet); font-weight: 700; }
.cell--min { background: color-mix(in srgb, var(--slate) 8%, var(--bg)); color: var(--slate); }
.cell--min-win {
  background: color-mix(in srgb, var(--violet) 26%, var(--bg));
  color: var(--violet);
  font-weight: 700;
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--violet) 55%, transparent);
}
.cell--min-bad { color: var(--coral); }

/* Highlighted winning row */

.row--pick th[scope="row"] { color: var(--violet); }
.row--pick .cell { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--violet) 18%, transparent); }
.row--pick .cell--min-win { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--violet) 55%, transparent); }

/* Tooltip */

.cell__tip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  width: max-content;
  max-width: 15rem;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  background: var(--fg);
  color: var(--bg);
  font-size: 0.76rem;
  font-weight: 400;
  line-height: 1.45;
  text-align: left;
  letter-spacing: 0;
  text-transform: none;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
  z-index: 20;
  box-shadow: 0 8px 30px rgba(0,0,0,0.22);
}

.cell__tip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--fg);
}

.cell__tip code {
  background: color-mix(in srgb, var(--bg) 22%, transparent);
  color: inherit;
}

.cell:hover .cell__tip,
.cell:focus .cell__tip,
.cell.is-pinned .cell__tip {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* Keep tooltips of edge cells from clipping off-screen */
.matrix tr td:first-of-type .cell__tip { left: 0; transform: translateX(0) translateY(4px); }
.matrix tr td:first-of-type .cell__tip::after { left: 1.4rem; }
.matrix tr td:first-of-type .cell:hover .cell__tip,
.matrix tr td:first-of-type .cell:focus .cell__tip,
.matrix tr td:first-of-type .cell.is-pinned .cell__tip { transform: translateX(0) translateY(0); }

.matrix tr td:nth-child(n+5) .cell__tip { left: auto; right: 0; transform: translateX(0) translateY(4px); }
.matrix tr td:nth-child(n+5) .cell__tip::after { left: auto; right: 1.4rem; }
.matrix tr td:nth-child(n+5) .cell:hover .cell__tip,
.matrix tr td:nth-child(n+5) .cell:focus .cell__tip,
.matrix tr td:nth-child(n+5) .cell.is-pinned .cell__tip { transform: translateX(0) translateY(0); }

/* Top row: the scroll wrapper clips upward, so flip its tooltips below the cell */
.matrix tbody tr:first-child .cell__tip {
  bottom: auto;
  top: calc(100% + 8px);
}
.matrix tbody tr:first-child .cell__tip::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: var(--fg);
}

/* --- Footer --- */

.doc__footer {
  display: flex;
  gap: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--faint);
}

.doc__home {
  font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--slate);
  text-decoration: none;
  transition: color 0.2s ease;
}
.doc__home:hover { color: var(--blue); }

/* --- A11y util --- */

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* --- Dark-mode nudges (tokens already flip via styles.css) --- */

@media (prefers-color-scheme: dark) {
  .cell:hover, .cell:focus, .cell.is-pinned {
    box-shadow: 0 3px 16px rgba(0,0,0,0.4);
  }
  .cell__tip { box-shadow: 0 8px 30px rgba(0,0,0,0.5); }
  .matrix thead th abbr { border-bottom-color: var(--faint); }
}

/* --- Pronoun-set toggle (he/they <-> she/they) --- */
/* Paired tokens: .v-he shows by default, .v-she swaps in under body.set-she. */

.v-she { display: none; }
body.set-she .v-he { display: none; }
body.set-she .v-she { display: inline; }

.switch {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
  margin-top: 1.7rem;
}

.switch__seg {
  display: inline-flex;
  border: 1px solid var(--faint);
  border-radius: 999px;
  padding: 3px;
  margin: 0;
}

.switch__seg label {
  display: inline-block;
  padding: 0.3rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.8rem;
  color: var(--muted);
  transition: color 0.2s ease, background 0.2s ease;
}

.switch__seg label:hover { color: var(--slate); }

.switch__seg input {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
  pointer-events: none;
}

.switch__seg label:has(input:checked) {
  background: color-mix(in srgb, var(--violet) 18%, var(--bg));
  color: var(--violet);
}

.switch__seg label:has(input:focus-visible) {
  outline: 2px solid var(--violet);
  outline-offset: 2px;
}

.switch__note {
  font-size: 0.78rem;
  font-style: italic;
  color: var(--muted);
}

/* --- Column-header tooltips (same box as cells, flipped below the thead) --- */

.cell-head {
  position: relative;
  cursor: help;
  outline: none;
  text-decoration: underline dotted;
  text-decoration-color: var(--faint);
  text-underline-offset: 3px;
}

.cell-head .cell__tip {
  bottom: auto;
  top: calc(100% + 8px);
}
.cell-head .cell__tip::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: var(--fg);
}
.cell-head:hover .cell__tip,
.cell-head:focus .cell__tip,
.cell-head.is-pinned .cell__tip {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* Outer header tips: anchor to the edge so they don't clip past the matrix */
.matrix thead th:nth-child(2) .cell__tip { left: 0; transform: translateX(0) translateY(4px); }
.matrix thead th:nth-child(2) .cell__tip::after { left: 1.4rem; }
.matrix thead th:nth-child(2):hover .cell__tip,
.matrix thead th:nth-child(2):focus .cell__tip,
.matrix thead th:nth-child(2).is-pinned .cell__tip { transform: translateX(0) translateY(0); }

.matrix thead th:nth-child(n+5) .cell__tip { left: auto; right: 0; transform: translateX(0) translateY(4px); }
.matrix thead th:nth-child(n+5) .cell__tip::after { left: auto; right: 1.4rem; }
.matrix thead th:nth-child(n+5):hover .cell__tip,
.matrix thead th:nth-child(n+5):focus .cell__tip,
.matrix thead th:nth-child(n+5).is-pinned .cell__tip { transform: translateX(0) translateY(0); }

/* --- Interactive room mixer (show, don't tell) --- */

.mixer {
  margin-top: 1.7rem;
  border: 1px solid var(--faint);
  border-radius: 12px;
  padding: 1.3rem 1.45rem;
  background: color-mix(in srgb, var(--violet) 4%, transparent);
}

.mixer__lead { font-size: 0.92rem; color: var(--slate); margin-bottom: 1.1rem; }

.mixer__sliders {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem 1.5rem;
  margin-bottom: 1.3rem;
}
@media (max-width: 540px) { .mixer__sliders { grid-template-columns: 1fr; } }

.mixer__slider { display: flex; align-items: center; gap: 0.7rem; }
.mixer__slider span {
  flex: 0 0 5.4rem;
  font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.mixer__slider input[type="range"] { flex: 1; min-width: 0; accent-color: var(--violet); cursor: pointer; }

.mixer__results { display: grid; gap: 0.35rem; }

.res {
  display: grid;
  grid-template-columns: 5rem 1fr 2.7rem auto;
  align-items: center;
  gap: 0.7rem;
  padding: 0.32rem 0.45rem;
  border-radius: 7px;
  transition: background 0.15s ease;
}
.res__name { font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', ui-monospace, monospace; font-size: 0.8rem; color: var(--fg); }
.res__bar { height: 9px; background: var(--faint); border-radius: 5px; overflow: hidden; }
.res__bar i { display: block; height: 100%; width: 0; background: var(--teal); transition: width 0.18s cubic-bezier(0.16,1,0.3,1); }
.res__score { font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', ui-monospace, monospace; font-weight: 700; font-size: 0.82rem; text-align: right; font-variant-numeric: tabular-nums; color: var(--slate); }
.res__min { font-size: 0.66rem; color: var(--muted); white-space: nowrap; text-transform: uppercase; letter-spacing: 0.03em; }
.res__min b { font-variant-numeric: tabular-nums; color: var(--slate); }
.res__min.neg b { color: var(--coral); }

.res--lead { background: color-mix(in srgb, var(--violet) 12%, transparent); }
.res--lead .res__name { color: var(--violet); font-weight: 700; }
.res--lead .res__bar i { background: var(--violet); }
.res--lead .res__score { color: var(--violet); }

.mixer__rank {
  margin-top: 1.2rem;
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  flex-wrap: wrap;
}
.mixer__rank-label {
  flex: 0 0 auto;
  font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}
.mixer__rank-list {
  font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.86rem;
  color: var(--muted);
}
.rk { transition: color 0.15s ease; }
.rk--lead { color: var(--violet); font-weight: 700; }
.rk__sep { margin: 0 0.5em; color: color-mix(in srgb, var(--muted) 50%, transparent); }
