/* ══════════════════════════════════════════════════════════════════
   /securityheaders-api — securityheaders.com API replacement (EN-14)
   Builds on api-docs.css (loaded first): .api-docs-page, .api-section,
   .endpoint-meta, .code-block, tables. Only what that file lacks lives
   here, tokens only (DESIGN.md).
   ══════════════════════════════════════════════════════════════════ */

/* Anchored sections clear the sticky top bar when jumped to. */
.sha-page .api-section {
  scroll-margin-top: 5rem;
}

/* ── Hero: the one-line migration, shown before anything else ───── */
.sha-hero-cta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
}
.sha-hero-cta .btn-cta-accent {
  min-height: 44px;
}

.sha-swap {
  display: grid;
  grid-template-columns: 1fr;
  margin: var(--space-3) 0 var(--space-2);
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  overflow: hidden;
}
.sha-swap__row {
  display: grid;
  gap: var(--space-1-5);
  padding: var(--space-3) var(--space-4);
  min-width: 0;
}
.sha-swap__row + .sha-swap__row {
  border-top: 1px solid var(--border2);
}
.sha-swap__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: 2rem;
}
.sha-swap__row code {
  display: block;
  overflow-x: auto;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: var(--fs-sm);
  line-height: 1.6;
  color: var(--muted2);
  background: none;
  padding: 0 0 var(--space-0-5);
  scrollbar-width: thin;
}
.sha-prompt {
  color: var(--muted);
  margin-right: var(--space-1);
}
.sha-swap__label {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.sha-swap__row--old .sha-swap__label {
  color: var(--red);
}
.sha-swap__row--old code {
  text-decoration: line-through;
  text-decoration-color: var(--red);
  color: var(--muted);
}
.sha-swap__row--new {
  background: var(--status-pass-bg);
}
.sha-swap__row--new .sha-swap__label {
  color: var(--green);
}
.sha-swap__row--new code {
  color: var(--text);
}

/* Copy button: a real button, 44px hit area on touch */
.sha-copy {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 var(--space-3);
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--on-accent, var(--white));
  font-family: var(--sans);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--dur) var(--ease-smooth);
}
.sha-copy:hover {
  background: var(--accent2);
}
.sha-copy:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* Status chips: same / differs / removed */
.sha-badge {
  display: inline-block;
  margin-left: var(--space-1);
  padding: var(--space-0-5) var(--space-1-5);
  border-radius: var(--radius-xs);
  font-family: var(--mono);
  font-size: var(--fs-2xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  vertical-align: middle;
  border: 1px solid transparent;
}
.sha-badge--pass { background: var(--status-pass-bg); color: var(--green); border-color: var(--status-pass-border); }
.sha-badge--warn { background: var(--status-warn-bg); color: var(--yellow); border-color: var(--status-warn-border); }
.sha-badge--fail { background: var(--status-fail-bg); color: var(--red); border-color: var(--status-fail-border); margin-left: 0; }

/* ── Status note: why this page exists, with its source ──────────── */
.sha-note {
  background: var(--status-info-bg);
  border: 1px solid var(--border2);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--muted2);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-6);
  font-size: var(--fs-sm);
  line-height: 1.6;
}
.sha-note a {
  color: var(--accent);
}

