/* Zeeshan Ali — zeeshanali.co
   Layout: a fixed index rail on the left, one wide reading column on the right.
   Palette: glacier greys with a deep teal accent; a single orange "shock" signal used only in graphics. */
:root {
  --bg: #E7ECEE;
  --surface: #F6F8F9;
  --rail: #DAE3E6;
  --ink: #10202B;
  --muted: #4B5C67;
  --line: #BFCCD3;
  --accent: #0A6B78;
  --accent-ink: #FFFFFF;
  --signal: #C2501A;
  --code: #DCE5E9;
  --f-display: "Bricolage Grotesque", ui-sans-serif, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --f-text: "Source Serif 4", Georgia, "Times New Roman", serif;
  --f-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B1419; --surface: #111D24; --rail: #0E1A20; --ink: #E4ECF0; --muted: #9DADB7;
    --line: #25363F; --accent: #5CC4CF; --accent-ink: #06151A; --signal: #F08A55; --code: #16262E;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0B1419; --surface: #111D24; --rail: #0E1A20; --ink: #E4ECF0; --muted: #9DADB7;
  --line: #25363F; --accent: #5CC4CF; --accent-ink: #06151A; --signal: #F08A55; --code: #16262E;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--f-text); font-size: 1.0625rem; line-height: 1.6;
  font-optical-sizing: auto; text-rendering: optimizeLegibility;
}
img { max-width: 100%; height: auto; }
a { color: var(--accent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: var(--bg); padding: 0.6rem 1rem; z-index: 50; }
.skip:focus { left: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 16.5rem minmax(0, 1fr); min-height: 100vh; }
.rail {
  position: sticky; top: 0; height: 100vh; background: var(--rail);
  padding: 2.25rem 1.75rem; display: flex; flex-direction: column; gap: 2.5rem;
}
.name { font-family: var(--f-display); font-weight: 700; font-size: 1.55rem; letter-spacing: -0.02em; line-height: 1.05; color: var(--ink); text-decoration: none; display: inline-block; }
.role { margin: 0.5rem 0 0; font-family: var(--f-mono); font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.rail nav { display: flex; flex-direction: column; gap: 0.15rem; }
.rail nav a {
  font-family: var(--f-display); font-weight: 500; font-size: 1.12rem; color: var(--ink); text-decoration: none;
  padding: 0.3rem 0 0.3rem 1.1rem; position: relative;
}
.rail nav a::before { content: ""; position: absolute; left: 0; top: 50%; width: 0.45rem; height: 0.45rem; margin-top: -0.22rem; background: transparent; transition: background 0.15s; }
.rail nav a:hover::before { background: var(--muted); }
.rail nav a[aria-current="page"] { font-weight: 700; }
.rail nav a[aria-current="page"]::before { background: var(--accent); }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 0.7rem; font-size: 0.82rem; }
.rail-foot .mail { font-family: var(--f-mono); font-size: 0.74rem; color: var(--muted); word-break: break-all; }
.linklike { align-self: flex-start; background: none; border: 0; padding: 0; font: inherit; font-family: var(--f-mono); font-size: 0.74rem; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 0.2em; }

main { min-width: 0; padding: 3.75rem clamp(1.25rem, 5vw, 4.75rem) 2.5rem; display: flex; flex-direction: column; min-height: 100vh; }
.wrap { width: 100%; max-width: 58rem; flex: 1; }
.foot { margin-top: 5rem; padding-top: 1.25rem; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 0.5rem 2rem; justify-content: space-between; font-family: var(--f-mono); font-size: 0.72rem; color: var(--muted); max-width: 58rem; }
.foot a { color: var(--muted); }

/* ---------- type ---------- */
h1, h2, h3, h4 { font-family: var(--f-display); letter-spacing: -0.018em; text-wrap: balance; margin: 0; line-height: 1.12; }
h1 { font-weight: 700; font-size: clamp(2.1rem, 4.4vw, 3.55rem); line-height: 1.04; letter-spacing: -0.028em; }
h2 { font-weight: 700; font-size: clamp(1.45rem, 2.4vw, 1.85rem); margin: 3.25rem 0 1rem; }
h3 { font-weight: 600; font-size: 1.22rem; }
p { margin: 0 0 1em; }
.kicker { font-family: var(--f-mono); font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin: 0 0 1rem; }
.kicker a { color: var(--muted); }
.lede { font-size: clamp(1.12rem, 1.5vw, 1.32rem); line-height: 1.5; max-width: 40rem; margin-top: 1.4rem; }
.meta { font-family: var(--f-mono); font-size: 0.74rem; color: var(--muted); margin: 0; }
.tag { display: inline-block; font-family: var(--f-mono); font-size: 0.68rem; letter-spacing: 0.04em; padding: 0.08rem 0.45rem; border: 1px solid var(--line); border-radius: 2px; color: var(--muted); }
.page-head { margin-bottom: 2.25rem; }
.page-head h1 { max-width: 20ch; }

.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.75rem; }
.btn { display: inline-flex; align-items: center; gap: 0.5rem; font-family: var(--f-display); font-weight: 600; font-size: 1rem; padding: 0.7rem 1.15rem; background: var(--accent); color: var(--accent-ink); text-decoration: none; border: 1.5px solid var(--accent); border-radius: 3px; cursor: pointer; }
.btn:hover { text-decoration: none; filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn.ghost:hover { background: var(--ink); color: var(--bg); filter: none; }

/* ---------- home ---------- */
.hero h1 { max-width: 17ch; }
.ridge { margin: 3rem 0 0; background: var(--surface); }
.ridge canvas { display: block; width: 100%; height: 22rem; }
.ridge figcaption { padding: 0.7rem 1rem 0.85rem; font-family: var(--f-mono); font-size: 0.7rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 0.4rem 1.5rem; }
.ridge figcaption i { display: inline-block; width: 1.4rem; height: 0; border-top: 2px solid var(--signal); vertical-align: middle; margin-right: 0.4rem; }

.sheet { margin: 0; display: grid; grid-template-columns: 11rem minmax(0, 1fr); }
.sheet dt, .sheet dd { padding: 0.85rem 0; border-top: 1px solid var(--line); margin: 0; }
.sheet dt { font-family: var(--f-mono); font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); padding-top: 1.05rem; }
.sheet dd:last-of-type, .sheet dt:last-of-type { border-bottom: 1px solid var(--line); }

