/* Peptides in Focus — article system v0.1
   Mobile-first. Logical properties throughout so one stylesheet serves LTR (en) and RTL (ar).
   Production: self-host fonts (woff2, font-display: swap) instead of Google Fonts. */

:root {
  --paper: #f6f2ea;
  --paper-2: #eee7da;
  --card: #fbf9f4;
  --ink: #15202a;
  --ink-2: #47525c;
  --ink-3: #6d757c;
  --rule: #d8cfbf;
  --accent: #963a1d;          /* the single accent: oxide red */
  --accent-soft: #f1e1d8;
  --ok: #2f5d50;              /* status ink for "regulated" marks (not a 2nd accent: used only in evidence glyphs) */
  --warn: #8a5a00;

  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;

  --measure: 40rem;
  --gutter: 1rem;
  --radius: 4px;
  --step--1: 0.875rem;
  --step-0: 1.0625rem;
  --step-1: 1.25rem;
  --step-2: 1.6rem;
  --step-3: clamp(1.9rem, 6vw, 2.9rem);
  color-scheme: light;
}

:lang(ar) {
  --serif: "Noto Naskh Arabic", "Geeza Pro", serif;
  --sans: "IBM Plex Sans Arabic", "Geeza Pro", system-ui, sans-serif;
  --step-0: 1.125rem;          /* Arabic needs a little more size and leading */
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #12171c; --paper-2: #1a2128; --card: #171d23;
    --ink: #ece6da; --ink-2: #b9b2a5; --ink-3: #8f897e;
    --rule: #2e363e; --accent: #e08a6a; --accent-soft: #33241e;
    --ok: #8cc2b0; --warn: #e0b45c; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #12171c; --paper-2: #1a2128; --card: #171d23;
  --ink: #ece6da; --ink-2: #b9b2a5; --ink-3: #8f897e;
  --rule: #2e363e; --accent: #e08a6a; --accent-soft: #33241e;
  --ok: #8cc2b0; --warn: #e0b45c; 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: 400 var(--step-0)/1.65 var(--sans);
  text-rendering: optimizeLegibility;
}
:lang(ar) body, body:lang(ar) { line-height: 1.85; }
img, svg { max-width: 100%; height: auto; }
a { color: inherit; text-decoration-color: var(--accent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.skip { position: absolute; inset-inline-start: -999px; }
.skip:focus { inset-inline-start: 1rem; top: 1rem; background: var(--ink); color: var(--paper); padding: .5rem .75rem; z-index: 10; }
.wrap { max-width: 72rem; margin-inline: auto; padding-inline: var(--gutter); }

/* ---------- Masthead ---------- */
.masthead { border-block-end: 1px solid var(--rule); background: var(--paper); position: sticky; top: 0; z-index: 5; }
.masthead .wrap { display: flex; align-items: center; gap: .75rem; min-height: 3.5rem; }
.brand { font: 600 1.05rem/1 var(--serif); letter-spacing: .01em; text-decoration: none; margin-inline-end: auto; display: flex; align-items: center; gap: .5rem; }
.brand svg { inline-size: 1.4rem; block-size: 1.4rem; }
.lang { font: 500 var(--step--1)/1 var(--sans); text-decoration: none; padding: .45rem .6rem; border: 1px solid var(--rule); border-radius: 999px; }
.nav { position: relative; }
.nav > summary { list-style: none; cursor: pointer; font: 500 var(--step--1)/1 var(--sans); padding: .5rem .6rem; border-radius: var(--radius); }
.nav > summary::-webkit-details-marker { display: none; }
.nav > summary::before { content: "☰"; margin-inline-end: .35rem; }
.nav[open] > summary::before { content: "✕"; }
.nav ul { list-style: none; margin: 0; padding: .5rem; position: absolute; inset-inline-end: 0; top: 2.6rem; min-inline-size: 15rem; background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: 0 10px 30px rgb(0 0 0 / .08); }
.nav li a { display: block; padding: .6rem .7rem; text-decoration: none; border-radius: 3px; }
.nav li a:hover { background: var(--paper-2); color: var(--ink); }

/* ---------- Article layout ---------- */
.article { padding-block: 1.25rem 4rem; }
.crumbs { font-size: var(--step--1); color: var(--ink-3); }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: .35rem; margin: 0 0 1rem; padding: 0; }
.crumbs li + li::before { content: "/"; margin-inline-end: .35rem; color: var(--rule); }
.crumbs a { text-decoration: none; }
.kicker { font: 600 .78rem/1.2 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin: 0 0 .6rem; }
:lang(ar) .kicker { letter-spacing: 0; font-size: .9rem; }
h1 { font: 600 var(--step-3)/1.12 var(--serif); margin: 0 0 1rem; letter-spacing: -.01em; text-wrap: balance; }
:lang(ar) h1 { line-height: 1.35; letter-spacing: 0; }
.dek { font-size: var(--step-1); color: var(--ink-2); margin: 0 0 1.25rem; max-inline-size: var(--measure); }

/* Answer first: this is the first thing on mobile, before any media */
.answer { background: var(--card); border: 1px solid var(--rule); border-inline-start: 4px solid var(--accent); padding: 1rem 1.1rem; border-radius: var(--radius); margin-block: 0 1rem; }
.answer h2 { font: 600 var(--step--1)/1.2 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--accent); margin: 0 0 .5rem; }
:lang(ar) .answer h2 { letter-spacing: 0; font-size: 1rem; }
.answer p { margin: 0 0 .6rem; }
.answer p:last-child { margin: 0; }

