/*
 * Guides, glossary, statistics and developer pages. Only what is specific to
 * these pages lives here; shared components (.card, .btn, .data-table, .crumbs,
 * .tag ...) come from style.css. Colours are the theme variables, so dark mode
 * follows the site theme.
 */

/* Small green labels need the darker "ink" shade of the accent to reach 4.5:1.
   The theme defines --accent-ink in light and dark; the fallback covers a theme
   without it (which also has no dark mode). */
:root { --seo-accent-text: var(--accent-ink, #0a6b54); }

.seo-visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.seo-kicker {
  display: block; font-size: .74rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--seo-accent-text); margin-bottom: .35rem;
}

/* ---------- Cards linking to guides ---------- */
.seo-card-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.seo-guide-card {
  display: flex; flex-direction: column; gap: .4rem;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; color: var(--ink); text-decoration: none;
}
.seo-guide-card:hover { border-color: var(--primary); text-decoration: none; }
.seo-guide-card h3 { font-size: 1.05rem; line-height: 1.35; margin: 0; color: var(--ink); }
.seo-guide-card:hover h3 { color: var(--primary); }
.seo-guide-card p { color: var(--ink-soft); font-size: .92rem; margin: 0; }
.seo-guide-card .muted-sm { margin-top: auto; padding-top: .3rem; }
/* Guide grids hold 2, 3 or 4 cards. Fixed column counts keep a lone card from
   dangling on a row: hub groups (4 or 2 guides) two per row, the home page's four
   in one row on desktop, and the three related guides in one row. */
:is(.seo-home-guides, .seo-hub-group) .seo-card-grid,
#related-guides .seo-card-grid { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 560px) {
  :is(.seo-home-guides, .seo-hub-group) .seo-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 700px) {
  #related-guides .seo-card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1000px) {
  .seo-home-guides .seo-card-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.seo-guide-card:focus-visible,
.seo-toc a:focus-visible,
.seo-az a:focus-visible,
.seo-anchor:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- Hub pages ---------- */
.seo-hub-head { max-width: 760px; margin-bottom: 1.6rem; }
.seo-hub-head h1 { margin-bottom: .4em; }
.seo-hub-group { margin-top: 2rem; }
.seo-hub-group > h2 { font-size: 1.25rem; margin: 0 0 .8rem; }
.seo-link-list { list-style: none; display: grid; gap: .55rem; }
.seo-link-list a { font-weight: 600; }

/* ---------- Guide article ---------- */
.seo-guide-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 250px; column-gap: 48px;
  grid-template-areas: "head toc" "body toc"; align-items: start;
}
.seo-guide-head { grid-area: head; max-width: 720px; }
.seo-guide-head h1 { font-size: clamp(1.7rem, 3.4vw, 2.4rem); margin-bottom: .35em; }
.seo-guide-meta { margin-bottom: 1.2rem; }
.seo-answer {
  border-left: 4px solid var(--accent); background: var(--card);
  border-radius: 0 var(--radius) var(--radius) 0; padding: 14px 18px; margin-bottom: 1.6rem;
  box-shadow: var(--shadow);
}
.seo-answer h2 { font-family: var(--font-body); font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--seo-accent-text); margin: 0 0 .35rem; }
.seo-answer p { color: var(--ink); margin: 0; font-size: 1.02rem; }
.seo-toc { grid-area: toc; position: sticky; top: 84px; font-size: .9rem; border-left: 2px solid var(--border); padding-left: 16px; }
.seo-toc h2 { font-family: var(--font-body); font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 .6rem; }
.seo-toc ol { list-style: none; display: grid; gap: .45rem; }
.seo-toc a { color: var(--ink-soft); display: block; line-height: 1.35; }
.seo-toc a:hover { color: var(--primary); }
.seo-guide-body { grid-area: body; max-width: 720px; min-width: 0; }