.works { list-style: none; margin: 0; padding: 0; }
.works li { display: grid; grid-template-columns: 4.25rem minmax(0, 1fr) auto; gap: 0 1.5rem; padding: 1.15rem 0; border-top: 1px solid var(--line); align-items: baseline; }
.works li:last-child { border-bottom: 1px solid var(--line); }
.works .yr { font-family: var(--f-mono); font-size: 0.8rem; color: var(--muted); }
.works h3 { margin-bottom: 0.3rem; }
.works h3 a { color: var(--ink); text-decoration: none; }
.works h3 a:hover { color: var(--accent); text-decoration: underline; }
.works p { margin: 0; color: var(--muted); font-size: 0.98rem; }

.posts { list-style: none; margin: 0; padding: 0; }
.post { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: 0 1.5rem; padding: 1.4rem 0; border-top: 1px solid var(--line); }
.post:last-child { border-bottom: 1px solid var(--line); }
.post time { font-family: var(--f-mono); font-size: 0.74rem; color: var(--muted); padding-top: 0.45rem; }
.post h3 a { color: var(--ink); text-decoration: none; }
.post h3 a:hover { color: var(--accent); text-decoration: underline; }
.post p { margin: 0.4rem 0 0; }
.post .meta { margin-top: 0.7rem; }
.post[hidden] { display: none; }

