/* ================================================
   Metrigram — metrigram.css
   2026 · DM Sans + DM Mono
   ================================================ */

/* 1 · Fonts ---------------------------------------- */

@font-face {
  font-family: 'DM Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/dm-mono-v10-latin/dm-mono-v10-latin-regular.woff2') format('woff2');
}
@font-face {
  font-family: 'DM Mono';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/dm-mono-v10-latin/dm-mono-v10-latin-italic.woff2') format('woff2');
}
@font-face {
  font-family: 'DM Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/dm-mono-v10-latin/dm-mono-v10-latin-500.woff2') format('woff2');
}

/* 2 · Custom Properties ---------------------------- */

:root {
  --w-nav:       10rem;
  --c-bg:        #ffffff;
  --c-text:      #1c1c1e;
  --c-muted:     #6e6e73;
  --c-border:    #e5e5e5;
  --c-nav-bg:    #f7f7f7;
  --c-nav-hover: #ececec;
  --c-link:      hsl(213, 100%, 30%);
  --c-link-hov:  hsl(213, 100%, 18%);
  --c-link-vis:  hsl(251,  50%, 52%);
  --c-accent:    #4ab4a3;
  --f-sans:      'DM Sans', system-ui, -apple-system, sans-serif;
  --f-mono:      'DM Mono', 'Courier New', monospace;
  --ease:        0.18s ease-out;
}

/* 3 · Reset ---------------------------------------- */

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

body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--f-sans);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* 4 · Typography ----------------------------------- */

h1 { font-size: 1.5rem;  font-weight: 600; margin: 0;           line-height: 1.2; }
h2 { font-size: 1.15rem; font-weight: 600; margin: 0 0 0.4em;   line-height: 1.3; }
h3 { font-size: 1rem;    font-weight: 400; font-style: italic;   margin: 0 0 0.4em; }
p  { margin: 0 0 1em; }

code, .mono {
  font-family: var(--f-mono);
  font-size: 0.875em;
}

img { max-width: 100%; height: auto; display: block; }

/* 5 · Links ---------------------------------------- */

a         { color: var(--c-link);     text-decoration: none; }
a:hover   { color: var(--c-link-hov); }
a:visited { color: var(--c-link-vis); }

/* 6 · Layout --------------------------------------- */

#layout {
  position: relative;
  transition: left var(--ease);
}

#main {
  margin-left: var(--w-nav);
}

/* 7 · Sidebar (injected by homenav.js) ------------- */

#menu {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--w-nav);
  background: var(--c-nav-bg);
  border-right: 1px solid var(--c-border);
  overflow-y: auto;
  z-index: 100;
  transition: transform var(--ease);
}

/* pure-menu class shims — homenav.js injects these */
.pure-menu {
  display: flex;
  flex-direction: column;
  padding-top: 0.5rem;
}

.pure-menu-heading {
  display: flex;
  justify-content: center;
  padding: 1.75rem 0 1.5rem;
}

.footer-img {
  width: 36px;
  display: block;
}

.pure-menu-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.pure-menu-item a,
.pure-menu-link {
  display: block;
  padding: 0.55rem 1rem;
  color: var(--c-text);
  font-family: var(--f-sans);
  font-size: 0.875rem;
  letter-spacing: 0.01em;
  text-decoration: none;
  transition: background var(--ease);
}

.pure-menu-item a:visited { color: var(--c-text); }

.pure-menu-item a:hover,
.pure-menu-link:hover {
  background: var(--c-nav-hover);
  color: var(--c-text);
}

.pure-menu-selected {
  background: var(--c-border);
}

.pure-menu-selected a {
  font-weight: 600;
}

/* 8 · Content regions ------------------------------ */

.header {
  padding: 2.75rem 2rem 1.25rem;
}

.header h2 {
  font-weight: 300;
  font-size: 0.9rem;
  color: var(--c-muted);
  font-style: normal;
  margin-top: 0.2em;
}

