/* ------------------------------------------------------------------ */
/*  issue-service · justificación técnica — estilos                    */
/* ------------------------------------------------------------------ */

:root {
  --paper:   #e9edf1;
  --surface: #ffffff;
  --surface-2: #f3f6f9;
  --ink:     #131a22;
  --muted:   #58636f;
  --line:    #d2dae2;
  --line-strong: #b9c4ce;
  --accent:  #1f5fd6;
  --accent-ink: #163f8c;
  --ok:      #157a5c;

  --maxw: 1080px;
  --pad: 24px;
  --radius: 10px;

  --fs-body: 1rem;
  --lh-body: 1.62;
  --sans: "IBM Plex Sans", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

html[data-theme="dark"] {
  --paper:   #0e141b;
  --surface: #151f2a;
  --surface-2: #101923;
  --ink:     #e7eef5;
  --muted:   #93a1b0;
  --line:    #26333f;
  --line-strong: #34424f;
  --accent:  #74a7ff;
  --accent-ink: #a9c6ff;
  --ok:      #4fc79e;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.mono { font-family: var(--mono); font-feature-settings: "ss01"; }

.wrap { max-width: var(--maxw); margin-inline: auto; padding-inline: var(--pad); }

em { font-style: italic; color: inherit; }

/* ---------------- top bar ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar__inner {
  display: flex; align-items: center; gap: 20px;
  height: 58px;
}
.brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); }
.brand__dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.brand__name { font-size: .92rem; font-weight: 600; letter-spacing: -0.01em; }

.nav { display: none; margin-left: auto; gap: 22px; }
.nav a {
  color: var(--muted); text-decoration: none; font-size: .9rem;
  padding: 4px 0; border-bottom: 2px solid transparent;
  transition: color .18s ease, border-color .18s ease;
}
.nav a:hover { color: var(--ink); }
.nav a.is-active { color: var(--ink); border-bottom-color: var(--accent); }

.theme {
  margin-left: auto;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: .78rem;
  transition: color .18s ease, border-color .18s ease;
}
.nav + .theme { margin-left: 0; }
.theme:hover { color: var(--ink); border-color: var(--accent); }

/* ---------------- hero ---------------- */
.hero { padding-top: 68px; padding-bottom: 40px; }
.hero__kicker {
  color: var(--accent-ink);
  font-size: .82rem; font-weight: 500;
  margin: 0 0 20px;
}
.hero__title {
  font-size: clamp(2.1rem, 5.2vw, 3.5rem);
  line-height: 1.04;
  letter-spacing: -0.025em;
  font-weight: 700;
  margin: 0 0 22px;
}
.hero__lede {
  max-width: 60ch;
  color: var(--muted);
  font-size: clamp(1rem, 1.6vw, 1.14rem);
  margin: 0 0 26px;
}
.chips { display: flex; flex-wrap: wrap; gap: 9px; list-style: none; padding: 0; margin: 0 0 42px; }
.chip {
  font-size: .78rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 5px 11px;
}

/* ---------------- diagram ---------------- */
.diagram { margin: 0; }
.diagram__scroll { overflow-x: auto; padding-bottom: 6px; }
.diagram__svg {
  display: block;
  width: 100%;
  min-width: 720px;
  height: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
}
.diagram__cap { margin-top: 12px; color: var(--muted); font-size: .8rem; }

.wire line { stroke: var(--line-strong); stroke-width: 1.6; }
.wlabel text { fill: var(--muted); font-size: 10px; text-anchor: middle; }
.node rect { fill: var(--surface-2); stroke: var(--line-strong); stroke-width: 1.4; }
.node--soft rect { fill: transparent; stroke-dasharray: 4 4; }
.node__t { fill: var(--ink); font-size: 13px; font-weight: 600; text-anchor: middle; font-family: var(--sans); }
.node__s { fill: var(--muted); font-size: 10px; text-anchor: middle; }

.token__halo { fill: color-mix(in srgb, var(--accent) 30%, transparent); }
.token__core { fill: var(--accent); }
.token {
  offset-path: path("M 74 150 L 1064 150");
  offset-distance: 0%;
  animation: token-flow 5.6s cubic-bezier(.55,0,.35,1) infinite;
}
@keyframes token-flow {
  0%   { offset-distance: 0%;   opacity: 0; }
  6%   { opacity: 1; }
  94%  { opacity: 1; }
  100% { offset-distance: 100%; opacity: 0; }
}

/* ---------------- blocks ---------------- */
.block { padding-top: 44px; padding-bottom: 44px; border-top: 1px solid var(--line); }
.h2 {
  font-size: clamp(1.45rem, 3vw, 2rem);
  letter-spacing: -0.02em;
  font-weight: 700;
  margin: 0 0 24px;
}
.prose { max-width: 68ch; color: var(--muted); margin: 0 0 26px; }
.prose .mono, .matrix .mono, .flow .mono, .dec__grid .mono, .status .mono {
  color: var(--ink);
  font-size: .92em;
}

/* ---------------- tables ---------------- */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.matrix { width: 100%; border-collapse: collapse; background: var(--surface); min-width: 520px; }
.matrix thead th {
  text-align: left;
  font-size: .82rem;
  font-weight: 600;
  color: var(--muted);
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-strong);
  background: var(--surface-2);
}
.matrix tbody th, .matrix td {
  text-align: left;
  vertical-align: top;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  font-weight: 400;
}
.matrix tbody tr:last-child th, .matrix tbody tr:last-child td { border-bottom: 0; }
.matrix tbody th { width: 26%; white-space: nowrap; }
.matrix td { color: var(--muted); }

/* ---------------- flow (secuencia real → numerada) ---------------- */
.flow { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.flow__step {
  display: grid; grid-template-columns: 40px 1fr; gap: 16px; align-items: start;
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.flow__step:last-child { border-bottom: 0; }
.flow__n {
  font-size: .9rem; color: var(--accent-ink);
  border: 1px solid var(--line-strong); border-radius: 6px;
  width: 32px; height: 32px; display: grid; place-items: center;
  background: var(--surface);
}
.flow__step p { margin: 3px 0 0; color: var(--muted); }

/* ---------------- decisions (spec entries, no card kit) ---------------- */
.dec {
  display: grid; grid-template-columns: 1fr; gap: 6px;
  padding: 26px 0; border-top: 1px solid var(--line);
}
.dec:first-of-type { border-top: 0; }
.dec__key {
  color: var(--accent-ink); font-size: .82rem;
  padding-top: 4px;
}
.dec__t { font-size: 1.18rem; letter-spacing: -0.01em; margin: 0 0 14px; font-weight: 600; }
.dec__grid { margin: 0; display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.dec__cell { background: var(--surface); padding: 14px 16px; }
.dec__cell dt { font-size: .78rem; font-weight: 600; color: var(--accent-ink); margin: 0 0 5px; }
.dec__cell dd { margin: 0; color: var(--muted); font-size: .95rem; }

/* ---------------- status ---------------- */
.status { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.status__item {
  display: grid; grid-template-columns: 24px 1fr; gap: 14px; align-items: start;
  padding: 13px 0; border-bottom: 1px solid var(--line);
}
.status__item:last-child { border-bottom: 0; }
.status__item span:last-child { color: var(--muted); }
.status__item strong { color: var(--ink); font-weight: 600; }
.status__mark {
  margin-top: 4px; width: 16px; height: 16px; border-radius: 4px;
  border: 1.6px solid var(--line-strong); position: relative;
}
.is-done .status__mark { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 16%, transparent); }
.is-done .status__mark::after {
  content: ""; position: absolute; left: 4px; top: 1px;
  width: 4px; height: 8px; border: solid var(--ok); border-width: 0 2px 2px 0;
  transform: rotate(42deg);
}
.is-todo .status__mark { border-style: dashed; }

/* ---------------- footer ---------------- */
.foot { border-top: 1px solid var(--line); padding: 30px 0 48px; }
.foot__inner { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: baseline; }
.foot__dom { color: var(--ink); font-weight: 600; font-size: .95rem; }
.foot__note { color: var(--muted); font-size: .86rem; }

/* ---------------- focus & motion ---------------- */
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .token { animation: none; opacity: 0; }
}

/* ---------------- responsive ---------------- */
@media (min-width: 720px) {
  .nav { display: flex; }
  .nav + .theme { margin-left: 22px; }
  .dec { grid-template-columns: 160px 1fr; gap: 28px; }
  .dec__grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 719px) {
  .theme { margin-left: auto; }
}

section[id] { scroll-margin-top: 74px; }