/* ────────────────────────────────────────────────────────────────────────
   imaan.co — design system
   ────────────────────────────────────────────────────────────────────── */

:root {
  /* palette */
  --bg:           #18171a;
  --bg-elev:      #1f1d22;
  --text:         #e9e6e0;
  --text-mute:    rgba(233, 230, 224, 0.55);
  --text-dim:     rgba(233, 230, 224, 0.38);
  --border:       rgba(233, 230, 224, 0.08);
  --border-soft:  rgba(233, 230, 224, 0.05);
  --border-strong:rgba(233, 230, 224, 0.18);

  --accent:        #e35a30;
  --accent-bg:     rgba(227, 90, 48, 0.12);
  --accent-bg-hi:  rgba(227, 90, 48, 0.18);
  --accent-border: rgba(227, 90, 48, 0.45);

  /* typography */
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* rhythm */
  --col:        560px;       /* main reading column */
  --col-wide:   856px;       /* with sidenote rail */
  --rail:       240px;
  --gutter:     40px;
  --section-y:  64px;
  --para-y:    22px;
}

/* ── base ───────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
html { color-scheme: dark; -webkit-font-smoothing: antialiased; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15.5px;
  line-height: 1.75;
  font-weight: 400;
  font-feature-settings: "ss01", "cv11";  /* Inter: single-storey a, alt 1 */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  text-rendering: optimizeLegibility;
}
body > main { flex: 1 0 auto; }
body > footer { flex: 0 0 auto; }

::selection { background: var(--accent-bg-hi); color: var(--text); }

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color .15s, text-decoration-color .15s;
}
a:hover { color: var(--accent); text-decoration-color: var(--accent); }

p { margin: 0; }
h1, h2, h3, h4 { margin: 0; font-weight: 500; letter-spacing: -0.01em; }
ul, ol { margin: 0; padding-left: 22px; }
li { margin: 4px 0; }
img, video { max-width: 100%; display: block; }
hr { border: 0; border-top: 1px solid var(--border); margin: 32px 0; }

em {
  font-family: "Newsreader", Georgia, "Times New Roman", serif;
  font-style: italic;
  font-weight: 400;
  font-size: 1.2em;
  line-height: 1;
  letter-spacing: -0.005em;
  font-optical-sizing: auto;
}

/* ── shared primitives ──────────────────────────────────────────────── */

