/* Structural CSS only - every color/font/size value comes from --tokens (see layout.mjs).
   Breakpoints: mobile <720, tablet 720-1039, desktop >=1040, extra step at 900 for
   hero-mosaic and the category grid. Per-site header collapse width is injected inline
   per build (see layout.mjs tokensStyle). */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
/* The HTML [hidden] default (display:none) is NOT reliably applied to SVG elements by the
   browser's own UA stylesheet (verified: a bare <svg hidden> still computes display:inline
   in Chromium) - without this rule the menu-open/menu-closed icon swap shows both icons
   at once. Author-level rule, so it has to be explicit rather than assumed. */
[hidden] { display: none; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-text);
  font-size: var(--body-size);
  line-height: var(--body-lead);
}
img { max-width: 100%; display: block; }
a { color: inherit; }
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 3px;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.sr-only--focusable:focus {
  position: fixed; top: 8px; left: 8px; width: auto; height: auto; margin: 0; padding: 10px 16px;
  background: var(--ink); color: var(--paper); z-index: 100; clip: auto;
}
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 var(--px); }
button { font: inherit; cursor: pointer; }

.demo-bar {
  background: var(--ink); color: var(--paper); text-align: center;
  font: 500 13px var(--f-ui); padding: 8px var(--px);
}

/* ---------- Header: shared bits ---------- */
.logo {
  font-family: var(--f-display); font-size: var(--logo-size); font-weight: var(--logo-weight);
  letter-spacing: var(--logo-track); text-transform: var(--logo-case); text-decoration: none; white-space: nowrap;
}
.logo em { font-style: var(--logo-b-style); color: var(--accent); }
.hdr { border-bottom: 1px solid var(--rule); background: var(--surface); }
.hdr__row1 { display: flex; align-items: center; gap: 16px; padding: 20px var(--px); }
.hdr__nav ul { list-style: none; display: flex; flex-wrap: wrap; gap: 0 30px; margin: 0; padding: 12px var(--px); border-top: 1px solid var(--rule); }
.hdr__nav a {
  display: inline-block; padding: 4px 0; font: var(--nav-weight) var(--nav-size) var(--f-ui);
  letter-spacing: var(--nav-track); text-transform: var(--nav-case); text-decoration: none; min-height: 32px;
}
.hdr__nav a[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--accent); }
.hdr__nav a:hover { color: var(--accent); text-decoration: underline; }

.search-toggle, .menu-toggle {
  width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 1px solid var(--rule); border-radius: var(--btn-radius); color: var(--ink);
}
.menu-toggle[aria-expanded="true"] .icon-open { display: none; }
.menu-toggle[aria-expanded="true"] .icon-close { display: block !important; }
.search-bar { border-bottom: 1px solid var(--rule); background: var(--surface); }
.search-bar form { display: flex; gap: 8px; align-items: center; padding: 14px var(--px); max-width: var(--wrap); margin: 0 auto; }
.search-bar input { flex: 1; min-width: 0; height: 52px; padding: 0 16px; border: 1px solid var(--rule); border-radius: var(--btn-radius); font: inherit; }
.search-bar button[type="submit"] { height: 52px; padding: 0 20px; background: var(--ink); color: var(--paper); border: 0; border-radius: var(--btn-radius); }
.search-close { width: 44px; height: 44px; background: none; border: 0; font-size: 22px; }

/* header variants */
.hdr--center .hdr__row1 { display: grid; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); padding: 26px var(--px) 18px; }
.hdr--center .hdr__tagline { margin: 0; color: var(--muted); font: 13px var(--f-ui); max-width: 26ch; }
.hdr--center .logo { text-align: center; }
.hdr--center .search-toggle { justify-self: end; }
.hdr--center .hdr__nav ul { justify-content: center; }

.hdr--left { border-bottom-width: var(--rule-heavy); border-bottom-color: var(--ink); }
.hdr--left .hdr__row1 { justify-content: space-between; align-items: flex-end; }
.hdr--left .hdr__mast { display: flex; align-items: baseline; gap: 14px; }
.hdr--left .hdr__meta { color: var(--muted); font: 13px var(--f-ui); }
.hdr--left .search-toggle { text-transform: uppercase; font-size: 13px; width: auto; height: 38px; padding: 0 14px; }
.hdr--left .search-toggle:hover { background: var(--ink); color: var(--paper); }
.hdr--left .hdr__nav ul { gap: 0 22px; }
.hdr--left .hdr__nav a[aria-current="page"] { box-shadow: inset 0 -3px 0 var(--accent); }