/* ── Grade scale: one strip of letter tiles, green to red ──────────── */
.sha-grades {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: var(--space-1-5);
  margin: var(--space-4) 0 var(--space-1);
  padding: 0;
  list-style: none;
}
.sha-grades__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-0-5);
  padding: var(--space-2) var(--space-1);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border2);
  background: var(--surface2);
}
.sha-grades__letter {
  font-family: var(--mono);
  font-size: var(--fs-lg);
  font-weight: 700;
  line-height: 1.2;
}
.sha-grades__floor {
  font-family: var(--mono);
  font-size: var(--fs-2xs);
  color: var(--muted2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.sha-grades__item--aplus,
.sha-grades__item--a { background: var(--status-pass-bg); border-color: var(--status-pass-border); color: var(--green); }
.sha-grades__item--b { background: var(--accent-glow-12); border-color: var(--accent-glow-30); color: var(--accent); }
.sha-grades__item--c,
.sha-grades__item--d { background: var(--status-warn-bg); border-color: var(--status-warn-border); color: var(--yellow); }
.sha-grades__item--e,
.sha-grades__item--f { background: var(--status-fail-bg); border-color: var(--status-fail-border); color: var(--red); }
.sha-grades__item--r { color: var(--muted2); }
.sha-grades__note {
  font-size: var(--fs-xs);
  color: var(--muted);
  margin-bottom: var(--space-4);
}

/* ── Example JSON: collapsed until asked for ─────────────────────── */
.sha-json {
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  background: var(--bg);
  margin: var(--space-3) 0;
}
.sha-json summary {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 600;
  list-style: none;
}
.sha-json summary::-webkit-details-marker {
  display: none;
}
.sha-json summary::after {
  content: "+";
  margin-left: auto;
  font-family: var(--mono);
  color: var(--accent);
}
.sha-json[open] summary::after {
  content: "\2212";
}
.sha-json summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}
.sha-json__icon {
  font-family: var(--mono);
  color: var(--cyan);
}
.sha-json__meta {
  font-family: var(--mono);
  font-size: var(--fs-2xs);
  font-weight: 400;
  color: var(--muted);
}
.sha-json .code-block {
  margin: 0;
  border: 0;
  border-top: 1px solid var(--border2);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  max-height: 32rem;
  overflow: auto;
}

/* ── Example tabs-free stack: curl / JS / Python / Actions ────────── */
.sha-example + .sha-example {
  margin-top: var(--space-4);
}
.sha-example h3 {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.sha-lang {
  font-family: var(--mono);
  font-size: var(--fs-2xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--cyan);
  background: var(--cyan-glow-08);
  border-radius: var(--radius-xs);
  padding: var(--space-0-5) var(--space-1-5);
}

/* ── Mapping table: old key → here ───────────────────────────────── */
.sha-map td:first-child,
.sha-map td:nth-child(2) {
  white-space: nowrap;
}

/* ── Limits: three numbers side by side ───────────────────────────── */
.sha-limits {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: var(--space-2);
  margin: var(--space-3) 0;
  padding: 0;
  list-style: none;
}
.sha-limits li {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  color: var(--muted2);
  font-size: var(--fs-sm);
}
.sha-limits strong {
  display: block;
  color: var(--text);
  font-family: var(--mono);
  font-size: var(--fs-xl);
  font-variant-numeric: tabular-nums;
  margin-bottom: var(--space-1);
}

/* ── Phone width: the swap rows stack their label above the code ─── */
@media (max-width: 600px) {
  .sha-swap__row {
    padding: var(--space-2) var(--space-3);
  }
  .sha-grades {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .sha-copy {
    min-height: 44px;
  }
  /* The mapping table becomes one block per field: no sideways scroll for the notes. */
  .table-responsive .sha-map,
  .sha-map tbody,
  .sha-map tr,
  .sha-map td,
  .sha-stack tbody,
  .sha-stack tr,
  .sha-stack td {
    display: block;
    width: 100%;
    min-width: 0; /* components.css gives every .table-responsive table 720px */
  }
  .table-responsive .sha-stack {
    display: block;
    width: 100%;
  }
  .sha-map thead,
  .sha-stack thead {
    display: none;
  }
  .sha-stack tr,
  .sha-map tr {
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--border);
  }
  .api-section .sha-stack td,
  .api-section .sha-map td,
  .api-section .sha-map td:first-child,
  .api-section .sha-map td:nth-child(2) {
    border: 0;
    padding: var(--space-0-5) var(--space-1);
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .sha-stack td[data-label]::before,
  .sha-map td[data-label]::before {
    content: attr(data-label);
    display: inline-block;
    min-width: 9.5rem;
    font-size: var(--fs-2xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
  }
  .sha-hero-cta .btn-cta-accent {
    width: 100%;
    justify-content: center;
  }
}

/* ── Plain prose list inside a section ────────────────────────────── */
.sha-list {
  margin: 0 0 var(--space-3);
  padding-left: var(--space-5);
  color: var(--muted2);
  font-size: 0.9rem;
  line-height: 1.65;
}
.sha-list li + li {
  margin-top: var(--space-1-5);
}
.sha-list code {
  background: var(--accent-glow-08);
  color: var(--cyan);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-xs);
  font-family: var(--mono);
  font-size: 0.85em;
}
.api-docs-intro code,
.sha-note code {
  font-family: var(--mono);
  font-size: 0.9em;
  color: var(--cyan);
}

/* Short tables fit the column at any width: the 720px floor components.css
   gives every .table-responsive table would push their last column off-screen. */
.table-responsive .sha-compact {
  min-width: 0;
}