.filters { margin-bottom: 1.75rem; display: grid; gap: 1rem; }
#q { width: 100%; max-width: 26rem; font: inherit; font-family: var(--f-display); padding: 0.7rem 0.9rem; background: var(--surface); color: var(--ink); border: 1.5px solid var(--line); border-radius: 3px; }
#q:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip { font-family: var(--f-mono); font-size: 0.74rem; padding: 0.3rem 0.7rem; background: transparent; color: var(--ink); border: 1px solid var(--line); border-radius: 2px; cursor: pointer; }
.chip:hover { border-color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 3rem; }
.cols ul { margin: 0; padding-left: 1.1rem; }
.cols li { margin-bottom: 0.5rem; }
.timeline { width: 100%; border-collapse: collapse; font-size: 0.98rem; }
.timeline th, .timeline td { text-align: left; vertical-align: top; padding: 0.95rem 1rem 0.95rem 0; border-top: 1px solid var(--line); }
.timeline tr:last-child td { border-bottom: 1px solid var(--line); }
.timeline th { font-family: var(--f-mono); font-weight: 400; font-size: 0.74rem; color: var(--muted); white-space: nowrap; width: 9.5rem; padding-top: 1.15rem; }
.timeline strong { font-family: var(--f-display); font-weight: 600; font-size: 1.05rem; }
.timeline span { display: block; color: var(--muted); }
.tablewrap { overflow-x: auto; margin: 1.5rem 0; }
.stat { font-family: var(--f-display); font-weight: 700; font-size: 2.1rem; letter-spacing: -0.02em; line-height: 1; }
.stats { display: flex; flex-wrap: wrap; gap: 1.5rem 3rem; margin: 1.75rem 0; }
.stats div span { display: block; font-family: var(--f-mono); font-size: 0.72rem; color: var(--muted); margin-top: 0.35rem; }

