/* =========================================================================
   Base: reset, typography, page layout, header, navigation, footer.
   Breakpoints used across the site: 520px, 720px, 860px, 980px.
   ========================================================================= */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-md);
  line-height: 1.55;
}
img, svg, canvas, iframe { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; margin: 0; text-wrap: balance; }
h1 { font-size: var(--fs-2xl); font-weight: 800; }
h2 { font-size: var(--fs-xl); font-weight: 800; }
h3, .h3 { font-size: var(--fs-lg); font-weight: 600; }
p { margin: 0; }
a { color: var(--link); text-underline-offset: 2px; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: var(--r-sm); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
:root[data-reduce-motion="true"] *, :root[data-reduce-motion="true"] *::before, :root[data-reduce-motion="true"] *::after {
  transition: none !important; animation: none !important;
}

.wrap {
  width: 100%;
  max-width: var(--content-width);
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
main { flex: 1; padding-block: var(--sp-6); }
main:focus { outline: none; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.skip-link {
  position: absolute; left: var(--sp-4); top: -100px; z-index: 50;
  background: var(--accent); color: var(--accent-ink); padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-sm); font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: var(--sp-2); }

.noscript {
  padding: var(--sp-4); background: var(--surface); border-bottom: 1px solid var(--line); text-align: center;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.site-header .wrap { display: flex; align-items: center; gap: var(--sp-5); padding-block: var(--sp-3); }
.logo {
  display: flex; align-items: center; gap: var(--sp-2); flex: none;
  color: var(--text); text-decoration: none;
  font-family: var(--font-display); font-weight: 800; font-size: 1.25rem; line-height: 1.1;
}
.logo-mark {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font-size: 1.15rem;
  box-shadow: inset 0 -3px 0 rgb(0 0 0 / 0.18);
}
.nav { display: flex; gap: var(--sp-1); }
.nav a {
  color: var(--muted); text-decoration: none; font-weight: 500;
  padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm);
}
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); box-shadow: inset 0 -2px 0 var(--accent); }

.header-search { flex: 1 1 160px; min-width: 0; max-width: 360px; margin-left: auto; }
@media (max-width: 980px) { .logo-text { display: none; } }

/* ---------- Bottom tab bar (phones) ---------- */
.tabbar { display: none; }
.tabbar svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

@media (max-width: 720px) {
  .nav { display: none; }
  .site-header .wrap { gap: var(--sp-3); }
  .header-search { max-width: none; }
  .logo-text { display: none; }
  h1 { font-size: 1.9rem; }
  main { padding-block: var(--sp-5); }
  .tabbar {
    display: grid; grid-template-columns: repeat(4, 1fr);
    position: fixed; inset: auto 0 0; z-index: 20;
    background: var(--surface); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px);
  }
  .tabbar a {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 8px 0 10px; min-height: var(--tap);
    font-size: var(--fs-xs); color: var(--muted); text-decoration: none;
  }
  .tabbar a[aria-current="page"] { color: var(--text); }
  .tabbar a[aria-current="page"] svg { stroke: var(--accent); }
}

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: var(--fs-sm); }
.site-footer .wrap { display: flex; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; padding-block: var(--sp-5); }
.site-footer nav { display: flex; gap: var(--sp-4); flex-wrap: wrap; }
.site-footer a { color: var(--muted); }
@media (max-width: 720px) { .site-footer { padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); } }

/* Line icons from js/dom.js icon() */
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon.fill { fill: currentColor; stroke: none; }
