/* AskRobots site styles: base, layout and components. Uses tokens.css.
 * No framework, no build step. Page-specific CSS goes in the page's
 * {% block head %}; legacy pages (not redesigned yet) also load style.css,
 * scoped to main.legacy-main. */

/* ── Base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: var(--fs-2)/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
img, svg { max-width: 100%; }
h1, h2, h3 { line-height: 1.25; }

.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;
}
.skip-link {
  position: absolute; left: var(--s4); top: -100px; z-index: 10;
  background: var(--surface); color: var(--accent); border: 2px solid var(--accent);
  border-radius: var(--r); padding: var(--s2) var(--s4); font-weight: 600;
}
.skip-link:focus { top: var(--s3); }

.wrap { width: 100%; max-width: var(--wide); margin: 0 auto; padding: 0 var(--gutter); }
main { flex: 1 0 auto; width: 100%; }
main:focus { outline: none; }

/* ── Header ───────────────────────────────────────────── */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.site-header.is-bare { background: none; border-bottom-color: transparent; }
.site-header__inner {
  display: flex; align-items: center; gap: var(--s5);
  min-height: 60px; padding-top: var(--s3); padding-bottom: var(--s3);
}
.brand {
  display: inline-flex; align-items: center; gap: var(--s2);
  font: 600 var(--fs-4)/1 var(--serif); letter-spacing: -.01em;
  color: var(--ink); text-decoration: none; white-space: nowrap;
}
.brand:hover { color: var(--ink); }
.brand svg { width: 26px; height: 26px; flex: none; }
.site-nav { margin-left: auto; display: flex; align-items: center; gap: var(--s4); font-size: var(--fs-1); }
.site-nav a { color: var(--ink-2); text-decoration: none; white-space: nowrap; }
.site-nav a:hover { color: var(--ink); text-decoration: underline; }
.site-nav a[aria-current="page"] { color: var(--ink); font-weight: 600; }
.theme-toggle {
  background: none; border: 1px solid var(--line-strong); border-radius: var(--r-pill);
  color: var(--ink-2); padding: 3px 10px; font: var(--fs-1) var(--sans); cursor: pointer;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--ink-2); }
[data-theme-lock] .theme-toggle { display: none; }

/* ── Search box (header and home) ─────────────────────── */
.search-form {
  display: flex; align-items: stretch; gap: var(--s2);
  border: 1px solid var(--line-strong); border-radius: var(--r-pill);
  background: var(--bg); padding: 4px 4px 4px var(--s4);
}
.search-form:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.search-form input[type="search"], .search-form input[type="text"] {
  flex: 1; min-width: 0; border: 0; background: none; color: var(--ink);
  font: 16px var(--sans); /* 16px: no iOS zoom-on-focus */ padding: 6px 0;
}
.search-form input:focus { outline: none; }
.search-form input::placeholder { color: var(--ink-3); opacity: 1; }
.search-form input[type="search"]::-webkit-search-cancel-button { cursor: pointer; }
.btn-primary {
  border: 0; border-radius: var(--r-pill); background: var(--accent); color: var(--on-accent);
  font: 600 var(--fs-2) var(--sans); padding: 6px var(--s4); cursor: pointer; white-space: nowrap;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:focus-visible { outline-offset: 3px; }
.site-header .search-form { flex: 1; max-width: 600px; }
.site-header .btn-primary { font-size: var(--fs-1); }

/* ── Footer ───────────────────────────────────────────── */
.site-footer { margin-top: var(--s7); border-top: 1px solid var(--line); font-size: var(--fs-1); color: var(--ink-3); }
.site-footer__inner { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); padding-top: var(--s4); padding-bottom: var(--s4); }
.site-footer a { color: var(--ink-2); }
.site-footer .brand-small { font: 600 var(--fs-2) var(--serif); color: var(--ink); }

