/* ------------------------------------------------------------------
   Smart Library — reset, page frame, typography, header, footer
   ------------------------------------------------------------------ */

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

html, body { margin: 0; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--t-body);
  line-height: 1.55;
  font-feature-settings: "ss01" 1, "cv05" 1;
  -webkit-font-smoothing: antialiased;
  padding-top: var(--nav);
}

[hidden] { display: none !important; }

img, svg { display: block; max-width: 100%; }

::selection { background: var(--accent); color: var(--paper-2); }

/* ---------- type ---------- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.14;
  letter-spacing: -0.012em;
  margin: 0;
  text-wrap: balance;
}

h1 { font-size: var(--t-h1); }
h2 { font-size: var(--t-h2); }
h3 { font-size: var(--t-h3); letter-spacing: 0; }

p { margin: 0; }

a { color: var(--accent); text-underline-offset: 2px; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-hover); }

strong { font-weight: 600; }

code, .mono, kbd {
  font-family: var(--font-mono);
  font-size: 0.86em;
  letter-spacing: -0.01em;
}

kbd {
  border: 1px solid var(--rule-2);
  border-bottom-width: 2px;
  border-radius: var(--r-sm);
  padding: 1px 5px;
  background: var(--paper-2);
  color: var(--muted);
  font-size: 0.72rem;
}

/* ---------- focus ---------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

.skip-link {
  position: fixed;
  top: var(--s-2);
  left: var(--s-2);
  z-index: 100;
  transform: translateY(-200%);
  background: var(--ink);
  color: var(--paper-2);
  padding: 10px 16px;
  border-radius: var(--r-sm);
  text-decoration: none;
  font-size: var(--t-sm);
}
.skip-link:focus { transform: none; color: var(--paper-2); }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- frame ---------- */
.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--gut);
}

main { display: block; }

/* ---------- header ---------- */
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 40;
  height: var(--nav);
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}

.topbar__inner {
  height: 100%;
  display: flex;
  align-items: center;
  gap: var(--s-5);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 1.125rem;
  letter-spacing: -0.015em;
  white-space: nowrap;
}
.brand:hover { color: var(--ink); }
.brand__mark {
  width: 24px;
  height: 24px;
  flex: none;
  color: var(--accent);
}
.brand__name b { font-weight: 600; }
.brand__name span { color: var(--muted); }

.topnav {
  display: flex;
  align-items: center;
  gap: var(--s-5);
  margin-inline-start: var(--s-2);
  flex: 1 1 auto;
  min-width: 0;
}
.topnav a {
  color: var(--ink-2);
  text-decoration: none;
  font-size: var(--t-sm);
  padding-block: 6px;
  border-bottom: 1px solid transparent;
}
.topnav a:hover { color: var(--accent); border-bottom-color: var(--accent); }
.topnav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); }

.topbar__actions {
  margin-inline-start: auto;
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.crumbs {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--t-xs);
  color: var(--muted);
  padding-block: var(--s-4) var(--s-3);
}
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent); }
.crumbs__sep { color: var(--rule-2); }

/* ---------- footer ---------- */
.site-footer {
  border-top: 1px solid var(--rule);
  margin-top: var(--s-9);
  padding-block: var(--s-6) var(--s-8);
  font-size: var(--t-xs);
  color: var(--muted);
}
.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-4) var(--s-6);
  align-items: baseline;
  justify-content: space-between;
}
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--accent); }
.site-footer__links { display: flex; gap: var(--s-4); }
.site-footer .path { color: var(--ink-2); word-break: break-all; }

/* ---------- helpers ---------- */
.spacer { flex: 1 1 auto; }
.grow { flex: 1 1 auto; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: var(--t-sm); }
.xs { font-size: var(--t-xs); }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

@media (max-width: 760px) {
  :root { --nav: 56px; }
  body { font-size: 0.9375rem; }
  .topnav { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
