/* zainhameedo.com — one stylesheet for every page. */

:root {
  --paper: #faf8f4;
  --ink: #1d1c1a;
  --muted: #6b675f;
  --faint: #9f998e;
  --rule: #e4dfd5;
  --wash: #f3efe7;
  --accent: #b4441f;
  --accent-soft: rgba(180, 68, 31, 0.12);
  --blue: #2f5d84;
  --blue-soft: rgba(47, 93, 132, 0.14);
  --good: #3d7a52;

  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --measure: 40rem;
  --wide: 66rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #141413;
    --ink: #e8e5de;
    --muted: #a39e94;
    --faint: #6f6a62;
    --rule: #2c2a27;
    --wash: #1c1b19;
    --accent: #e27a52;
    --accent-soft: rgba(226, 122, 82, 0.16);
    --blue: #86abcc;
    --blue-soft: rgba(134, 171, 204, 0.16);
    --good: #7fb592;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #141413;
  --ink: #e8e5de;
  --muted: #a39e94;
  --faint: #6f6a62;
  --rule: #2c2a27;
  --wash: #1c1b19;
  --accent: #e27a52;
  --accent-soft: rgba(226, 122, 82, 0.16);
  --blue: #86abcc;
  --blue-soft: rgba(134, 171, 204, 0.16);
  --good: #7fb592;
  color-scheme: dark;
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.1875rem;
  line-height: 1.6;
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent-soft); }

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-color: var(--faint);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  transition: text-decoration-color 0.15s;
}
a:hover { text-decoration-color: var(--accent); }

/* Layout ------------------------------------------------------------------ */

.page { max-width: var(--measure); margin: 0 auto; padding: 0 1rem; }
.wide { max-width: var(--wide); margin-left: auto; margin-right: auto; padding: 0 1rem; }

.site-header {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 1.5rem 1rem 0;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--sans);
  font-size: 0.875rem;
}
.site-header .home { text-decoration: none; font-weight: 500; letter-spacing: -0.01em; }
.site-header nav { display: flex; gap: 1.25rem; align-items: baseline; }
.site-header nav a { text-decoration: none; color: var(--muted); }
.site-header nav a:hover { color: var(--ink); }