/* Review strip: who wrote it, who checked it, when */
.review { display: grid; grid-template-columns: 1fr 1fr; gap: .1rem 1rem; font-size: var(--step--1); color: var(--ink-2); border-block: 1px solid var(--rule); padding-block: .8rem; margin-block-end: 1.5rem; }
.review div { padding-block: .25rem; }
.review dt { color: var(--ink-3); font-size: .78rem; }
.review dd { margin: 0; color: var(--ink); font-weight: 500; }
.review .pending { color: var(--warn); font-weight: 600; }
.review .full { grid-column: 1 / -1; }

.draft-banner { background: var(--warn); color: #fff; font: 600 var(--step--1)/1.4 var(--sans); padding: .55rem var(--gutter); text-align: center; }

/* Body copy */
.prose > :where(p, ul, ol, h2, h3, .callout, .tool) { max-inline-size: var(--measure); }
.prose h2 { font: 600 var(--step-2)/1.2 var(--serif); margin: 2.5rem 0 .75rem; scroll-margin-top: 4.5rem; text-wrap: balance; }
:lang(ar) .prose h2 { line-height: 1.45; }
.prose h3 { font: 600 var(--step-1)/1.3 var(--sans); margin: 1.75rem 0 .5rem; }
.prose p, .prose ul, .prose ol { margin: 0 0 1rem; }
.prose li { margin-block-end: .35rem; }
.prose strong { font-weight: 600; }

/* Citations: visible, tappable, next to the claim */
.cite { font: 600 .72em/1 var(--sans); vertical-align: super; text-decoration: none; color: var(--accent); padding-inline: .1em; }
.cite::before { content: "["; } .cite::after { content: "]"; }
.source-note { font-size: var(--step--1); color: var(--ink-2); border-inline-start: 2px solid var(--rule); padding-inline-start: .75rem; margin: -.25rem 0 1.25rem; }
.unverified { background: repeating-linear-gradient(-45deg, transparent 0 6px, var(--accent-soft) 6px 12px); outline: 1px dashed var(--warn); padding-inline: .2em; }

/* Table of contents */
.toc { font-size: var(--step--1); border: 1px solid var(--rule); border-radius: var(--radius); margin-block: 0 1.5rem; background: var(--card); }
.toc summary { cursor: pointer; padding: .75rem 1rem; font-weight: 600; }
.toc ol { margin: 0; padding: 0 1rem .9rem 2.2rem; }
:lang(ar) .toc ol { padding: 0 2.2rem .9rem 1rem; }
.toc li { margin-block: .3rem; }

/* ---------- Evidence/category table ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-block: 1rem 1.5rem; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--card); }
.table-wrap:focus-visible { outline-offset: 0; }
table { border-collapse: collapse; inline-size: 100%; min-inline-size: 40rem; font-size: var(--step--1); }
caption { caption-side: top; text-align: start; padding: .8rem 1rem; font: 600 var(--step--1)/1.4 var(--sans); color: var(--ink-2); border-block-end: 1px solid var(--rule); }
th, td { text-align: start; vertical-align: top; padding: .7rem .8rem; border-block-end: 1px solid var(--rule); }
thead th { font-weight: 600; background: var(--paper-2); color: var(--ink); white-space: nowrap; }
tbody th { font-weight: 600; inline-size: 9.5rem; }
tbody tr:last-child > * { border-block-end: 0; }
.swatch { display: inline-block; inline-size: .7rem; block-size: .7rem; border-radius: 2px; margin-inline-end: .4rem; vertical-align: baseline; }
.sw-med { background: var(--ink); }
.sw-sup { background: transparent; border: 2px solid var(--ink); }
.sw-cos { background: repeating-linear-gradient(90deg, var(--ink) 0 2px, transparent 2px 4px); }
.sw-rsch { background: var(--accent); }
.scroll-hint { font-size: .78rem; color: var(--ink-3); margin: -1rem 0 1.5rem; }
@media (min-width: 52rem) { .scroll-hint { display: none; } }

/* Mobile: the category table becomes stacked cards (still a real table for screen readers) */
@media (max-width: 40rem) {
  .stack table, .stack thead, .stack tbody, .stack tr, .stack th, .stack td { display: block; min-inline-size: 0; }
  .stack thead { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .stack tbody tr { border-block-end: 1px solid var(--rule); padding-block: .4rem; }
  .stack tbody tr:last-child { border-block-end: 0; }
  .stack tbody th { inline-size: auto; border: 0; font-size: 1rem; padding-block-end: .2rem; }
  .stack td { border: 0; padding-block: .25rem; }
  .stack td::before { content: attr(data-label); display: block; font-size: .72rem; letter-spacing: .04em; color: var(--ink-3); text-transform: uppercase; }
  :lang(ar) .stack td::before { letter-spacing: 0; font-size: .8rem; }
  .stack + .scroll-hint { display: none; }
}

/* ---------- Figures ---------- */
figure { margin: 1.5rem 0 2rem; }
.figure-card { background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1rem; }
figcaption { font-size: var(--step--1); color: var(--ink-2); margin-block-start: .6rem; }
figcaption b { color: var(--ink); }
.fig-ink { fill: var(--ink); } .fig-ink-2 { fill: var(--ink-2); } .fig-rule { stroke: var(--rule); }
.fig-accent { fill: var(--accent); } .fig-stroke-ink { stroke: var(--ink); } .fig-stroke-accent { stroke: var(--accent); }
.fig-paper { fill: var(--card); }
.fig-text { font: 500 13px var(--sans); fill: var(--ink); }
.fig-small { font: 400 11.5px var(--sans); fill: var(--ink-2); }
.fig-label { font: 600 12px var(--sans); fill: var(--accent); letter-spacing: .06em; }
:lang(ar) .fig-text { font-size: 14px; } :lang(ar) .fig-small { font-size: 12.5px; } :lang(ar) .fig-label { letter-spacing: 0; font-size: 13px; }
.fig-mobile { display: block; } .fig-desktop { display: none; }
@media (min-width: 40rem) { .fig-mobile { display: none; } .fig-desktop { display: block; } }

/* ---------- Checklist ---------- */
.checklist { list-style: none; padding: 0; counter-reset: c; }
.checklist li { counter-increment: c; position: relative; padding-inline-start: 2.4rem; margin-block-end: .9rem; }
.checklist li::before { content: counter(c); position: absolute; inset-inline-start: 0; top: .1rem; inline-size: 1.65rem; block-size: 1.65rem; border-radius: 50%; border: 1.5px solid var(--accent); color: var(--accent); font: 600 .85rem/1.55rem var(--sans); text-align: center; }

/* ---------- Callouts ---------- */
.callout { border: 1px solid var(--rule); background: var(--paper-2); border-radius: var(--radius); padding: .9rem 1rem; margin-block: 1.25rem; font-size: var(--step--1); }
.callout strong { display: block; margin-block-end: .25rem; font-size: var(--step-0); }

/* Tool link: always labelled, disclosed, after the answer. Disabled until verified. */
.tool { border: 1px dashed var(--ink-3); border-radius: var(--radius); padding: 1rem; margin-block: 2rem; font-size: var(--step--1); }
.tool .label { font: 600 .72rem/1 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.tool[data-state="disabled"] { opacity: .75; }
.tool .btn { display: inline-block; margin-block: .6rem; padding: .65rem 1rem; border-radius: var(--radius); background: var(--ink); color: var(--paper); text-decoration: none; font-weight: 600; }
.tool[data-state="disabled"] .btn { background: var(--rule); color: var(--ink-2); pointer-events: none; }

/* ---------- Sources ---------- */
.sources { border-block-start: 2px solid var(--ink); margin-block-start: 3rem; padding-block-start: 1rem; font-size: var(--step--1); }
.sources h2 { margin-block-start: 0 !important; font-size: var(--step-1) !important; }
.sources ol { padding-inline-start: 1.4rem; }
.sources li { margin-block-end: .6rem; color: var(--ink-2); scroll-margin-top: 4.5rem; }
.sources li:target { background: var(--accent-soft); outline: 4px solid var(--accent-soft); }
.sources .what { display: block; color: var(--ink); }
.ltr { direction: ltr; unicode-bidi: isolate; }

/* ---------- Footer ---------- */
.site-foot { border-block-start: 1px solid var(--rule); padding-block: 2rem 3rem; font-size: var(--step--1); color: var(--ink-2); }
.site-foot ul { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; }

/* ---------- Desktop: rail for the answer + review details ---------- */
@media (min-width: 64rem) {
  :root { --gutter: 2rem; }
  .article-grid { display: grid; grid-template-columns: minmax(0, 1fr) 17rem; gap: 3.5rem; align-items: start; }
  .rail { position: sticky; top: 5rem; }
  .rail .toc { display: block; }
  .rail .toc summary { pointer-events: none; }
  .head-block { max-inline-size: 48rem; }
}
@media (max-width: 63.99rem) { .rail { display: contents; } }

@media (prefers-reduced-motion: no-preference) {
  .sources li:target { transition: background .6s ease; }
}
@media print {
  .masthead, .nav, .tool, .toc, .draft-banner { display: none; }
  body { background: #fff; color: #000; }
}

/* Fix: caption inside a stacked (block) table */
@media (max-width: 40rem) { .stack caption { display: block; inline-size: auto; } }
/* Note: in RTL documents, SVG text-anchor "start" anchors on the right edge. Author RTL figures with "start". */

/* =========================================================
   Playbook v1 components (design/PLAYBOOK.md)
   ========================================================= */
:root { --ev-strong: #2f6b4f; --ev-mixed: #9a6a00; --ev-none: #a33a2a; --grid: rgb(21 32 42 / .06); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --ev-strong: #7cc4a0; --ev-mixed: #e0b45c; --ev-none: #ee8a78; --grid: rgb(236 230 218 / .06); } }
:root[data-theme="dark"] { --ev-strong: #7cc4a0; --ev-mixed: #e0b45c; --ev-none: #ee8a78; --grid: rgb(236 230 218 / .06); }

/* Lab-notebook grid behind the header, with "+" corner marks */
.head-block { position: relative; padding: 1rem 0 .25rem; }
.head-block::before { content: ""; position: absolute; inset: -.5rem calc(-1 * var(--gutter)) 0; z-index: -1;
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px; mask-image: linear-gradient(to bottom, #000 40%, transparent); }
.head-block::after { content: "+"; position: absolute; inset-inline-end: 0; top: 0; font: 400 1rem/1 var(--mono); color: var(--ink-3); }

/* Fact chips: orientation only — never doses or efficacy numbers */
.chips { list-style: none; display: flex; flex-wrap: wrap; gap: .5rem; padding: 0; margin: 0 0 1.25rem; }
.chips li { font-size: var(--step--1); border: 1px solid var(--rule); background: var(--card); border-radius: 999px; padding: .35rem .75rem; }
.chips b { color: var(--accent); font-weight: 600; }

/* Evidence badges: reserved colours, always with a text label (not colour alone) */
.ev { display: inline-flex; align-items: center; gap: .35rem; font: 600 .78rem/1.2 var(--sans); padding: .2rem .5rem; border-radius: 3px; border: 1px solid currentColor; white-space: nowrap; }
.ev::before { content: ""; inline-size: .5rem; block-size: .5rem; border-radius: 50%; background: currentColor; }
.ev-strong { color: var(--ev-strong); } .ev-mixed { color: var(--ev-mixed); } .ev-none { color: var(--ev-none); }

/* Signature bead chain hero: beads link once on entering view */
.chain { display: block; inline-size: 100%; max-inline-size: 34rem; margin: 0 auto; }
.chain .bead { fill: var(--card); stroke: var(--ink); stroke-width: 2; }
.chain .bead.key { fill: var(--accent); stroke: var(--accent); }
.chain .bond { stroke: var(--ink); stroke-width: 2; stroke-linecap: round; }
.chain .lbl { font: 500 12px var(--sans); fill: var(--ink-2); }
:lang(ar) .chain .lbl { font-size: 13.5px; }
@media (prefers-reduced-motion: no-preference) {
  .js .chain .bead { transform-box: fill-box; transform-origin: center; transform: scale(.2); opacity: 0; transition: transform .5s cubic-bezier(.3,1.4,.5,1), opacity .3s; }
  .js .chain .bond { stroke-dasharray: 30; stroke-dashoffset: 30; transition: stroke-dashoffset .4s ease; }
  .js .chain.in .bead { transform: scale(1); opacity: 1; }
  .js .chain.in .bond { stroke-dashoffset: 0; }
  .js .chain.in .bead:nth-of-type(2) { transition-delay: .12s } .js .chain.in .bead:nth-of-type(3) { transition-delay: .24s }
  .js .chain.in .bead:nth-of-type(4) { transition-delay: .36s } .js .chain.in .bead:nth-of-type(5) { transition-delay: .48s }
  .js .chain.in .bead:nth-of-type(6) { transition-delay: .6s }  .js .chain.in .bond { transition-delay: .7s }
}

/* Words to know */
.glossary { border: 1px solid var(--rule); border-radius: var(--radius); background: var(--card); padding: .9rem 1rem; margin-block: 1.5rem; font-size: var(--step--1); }
.glossary h2 { font: 600 var(--step-0)/1.3 var(--sans) !important; margin: 0 0 .5rem !important; }
.glossary dl { margin: 0; display: grid; gap: .5rem; }
.glossary dt { font-weight: 600; } .glossary dd { margin: 0; color: var(--ink-2); }
dfn { font-style: normal; font-weight: 600; border-block-end: 1px dotted var(--ink-3); }

/* FAQ: native details, no JS */
.faq details { border-block-end: 1px solid var(--rule); }
.faq summary { cursor: pointer; list-style: none; padding: .9rem 0; font-weight: 600; display: flex; justify-content: space-between; gap: 1rem; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font: 400 1.25rem/1 var(--mono); color: var(--accent); }
.faq details[open] summary::after { content: "–"; }
.faq details > div { padding-block-end: .9rem; color: var(--ink-2); }

/* Tracked next-step card (live state) */
.next { border: 1px solid var(--rule); border-inline-start: 4px solid var(--ink); background: var(--card); border-radius: var(--radius); padding: 1rem 1.1rem; margin-block: 2rem; }
.next .disclose { font-size: .78rem; color: var(--ink-3); margin: .5rem 0 0; }
.next .go { display: inline-block; margin-block-start: .5rem; padding: .7rem 1.1rem; background: var(--ink); color: var(--paper); border-radius: var(--radius); text-decoration: none; font-weight: 600; min-block-size: 44px; }
.next .go:hover { background: var(--accent); color: #fff; }
.next[data-state="disabled"] .go { background: var(--rule); color: var(--ink-2); pointer-events: none; }

/* Production: editor-only markings off; inactive next-step card hidden until verified */
.unverified { background: none; outline: 0; padding: 0; }
.next[data-state="disabled"] { display: none; }
.masthead .lang { margin-inline-start: auto; }
.brand { margin-inline-end: 0; }