.hdr--inline .hdr__row1 { gap: 24px; }
.hdr--inline .hdr__nav { flex: 1; min-width: 0; border: 0; padding: 0; }
.hdr--inline .hdr__nav ul { padding: 0; border: 0; gap: 4px; }
.hdr--inline .hdr__nav a { border-radius: var(--chip-radius); padding: 8px 10px; }
.hdr--inline .hdr__nav a[aria-current="page"] { box-shadow: none; background: var(--accent-soft); }
.hdr--inline .search-toggle { background: var(--accent-soft); border: 0; border-radius: var(--chip-radius); }

/* mobile header (shown/hidden per-site via inline nav-collapse media query) */
.hdr-mobile { background: var(--surface); border-bottom: 1px solid var(--rule); }
.hdr-mobile__bar { display: flex; align-items: center; justify-content: space-between; min-height: 60px; padding: 0 var(--px); gap: 12px; }
.hdr-mobile__bar .logo--mobile { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.hdr-mobile__actions { display: flex; gap: 8px; flex-shrink: 0; }
.mobile-menu { padding: 12px var(--px) 20px; }
.mobile-menu__list { list-style: none; margin: 0 0 16px; padding: 0; display: grid; grid-template-columns: 1fr; }
@media (min-width: 720px) { .mobile-menu__list { grid-template-columns: repeat(2, 1fr); } }
.mobile-menu__list a { display: flex; justify-content: space-between; align-items: center; min-height: 54px; border-bottom: 1px solid var(--rule); text-decoration: none; font: var(--nav-weight) var(--nav-size) var(--f-ui); }
.mobile-menu__service { list-style: none; margin: 0; padding: 12px 0 0; display: flex; flex-wrap: wrap; gap: 8px 20px; border-top: 1px solid var(--rule); }
.mobile-menu__service a { font: 14px var(--f-ui); color: var(--muted); text-decoration: none; }

/* ---------- Hero ---------- */
.hero { padding-top: var(--hero-pt); padding-bottom: var(--section-gap); }
.lead__media { display: block; margin-bottom: 16px; }
.lead__title { font-family: var(--f-display); font-size: var(--lead-title); font-weight: var(--h-weight); letter-spacing: var(--h-track); line-height: var(--h-lead); margin: 8px 0; text-wrap: balance; overflow-wrap: anywhere; }
.lead__title a { text-decoration: none; }
.lead__title a:hover { text-decoration: underline; }
.lead--noimg .lead__body { max-width: 880px; }
.kicker { font: var(--kicker-track) var(--kicker-size) var(--f-ui); letter-spacing: var(--kicker-track); text-transform: var(--kicker-case); margin: 0; color: var(--accent); }
.kicker a { text-decoration: none; color: inherit; }
.dek { font-size: 20px; color: var(--muted); margin: 10px 0; max-width: 60ch; }
.meta { font: 13px var(--f-ui); color: var(--muted); margin: 4px 0 0; }

/* .hero--feature itself is a plain single-column flow: its two real children are the lead
   article (full width) and the secondary-stories block (full width) stacked below it. The
   image|text split lives INSIDE .lead (see below) - putting grid-template-columns on
   .hero--feature instead was the bug: with only 2 non-spanning children and .hero__secondary
   forced to span both columns, column 2 of row 1 ended up empty (image+title stuck in
   column 1, big gap on the right). */
.hero--feature .lead { display: grid; gap: var(--gap); grid-template-columns: 1fr; }
@media (min-width: 720px) {
  .hero--feature .lead:not(.lead--noimg) { grid-template-columns: 1fr 1fr; align-items: start; }
}
@media (min-width: 1040px) {
  .hero--feature .lead:not(.lead--noimg) { grid-template-columns: 1.2fr 1fr; }
}
.hero--feature .lead__media { margin-bottom: 0; }
.hero__secondary { border-top: 1px solid var(--rule); margin-top: var(--gap); padding-top: var(--gap); }
/* Rows (mobile) and cards (tablet/desktop) render the SAME `secondary` list twice in the
   markup - CSS shows exactly one. Bug fixed here: the unconditional `.hero__secondary-rows`
   rule used to be declared AFTER the @media rule hiding it on wider screens; with equal
   selector specificity the later, unconditional rule always won, so rows stayed visible
   alongside cards at every width. Base (mobile-first, rows visible) rules must come first,
   with the width override declared after them. */
.hero__secondary-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.hero__secondary-cards { display: none; gap: var(--gap); }
@media (min-width: 720px) {
  .hero__secondary-rows { display: none; }
  .hero__secondary-cards { display: grid; grid-template-columns: repeat(3, 1fr); }
}

.hero--dense { display: grid; gap: var(--gap); grid-template-columns: 1fr; }
@media (min-width: 720px) { .hero--dense { grid-template-columns: 1.5fr 1fr; } .hero--dense .hero__latest { grid-column: 1 / -1; } }
@media (min-width: 1040px) { .hero--dense { grid-template-columns: 2.1fr 1.2fr 1fr; } .hero--dense .hero__latest { grid-column: auto; } }
.lead__related { list-style: none; margin: 16px 0 0; padding: 12px 0 0; border-top: 1px solid var(--rule); display: grid; gap: 8px; }
.lead__related li::before { content: "\2014 "; color: var(--muted); }
.lead__related a { text-decoration: none; }
.hero__col2 { display: grid; gap: var(--gap); }
@media (min-width: 720px) { .hero__col2 { border-left: 1px solid var(--rule); padding-left: var(--gap); margin-left: calc(var(--gap) / -2 + var(--gap) / 2 - var(--gap)); } }
.col2-item__title { font: var(--h-weight) 20px var(--f-display); margin: 6px 0; text-wrap: balance; }
.col2-item__title a { text-decoration: none; }
.hero__latest h2 { font-size: 15px; text-transform: uppercase; letter-spacing: 0.06em; border-top: var(--sec-rule) solid var(--ink); padding-top: 12px; margin: 0 0 12px; }
.hero__latest ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.hero__latest li { display: grid; grid-template-columns: 64px minmax(0,1fr); gap: 8px; font-size: 14px; }
.hero__latest time { color: var(--muted); }
.hero__latest a { text-decoration: none; }
@media (min-width: 720px) and (max-width: 1039px) { .hero__latest ol { grid-template-columns: 1fr 1fr; } .hero__latest li { grid-column: span 1; } }

.hero--mosaic { display: grid; gap: var(--gap); grid-template-columns: 1fr; }
@media (min-width: 720px) { .hero--mosaic { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1040px) { .hero--mosaic { grid-template-columns: 1.3fr 1fr; } }
.hero__mosaic { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 720px) and (max-width: 1039px) { .hero__mosaic { grid-template-columns: repeat(4, 1fr); } }
.tile__title { font-size: calc(var(--card-title) * 0.9); margin: 6px 0 0; }
.tile__title a { text-decoration: none; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; background: var(--accent-soft); padding: 14px var(--px); margin: 0 0 var(--section-gap); }
.chips__label { font: 600 13px var(--f-ui); margin-right: 8px; }
.chip { border-radius: var(--chip-radius); padding: 6px 14px; background: var(--surface); text-decoration: none; font: 14px var(--f-ui); }

/* ---------- Cards / rows / tiles / images ---------- */
.card__title, .row__title, .tile__title { font-family: var(--f-display); }
.card__title { font-size: var(--card-title); margin: 10px 0 4px; line-height: 1.2; text-wrap: balance; }
.card__title a, .row__title a { text-decoration: none; }
.card__title a:hover, .row__title a:hover, .lead__title a:hover, .tile__title a:hover { text-decoration: underline; }
.row { display: grid; grid-template-columns: minmax(0,1fr) 96px; gap: 12px; align-items: start; list-style: none; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.row--noimg { grid-template-columns: 1fr; }
.row__title { font-size: calc(var(--card-title) * 0.86); margin: 4px 0; line-height: 1.25; }
.row__title--sm { font-size: 16px; }
.row__thumb { display: block; }
.kicker-line { margin: 0; font: 12px var(--f-ui); color: var(--muted); }

.fig, .ph { position: relative; overflow: hidden; background: var(--ph-a); border-radius: var(--img-radius); }
.fig.r-43 { aspect-ratio: 4/3; } .fig.r-32, .ph.r-32 { aspect-ratio: 3/2; } .fig.r-169, .ph.r-169 { aspect-ratio: 16/9; }
.fig.r-11, .ph.r-11 { aspect-ratio: 1/1; } .fig.r-54, .ph.r-54 { aspect-ratio: 5/4; } .fig.r-1610, .ph.r-1610 { aspect-ratio: 16/10; }
.fig img { width: 100%; height: 100%; object-fit: cover; }
.fig--broken img { display: none; }
.fig--broken::after, .ph::after { content: ""; }
.ph--note { display: flex; align-items: center; justify-content: center; background: var(--ph-b); padding: 12px; text-align: center; }
.ph--note span { font: 12px var(--f-ui); color: var(--muted); }

/* ---------- Home sections ---------- */
.home-sec { max-width: var(--wrap); margin: var(--section-gap) auto 0; padding: 0 var(--px); border-top: var(--sec-rule) solid var(--ink); padding-top: 24px; }
.sec__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; margin-bottom: 24px; }
.sec__title { font-family: var(--f-display); font-size: var(--sec-title); margin: 0; }
.sec__desc { flex-basis: 100%; margin: 0; color: var(--muted); font-size: 14px; }
.sec__more { text-decoration: none; font: 600 14px var(--f-ui); white-space: nowrap; }
.leadlist { display: grid; gap: var(--gap); grid-template-columns: 1fr; }
@media (min-width: 720px) { .leadlist { grid-template-columns: 1.3fr 1fr; } }
.leadlist__rows { list-style: none; margin: 0; padding: 0; }
.grid4 { display: grid; gap: var(--gap); grid-template-columns: repeat(2, 1fr); }
@media (min-width: 1040px) { .grid4 { grid-template-columns: repeat(4, 1fr); } }
.grid-three { display: grid; gap: var(--gap); grid-template-columns: 1fr; }
@media (min-width: 720px) { .grid-three { grid-template-columns: repeat(3, 1fr); } }

.latest-sec { max-width: var(--wrap); margin: var(--section-gap) auto 0; padding: 24px var(--px) 0; border-top: var(--sec-rule) solid var(--ink); }
.latest-sec__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; grid-template-columns: 1fr; }
@media (min-width: 1040px) { .latest-sec__list { grid-template-columns: 1fr 1fr; column-gap: var(--gap); } }

/* ---------- Category page ---------- */
.category { max-width: var(--wrap); margin: 0 auto; padding: 32px var(--px) var(--section-gap); }
.breadcrumb { font: 13px var(--f-ui); color: var(--muted); margin: 0 0 12px; }
.breadcrumb a { text-decoration: none; }
.cat-title { font-family: var(--f-display); font-size: var(--cat-title); margin: 0 0 8px; }
.cat-desc { color: var(--muted); max-width: 60ch; margin: 0 0 32px; }
.cat-lead { display: grid; gap: var(--gap); grid-template-columns: 1fr; margin-bottom: var(--section-gap); }
@media (min-width: 720px) { .cat-lead { grid-template-columns: 1.25fr 1fr; } }
.cat-grid { display: grid; gap: var(--gap); grid-template-columns: 1fr; }
@media (min-width: 720px) { .cat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .cat-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1040px) { .cat-grid { grid-template-columns: repeat(4, 1fr); } }
.cat-grid--few { grid-template-columns: unset; display: flex; flex-wrap: wrap; gap: var(--gap); }
.cat-grid--few .card { flex: 0 1 260px; }
.cat-empty { text-align: center; max-width: 560px; margin: 0 auto var(--section-gap); padding: 48px 16px; }
.cat-empty h2 { font-family: var(--f-display); }
.cat-empty__ctas { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin-top: 20px; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 20px; border-radius: var(--btn-radius); text-decoration: none; font: 600 14px var(--f-ui); }
.btn--primary { background: var(--ink); color: var(--paper); }
.btn--secondary { border: 1px solid var(--rule); }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: var(--section-gap); flex-wrap: wrap; }
.pg-numbers { list-style: none; display: none; gap: 4px; margin: 0; padding: 0; }
@media (min-width: 720px) { .pg-numbers { display: flex; } .pg-compact { display: none; } }
.pg-numbers a, .pg-gap { min-width: 36px; min-height: 36px; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; border-radius: var(--btn-radius); }
.pg-numbers a[aria-current="page"] { background: var(--ink); color: var(--paper); }
.pg-btn { min-height: 44px; padding: 0 16px; display: inline-flex; align-items: center; border: 1px solid var(--rule); border-radius: var(--btn-radius); text-decoration: none; }
.pg-btn[aria-disabled="true"] { color: var(--muted); pointer-events: none; opacity: 0.6; }