.mode {
  font: inherit;
  color: var(--muted);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.mode:hover { color: var(--ink); }

main { padding: 4.5rem 0 3rem; }

footer.site-footer {
  max-width: var(--measure);
  margin: 4rem auto 0;
  padding: 1.5rem 1rem 3rem;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.8125rem;
  color: var(--faint);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
footer.site-footer a { color: var(--muted); text-decoration: none; }
footer.site-footer a:hover { color: var(--ink); }

/* Type -------------------------------------------------------------------- */

h1, h2, h3 { font-weight: 500; line-height: 1.2; letter-spacing: -0.012em; }
h1 { font-size: 2.5rem; margin: 0 0 0.75rem; }
h2 { font-size: 1.5rem; margin: 3.25rem 0 0.75rem; }
h3 { font-size: 1.1875rem; margin: 2rem 0 0.5rem; }
p { margin: 0 0 1.1rem; }
.lede { font-size: 1.375rem; line-height: 1.5; color: var(--ink); }
.muted { color: var(--muted); }
.meta { font-family: var(--sans); font-size: 0.8125rem; color: var(--faint); letter-spacing: 0.01em; }
.label {
  font-family: var(--sans);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}

ul, ol { padding-left: 1.25rem; margin: 0 0 1.1rem; }
li { margin-bottom: 0.35rem; }
li::marker { color: var(--faint); }

hr { border: 0; border-top: 1px solid var(--rule); margin: 3rem 0; }

code, pre { font-family: var(--mono); font-size: 0.8125rem; }
code { background: var(--wash); padding: 0.1em 0.3em; border-radius: 3px; }
pre {
  background: var(--wash);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  line-height: 1.55;
}
pre code { background: none; padding: 0; }
.tok-k { color: var(--blue); }
.tok-c { color: var(--faint); font-style: italic; }
.tok-s { color: var(--accent); }

blockquote {
  margin: 1.5rem 0;
  padding-left: 1.1rem;
  border-left: 2px solid var(--rule);
  color: var(--muted);
}

/* Home -------------------------------------------------------------------- */

.intro h1 { font-size: 2.25rem; }
.intro p { max-width: 36rem; }

.section-label { margin: 3.5rem 0 1rem; }

.entries { list-style: none; padding: 0; margin: 0; }
.entries li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.15rem 1.5rem;
  padding: 0.9rem 0;
  border-top: 1px solid var(--rule);
  margin: 0;
}
.entries li:last-child { border-bottom: 1px solid var(--rule); }
.entries a.title { text-decoration: none; font-size: 1.1875rem; }
.entries a.title:hover { color: var(--accent); }
.entries .when { font-family: var(--sans); font-size: 0.8125rem; color: var(--faint); white-space: nowrap; padding-top: 0.3rem; }
.entries .what { grid-column: 1 / -1; color: var(--muted); font-size: 1rem; line-height: 1.5; }

.feature {
  display: block;
  text-decoration: none;
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
  background: var(--wash);
  transition: border-color 0.2s;
}
.feature:hover { border-color: var(--faint); }
.feature .art { display: block; width: 100%; height: auto; border-bottom: 1px solid var(--rule); background: var(--paper); }
.feature .body { padding: 1.1rem 1.25rem 1.25rem; }
.feature .body h3 { margin: 0.25rem 0 0.35rem; font-size: 1.375rem; }
.feature .body p { margin: 0; color: var(--muted); font-size: 1rem; line-height: 1.5; }

.elsewhere { display: flex; gap: 1.5rem; flex-wrap: wrap; font-family: var(--sans); font-size: 0.875rem; }
.elsewhere a { color: var(--muted); text-decoration: none; }
.elsewhere a:hover { color: var(--ink); }

/* Essay / project pages --------------------------------------------------- */

.byline { margin: 0 0 2.5rem; }
.byline a { color: var(--muted); }

.note {
  font-family: var(--sans);
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--muted);
  border-left: 2px solid var(--accent);
  padding: 0.1rem 0 0.1rem 0.9rem;
  margin: 1.75rem 0;
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
  margin: 2.5rem 0 1rem;
}
.stats div { background: var(--paper); padding: 0.9rem 1rem; }
.stats b { display: block; font-family: var(--sans); font-weight: 500; font-size: 1.375rem; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stats span { font-family: var(--sans); font-size: 0.75rem; color: var(--muted); }

figure { margin: 2.25rem 0 2.75rem; }
figure.wide { padding: 0 1rem; }
figcaption {
  font-family: var(--sans);
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--muted);
  margin-top: 0.75rem;
  max-width: var(--measure);
}
figcaption b { color: var(--ink); font-weight: 600; }

.fig-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.fig-title { font-family: var(--sans); font-size: 0.875rem; font-weight: 600; }
.fig-sub { font-family: var(--sans); font-size: 0.8125rem; color: var(--muted); }

.panel { background: var(--wash); border: 1px solid var(--rule); border-radius: 8px; }

/* Controls */
.controls { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; font-family: var(--sans); font-size: 0.8125rem; }
select, .seg button {
  font: inherit;
  font-family: var(--sans);
  font-size: 0.8125rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
}
select { padding-right: 1.6rem; }
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; cursor: pointer; color: var(--muted); background: var(--paper); }
.seg button + button { border-left: 1px solid var(--rule); }
.seg button[aria-pressed="true"] { color: var(--ink); background: var(--wash); }

