/* base.css — reset, document type, layout frame, header/nav/footer.
   Component styling lives in components.css; breakpoints in responsive.css. */

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: var(--body);
  line-height: 1.65;
  letter-spacing: -0.01em;
  transition: background var(--hover-ms) var(--ease),
    color var(--hover-ms) var(--ease);
}

h1, h2, h3 {
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

h1 { font-size: 2rem; margin: 0 0 1rem; }
h2 { font-size: 1.375rem; margin: 2.75rem 0 0.75rem; }
h3 { font-size: 1.125rem; margin: 2rem 0 0.5rem; }
p { margin: 0 0 1rem; }

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: text-decoration-color var(--hover-ms) var(--ease);
}

a:hover {
  text-decoration-color: var(--fg);
}

/* Visible keyboard focus everywhere. Never remove for aesthetics. */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 3px;
  border-radius: 2px;
}

::selection {
  background: var(--surface);
}

code, pre {
  font-family: var(--mono);
  font-size: 0.9em;
}

pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  line-height: 1.6;
}

/* Narrow column shared by header, main, footer. */
.wrap {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* One quiet entrance for the header on first paint. */
@media (prefers-reduced-motion: no-preference) {
  .site-header {
    animation: header-in 550ms var(--ease) both;
  }
}

@keyframes header-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* Quiet top bar: name left, nav right. */
.site-header {
  padding: 1.75rem 0 0;
}

.site-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-name {
  font-weight: 500;
  font-size: 1rem;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.site-name:hover {
  text-decoration: underline;
  text-decoration-color: var(--fg);
}

.site-nav ul {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
}

/* Flex items, so links and the icon button share one exact baseline
   regardless of inline-baseline quirks across browsers. */
.site-nav li {
  display: flex;
  align-items: center;
}

.site-nav a {
  display: inline-block;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  font-size: 0.95rem;
  text-decoration: none;
  color: var(--muted);
  transition: color var(--hover-ms) var(--ease),
    background var(--hover-ms) var(--ease);
}

.site-nav a:hover {
  color: var(--fg);
}

/* Active page: subtle background treatment, nothing louder. */
.site-nav a[aria-current="page"] {
  color: var(--fg);
  background: var(--surface);
}

.menu-button,
.theme-button {
  background: none;
  border: 0;
  color: var(--muted);
  font: inherit;
  line-height: 1;
  cursor: pointer;
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: color var(--hover-ms) var(--ease),
    background var(--hover-ms) var(--ease);
}

.menu-button:hover,
.theme-button:hover {
  color: var(--fg);
  background: var(--surface);
}

.theme-button svg {
  width: 15px;
  height: 15px;
  display: block;
}

/* One icon per mode; the active one follows html[data-theme]. */
.theme-button .theme-icon {
  display: none;
}

:root[data-theme="light"] .theme-icon-sun,
:root[data-theme="dark"] .theme-icon-moon,
:root[data-theme="system"] .theme-icon-monitor {
  display: block;
}

/* Footer: tiny, never dominant. */
.site-footer {
  margin-top: 4rem;
  padding: 1.5rem 0 2.5rem;
  border-top: 1px solid var(--border);
  font-size: var(--meta);
  color: var(--muted);
}

.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  align-items: baseline;
  justify-content: space-between;
}

.site-footer ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin: 0;
  padding: 0;
}

.site-footer p {
  margin: 0;
}