/* ---------- article ---------- */
.post-head { max-width: 46rem; margin-bottom: 2.25rem; }
.post-head h1 { font-size: clamp(2rem, 4vw, 3.1rem); }
.post-head .meta { margin-top: 1.4rem; }
.toc { max-width: 46rem; margin-bottom: 2.25rem; padding: 1rem 1.25rem; background: var(--surface); }
.toc .kicker { margin-bottom: 0.5rem; }
.toc ol { margin: 0; padding-left: 1.2rem; font-size: 0.96rem; }
.prose { max-width: 42rem; font-size: 1.16rem; line-height: 1.72; }
.prose h2 { font-size: 1.6rem; margin-top: 2.75rem; }
.prose h3 { font-size: 1.25rem; margin: 2rem 0 0.6rem; }
.prose ul, .prose ol { padding-left: 1.3rem; margin: 0 0 1.2em; }
.prose li { margin-bottom: 0.4em; }
.prose blockquote { margin: 1.75rem 0; padding: 0 0 0 1.25rem; border-left: 3px solid var(--signal); font-style: italic; color: var(--muted); }
.prose blockquote p:last-child { margin-bottom: 0; }
.prose code { font-family: var(--f-mono); font-size: 0.86em; background: var(--code); padding: 0.1em 0.35em; border-radius: 2px; }
.prose pre { background: var(--code); padding: 1rem 1.15rem; overflow-x: auto; font-size: 0.88rem; line-height: 1.55; border-radius: 3px; }
.prose pre code { background: none; padding: 0; font-size: inherit; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.5rem 0; }
.prose figure { margin: 2rem 0; }
.prose figcaption { font-family: var(--f-mono); font-size: 0.74rem; color: var(--muted); margin-top: 0.6rem; }
.prose table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.prose th, .prose td { text-align: left; padding: 0.55rem 0.8rem 0.55rem 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.prose th { font-family: var(--f-mono); font-weight: 500; font-size: 0.74rem; color: var(--muted); }
.prose .katex-display { overflow-x: auto; overflow-y: hidden; padding: 0.4rem 0; }
.note { max-width: 42rem; font-family: var(--f-mono); font-size: 0.74rem; color: var(--muted); margin-top: 2.5rem; }
.post-foot { max-width: 42rem; margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.pn { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-top: 1.75rem; }
.pn a { font-family: var(--f-display); font-weight: 600; color: var(--ink); text-decoration: none; line-height: 1.25; }
.pn a:hover { color: var(--accent); }
.pn .r { text-align: right; }
.pn .kicker { display: block; margin-bottom: 0.3rem; }

/* ---------- contact ---------- */
.mailbox { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1rem; margin: 1.5rem 0 0.5rem; }
.mailbox code { font-family: var(--f-mono); font-size: clamp(1rem, 2.2vw, 1.35rem); background: var(--surface); padding: 0.6rem 0.9rem; word-break: break-all; }

.rail .cvbtn { align-self: stretch; justify-content: center; padding: 0.6rem 0.9rem; font-size: 0.95rem; margin-top: -1rem; }
.form { max-width: 36rem; display: grid; gap: 1.1rem; }
.field { display: grid; gap: 0.35rem; }
.field label { font-family: var(--f-mono); font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.field input, .field textarea { width: 100%; font: inherit; font-size: 1rem; padding: 0.7rem 0.85rem; background: var(--surface); color: var(--ink); border: 1.5px solid var(--line); border-radius: 3px; }
.field textarea { resize: vertical; min-height: 9rem; }
.field input:focus, .field textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.field.bad input, .field.bad textarea { border-color: var(--signal); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.25rem; }
#f-status { margin: 0; font-family: var(--f-mono); font-size: 0.8rem; color: var(--muted); }
#f-status.err { color: var(--signal); }
#f-status.ok { color: var(--accent); }
.btn[disabled] { opacity: 0.6; cursor: wait; }

/* ---------- small screens ---------- */
@media (max-width: 52rem) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { position: static; height: auto; flex-direction: column; gap: 1.1rem; padding: 1.25rem max(1.25rem, env(safe-area-inset-left)) 1rem; }
  .rail nav { flex-direction: row; flex-wrap: wrap; gap: 0.1rem 1.1rem; }
  .rail nav a { padding-left: 0; padding-bottom: 0.25rem; font-size: 1.02rem; }
  .rail nav a::before { left: 0; right: 0; top: auto; bottom: 0; width: auto; height: 2px; margin: 0; }
  .rail-foot { margin-top: 0; flex-direction: row; justify-content: space-between; align-items: center; gap: 1rem; }
  .rail .cvbtn { align-self: flex-start; margin-top: 0; }
  .sheet dt:last-of-type { border-bottom: 0; }
  .rail-foot .mail { display: none; }
  main { padding: 2.25rem max(1.25rem, env(safe-area-inset-right)) 2rem max(1.25rem, env(safe-area-inset-left)); }
  .ridge canvas { height: 15rem; }
  .sheet { grid-template-columns: minmax(0, 1fr); }
  .sheet dt { border-bottom: 0; padding-bottom: 0; }
  .sheet dd { border-top: 0; padding-top: 0.2rem; }
  .works li { grid-template-columns: minmax(0, 1fr); gap: 0.3rem; }
  .post { grid-template-columns: minmax(0, 1fr); gap: 0.3rem; }
  .post time { padding-top: 0; }
  .cols { grid-template-columns: minmax(0, 1fr); }
  .timeline th { display: block; width: auto; padding-bottom: 0; border-bottom: 0; }
  .timeline td { display: block; border-top: 0; padding-top: 0.2rem; }
  .timeline tr { display: block; border-top: 1px solid var(--line); padding: 0.75rem 0; }
  .timeline th, .timeline td { border-top: 0 !important; border-bottom: 0 !important; padding-left: 0; }
  .pn { grid-template-columns: minmax(0, 1fr); }
  .pn .r { text-align: left; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; } }
.meta + .prose { margin-top: 0.9rem; }