/* Charts (SVG) */
svg text { font-family: var(--sans); fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.axis path, .axis line { stroke: var(--rule); }
svg text.halo, #est-canvas text { paint-order: stroke; stroke: var(--paper); stroke-width: 4px; stroke-linejoin: round; }
.axis text { fill: var(--faint); }
.grid line { stroke: var(--rule); stroke-dasharray: 2 3; }
.grid .domain { display: none; }
.tip {
  position: fixed;
  pointer-events: none;
  z-index: 50;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 0.75rem;
  line-height: 1.45;
  padding: 0.45rem 0.6rem;
  border-radius: 5px;
  max-width: 260px;
  opacity: 0;
  transition: opacity 0.1s;
}
.tip b { font-weight: 600; }

/* Supply web */
.web { display: grid; grid-template-columns: minmax(0, 1fr) 19rem; gap: 1.25rem; align-items: start; }
.web-canvas { min-width: 0; }
.web-canvas svg { display: block; width: 100%; height: auto; overflow: visible; }
.web .node { cursor: pointer; }
.web .node rect { fill: var(--faint); opacity: 0.55; transition: opacity 0.15s, fill 0.15s; }
.web .node.crit rect { fill: var(--ink); opacity: 0.5; }
.web .node.on rect { fill: var(--accent); opacity: 1; }
.web .node.alt rect { fill: var(--blue); opacity: 0.9; }
.web .node.dim rect { opacity: 0.14; }
.web .node text { font-size: 10px; fill: var(--faint); }
.web .node.on text, .web .node.alt text { fill: var(--ink); }
.web .node.sup.on text { font-weight: 600; }
.web .node.product text { font-size: 13px; fill: var(--ink); font-weight: 500; }
.web .node.product rect { fill: var(--ink); opacity: 0.85; }
.web .node.product.on rect { fill: var(--accent); }
.web .link { fill: none; stroke: var(--faint); stroke-opacity: 0.08; transition: stroke-opacity 0.15s; }
.web .link.on { stroke: var(--accent); stroke-opacity: 0.55; }
.web .link.alt { stroke: var(--blue); stroke-opacity: 0.45; stroke-dasharray: 3 3; }
.web .col-label { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 600; fill: var(--faint); }

.readout { padding: 1.1rem 1.15rem; font-family: var(--sans); font-size: 0.8125rem; line-height: 1.5; position: sticky; top: 1rem; }
.readout h4 { font-family: var(--serif); font-weight: 500; font-size: 1.25rem; margin: 0.15rem 0 0.15rem; letter-spacing: -0.01em; line-height: 1.25; }
.readout .sub { color: var(--muted); margin-bottom: 0.9rem; }
.readout .big { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem 0.9rem; margin: 0.9rem 0; padding: 0.9rem 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.readout .big b { display: block; font-size: 1.375rem; font-weight: 500; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--ink); }
.readout .big b.hot { color: var(--accent); }
.readout .big span { color: var(--muted); font-size: 0.75rem; }
.readout table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.readout td { padding: 0.28rem 0; border-top: 1px solid var(--rule); vertical-align: top; }
.readout td:last-child { text-align: right; color: var(--muted); white-space: nowrap; }
.readout .tag { display: inline-block; font-size: 0.6875rem; padding: 0 0.3rem; border-radius: 3px; background: var(--accent-soft); color: var(--accent); margin-left: 0.3rem; }
.readout .tag.crit { background: var(--wash); color: var(--muted); border: 1px solid var(--rule); }
.readout .hint { color: var(--faint); margin-top: 0.75rem; }

.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-family: var(--sans); font-size: 0.75rem; color: var(--muted); margin-top: 0.6rem; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 0.35rem; vertical-align: -1px; }

/* Small multiples */
.multiples { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.25rem; }
.multiples .mult-title { font-family: var(--sans); font-size: 0.8125rem; font-weight: 600; }
.multiples .mult-sub { font-family: var(--sans); font-size: 0.75rem; color: var(--muted); }
.multiples svg { width: 100%; height: auto; display: block; }

.two-up { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.75rem; }
.two-up svg { width: 100%; height: auto; display: block; }

/* Architecture */
.arch svg { width: 100%; height: auto; display: block; }
.arch .box rect { fill: var(--paper); stroke: var(--rule); }
.arch .box.hl rect { stroke: var(--ink); }
.arch .box .t { font-family: var(--sans); font-size: 13px; font-weight: 600; fill: var(--ink); }
.arch .box .s { font-family: var(--sans); font-size: 11px; fill: var(--muted); }
.arch .edge { stroke: var(--faint); fill: none; }
.arch .lane { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 600; fill: var(--faint); }

/* Embedded apps (older projects) */
.embed { border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; background: var(--wash); }
.embed iframe { display: block; width: 100%; height: 820px; border: 0; }
.shot { border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; }
.shot img { display: block; width: 100%; height: auto; }