/* ---------- Article ---------- */
.article { max-width: var(--wrap); margin: 0 auto; padding: 32px var(--px) var(--section-gap); }
.article__head { max-width: var(--article-head); margin: 0 auto 24px; }
.article__head h1 { font-family: var(--f-display); font-size: var(--article-title); font-weight: var(--h-weight); line-height: var(--h-lead); letter-spacing: var(--h-track); margin: 8px 0; text-wrap: balance; }
.dek--lg { font-size: 23px; }
.article__head .meta { border-top: 1px solid var(--rule); padding-top: 12px; margin-top: 16px; }
.article__figure { max-width: var(--article-fig); margin: 0 auto 32px; }
.article__figure figcaption { font: 13px var(--f-ui); color: var(--muted); margin-top: 8px; }
.article__body { max-width: var(--article-head); margin: 0 auto; }
.article__body--with-toc { display: grid; gap: var(--gap); grid-template-columns: 1fr; }
@media (min-width: 1040px) { .article__body--with-toc { grid-template-columns: 200px minmax(0, 680px); max-width: none; } }
.toc--side { display: none; }
@media (min-width: 1040px) { .toc--side { display: block; position: sticky; top: 24px; align-self: start; } .toc--inline { display: none; } }
.toc h2, .toc summary { font-size: 14px; text-transform: uppercase; letter-spacing: 0.06em; cursor: pointer; }
.toc ol { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; font-size: 14px; }
.toc a { text-decoration: none; color: var(--muted); }
.prose { max-width: 680px; font-size: var(--body-size); line-height: var(--body-lead); }
.prose h2 { font-size: calc(var(--body-size) * 1.5); font-family: var(--f-display); }
.prose h3 { font-size: calc(var(--body-size) * 0.95); font-family: var(--f-ui); font-weight: 700; }
.prose a { color: inherit; text-decoration-color: var(--accent); }
.sources, .related { max-width: var(--article-head); margin: var(--section-gap) auto 0; padding-top: 24px; border-top: var(--sec-rule) solid var(--ink); }
.sources ol { padding-left: 20px; }
.sources li { margin-bottom: 8px; }

