/* Shared styling for the written pages: guides, comparisons and docs.
   The tokens match the landing page so the two read as one site. */

:root {
  color-scheme: dark;
  --bg: #0a0a0a;
  --surface: #121212;
  --surface-2: #181818;
  --surface-3: #1f1f1f;
  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.13);
  --text: #ededed;
  --muted: #a8a8a8;
  --dim: #7d7d7d;
  --accent: #93b4ff;
  --font: "Geist", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --measure: 720px;
  --radius: 14px;
  --radius-lg: 20px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  /* so an anchor does not land under the progress bar */
  scroll-padding-top: 32px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 17.5px/1.75 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: #c3d5ff; }

.wrap {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 24px;
}

/* how far down the page you are */
.progress {
  position: fixed;
  inset: 0 auto auto 0;
  height: 2px;
  width: 0;
  background: var(--accent);
  z-index: 50;
  transition: width 0.1s linear;
}

/* breadcrumbs */
.crumbs {
  max-width: var(--measure);
  margin: 30px auto 0;
  padding: 0 24px;
  font-size: 13.5px;
  color: var(--dim);
  letter-spacing: 0.01em;
}
.crumbs a { color: var(--dim); text-decoration: none; }
.crumbs a:hover { color: var(--text); }
.crumbs span { margin: 0 7px; opacity: 0.45; }

article { padding: 22px 0 72px; }

h1 {
  font-size: clamp(32px, 5.2vw, 46px);
  line-height: 1.1;
  letter-spacing: -0.032em;
  font-weight: 700;
  margin: 12px 0 16px;
  text-wrap: balance;
}

.standfirst {
  font-size: 20px;
  line-height: 1.6;
  color: var(--muted);
  letter-spacing: -0.005em;
  margin: 0 0 10px;
  text-wrap: pretty;
}

.byline {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--dim);
  margin: 0 0 36px;
  padding-bottom: 26px;
  border-bottom: 1px solid var(--line);
}

h2 {
  font-size: clamp(23px, 3vw, 28px);
  line-height: 1.25;
  letter-spacing: -0.024em;
  font-weight: 650;
  margin: 56px 0 16px;
  text-wrap: balance;
  scroll-margin-top: 24px;
}

h3 {
  font-size: 19.5px;
  line-height: 1.35;
  letter-spacing: -0.012em;
  font-weight: 650;
  margin: 34px 0 10px;
}

p { margin: 0 0 20px; text-wrap: pretty; }

ul, ol { margin: 0 0 22px; padding-left: 24px; }
li { margin: 0 0 10px; }
li::marker { color: var(--dim); }