.seo-prose { overflow-wrap: break-word; }
.seo-prose p, .seo-prose ul, .seo-prose ol { color: var(--ink-soft); margin-bottom: 1em; }
.seo-prose ul, .seo-prose ol { padding-left: 1.4em; }
.seo-prose li { margin-bottom: .35em; }
.seo-prose li::marker { color: var(--muted); }
.seo-prose strong { color: var(--ink); }
.seo-prose h3 { font-size: 1.08rem; margin: 1.4em 0 .45em; }
.seo-prose .table-wrap { margin: 0 0 1.2em; }
.seo-prose code { overflow-wrap: anywhere; }
.seo-prose a { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--primary) 35%, transparent); text-underline-offset: 2px; }
.seo-prose a:hover { text-decoration-color: currentColor; }
/* Cards and tags inside an article are whole-block links, not inline prose links. */
.seo-prose a:is(.seo-guide-card, .tag, .btn) { text-decoration: none; }
.seo-prose .seo-guide-card h3 { margin: 0; }
.seo-prose .seo-guide-card p { margin: 0; color: var(--ink-soft); }
.seo-prose .data-table th, .seo-prose .data-table td { font-size: .9rem; }
.seo-section { scroll-margin-top: 84px; }
.seo-section + .seo-section { margin-top: 2.2rem; }
.seo-section > h2 { margin-top: 0; }
.seo-example {
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 16px; margin: 0 0 1.2em;
}
.seo-example figcaption { font-size: .74rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin-bottom: .3rem; }
.seo-example p { margin: 0; color: var(--ink); }
.seo-note { border-left: 3px solid var(--gold); padding: 2px 0 2px 14px; }
.seo-terms .keyword-tags { list-style: none; padding: 0; }
.seo-cta {
  margin-top: 2.6rem; padding: 20px 22px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--card); display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px;
}
.seo-cta p { flex: 1 1 100%; margin: 0 0 .3rem; color: var(--ink-soft); }
.seo-cta .btn { text-decoration: none; }

/* Row headers inside tables on these pages read as data, not as column labels. */
:is(.seo-guide, .seo-dev, .seo-stats) .data-table tbody th {
  text-transform: none; letter-spacing: normal; font-size: inherit; font-weight: 600;
  color: var(--ink); text-align: left; vertical-align: top;
}
:is(.seo-guide, .seo-dev, .seo-stats) .data-table tbody tr:last-child th { border-bottom: none; }

/* ---------- Code ---------- */
.seo-code-wrap { position: relative; margin: 0 0 1.2em; }
.seo-code {
  background: var(--bg); color: var(--ink); border: 1px solid var(--border); border-radius: 8px;
  padding: 14px 16px; padding-right: 70px; overflow-x: auto; font-size: .82rem; line-height: 1.55;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre;
}
.seo-code code { background: none; padding: 0; font-size: inherit; overflow-wrap: normal; }
.seo-copy { position: absolute; top: 8px; right: 8px; }