/* ── Messages ─────────────────────────────────────────── */
.flash { margin: var(--s4) auto 0; max-width: var(--content); padding: var(--s3) var(--s4);
  border: 1px solid var(--line); border-left: 4px solid var(--warn); border-radius: var(--r);
  background: var(--warn-wash); color: var(--ink); }
.flash.is-error { border-left-color: var(--bad); }

/* ── Chips ────────────────────────────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); border-radius: var(--r-pill);
  padding: 1px 10px; background: var(--surface); color: var(--ink-2);
  font-size: 12.5px; line-height: 1.6; text-decoration: none; white-space: nowrap;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
a.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip--good { border-color: var(--good); color: var(--good); background: var(--good-wash); }
.chip--pending { border-style: dashed; border-color: var(--line-strong); color: var(--ink-3); background: transparent; }
.chip--notice { border-color: var(--warn); color: var(--warn); background: var(--warn-wash); }
.meter { flex: none; width: 34px; height: 5px; border-radius: 3px; background: var(--line); position: relative; overflow: hidden; }
.meter > span { position: absolute; inset: 0 auto 0 0; background: currentColor; }

/* ── Results page ─────────────────────────────────────── */
.results-layout {
  display: grid; grid-template-columns: minmax(0, var(--content)) minmax(0, 1fr);
  gap: var(--s7); padding-top: var(--s5);
}
.results-meta { color: var(--ink-3); font-size: var(--fs-1); margin: 0 0 var(--s2); }
.relaxed-note, .suggestion {
  margin: 0 0 var(--s3); padding: var(--s2) var(--s3); border-radius: var(--r);
  background: var(--surface-2); color: var(--ink-2); font-size: var(--fs-1);
}
.suggestion { font-size: var(--fs-2); }
.suggestion a { font-weight: 600; }

.result { padding: var(--s4) 0 var(--s5); border-bottom: 1px solid var(--line); min-width: 0; }
.result:last-of-type { border-bottom: 0; }
.result__src { display: flex; align-items: center; gap: var(--s3); font-size: var(--fs-1); min-width: 0; }
.result__fav {
  flex: none; width: 28px; height: 28px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line);
  font: 600 13px/1 var(--serif); color: var(--ink-2); text-transform: uppercase;
}
.result__site { min-width: 0; line-height: 1.35; }
.result__site b { display: block; font-weight: 500; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result__site span { display: block; color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result__title { font: 500 var(--fs-4)/1.3 var(--serif); margin: var(--s2) 0 var(--s1); overflow-wrap: anywhere; }
.result__title a { color: var(--title); text-decoration: none; }
.result__title a:hover { text-decoration: underline; }
.result__title a:visited { color: var(--ink-2); }
.result__snippet { margin: 0; color: var(--ink-2); max-width: 66ch; overflow-wrap: anywhere; }
.result__snippet b { font-weight: 600; color: var(--ink); background: var(--hl); padding: 0 1px; border-radius: 2px; }
.result__summary { margin: var(--s2) 0 0; font-size: var(--fs-1); color: var(--ink-2); max-width: 66ch; }
.result__summary strong { font-weight: 600; color: var(--ink); }
.result__summary .muted { color: var(--ink-3); }
.result__facts { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin-top: var(--s3); font-size: 12.5px; }
.result__facts .note { color: var(--ink-3); }
.about-link { margin-left: auto; font-size: 12.5px; font-weight: 500; text-decoration: none; white-space: nowrap; }
.about-link:hover { text-decoration: underline; }

.pager { display: flex; flex-wrap: wrap; gap: var(--s2); padding: var(--s5) 0; font-size: var(--fs-1); }
.pager a, .pager span {
  min-width: 40px; min-height: 36px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: var(--r-pill); padding: 6px 12px;
  text-decoration: none; color: var(--ink-2); background: var(--surface);
}
.pager a:hover { border-color: var(--accent); color: var(--accent); }
.pager [aria-current="page"] { background: var(--ink); color: var(--bg); border-color: var(--ink); font-weight: 600; }

.empty-state { padding: var(--s6) 0; max-width: 60ch; }
.empty-state__title { font: 500 var(--fs-5)/1.2 var(--serif); margin: 0 0 var(--s3); overflow-wrap: anywhere; }
.empty-state p, .empty-state li { color: var(--ink-2); }
.empty-state ul { padding-left: 1.2em; }

.side-card {
  position: sticky; top: var(--s5); align-self: start;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow); padding: var(--s4) var(--s5); font-size: 14px; color: var(--ink-2);
}
.side-card h2 { font: 600 var(--fs-3)/1.3 var(--serif); color: var(--ink); margin: 0 0 var(--s3); }
.side-card dl { margin: 0; display: grid; gap: var(--s3); }
.side-card dt { margin: 0 0 2px; }
.side-card dd { margin: 0; }
.side-card p { margin: var(--s3) 0 0; font-size: var(--fs-1); color: var(--ink-3); }

/* ── Home ─────────────────────────────────────────────── */
.hero { max-width: 720px; margin: 0 auto; padding: 9vh var(--gutter) var(--s6); text-align: center; }
.hero h1 { font: 500 clamp(32px, 6vw, var(--fs-6))/1.1 var(--serif); letter-spacing: -.02em; margin: 0 0 var(--s3); }
.hero .lede { color: var(--ink-2); font-size: var(--fs-3); margin: 0 auto var(--s6); max-width: 34em; }
.hero .search-form { background: var(--surface); box-shadow: var(--shadow); padding: 6px 6px 6px var(--s5); text-align: left; }
.hero .search-form input[type="search"] { font-size: var(--fs-3); padding: 10px 0; }
.hero .btn-primary { padding: 0 var(--s5); }
.hero__options { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: var(--s2) var(--s4);
  margin: var(--s4) 0 0; font-size: var(--fs-1); color: var(--ink-3); }
.hero__options a { color: var(--ink-2); }
.safe-toggle { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); cursor: pointer; }
.safe-toggle input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }

