/* Base: reset, type, layout, header, footer. Requires tokens.css (and fonts.css). */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: var(--s-6); }
body, h1, h2, h3, h4, p, figure, blockquote, dl, dd, ol, ul { margin: 0; }
ul[class], ol[class] { list-style: none; padding: 0; }
img, svg { display: block; max-width: 100%; height: auto; }
input, button, textarea, select { font: inherit; color: inherit; }

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  font-weight: var(--fw-regular);
  font-kerning: normal;
  font-variant-numeric: tabular-nums;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}
main { flex: 1 0 auto; }
::selection { background: var(--selection); color: var(--text); }

/* ---------- Typography ---------- */
h1, h2, h3, h4 {
  font-weight: var(--fw-medium);
  line-height: var(--lh-snug);
  letter-spacing: var(--tracking-tight);
  text-wrap: balance;
}
h1 { font-size: var(--fs-2xl); font-weight: var(--fw-light); line-height: var(--lh-tight); max-width: 20ch; }
h2 { font-size: var(--fs-xl); font-weight: var(--fw-regular); max-width: 28ch; }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }

.prose > * + * { margin-top: var(--s-4); }
.prose > * + :is(h2, h3, h4) { margin-top: var(--s-7); }
.prose > :is(h2, h3, h4) + * { margin-top: var(--s-3); }
.prose, .prose p, .prose li { max-width: var(--measure); }
p { text-wrap: pretty; }

.lead { font-size: var(--fs-md); line-height: 1.5; color: var(--text); max-width: 52ch; }
.muted { color: var(--text-2); }
small, .small { font-size: var(--fs-sm); }

ul:not([class]), ol:not([class]) { padding-left: 1.25em; }
li + li { margin-top: var(--s-2); }
ul:not([class]) > li::marker { color: var(--text-2); }

strong { font-weight: var(--fw-semibold); }
abbr[title] { text-decoration: underline dotted; text-underline-offset: 0.2em; }
hr { border: 0; border-top: var(--hair) solid var(--rule); margin: var(--s-7) 0; }

/* ---------- Links ---------- */
a {
  color: var(--accent-text);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}
a:hover { text-decoration-thickness: 2px; }
a:visited { color: var(--accent-text); }

/* ---------- Focus and skip link ---------- */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: var(--radius);
}
.skip-link {
  position: absolute;
  left: var(--gutter);
  top: var(--s-2);
  z-index: 10;
  padding: var(--s-2) var(--s-4);
  background: var(--text);
  color: var(--bg);
  font-size: var(--fs-sm);
  transform: translateY(-200%);
}
.skip-link:focus-visible { transform: none; color: var(--bg); }
.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;
}

/* ---------- Code ---------- */
code, kbd, samp, pre { font-family: var(--font-mono); font-size: 0.9em; }
:not(pre) > code {
  padding: 0.1em 0.3em;
  background: var(--bg-sunk);
  border-radius: var(--radius);
}
pre {
  padding: var(--s-4) var(--s-5);
  background: var(--bg-sunk);
  border-left: var(--rule-heavy) solid var(--rule-strong);
  overflow-x: auto;
  line-height: 1.5;
  font-size: var(--fs-sm);
  tab-size: 2;
}
pre:focus-visible { outline-offset: 0; }

/* ---------- Tables (base; spec variant in components.css) ---------- */
.table-scroll { overflow-x: auto; max-width: 100%; }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
caption { text-align: left; font-size: var(--fs-sm); color: var(--text-2); padding-bottom: var(--s-3); }
th, td { text-align: left; vertical-align: top; padding: var(--s-3) var(--s-4) var(--s-3) 0; border-bottom: var(--hair) solid var(--rule); }
th { font-weight: var(--fw-semibold); }
thead th { border-bottom: var(--rule-w) solid var(--rule-strong); font-weight: var(--fw-medium); color: var(--text-2); }

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

/* The margin-column grid: a narrow reference column on the left, content on the right.
   Stacks below 60rem. Used by .section in components.css and by page heads. */
.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-3) var(--s-7);
}
@media (min-width: 60rem) {
  .grid { grid-template-columns: var(--margin-col) minmax(0, 1fr); }
  .grid > .grid__full { grid-column: 1 / -1; }
  .grid > .grid__main { grid-column: 2; }
}

/* ---------- Header ----------
   <header class="site-header">
     <div class="wrap site-header__inner">
       <a class="wordmark" href="/">Devanka</a>
       <nav class="site-nav" aria-label="Main"><ul>...</ul></nav>
       <div class="site-header__account"></div>   <- future "Sign in" link to app.ankasum.com
     </div>
   </header>
   Mark the current page with aria-current="page". */
.site-header { border-bottom: var(--hair) solid var(--rule); }
.site-header__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--s-3) var(--s-6);
  padding-block: var(--s-5);
}
.wordmark {
  font-weight: var(--fw-semibold);
  font-size: 1.1875rem;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
  margin-right: auto;
}
.wordmark:visited { color: var(--text); }
.wordmark__by { font-weight: var(--fw-regular); color: var(--text-2); font-size: var(--fs-sm); margin-left: 0.4em; letter-spacing: 0; }
.site-nav ul { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-5); list-style: none; padding: 0; margin: 0; }
.site-nav li + li { margin-top: 0; }
.site-nav a, .site-header__account a {
  display: inline-block;
  padding-block: var(--s-2);   /* 24px+ target height */
  color: var(--text);
  text-decoration: none;
  font-size: var(--fs-sm);
}
.site-nav a:visited { color: var(--text); }
.site-nav a:hover { text-decoration: underline; text-underline-offset: 0.35em; }
.site-nav a[aria-current="page"] { text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 0.35em; }
.site-header__account:empty { display: none; }
.site-header__account a {
  padding-inline: var(--s-3);
  border: var(--hair) solid var(--rule-strong);
  border-radius: var(--radius);
}
@media (max-width: 40rem) {
  .site-header__inner { flex-direction: column; align-items: flex-start; gap: var(--s-2); }
  .wordmark { margin-right: 0; }
}

/* ---------- Footer ---------- */
.site-footer {
  margin-top: var(--s-9);
  border-top: var(--hair) solid var(--rule);
  padding-block: var(--s-7) var(--s-6);
  font-size: var(--fs-sm);
  color: var(--text-2);
}
.site-footer a { color: var(--text-2); }
.site-footer a:hover { color: var(--text); }

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

/* ---------- Print ---------- */
@media print {
  .site-header nav, .site-header__account, .skip-link { display: none; }
  body { background: #fff; color: #000; }
  a { color: #000; }
}
