/* Pikel Partner API docs — shared styles.
   Tokens are lifted from brand/color/palette.json (system.dark / system.light) plus
   brand.cobalt / brand.cobaltInk as the single accent. No build step: plain CSS,
   loaded by both pages. */

:root {
  color-scheme: light;

  --canvas: #F5F5F6;
  --tile: #FFFFFF;
  --tile-elevated: #FFFFFF;
  --hairline: #E6E7EB;
  --hairline-soft: #EDEEF1;
  --text-primary: #16171B;
  --text-secondary: #5A616C;
  --text-tertiary: #6E7580;
  --accent: #2563EB;       /* brand.cobalt — fills, buttons, always white text on it */
  --accent-text: #1D4ED8;  /* brand.cobaltInk — links and accent text on light backgrounds */
  --going: #0E8F55;
  --maybe: #A16207;
  --alert: #DC4A4A;
  --code-bg: #16171B;
  --code-text: #E9EBF0;
  --code-border: #2A2D34;

  --radius: 10px;
  --radius-sm: 6px;
  --radius-pill: 999px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --nav-height: 64px;
  --content-width: 760px;

  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; }
[hidden] { display: none !important; }

a {
  color: var(--accent-text);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent-text) 35%, transparent);
}
a:hover { border-bottom-color: var(--accent-text); }
a.plain { border-bottom: none; }

/* ---------- Top nav ---------- */

.topnav {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--nav-height);
  padding-top: env(safe-area-inset-top, 0px);
  display: flex;
  align-items: center;
  gap: 24px;
  padding-inline: 20px;
  background: color-mix(in srgb, var(--canvas) 88%, transparent);
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  border-bottom: 1px solid var(--hairline);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text-primary);
  border-bottom: none;
  flex-shrink: 0;
}
/* Recolour the brand SVGs per theme via CSS mask, rather than inlining hand-copied path
   data (mark.svg / wordmark.svg on disk are the exact, unedited brand files). */
.brand .mark {
  display: inline-block;
  width: 22px; height: 22px;
  background-color: var(--accent);
  -webkit-mask: url("mark.svg") no-repeat center / contain;
  mask: url("mark.svg") no-repeat center / contain;
  flex-shrink: 0;
}
.brand .wordmark {
  display: inline-block;
  width: 64px; height: 16px;
  background-color: var(--text-primary);
  -webkit-mask: url("wordmark.svg") no-repeat left center / contain;
  mask: url("wordmark.svg") no-repeat left center / contain;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-left: auto;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
}
.nav-links a { color: var(--text-secondary); border-bottom: none; }
.nav-links a:hover, .nav-links a[aria-current="page"] { color: var(--text-primary); }
.nav-links .pill {
  color: var(--going);
  border: 1px solid color-mix(in srgb, var(--going) 45%, transparent);
  border-radius: var(--radius-pill);
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
}

@media (max-width: 560px) {
  .nav-links a:not(.primary) { display: none; }
  .brand .wordmark { display: none; }
}

/* ---------- Page shell ---------- */

main { display: block; }

.shell {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 56px 20px 96px;
}

@media (max-width: 640px) {
  .shell { padding: 36px 16px 72px; }
}

section { margin-top: 64px; }
section:first-of-type { margin-top: 0; }

h1, h2, h3 { line-height: 1.25; letter-spacing: -0.01em; font-weight: 650; }
h1 { font-size: clamp(1.9rem, 5vw, 2.5rem); margin: 0 0 16px; }
h2 { font-size: 1.4rem; margin: 0 0 12px; }
h3 { font-size: 1.05rem; margin: 24px 0 8px; }
p { margin: 0 0 16px; color: var(--text-secondary); max-width: 62ch; }
p.lede { font-size: 1.1rem; color: var(--text-primary); max-width: 58ch; }

ol.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }
ol.steps > li {
  counter-increment: step;
  position: relative;
  padding: 0 0 28px 44px;
  border-left: 1px solid var(--hairline);
  margin-left: 15px;
}
ol.steps > li:last-child { padding-bottom: 4px; border-color: transparent; }
ol.steps > li::before {
  content: counter(step);
  position: absolute;
  left: -16px;
  top: 0;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
ol.steps h3 { margin-top: 0; }
ol.steps p { margin-bottom: 0; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--radius-pill);
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  border-bottom: none;
  cursor: pointer;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, black); }
.btn-secondary { background: transparent; color: var(--text-primary); border-color: var(--hairline); }
.btn-secondary:hover { border-color: var(--text-tertiary); }
.btn:active { transform: scale(0.98); }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 28px; }

/* ---------- Code ---------- */

pre {
  background: var(--code-bg);
  color: var(--code-text);
  border: 1px solid var(--code-border);
  border-radius: var(--radius);
  padding: 18px 18px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
  position: relative;
}
code { font-family: var(--font-mono); font-size: 0.9em; }
:not(pre) > code {
  background: var(--hairline-soft);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
}

.code-block { position: relative; margin: 16px 0 24px; }
.code-label {
  position: absolute;
  top: -10px;
  left: 14px;
  background: var(--canvas);
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 600;
  padding: 0 6px;
  font-family: var(--font-mono);
}
.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--tile-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--code-border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: var(--font-sans);
  padding: 5px 10px;
  cursor: pointer;
}
.copy-btn:hover { color: var(--text-primary); }
.copy-btn:active { transform: scale(0.96); }

/* ---------- Panels / cards ---------- */

.panel {
  background: var(--tile);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 20px 22px;
}
.panel + .panel { margin-top: 14px; }

.rule-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 640px) { .rule-grid { grid-template-columns: 1fr; } }
.rule-grid .panel h3 { margin-top: 0; }

.callout {
  border-left: 3px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, var(--tile));
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 14px 18px;
  margin: 20px 0;
}
.callout p { margin: 0; color: var(--text-primary); }
.callout strong { color: var(--accent-text); }

.callout.warn { border-left-color: var(--maybe); background: color-mix(in srgb, var(--maybe) 8%, var(--tile)); }
.callout.warn strong { color: var(--maybe); }

/* ---------- Match chain ---------- */

.match-chain {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 20px 0 8px;
  font-family: var(--font-mono);
  font-size: 13px;
}
.match-chain .node {
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  background: var(--tile);
}
.match-chain .node.guest { border-color: color-mix(in srgb, var(--maybe) 50%, var(--hairline)); color: var(--maybe); }
.match-chain .arrow { color: var(--text-tertiary); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  font-family: var(--font-mono);
}
.badge.going { color: var(--going); background: color-mix(in srgb, var(--going) 14%, transparent); }
.badge.maybe { color: var(--maybe); background: color-mix(in srgb, var(--maybe) 14%, transparent); }

/* ---------- Tables ---------- */

.tbl-wrap { overflow-x: auto; border: 1px solid var(--hairline); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 480px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--hairline); vertical-align: top; }
thead th { color: var(--text-tertiary); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; background: var(--hairline-soft); }
tbody tr:last-child td { border-bottom: none; }
td code, th code { white-space: nowrap; }

/* ---------- Footer ---------- */

footer {
  border-top: 1px solid var(--hairline);
  padding: 32px 20px calc(32px + env(safe-area-inset-bottom, 0px));
  max-width: var(--content-width);
  margin: 0 auto;
  color: var(--text-tertiary);
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
footer a { color: var(--text-secondary); }

/* ---------- Reference page shell ---------- */

.ref-shell { padding-top: 0; }
#redoc-container { min-height: calc(100dvh - var(--nav-height)); }
