/* ============================================================
   Tamerix -- shared issue component library
   Loaded by every issue page AFTER core.css and BEFORE the
   issue's own styles.css:

     <link rel="stylesheet" href="../../assets/core.css">
     <link rel="stylesheet" href="../../assets/issue.css">
     <link rel="stylesheet" href="./styles.css">

   This file owns the editorial + interactive components that are
   identical across issues: prose marks, form chrome, code blocks,
   tables, panels, message cards, JSON blocks, the step trace, and
   the comparison matrix. It uses var(--accent) / var(--accent-soft),
   so it themes itself to whatever accent the issue declares.

   What does NOT belong here: an issue's accent (that goes at the top
   of the issue's own styles.css) and any component bespoke to one
   issue (its specific toy: keep those in the issue's styles.css).

   Adding a new issue: link this file, declare your accent + bespoke
   components in your styles.css, done. Never edit this file to add an
   issue; edit it only to change a shared component for ALL issues.
   ============================================================ */

/* ============================================================
   Prose marks (the editorial primitives)
   ============================================================ */

.why-card {
  background: var(--surface);
  border-left: 2px solid var(--accent);
  padding: 16px 20px;
  margin: 18px 0 22px;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.why-card p { margin: 0 0 8px; }
.why-card p:last-child { margin: 0; }
.why-card strong { color: var(--accent); }

.math-card {
  background: var(--surface);
  border: 1px solid var(--hairline-cool);
  padding: 18px 22px;
  margin: 18px 0;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 15px;
  line-height: 1.7;
}
.math-card .formula { text-align: center; margin: 6px 0; font-size: 16px; color: var(--ink); }
.math-card .legend {
  font-family: var(--font-ui);
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 12px;
  border-top: 1px solid var(--hairline-cool);
  padding-top: 10px;
  line-height: 1.55;
}
.math-card .legend .sym { color: var(--accent); font-family: var(--font-mono); font-weight: 600; }

.takeaway {
  font-style: italic;
  color: var(--accent);
  margin: 24px 0 0;
  padding: 10px 14px;
  border-left: 2px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.takeaway::before { content: "\2192  "; font-weight: 700; }

.callout {
  border: 1px dashed var(--accent);
  background: var(--surface);
  padding: 14px 18px;
  margin: 18px 0;
  border-radius: var(--radius);
  font-size: 14.5px;
  line-height: 1.55;
}
.callout strong { color: var(--accent); }
.callout ul { margin: 6px 0; padding-left: 22px; }
.callout li { margin: 4px 0; }

.note {
  background: var(--accent-soft);
  border-left: 2px solid var(--accent);
  padding: 12px 16px;
  margin: 16px 0;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 14.5px;
}
.reading-hint { font-size: 13px; color: var(--muted); font-style: italic; margin: 6px 0 10px; }
.numbers-area { margin: 14px 0; overflow-x: auto; }

/* ============================================================
   Form chrome (buttons, sliders, text input)
   ============================================================ */

input[type=text] {
  flex: 1;
  min-width: 260px;
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 15px;
  border: 1px solid var(--hairline-cool);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}
input[type=text]:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

button {
  padding: 10px 18px;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  letter-spacing: 0.02em;
}
button:hover { filter: brightness(0.92); }
button:focus { outline: 2px solid var(--ink); outline-offset: 2px; }
button:disabled { opacity: 0.5; cursor: default; }

.slider-row {
  display: grid;
  grid-template-columns: 150px 1fr 60px;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  font-family: var(--font-ui);
  font-size: 13px;
}
.slider-row .name { color: var(--muted); text-align: right; }
.slider-row input[type=range] { width: 100%; accent-color: var(--accent); }
.slider-row .val {
  font-family: var(--font-mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  font-weight: 600;
  text-align: right;
}

.run-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0;
  flex-wrap: wrap;
  font-family: var(--font-ui);
  font-size: 12.5px;
  color: var(--muted);
}
.loop-status { font-family: var(--font-ui); font-size: 12.5px; color: var(--muted); }
.loop-status strong { color: var(--accent); }

/* ============================================================
   Code + tables
   ============================================================ */

pre.code-block {
  background: var(--surface);
  border: 1px solid var(--hairline-cool);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin: 14px 0;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink);
  overflow-x: auto;
  white-space: pre;
  tab-size: 4;
}
pre.code-block code { font-family: inherit; background: none; padding: 0; }
code { font-family: var(--font-mono); font-size: 0.92em; }

.num-grid {
  font-family: var(--font-body);
  font-size: 14px;
  border-collapse: collapse;
  margin: 8px 0;
  width: 100%;
}
.num-grid th, .num-grid td {
  padding: 8px 12px;
  text-align: left;
  border: 1px solid var(--hairline-cool);
  vertical-align: top;
}
.num-grid th {
  background: var(--surface);
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
  font-family: var(--font-ui);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.num-grid td.row-label, .num-grid th.row-label { background: var(--surface); color: var(--accent); font-weight: 600; }
.num-grid code { font-size: 12.5px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--hairline-cool);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 14px 0;
}
.panel .panel-head {
  font-family: var(--font-ui);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 10px;
  font-weight: 600;
}

/* ============================================================
   Message cards (System / Human / AI / Tool) + JSON blocks
   ============================================================ */

.msg-flow { display: flex; flex-direction: column; gap: 10px; margin: 14px 0; }
.msg-card {
  background: var(--surface);
  border: 1px solid var(--hairline-cool);
  border-left: 3px solid var(--muted);
  border-radius: var(--radius);
  padding: 10px 14px;
}
.msg-card .role-chip {
  display: inline-block;
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 2px 8px;
  border-radius: 10px;
  margin-bottom: 6px;
  background: var(--bg);
  color: var(--muted);
}
.msg-card .msg-body {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
}
/* role colours: system=ink, human=slate, ai=accent, tool=rust */
.msg-card.system { border-left-color: var(--ink); }
.msg-card.system .role-chip { background: #e7eaee; color: var(--ink); }
.msg-card.human  { border-left-color: var(--subtle); }
.msg-card.human  .role-chip { background: #e9edf2; color: #475569; }
.msg-card.ai     { border-left-color: var(--accent); }
.msg-card.ai     .role-chip { background: var(--accent-soft); color: var(--accent); }
.msg-card.tool   { border-left-color: #b45309; }
.msg-card.tool   .role-chip { background: #f7ede0; color: #b45309; }

.json-block {
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.55;
  background: var(--bg);
  border: 1px solid var(--hairline-cool);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin: 6px 0 0;
  overflow-x: auto;
  white-space: pre;
  color: var(--ink);
}
.id-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 600;
}

/* ============================================================
   Step trace (vertical timeline of steps; step-kind colours
   that an issue needs are added in its own styles.css)
   ============================================================ */

.trace { display: flex; flex-direction: column; gap: 0; margin-top: 8px; }
.trace .trace-step {
  position: relative;
  padding: 0 0 14px 30px;
  border-left: 2px solid var(--hairline-cool);
  margin-left: 8px;
}
.trace .trace-step:last-child { border-left-color: transparent; }
.trace .trace-step .dot {
  position: absolute;
  left: -8px;
  top: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px var(--accent);
}
.trace .trace-step .step-label {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 6px;
}
.trace .trace-step .step-body {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
}
.trace .trace-step .step-note { font-family: var(--font-ui); font-size: 12.5px; color: var(--muted); margin: 4px 0 0; }

/* ============================================================
   Comparison matrix (color-coded cells; cell-good themes to accent)
   ============================================================ */

.method-matrix {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-ui);
  font-size: 13px;
  margin: 14px 0;
}
.method-matrix th, .method-matrix td {
  border: 1px solid var(--hairline-cool);
  padding: 8px 12px;
  text-align: center;
  vertical-align: middle;
}
.method-matrix thead th {
  background: var(--surface);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 600;
}
.method-matrix th.row-head, .method-matrix td.row-head {
  text-align: left;
  background: var(--surface);
  color: var(--accent);
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
}
.method-matrix .cell-good { background: var(--accent-soft); color: var(--accent); }
.method-matrix .cell-mid  { background: #faf6ec; color: #6b6258; }
.method-matrix .cell-low  { background: #fbe8de; color: #6b2912; }
.method-matrix .cell-na   { color: var(--muted); font-style: italic; }
.method-matrix code { font-family: var(--font-mono); font-size: 12px; }

/* ============================================================
   Responsive (shared components only)
   ============================================================ */

@media (max-width: 700px) {
  .num-grid th, .num-grid td { padding: 6px 8px; font-size: 13px; }
  pre.code-block { font-size: 12px; padding: 12px 14px; }
  .panel { padding: 14px 16px; }
  .math-card { font-size: 13.5px; padding: 14px 16px; }
  .math-card .formula { font-size: 14px; }
  .why-card { padding: 14px 16px; }
  .callout, .note { padding: 12px 14px; font-size: 13.5px; }
  .slider-row { grid-template-columns: 120px 1fr 56px; gap: 8px; font-size: 12px; }
  .msg-card .msg-body { font-size: 12px; }
  .json-block { font-size: 11.5px; }
  .trace .trace-step .step-body { font-size: 12px; }
  .method-matrix { font-size: 11px; }
  .method-matrix th, .method-matrix td { padding: 6px 8px; }
  input[type=text] { font-size: 14px; min-width: 180px; }
  button { padding: 8px 14px; font-size: 13px; }
}

@media (max-width: 480px) {
  .num-grid th, .num-grid td { padding: 5px 6px; font-size: 12px; }
  pre.code-block { font-size: 11px; }
  .slider-row { grid-template-columns: 84px 1fr 44px; font-size: 11px; }
  .trace .trace-step { padding-left: 24px; }
  .method-matrix { display: block; overflow-x: auto; white-space: nowrap; }
  .method-matrix tbody, .method-matrix thead { display: table; width: 100%; }
}