/* Maze (projects/pathfinding-maze.html; behavior lives in js/maze.js) */
.maze-controls { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin: 1.25rem 0 0.75rem; font-family: var(--sans); font-size: 0.8125rem; }
.maze-button { font: inherit; color: var(--ink); background: var(--paper); border: 1px solid var(--rule); border-radius: 6px; padding: 0.35rem 0.7rem; cursor: pointer; }
.maze-button:hover { border-color: var(--faint); }
.maze-grid { max-width: 30rem; display: grid; grid-template-columns: repeat(15, 1fr); gap: 1px; background: var(--rule); border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; user-select: none; }
.maze-grid .cell { aspect-ratio: 1; background: var(--paper); cursor: pointer; transition: background-color 0.12s; }
.maze-grid .cell.wall { background: var(--ink) !important; border-color: transparent !important; box-shadow: none !important; }
.maze-grid .cell.start { background: var(--blue) !important; }
.maze-grid .cell.end { background: var(--accent) !important; }
.maze-grid .cell.visited { background: var(--blue-soft); }
.maze-grid .cell.path { background: var(--accent-soft) !important; box-shadow: inset 0 0 0 2px var(--accent); }
.legend .start { background: var(--blue); }
.legend .end { background: var(--accent); }
.legend .wall { background: var(--ink); }
.legend .path { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.algorithm-explanation { font-family: var(--sans); font-size: 0.875rem; color: var(--muted); line-height: 1.55; margin-top: 1rem; }
.wall-message { position: fixed; top: 1rem; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--paper); font-family: var(--sans); font-size: 0.8125rem; padding: 0.5rem 0.9rem; border-radius: 6px; z-index: 100; }

/* Responsive -------------------------------------------------------------- */

@media (max-width: 860px) {
  .web { grid-template-columns: 1fr; }
  .readout { position: static; }
  .multiples { grid-template-columns: 1fr; }
  .two-up { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 560px) {
  body { font-size: 1.0625rem; }
  h1 { font-size: 2rem; }
  .intro h1 { font-size: 1.875rem; }
  .lede { font-size: 1.1875rem; }
  main { padding-top: 3rem; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .embed iframe { height: 640px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Project pages ----------------------------------------------------------- */

.tbl { width: 100%; border-collapse: collapse; font-family: var(--sans); font-size: 0.8125rem; font-variant-numeric: tabular-nums; }
.tbl th { text-align: right; font-weight: 500; color: var(--muted); padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--ink); white-space: nowrap; }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl td { text-align: right; padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--rule); }
.tbl td.best { font-weight: 600; color: var(--ink); }
.tbl td.dim { color: var(--faint); }
.tbl caption { caption-side: bottom; text-align: left; color: var(--muted); font-size: 0.75rem; padding-top: 0.6rem; }

.range { display: flex; align-items: center; gap: 0.75rem; font-family: var(--sans); font-size: 0.8125rem; color: var(--muted); }
.range input[type="range"] { flex: 1; accent-color: var(--accent); }
.range output { font-variant-numeric: tabular-nums; color: var(--ink); min-width: 3.5rem; font-weight: 600; }
.play { font: inherit; font-family: var(--sans); font-size: 0.8125rem; color: var(--ink); background: var(--paper); border: 1px solid var(--rule); border-radius: 6px; padding: 0.35rem 0.7rem; cursor: pointer; }

.callout { font-family: var(--sans); display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--rule); border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; margin: 1rem 0 0; }
.callout div { background: var(--paper); padding: 0.8rem 0.9rem; }
.callout b { display: block; font-weight: 500; font-size: 1.375rem; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.callout span { font-size: 0.75rem; color: var(--muted); }

.race { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.25rem 1rem; }
.race .lane-title { font-family: var(--sans); font-size: 0.8125rem; font-weight: 600; margin-bottom: 0.15rem; }
.race .lane-stat { font-family: var(--sans); font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; margin-bottom: 0.4rem; min-height: 2.3em; }
.race canvas { width: 100%; height: auto; display: block; border: 1px solid var(--rule); border-radius: 4px; cursor: crosshair; image-rendering: pixelated; }

.pull { font-size: 1.375rem; line-height: 1.45; margin: 2rem 0; padding: 0 0 0 1.1rem; border-left: 2px solid var(--accent); }
.pull cite { display: block; font-style: normal; font-family: var(--sans); font-size: 0.8125rem; color: var(--muted); margin-top: 0.4rem; }

@media (max-width: 860px) {
  .race { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .callout { grid-template-columns: 1fr; }
}

/* Narrow screens: let button groups wrap and wide tables scroll inside their figure. */
.seg { flex-wrap: wrap; max-width: 100%; }
.fig-head { min-width: 0; }
.fig-head > * { min-width: 0; max-width: 100%; }
#table, #bands { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 560px) {
  .seg button { padding: 0.3rem 0.45rem; }
  .tbl { font-size: 0.75rem; }
  .tbl th, .tbl td { padding: 0.35rem 0.4rem; }
}