strong { font-weight: 600; color: #fff; }

code {
  font: 500 0.87em/1.5 var(--mono);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1.5px 6px;
  color: #e4e4e4;
}

pre {
  background: #0e0e0e;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  overflow-x: auto;
  margin: 0 0 26px;
}
pre code { background: none; border: 0; padding: 0; font-size: 14px; line-height: 1.65; color: #d8d8d8; }

/* pictures */
figure { margin: 0 0 32px; }
figure img {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line-2);
  display: block;
  background: var(--surface);
}
figcaption {
  font-size: 14px;
  line-height: 1.55;
  color: var(--dim);
  margin-top: 12px;
  padding-left: 2px;
}

/* on this page */
.toc {
  margin: 0 0 40px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.toc h2 {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--dim);
  margin: 0 0 12px;
}
.toc ol { list-style: none; margin: 0; padding: 0; counter-reset: toc; }
.toc li { margin: 0; counter-increment: toc; }
.toc a {
  display: block;
  padding: 5px 0;
  color: var(--muted);
  text-decoration: none;
  font-size: 15.5px;
  line-height: 1.45;
}
.toc a::before {
  content: counter(toc) ".";
  color: var(--dim);
  margin-right: 9px;
  font-variant-numeric: tabular-nums;
}
.toc a:hover { color: #fff; }

/* the answer at the top of a guide */
.answer {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  margin: 0 0 36px;
}
.answer p:last-child { margin-bottom: 0; }
.answer .label {
  display: block;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 10px;
}

/* a step */
.step {
  border-left: 2px solid var(--line-2);
  padding-left: 22px;
  margin: 0 0 30px;
}
.step h3 { margin-top: 0; }
.step p:last-child { margin-bottom: 0; }

/* a comparison entry */
.pick {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px 26px;
  margin: 0 0 22px;
  transition: border-color 0.25s var(--ease);
}
.pick:hover { border-color: var(--line-2); }
.pick h3 { margin-top: 0; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.pick .tag {
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.02em;
  color: #0a0a0a;
  background: var(--accent);
  border-radius: 999px;
  padding: 3px 10px;
}
.pick .meta { font-size: 14px; color: var(--dim); margin: -4px 0 16px; }
.pick ul { margin-bottom: 0; }

table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 30px;
  font-size: 15px;
}
th, td {
  text-align: left;
  padding: 12px 13px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  line-height: 1.5;
}
th {
  font-weight: 600;
  color: #fff;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom-color: var(--line-2);
}
td:first-child { font-weight: 550; color: #fff; }
.table-scroll { overflow-x: auto; margin: 0 0 30px; }
.table-scroll table { margin: 0; min-width: 540px; }

/* the call to action */
.cta {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg);
  padding: 30px 28px 28px;
  margin: 52px 0;
  text-align: center;
}
.cta h2 { margin: 0 0 10px; font-size: 23px; }
.cta p { color: var(--muted); margin: 0 0 20px; font-size: 16px; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 24px;
  border-radius: 999px;
  background: #fff;
  color: #0a0a0a;
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
  border: 1px solid transparent;
  transition: transform 0.2s var(--ease), background 0.2s var(--ease);
}
.btn:hover { background: #e9e9e9; color: #0a0a0a; transform: translateY(-1px); }

/* questions */
details.faq {
  border-bottom: 1px solid var(--line);
  padding: 18px 0;
}
details.faq summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 17px;
  line-height: 1.45;
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  transition: color 0.2s var(--ease);
}
details.faq summary:hover { color: #fff; }
details.faq summary::-webkit-details-marker { display: none; }
details.faq summary::after { content: "+"; color: var(--dim); font-weight: 400; flex: 0 0 auto; }
details.faq[open] summary::after { content: "−"; }
details.faq p { margin: 14px 0 0; color: var(--muted); font-size: 16.5px; }

/* what to read next */
.next {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
  margin: 0 0 26px;
}
.next a {
  display: block;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  font-weight: 550;
  font-size: 15.5px;
  line-height: 1.4;
  transition: border-color 0.25s var(--ease), background 0.25s var(--ease), transform 0.25s var(--ease);
}
.next a:hover {
  border-color: var(--line-2);
  background: var(--surface-2);
  color: #fff;
  transform: translateY(-2px);
}
.next a span { display: block; font-weight: 400; font-size: 13.5px; color: var(--dim); margin-top: 5px; }

/* Arriving on scroll. The hidden state is only applied once JavaScript has set .js-reveal on
   the document, so without it — or if anything fails — every word is on the page as normal. */
.js-reveal .reveal {
  opacity: 0;
  transform: translateY(14px);
}
.js-reveal .reveal.in {
  opacity: 1;
  transform: none;
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js-reveal .reveal { opacity: 1; transform: none; }
  .btn:hover, .next a:hover { transform: none; }
  .progress { transition: none; }
}

@media (max-width: 680px) {
  body { font-size: 16.5px; line-height: 1.72; }
  .wrap, .crumbs { padding: 0 20px; }
  h2 { margin-top: 44px; }
  .cta { padding: 26px 22px 24px; }
  .pick { padding: 20px 20px; }
}

/* ── Index rows ─────────────────────────────────────────────
   One column, every row the same shape: an icon, a title, a line about it. A grid of five always
   leaves one stranded on its own; a list never does, and it reads in order. */
.cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 4px 0 8px;
}

.card {
  display: grid;
  grid-template-columns: 44px 1fr 20px;
  align-items: center;
  gap: 18px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.25s var(--ease), background 0.25s var(--ease);
}
.card:hover {
  border-color: var(--line-2);
  background: var(--surface-2);
  color: var(--text);
}

.card .icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  color: var(--accent);
  transition: background 0.25s var(--ease), color 0.25s var(--ease);
}
.card:hover .icon { background: rgba(147, 180, 255, 0.12); color: #b9ceff; }
.card .icon svg { width: 20px; height: 20px; }

.card .body { min-width: 0; }
.card h3 {
  margin: 0 0 3px;
  font-size: 17px;
  line-height: 1.35;
  letter-spacing: -0.014em;
  font-weight: 600;
  color: #fff;
}
.card p {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--muted);
}

.card .go {
  color: var(--dim);
  display: grid;
  place-items: center;
  transition: color 0.25s var(--ease), transform 0.25s var(--ease);
}
.card .go svg { width: 17px; height: 17px; }
.card:hover .go { color: var(--accent); transform: translateX(3px); }

@media (max-width: 560px) {
  .card { grid-template-columns: 38px 1fr; gap: 14px; padding: 16px; }
  .card .icon { width: 38px; height: 38px; border-radius: 10px; }
  .card .icon svg { width: 18px; height: 18px; }
  .card .go { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .card:hover .go { transform: none; }
}

/* ── The section rail ───────────────────────────────────────
   A fixed list of the page's sections with a dot that springs to whichever one you are reading.
   It only appears when there is room beside the column; below that the inline contents box does
   the same job. */
.rail { display: none; }

.rail nav { position: relative; }

.rail ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
}

.rail li { position: relative; display: block; margin: 0; padding: 0; }

.rail a {
  display: block;
  font: 400 11px/1.4 var(--mono);
  color: rgba(255, 255, 255, 0.38);
  text-decoration: none;
  transition: color 0.2s;
}
.rail a:hover,
.rail a[data-active="true"] { color: #fff; font-weight: 500; }

.rail .dot {
  position: absolute;
  left: -14px;
  top: 0;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #fff;
  pointer-events: none;
  z-index: 10;
  will-change: transform;
  transform: translate3d(0, 0, 0);
}

@media (min-width: 1240px) {
  .rail {
    display: flex;
    flex-direction: column;
    gap: 32px;
    position: fixed;
    /* the same place it sits on ahmedgiad.vercel.app: fixed to the left edge, not to the column */
    left: 88px;
    top: 80px;
    width: 140px;
    height: fit-content;
    z-index: 40;
    animation: railIn 0.65s cubic-bezier(0.23, 1, 0.32, 1) 80ms 1 backwards;
  }
  .toc { display: none; }
}

@keyframes railIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .rail { animation: none; }
}