.eyebrow {
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.muted { color: var(--text-mute); }
.dim   { color: var(--text-dim); }

.link {
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  cursor: pointer;
}
.link:hover { color: var(--accent); text-decoration-color: var(--accent); }

.back-link {
  display: inline-block;
  font-size: 13px;
  color: var(--text-mute);
  text-decoration: none;
  letter-spacing: 0.02em;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1px;
  white-space: nowrap;
}
.back-link:hover { color: var(--accent); border-color: var(--accent); }

/* ── code blocks ────────────────────────────────────────────────────── */

.code, pre code, pre {
  font-family: "ui-monospace", "SF Mono", "Menlo", "Consolas", monospace;
  font-size: 13px;
  line-height: 1.65;
}

pre.code {
  background: #0f0e12;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 18px 20px;
  margin: 0;
  color: #d8d4cc;
  overflow-x: auto;
  white-space: pre;
  font-feature-settings: normal;
}
pre.code .tok-k { color: #e088b0; }   /* keyword */
pre.code .tok-s { color: #8fd4a5; }   /* string */
pre.code .tok-n { color: #d8c590; }   /* number */
pre.code .tok-c { color: #6f6a62; font-style: italic; } /* comment */
pre.code .tok-f { color: #9ab8e0; }   /* function name */

code.inline {
  font-family: ui-monospace, monospace;
  font-size: 0.9em;
  padding: 1px 5px;
  background: rgba(233, 230, 224, 0.06);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  color: var(--text);
}

/* ── pull quote ─────────────────────────────────────────────────────── */

.pull {
  border-left: 2px solid var(--accent);
  padding: 6px 0 6px 20px;
  font-size: 19px;
  line-height: 1.45;
  letter-spacing: -0.005em;
  color: var(--text);
}

/* ── tables ─────────────────────────────────────────────────────────── */

.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.tbl th, .tbl td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.tbl th {
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.tbl tr:last-child td { border-bottom: none; }

/* ── video / embed placeholder ──────────────────────────────────────── */

.embed {
  aspect-ratio: 16 / 9;
  background:
    repeating-linear-gradient(135deg,
      rgba(255,255,255,0.025) 0 12px,
      rgba(255,255,255,0.05) 12px 24px);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ────────────────────────────────────────────────────────────────────────
   PAGE: homepage
   ────────────────────────────────────────────────────────────────────── */

.home {
  max-width: var(--col);
  margin: 0 auto;
  padding: 110px 24px 110px;
  position: relative;
}

.home .name {
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-bottom: 36px;
}

.home p { margin-bottom: var(--para-y); }
.home .intro { margin-bottom: var(--section-y); }
.home .intro p:last-child { margin-bottom: 0; }

.home .grid {
  display: flex;
  flex-direction: column;
  gap: 40px;
  margin-bottom: var(--section-y);
}

.home .grid .block { display: flex; flex-direction: column; gap: 16px; }
.home .grid .block .eyebrow { margin: 0; }

.home .item { display: flex; flex-direction: column; gap: 4px; }
.home .item .name-row { font-size: 15px; font-weight: 500; }
.home .item .name-row a { text-decoration: none; border-bottom: 1px solid var(--border-strong); padding-bottom: 1px; }
.home .item .name-row a:hover { border-color: var(--accent); }
.home .item .arr { color: var(--text-dim); margin-left: 4px; font-size: 0.9em; }
.home .item .desc { color: var(--text-mute); font-size: 13.5px; line-height: 1.5; max-width: 420px; }

.home .section h2 { all: unset; }
.home .section { margin-bottom: var(--section-y); }
.home .section .eyebrow { margin-bottom: 18px; }
.home .section p { margin-bottom: 18px; }
.home .section p:last-child { margin-bottom: 0; }

/* Footer is a normal-flow strip at the bottom of the page. The body flex
   layout pushes it to the viewport bottom on short pages. */
.home-foot {
  display: flex;
  justify-content: flex-end;
  align-items: baseline;
  padding: 32px 40px;
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  border-top: 1px solid var(--border-soft);
}

@media (max-width: 720px) {
  .home { padding: 56px 22px 56px; }
  .home .item .desc { max-width: none; }
  .home-foot { padding: 22px; font-size: 11px; flex-direction: column; gap: 6px; }
}

/* ────────────────────────────────────────────────────────────────────────
   PAGE: writing (index)
   ────────────────────────────────────────────────────────────────────── */

.archive {
  max-width: 1000px;
  margin: 0 auto;
  padding: 80px 40px 110px;
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 56px;
}

.archive .crumb { grid-column: 1 / -1; margin-bottom: 18px; }

.archive .filter .eyebrow { margin-bottom: 14px; }
.archive .topics { display: flex; flex-direction: column; gap: 6px; }
.archive .topic {
  all: unset;
  cursor: pointer;
  font-size: 14px;
  padding: 4px 0;
  color: var(--text-mute);
  display: flex; align-items: center; gap: 10px;
  transition: color .15s;
}
.archive .topic .dot {
  width: 6px; height: 6px;
  border-radius: 1px;
  background: var(--border-strong);
  transition: background .15s;
}
.archive .topic:hover { color: var(--text); }
.archive .topic[aria-pressed="true"] { color: var(--accent); }
.archive .topic[aria-pressed="true"] .dot { background: var(--accent); }

.archive .title { font-size: 24px; margin-bottom: 8px; }
.archive .lede {
  font-size: 14px; color: var(--text-mute);
  line-height: 1.55;
  max-width: 520px;
  margin-bottom: 36px;
}

.archive .posts { display: flex; flex-direction: column; }
.archive .post-row {
  display: block;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
  color: inherit;
  text-decoration: none;
}
.archive .post-row:last-child { border-bottom: none; }
.archive .post-row .post-title {
  font-size: 17px;
  font-weight: 500;
  margin-bottom: 4px;
  letter-spacing: -0.005em;
}
.archive .post-row:hover .post-title { color: var(--accent); }
.archive .post-row .post-desc {
  color: var(--text-mute);
  font-size: 14px;
  line-height: 1.55;
  margin-bottom: 8px;
  max-width: 540px;
}
.archive .post-row .post-meta {
  font-size: 11.5px;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  font-weight: 500;
}
.archive .post-row .post-meta span + span::before {
  content: "·"; margin: 0 7px; color: var(--border-strong);
}

.archive .empty {
  padding: 40px 0;
  color: var(--text-dim);
  font-size: 14px;
}

@media (max-width: 800px) {
  .archive {
    grid-template-columns: 1fr;
    gap: 22px;
    padding: 56px 22px 80px;
  }
  .archive .filter { order: 1; }
  .archive .filter .eyebrow { margin-bottom: 10px; }
  .archive .topics { flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .archive .topic {
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 12.5px;
  }
  .archive .topic .dot { display: none; }
  .archive .topic[aria-pressed="true"] {
    border-color: var(--accent);
    background: var(--accent-bg);
  }
  .archive .main { order: 2; }
  .archive .title { font-size: 22px; }
}

/* ────────────────────────────────────────────────────────────────────────
   PAGE: blog post
   ────────────────────────────────────────────────────────────────────── */

.post-wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 72px 40px 120px;
}

.post-wrap .crumb { margin-bottom: 28px; }

.post-wrap .head {
  margin-bottom: 48px;
  max-width: 560px;
}
.post-wrap .head .h-title {
  font-size: 32px;
  line-height: 1.18;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}
.post-wrap .head .h-sub {
  font-size: 15px;
  color: var(--text-mute);
  line-height: 1.55;
}
.post-wrap .head .h-topics {
  margin-top: 16px;
  display: flex; gap: 6px;
  flex-wrap: wrap;
}
.post-wrap .head .h-topics .t {
  font-size: 11px; letter-spacing: 0.1em;
  text-transform: uppercase; font-weight: 500;
  color: var(--text-dim);
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
}

/* CSS-Grid sidenote rail.  Body content goes in col 1, sidenotes in col 2.
   Auto-flow fills col 2 cells on the same row as the previous body item — so
   a sidenote rendered immediately after its referenced paragraph lands beside
   it. */
.post {
  display: grid;
  grid-template-columns: minmax(0, 560px) var(--rail);
  column-gap: 56px;
  align-items: start;
}
.post > * { grid-column: 1; min-width: 0; }
.post > .sn { grid-column: 2; }

.post > p   { font-size: 16px; line-height: 1.78; margin-bottom: var(--para-y); }
.post > h2  { font-size: 21px; margin: 36px 0 12px; letter-spacing: -0.01em; }
.post > h3  { font-size: 17px; margin: 24px 0 8px; color: var(--text); }
.post > ul, .post > ol { font-size: 16px; line-height: 1.78; margin-bottom: var(--para-y); }
.post > pre.code, .post > .pull, .post > .tbl, .post > .embed { margin-bottom: var(--para-y); }
.post > h2 + p, .post > h3 + p { margin-top: 0; }

/* superscript anchor — bare number, orange, no decoration; underline on hover/active */
.sn-mark {
  font-feature-settings: "sups";
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
  margin: 0 1px;
  border-radius: 2px;
  transition: text-decoration-color .12s, background .12s;
}
.sn-mark:hover {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.sn-mark.is-active {
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 2px;
  text-decoration-color: var(--accent);
}

/* sidenote card (desktop rail) */
.sn {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-mute);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity .18s, background .18s, border-color .18s, color .18s;
  align-self: start;
  max-width: var(--rail);
}
.sn:hover { opacity: 0.85; }
.sn .sn-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.sn .sn-n {
  font-size: 11px; font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--accent);
}
.sn .sn-kind {
  font-size: 10px; font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.sn .sn-body p { margin: 0; }
.sn .sn-body .quote { color: var(--text); }
.sn .sn-body .handle { color: var(--text-dim); font-size: 12px; margin-bottom: 4px; }
.sn .sn-body .url { color: var(--text-dim); font-size: 11.5px; margin-top: 6px; }
.sn .sn-body .embed { margin-bottom: 8px; aspect-ratio: 16/9; }

/* active state — orange-card treatment */
.post.has-active .sn { opacity: 0.18; }
.post.has-active .sn.is-active,
.sn.is-active {
  opacity: 1;
  background: var(--accent-bg-hi);
  border-color: var(--accent-border);
  color: var(--text);
}

/* mobile: rail collapses, sidenotes become inline collapsible cards */
.post .sn-toggle { display: none; }

@media (max-width: 900px) {
  .post-wrap { padding: 48px 22px 80px; }
  .post-wrap .head .h-title { font-size: 26px; }
  .post {
    grid-template-columns: 1fr;
    column-gap: 0;
  }
  .post > .sn { grid-column: 1; margin-bottom: var(--para-y); }

  .sn {
    opacity: 1;
    border: 1px solid var(--border);
    background: transparent;
    padding: 0;
    cursor: default;
    max-width: 100%;
  }
  .sn .sn-toggle {
    all: unset;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 11px 14px;
    cursor: pointer;
    font-size: 11.5px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent);
    font-weight: 500;
  }
  .sn .sn-toggle .sn-toggle-icon {
    color: var(--text-dim);
    font-size: 16px;
    line-height: 1;
    transition: transform .18s;
  }
  .sn[data-open="true"] .sn-toggle .sn-toggle-icon { transform: rotate(45deg); }
  .sn .sn-head { display: none; }
  .sn .sn-body {
    display: none;
    padding: 0 14px 14px;
    color: var(--text-mute);
  }
  .sn[data-open="true"] {
    background: var(--accent-bg);
    border-color: var(--accent-border);
  }
  .sn[data-open="true"] .sn-body { display: block; }
  .sn.is-active { background: var(--accent-bg-hi); border-color: var(--accent-border); }
}