/* ---------- Search ---------- */
.search-page { max-width: 960px; padding-top: 32px; padding-bottom: var(--section-gap); }
.search-page__form { display: flex; gap: 8px; margin: 16px 0 32px; }
.search-page__form input { flex: 1; min-width: 0; height: 52px; padding: 0 16px; border: 1px solid var(--rule); border-radius: var(--btn-radius); font: inherit; }
.search-page__form button { height: 52px; padding: 0 24px; background: var(--ink); color: var(--paper); border: 0; border-radius: var(--btn-radius); }
.search-results__item { display: grid; grid-template-columns: minmax(0,1fr); gap: 4px; padding: 16px 0; border-bottom: 1px solid var(--rule); }
@media (min-width: 720px) { .search-results__item--img { grid-template-columns: 120px minmax(0,1fr); gap: 16px; } }
.search-no-results ul { padding-left: 20px; }
.search-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

/* ---------- Info pages / 404 ---------- */
.info-page { max-width: var(--wrap); margin: 0 auto; padding: 32px var(--px) var(--section-gap); display: grid; gap: var(--gap); grid-template-columns: 1fr; }
@media (min-width: 1040px) { .info-page { grid-template-columns: 200px minmax(0,680px); } }
.info-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
@media (max-width: 1039px) { .info-nav ul { flex-direction: row; flex-wrap: wrap; } }
.info-nav a { display: block; padding: 8px 0 8px 12px; border-left: 2px solid transparent; text-decoration: none; }
.info-nav a[aria-current="page"] { border-left-color: var(--accent); font-weight: 600; }
.page-404 { max-width: 760px; margin: 0 auto; padding: 48px var(--px) var(--section-gap); text-align: center; }

/* ---------- Footer ---------- */
.site-footer { border-top: var(--rule-heavy) solid var(--ink); background: var(--footer-bg); margin-top: var(--section-gap); }
.footer__grid { display: grid; gap: var(--gap); grid-template-columns: 1fr; padding: 48px var(--px) 24px; }
@media (min-width: 720px) { .footer__grid { grid-template-columns: repeat(2, 1fr); } .footer__about { grid-column: 1 / -1; } }
@media (min-width: 1040px) { .footer__grid { grid-template-columns: 1.6fr 1fr 0.8fr; } .footer__about { grid-column: auto; } }
.footer__sections ul, .footer__service ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 12px; }
.footer__sections a, .footer__service a { text-decoration: none; font-size: 14px; }
.footer__demo-note { font-size: 12px; color: var(--muted); }
.footer__bottom { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding: 16px var(--px) 24px; border-top: 1px solid var(--rule); font-size: 13px; }
.footer__bottom a { text-decoration: none; }
