/* PHB Docs — scorebook-inspired technical documentation
   This stylesheet belongs to docs/ only. It is not an app stylesheet and does
   not follow .opencode/skills/phb-app-design-rules. */

:root {
  --paper: #f7f8fa;
  --surface: #ffffff;
  --ink: #151c27;
  --muted: #5c6675;
  --navy: #0e2148;
  --blue: #0038a8;
  --red: #ce1126;
  --yellow: #fcd116;
  --line: #dce2ea;
  --line-strong: #b8c2d0;
  --wash: #edf2f8;
  --sans: "IBM Plex Sans JP", -apple-system, "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
  --mono: "IBM Plex Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.9;
  -webkit-text-size-adjust: 100%;
}

a {
  color: var(--blue);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--red);
}

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

img,
svg {
  max-width: 100%;
}

code,
pre,
kbd,
samp {
  font-family: var(--mono);
}

code {
  background: var(--wash);
  border-radius: 2px;
  padding: 0.12em 0.35em;
  font-size: 0.86em;
  overflow-wrap: anywhere;
}

pre {
  margin: 14px 0 20px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--navy);
  border-radius: 3px;
  overflow-x: auto;
  line-height: 1.7;
}

pre code {
  background: none;
  padding: 0;
  font-size: 0.8rem;
  overflow-wrap: normal;
  white-space: pre;
}

strong,
b {
  font-weight: 600;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--navy);
  color: #fff;
  padding: 8px 14px;
}

.skip:focus {
  left: 8px;
  top: 8px;
  color: #fff;
}

/* ---- top bar ---- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(247, 248, 250, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 28px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--navy);
  text-decoration: none;
  line-height: 1.2;
}

.brand:hover {
  color: var(--navy);
}

.brand-mark {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  background: linear-gradient(
    to right,
    var(--blue) 0 33.34%,
    var(--red) 33.34% 66.67%,
    var(--yellow) 66.67% 100%
  );
  border: 1px solid var(--navy);
}

.brand-text {
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.brand-text span {
  color: var(--muted);
  font-weight: 400;
}

.toplinks {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: 0.8rem;
  white-space: nowrap;
}

.toplinks a {
  color: var(--muted);
  text-decoration: none;
}

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

.mobile-nav {
  display: none;
  margin-left: auto;
  position: relative;
}

.mobile-nav summary {
  cursor: pointer;
  list-style: none;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  padding: 4px 10px;
  font-size: 0.8rem;
  color: var(--navy);
  background: var(--surface);
}

.mobile-nav summary::-webkit-details-marker {
  display: none;
}

.mobile-nav[open] summary {
  border-color: var(--blue);
  color: var(--blue);
}

.mobile-nav nav {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: min(78vw, 280px);
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  box-shadow: 0 12px 30px rgba(14, 33, 72, 0.12);
}

.mobile-nav nav a {
  display: block;
  padding: 5px 0;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.84rem;
}

.mobile-nav nav a[aria-current="page"] {
  color: var(--blue);
  font-weight: 600;
}

.mobile-nav .navlabel {
  margin: 10px 0 2px;
}

.mobile-nav .navlabel:first-child {
  margin-top: 0;
}

/* ---- layout ---- */

.shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 40px 24px 80px;
  display: grid;
  grid-template-columns: 220px minmax(0, 720px) 176px;
  gap: 48px;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 104px);
  overflow-y: auto;
  padding-right: 4px;
}

.navgroup {
  margin: 0 0 22px;
}