.content,
.content-no-header {
  padding: 2rem;
  max-width: 680px;
  line-height: 1.65;
  margin-bottom: 3rem;
}

.content-subhead {
  margin: 1.5em 0 0.75em;
  font-weight: 500;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--c-muted);
}

/* 9 · Swatches ------------------------------------- */

.swatch-row {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0.75rem;
  margin: 1.25rem 0 1.75rem;
}

.swatch-cell {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.swatch {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 3px;
}

.swatch-cell code {
  font-size: 0.65rem;
  color: var(--c-text);
  line-height: 1.3;
  word-break: break-all;
}

.swatch-cell span {
  font-family: var(--f-mono);
  font-size: 0.65rem;
  color: var(--c-muted);
}

@media (max-width: 48em) {
  .swatch-row {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* 9b · Data table ---------------------------------- */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin: 1.25rem 0 1.75rem;
}

.data-table th {
  text-align: left;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  border-bottom: 2px solid var(--c-border);
  color: var(--c-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.data-table td {
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid var(--c-border);
  vertical-align: middle;
}

.dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.12);
  vertical-align: middle;
  margin-right: 0.5rem;
}

/* 9c · Math (KaTeX) -------------------------------- */

.katex-display {
  overflow-x: auto;
  margin: 1rem 0;
}

.defn {
  border-left: 3px solid var(--c-accent);
  padding: 0.65rem 0 0.65rem 1rem;
  margin: 1.25rem 0;
}

.defn p { margin-bottom: 0.6em; }
.defn p:last-child { margin-bottom: 0; }

.defn-label {
  font-weight: 500;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--c-muted);
  margin-bottom: 0.6em;
}

/* 9d · Grid ---------------------------------------- */

.grid-2 { display: grid; grid-template-columns: 1fr 1fr;         gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr);  gap: 1rem; }

/* backward compat with pure-g */
.pure-g               { display: grid; grid-template-columns: repeat(12, 1fr); gap: 1rem; }
.pure-u-1-2           { grid-column: span 6; }
.pure-u-1-4           { grid-column: span 3; }
.pure-u-1             { grid-column: span 12; }
.pure-img-responsive  { max-width: 100%; height: auto; }

/* 9e · Nav external links ------------------------- */

.nav-external-group {
  border-top: 1px solid var(--c-border);
  margin-top: 0.5rem;
  padding-top: 0.25rem;
}

.nav-external {
  color: var(--c-muted) !important;
  font-size: 0.8rem;
}

.nav-external:hover {
  color: var(--c-text) !important;
}

/* 10 · Hamburger ----------------------------------- */

.menu-link {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 2.75rem;
  height: 2.75rem;
  align-items: center;
  justify-content: center;
  z-index: 200;
  cursor: pointer;
}

.menu-link:hover { background: #000; }

.menu-link span {
  position: relative;
  display: block;
  width: 1.2rem;
  height: 2px;
  background: #1c1c1e;
  pointer-events: none;
}

.menu-link span::before,
.menu-link span::after {
  content: '';
  position: absolute;
  display: block;
  width: 100%;
  height: 2px;
  background: #1c1c1e;
  pointer-events: none;
}

.menu-link span::before { top: -6px; }
.menu-link span::after  { top:  6px; }

.menu-link:hover span,
.menu-link:hover span::before,
.menu-link:hover span::after { background: #fff; }

/* 11 · Responsive ---------------------------------- */

@media (min-width: 48em) {
  .menu-link { display: none; }
}

@media (max-width: 48em) {
  .menu-link { display: flex; }

  #main { margin-left: 0; }

  #menu {
    transform: translateX(-100%);
  }

  #menu.active {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.07);
  }

  #layout.active {
    left: var(--w-nav);
  }

  .pure-g { grid-template-columns: 1fr; }
  .pure-u-1-2,
  .pure-u-1-4 { grid-column: span 12; }
  .grid-2,
  .grid-4     { grid-template-columns: 1fr; }
}