.how { max-width: 960px; margin: 0 auto; padding: var(--s6) var(--gutter) var(--s7);
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s5); }
.how > h2 { grid-column: 1 / -1; font: 600 var(--fs-4) var(--serif); margin: 0; }
.how__item { border-top: 2px solid var(--ink); padding-top: var(--s3); }
.how__item h3 { font: 600 var(--fs-3)/1.3 var(--serif); margin: 0 0 var(--s2); }
.how__item p { margin: 0; color: var(--ink-2); }
.how__sample { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s3); }

.topics { max-width: 960px; margin: 0 auto; padding: 0 var(--gutter) var(--s5); }
.topics h2 { font: 600 var(--fs-4) var(--serif); margin: 0 0 var(--s4); }
.topics__grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s3); }
.topics__grid a {
  display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: var(--s3) var(--s4); text-decoration: none; color: var(--ink); font-weight: 600;
}
.topics__grid a:hover { border-color: var(--accent); color: var(--accent); }

/* ── Legacy pages (not redesigned yet) ────────────────── */
main.legacy-main { max-width: 840px; margin: 0 auto; padding: 20px; }

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 960px) {
  .results-layout { grid-template-columns: minmax(0, 1fr); gap: var(--s5); }
  .side-card { position: static; }
}
@media (max-width: 720px) {
  .how { grid-template-columns: minmax(0, 1fr); padding-top: var(--s5); }
  .topics__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { padding-top: var(--s6); }
}
@media (max-width: 600px) {
  .site-header__inner { flex-wrap: wrap; gap: var(--s3); }
  .site-header .search-form { order: 3; flex-basis: 100%; max-width: none; }
  .site-nav .hide-sm { display: none; }
  .result__title { font-size: 19px; }
  .about-link { margin-left: 0; }
  .hero .search-form { padding-left: var(--s4); }
  .hero .btn-primary { padding: 0 var(--s4); }
}
@media (prefers-reduced-motion: no-preference) {
  .chip, .pager a, .topics__grid a { transition: border-color .15s ease, color .15s ease; }
}