.navlabel {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.sidebar a {
  display: block;
  padding: 5px 0 5px 10px;
  border-left: 2px solid transparent;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.84rem;
  line-height: 1.5;
}

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

.sidebar a[aria-current="page"] {
  border-left-color: var(--red);
  color: var(--navy);
  font-weight: 600;
}

main {
  min-width: 0;
}

.pagehead {
  margin: 0 0 36px;
  padding: 0 0 20px;
  border-bottom: 2px solid var(--navy);
}

h1 {
  margin: 0 0 12px;
  color: var(--navy);
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.lede {
  margin: 0 0 14px;
  max-width: 62ch;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.85;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin: 0;
  color: var(--muted);
  font-size: 0.74rem;
}

.meta .date {
  border-bottom: 2px solid var(--yellow);
  padding-bottom: 1px;
}

article {
  min-width: 0;
}

article > section {
  margin: 0;
}

h2 {
  margin: 48px 0 14px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--navy);
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.45;
}

article > section:first-child h2 {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

h3 {
  margin: 30px 0 8px;
  color: var(--navy);
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.5;
}

h4 {
  margin: 20px 0 6px;
  color: var(--navy);
  font-size: 0.92rem;
  font-weight: 600;
}

p {
  margin: 0 0 1em;
}

ul,
ol {
  margin: 0 0 1em;
  padding-left: 1.4em;
}

li {
  margin: 0.18em 0;
}

.small {
  color: var(--muted);
  font-size: 0.8rem;
}

.muted {
  color: var(--muted);
}

/* ---- table of contents ---- */

.toc {
  position: sticky;
  top: 88px;
  align-self: start;
  font-size: 0.78rem;
  line-height: 1.6;
}

.toclabel {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.toc a {
  display: block;
  padding: 4px 0 4px 10px;
  border-left: 1px solid var(--line);
  color: var(--muted);
  text-decoration: none;
}

.toc a:hover {
  border-left-color: var(--red);
  color: var(--navy);
}

.toc a.sub {
  padding-left: 20px;
  font-size: 0.74rem;
}

/* ---- tables ---- */

.tablewrap {
  margin: 14px 0 22px;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  line-height: 1.65;
}

caption {
  caption-side: top;
  padding: 10px 12px 0;
  color: var(--muted);
  font-size: 0.72rem;
  text-align: left;
}

th {
  padding: 9px 12px;
  background: #e9eef5;
  border-bottom: 2px solid var(--navy);
  color: var(--navy);
  font-size: 0.76rem;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:nth-child(even) {
  background: #fafbfd;
}

th.num,
td.num {
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

td code {
  white-space: normal;
}

.nowrap {
  white-space: nowrap;
}

/* ---- scoreboard strip ---- */

.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 18px 0 24px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.stat {
  min-width: 0;
  padding: 14px 16px;
  border-left: 1px solid var(--line);
}

.stat:first-child {
  border-left: 0;
}

.stat b {
  display: block;
  color: var(--navy);
  font-family: var(--mono);
  font-size: 1.5rem;
  font-weight: 500;
  line-height: 1.2;
}

.stat span {
  color: var(--muted);
  font-size: 0.72rem;
}

/* ---- flow ---- */

.flow {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 18px 0 24px;
  padding: 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
}

.flow li {
  margin: 0;
  padding: 14px 16px;
  border-left: 1px solid var(--line);
}

.flow li:first-child {
  border-left: 0;
}

.flow b {
  display: block;
  color: var(--navy);
  font-size: 0.8rem;
}

.flow span {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.6;
}

/* ---- callout ---- */

.callout {
  margin: 16px 0 22px;
  padding: 12px 16px;
  background: var(--wash);
  border-left: 3px solid var(--blue);
  font-size: 0.88rem;
}

.callout.warn {
  background: #fdf1f2;
  border-left-color: var(--red);
}

.callout p:last-child {
  margin-bottom: 0;
}

.callout .title {
  display: block;
  margin-bottom: 2px;
  color: var(--navy);
  font-weight: 600;
}

/* ---- definition lists ---- */

.facts {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  gap: 4px 16px;
  margin: 12px 0 20px;
  font-size: 0.86rem;
}

.facts dt {
  color: var(--muted);
}

.facts dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* ---- phases ---- */

.phase {
  position: relative;
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 16px;
  padding: 0 0 26px;
}

.phase::before {
  content: "";
  position: absolute;
  left: 27px;
  top: 40px;
  bottom: 0;
  width: 1px;
  background: var(--line);
}

.phase:last-child::before {
  display: none;
}

.phase .num {
  color: var(--navy);
  font-family: var(--mono);
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1.5;
}

.phase .body {
  min-width: 0;
}

.phase h3 {
  margin-top: 0;
}

.phase dl {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 3px 12px;
  margin: 8px 0 0;
  font-size: 0.84rem;
}

.phase dt {
  color: var(--muted);
}

.phase dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* ---- agent map ---- */

.agentmap {
  margin: 16px 0;
  padding: 6px;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
}

.agentmap svg {
  display: block;
  width: 100%;
  min-width: 760px;
  height: auto;
  font-family: var(--sans);
}

.agentmap g.agent {
  cursor: pointer;
}

.agentmap g.agent:hover rect.box {
  stroke-width: 3;
}

.agentmap g.agent.sel rect.box {
  stroke-width: 3.5;
}

.agentmap g.agent.dim {
  opacity: 0.18;
}

.agentmap text {
  font-size: 11px;
  fill: var(--ink);
}

.agentmap text.flbl {
  font-size: 10px;
  fill: var(--muted);
  font-weight: 400;
}

.agentmap text.lbl {
  font-weight: 600;
}

.agentmap text.small {
  font-size: 10px;
  fill: var(--muted);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 14px;
  margin: 12px 0 16px;
}

.chipgroup {
  align-self: center;
  margin: 0 4px 0 8px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
}

.chips button {
  padding: 2px 0;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
}

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

.chips button.on {
  border-bottom-color: var(--red);
  color: var(--navy);
}

.agentdetail {
  min-height: 180px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.agentdetail h4 {
  margin: 0 0 4px;
  font-size: 0.95rem;
}

.agentdetail .role {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.75;
}

.agentdetail h5 {
  margin: 12px 0 4px;
  color: var(--navy);
  font-size: 0.72rem;
  font-weight: 600;
}

.agentdetail ul {
  margin: 0 0 0 18px;
  padding: 0;
}

.agentdetail li {
  font-size: 0.8rem;
  line-height: 1.7;
}

/* ---- pager ---- */

.pager {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 64px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 0.82rem;
}

.pager a {
  text-decoration: none;
}

.pager .next {
  margin-left: auto;
  text-align: right;
}

/* ---- 404 ---- */

.notfound {
  max-width: 640px;
  margin: 0 auto;
  padding: 80px 24px;
}

.notfound h1 {
  font-size: 3rem;
  font-family: var(--mono);
  font-weight: 500;
}

.notfound .links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  margin-top: 24px;
}

/* ---- responsive ---- */

@media (max-width: 1199px) {
  .shell {
    max-width: 1000px;
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .toc {
    display: none;
  }
}

@media (max-width: 860px) {
  .toplinks {
    display: none;
  }

  .mobile-nav {
    display: block;
  }

  .shell {
    display: block;
    max-width: 760px;
    padding: 24px 16px 56px;
  }

  .sidebar {
    display: none;
  }

  h1 {
    font-size: 1.65rem;
  }

  h2 {
    margin-top: 40px;
    font-size: 1.2rem;
  }

  .stat-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat:nth-child(3) {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .stat:nth-child(4) {
    border-top: 1px solid var(--line);
  }

  .flow {
    grid-template-columns: 1fr;
  }

  .flow li {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .flow li:first-child {
    border-top: 0;
  }

  .facts,
  .phase dl {
    grid-template-columns: 92px minmax(0, 1fr);
  }

  .phase {
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 12px;
  }

  .phase::before {
    left: 19px;
  }

  .phase .num {
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  .topbar-inner {
    padding: 0 16px;
    gap: 12px;
  }

  .brand-text {
    font-size: 0.78rem;
  }

  .facts,
  .phase dl {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .facts dt,
  .phase dt {
    margin-top: 8px;
    font-size: 0.76rem;
  }
}

/* The agent map is the centerpiece of agents.html. Give that page a wider
   content column on desktop by using the TOC space, so the diagram stays
   legible without changing the topbar or the other pages' layout. */
@media (min-width: 1200px) {
  body.wide .shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  body.wide .toc {
    display: none;
  }

  body.wide .agentmap svg {
    min-width: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}

@media print {
  .topbar,
  .sidebar,
  .toc,
  .mobile-nav,
  .pager {
    display: none;
  }

  .shell {
    display: block;
    max-width: none;
    padding: 0;
  }

  body {
    background: #fff;
  }

  a {
    color: var(--ink);
  }
}