/* ---------- Glossary ---------- */
.seo-az {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 1.4rem; position: sticky; top: 62px; z-index: 5;
  background: var(--bg); padding: 8px 0; border-bottom: 1px solid var(--border);
}
.seo-az a {
  min-width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 8px; background: var(--card); font-weight: 600; color: var(--ink-soft);
}
.seo-az a:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.seo-letter { max-width: 780px; scroll-margin-top: 120px; }
.seo-letter > h2 { font-size: 1.5rem; color: var(--primary); margin: 1.6rem 0 .6rem; scroll-margin-top: 120px; }
.seo-glossary { display: grid; gap: 12px; }
.seo-term {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; scroll-margin-top: 120px;
}
.seo-term:target { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.seo-term dt { display: flex; align-items: baseline; gap: 8px; margin-bottom: .3rem; }
.seo-term dfn { font-style: normal; font-weight: 700; font-family: var(--font-display); font-size: 1.08rem; color: var(--ink); }
/* Full opacity: a faded link fails text contrast, and the mark is small anyway. */
.seo-anchor { color: var(--muted); font-size: .9rem; }
.seo-term:hover .seo-anchor, .seo-anchor:focus-visible { color: var(--primary); }
.seo-term dd p { color: var(--ink-soft); margin: 0 0 .4em; }
.seo-term dd p:last-child { margin-bottom: 0; }
.seo-updated { margin-top: 2rem; }

/* ---------- Statistics ---------- */
.seo-figures {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: 12px; margin-bottom: 1.6rem;
}
.seo-figures > div {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px;
}
.seo-figures dt { font-size: .74rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.seo-figures dd { font-family: var(--font-display); font-size: 1.7rem; font-weight: 700; color: var(--ink); line-height: 1.2; font-variant-numeric: tabular-nums; }
.seo-figures dd.muted-sm { font-family: var(--font-body); font-size: .8rem; font-weight: 400; color: var(--muted); margin-top: .25rem; }
.seo-stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 16px; margin-bottom: 16px; }
.seo-panel {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; min-width: 0; margin-bottom: 16px;
}
.seo-stats-grid .seo-panel { margin-bottom: 0; }
.seo-panel > h2 { font-size: 1.15rem; margin: 0 0 .7rem; }
.seo-panel .data-table th, .seo-panel .data-table td { padding: 8px 10px; }
.seo-panel .data-table tbody th { font-weight: 500; }
.seo-stats .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.seo-bar { display: block; height: 6px; margin-top: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.seo-bar span { display: block; height: 100%; background: var(--primary); border-radius: 3px; }
.seo-chart-wrap { margin: .6rem 0 .8rem; }
.seo-chart { width: 100%; height: auto; display: block; }
.seo-chart-grid { stroke: var(--border); stroke-width: 1; }
.seo-chart-axis { fill: var(--muted); font-size: 12px; font-family: var(--font-body); }
.seo-chart-value { fill: var(--ink-soft); font-size: 12px; font-weight: 600; font-family: var(--font-body); }
.seo-chart-bar { fill: var(--primary); }
.seo-chart-bar:hover { fill: var(--accent); }
/* The compact drawing replaces the wide one on phones (see seo_month_chart()). */
.seo-chart-compact { display: none; }
.seo-chart-compact .seo-chart-axis, .seo-chart-compact .seo-chart-value { font-size: 13px; }
@media (max-width: 560px) {
  .seo-chart:not(.seo-chart-compact) { display: none; }
  .seo-chart-compact { display: block; }
}
.seo-details summary { cursor: pointer; font-weight: 600; color: var(--primary); margin-bottom: .6rem; }
.seo-subjects { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; }
.seo-subjects li {
  display: inline-flex; align-items: baseline; gap: 6px; border: 1px solid var(--border); border-radius: 999px;
  padding: .2em .8em; background: var(--bg);
}
.seo-methodology { max-width: 780px; margin-top: 1.6rem; }
.seo-cite-box {
  max-width: 780px; margin-top: 1.4rem; padding: 16px 18px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--card);
}
.seo-cite-box h2 { font-size: 1.05rem; margin: 0 0 .5rem; }
.seo-cite-box p { color: var(--ink-soft); font-size: .92rem; margin-bottom: .7rem; overflow-wrap: anywhere; }

/* ---------- Developers ---------- */
.seo-overview { margin-bottom: 2rem; }
.seo-dev-body { max-width: 860px; }
.seo-tools td, .seo-tools th { font-size: .88rem; }
.seo-tools th code { white-space: nowrap; }

/* ---------- Snippets inside other pages ---------- */
.seo-record-help { margin-top: .8rem; font-size: .88rem; color: var(--ink-soft); }
.seo-record-help-label {
  font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin-right: .3rem;
}

/* ---------- Narrow screens ---------- */
@media (max-width: 900px) {
  .seo-guide-layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "toc" "body"; }
  .seo-toc {
    position: static; margin: 0 0 1.8rem; border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--card); padding: 14px 16px;
  }
  .seo-toc ol { list-style: decimal; padding-left: 1.3em; gap: .3rem; }
}
@media (max-width: 520px) {
  .seo-code { font-size: .78rem; padding-right: 16px; padding-top: 44px; }
  .seo-panel { padding: 14px; }
  .seo-figures dd { font-size: 1.45rem; }
}
@media (prefers-reduced-motion: no-preference) {
  html:has(.seo-guide, .seo-glossary-page) { scroll-behavior: smooth; }
}
