/* Sahib reading guides · Haram Ivory by default, Kiswah Night on request or by system setting.
   Tokens follow Sahib Brand Guidelines v1.0 (same names as site.css). Values marked "proposed" are not in v1.0. */

:root, [data-theme="ivory"] {
  --bg-canvas: #F6F0E4;
  --bg-surface: #FCF9F2;
  --bg-raised: #E7DAC2;
  --text-primary: #2B2620;
  --text-secondary: #6E6353;
  --text-accent: #7F612C;
  --display-gold: #A88446;       /* 24pt and above, and marks */
  --action-primary: #7F612C;
  --action-primary-label: #F6F0E4;
  --control-selected: #7F612C;
  --line-hairline: rgb(43 38 32 / .1);   /* proposed: Ivory hairline is not defined in v1.0 */
  --line-strong: rgb(43 38 32 / .22);    /* proposed: map rays and diagram guides */
  color-scheme: light;
}
[data-theme="kiswah"] {
  --bg-canvas: #0E0D0B;
  --bg-surface: #1B1915;
  --bg-raised: #28241E;
  --text-primary: #EADBB0;
  --text-secondary: #A8997A;
  --text-accent: #C9A55C;
  --display-gold: #C9A55C;
  --action-primary: #C9A55C;
  --action-primary-label: #0E0D0B;
  --control-selected: #C9A55C;
  --line-hairline: rgb(234 219 176 / .12);
  --line-strong: rgb(234 219 176 / .26);
  color-scheme: dark;
}
:root {
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-8: 32px;
  --radius-well: 12px; --radius-input: 16px; --radius-card: 22px; --radius-pill: 999px;
  --font-display: "Marcellus", serif;
  --font-text: "Jost", -apple-system, "SF Pro Text", Roboto, sans-serif;
  --font-arabic: "Amiri", "Geeza Pro", "Noto Naskh Arabic", serif;
  --gutter: clamp(16px, 4vw, 56px);
  --rail: 56px;            /* the plan line's margin */
  --ease-out: cubic-bezier(.22, 1, .36, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 96px; }
body {
  margin: 0;
  background: var(--bg-canvas);
  color: var(--text-primary);
  font: 400 17px/1.65 var(--font-text);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--text-accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
button { font: inherit; color: inherit; }
p, h1, h2, h3, h4, dl, dd, ul, ol, figure, blockquote { margin: 0; }
ul, ol { padding: 0; list-style: none; }
::selection { background: var(--bg-raised); color: var(--text-primary); }
:focus-visible { outline: 2px solid var(--control-selected); outline-offset: 3px; border-radius: 4px; }
html { scrollbar-color: var(--bg-raised) var(--bg-canvas); }

.ic { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.skip { position: fixed; left: 16px; top: -80px; z-index: 100; background: var(--bg-surface); color: var(--text-primary); padding: 12px 18px; border-radius: var(--radius-pill); text-decoration: none; font-weight: 500; }
.skip:focus { top: 16px; }

/* ---------- Top bar ---------- */
.bar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: var(--space-4);
  height: 64px; padding: 0 var(--gutter);
  background: var(--bg-canvas);
  border-bottom: 1px solid var(--line-hairline);
}
.bar-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text-primary); min-height: 48px; }
.bar-brand img { width: 28px; height: 28px; }
.bar-brand span { font: 400 20px/1 var(--font-display); letter-spacing: .14em; padding-top: 2px; }
.mark-dark { display: none; }
[data-theme="kiswah"] .mark-light { display: none; }
[data-theme="kiswah"] .mark-dark { display: block; }
.bar-tools { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); }
.round {
  width: 48px; height: 48px; display: grid; place-items: center; border: 0; border-radius: 50%;
  background: var(--bg-raised); color: var(--text-primary); cursor: pointer;
}
.round .ic { width: 20px; height: 20px; }
.round .i-sun { display: none; }
[data-theme="kiswah"] .round .i-sun { display: block; }
[data-theme="kiswah"] .round .i-moon { display: none; }

/* Mobile contents: one row of rites under the bar */
.chips { display: none; }

/* ---------- Layout: sticky route on the left, the path on the right ---------- */
.guide {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 760px);
  justify-content: center;
  gap: clamp(32px, 6vw, 104px);
  padding: 0 var(--gutter);
}
.side { padding: clamp(40px, 7vh, 72px) 0 32px; }
.side-sticky { position: sticky; top: 88px; }
.title { font: 400 clamp(44px, 4.4vw, 68px)/1.02 var(--font-display); letter-spacing: -0.015em; text-wrap: balance; }
.lede { margin-top: var(--space-5); font-size: 18px; line-height: 1.6; max-width: 30em; text-wrap: pretty; }

.route { margin-top: var(--space-8); position: relative; }
.route::before { content: ""; position: absolute; left: 6px; top: 12px; bottom: 12px; width: 2px; background: var(--bg-raised); }
.route a {
  position: relative; display: grid; grid-template-columns: 14px 1fr auto; align-items: center; gap: 14px;
  min-height: 48px; text-decoration: none; color: var(--text-primary);
}
.route a::before { content: ""; width: 14px; height: 14px; border: 2px solid var(--display-gold); background: var(--bg-canvas); transition: background-color .3s; }
.route a.is-past::before, .route a[aria-current="true"]::before { background: var(--display-gold); }
.route b { font-weight: 500; }
.route small { font-size: 14px; color: var(--text-secondary); }
.route a[aria-current="true"] b { color: var(--text-accent); font-weight: 600; }
.route a.is-ref { margin-top: 6px; }
.route a.is-ref::before { border-radius: 50%; border-width: 1.5px; }




/* ---------- The path ---------- */
.path { position: relative; padding: clamp(40px, 7vh, 72px) 0 0 var(--rail); }
.path-track, .path-fill { position: absolute; left: 14px; top: calc(clamp(40px, 7vh, 72px) + 6px); width: 2.5px; bottom: 0; }
.path-track { background: var(--bg-raised); }
.path-fill { background: var(--display-gold); transform-origin: top; transform: scaleY(var(--p, 0)); }
.path-start { position: absolute; left: 10.5px; top: clamp(40px, 7vh, 72px); width: 9.5px; height: 9.5px; border-radius: 50%; background: var(--text-accent); box-shadow: 0 0 0 4px var(--bg-canvas); }

.rite { position: relative; padding-bottom: 72px; }
.rite + .rite { padding-top: 24px; }
.rite-head { position: relative; margin-bottom: var(--space-8); padding-top: 28px; }
.rite-node {
  position: absolute; left: calc(var(--rail) * -1); top: 30px; width: 31px; height: 31px;
  display: grid; place-items: center; background: var(--bg-canvas); border: 2.5px solid var(--display-gold);
  font: 600 15px/1 var(--font-text); color: var(--text-accent); transition: background-color .35s, color .35s;
}
.rite.is-past .rite-node, .rite.is-here .rite-node { background: var(--display-gold); color: var(--bg-canvas); }
.rite-head h2 { font: 400 clamp(34px, 3.2vw, 44px)/1.08 var(--font-display); letter-spacing: -0.01em; }
.rite-head .where { margin-top: 6px; color: var(--text-secondary); font-size: 16px; }
.rite-intro { max-width: 38em; }
.rite-intro + .rite-intro { margin-top: var(--space-4); }

.sub { font: 600 19px/1.3 var(--font-text); margin: 48px 0 var(--space-3); }
.sub-lede { color: var(--text-secondary); margin-bottom: var(--space-4); max-width: 38em; }

.steps { counter-reset: step; }
.step { position: relative; counter-increment: step; padding: 22px 0 6px; }
.step::before {
  content: ""; position: absolute; left: calc(var(--rail) * -1 + 10px); top: 30px; width: 11px; height: 11px;
  background: var(--bg-canvas); border: 2px solid var(--display-gold); transition: background-color .3s;
}
.step.is-past::before { background: var(--display-gold); }
.step h3 { font: 600 19px/1.35 var(--font-text); display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.step h3 .n { font: 600 17px/1 var(--font-text); color: var(--text-accent); min-width: 1.4em; }
.step > p, .step > ul, .step > .note { margin-top: 8px; max-width: 38em; }
.step > p + p { margin-top: var(--space-3); }
.bullets { display: grid; gap: 6px; }
.bullets li { position: relative; padding-left: 20px; }
.bullets li::before { content: ""; position: absolute; left: 0; top: 13px; width: 9px; height: 2px; background: var(--text-secondary); }
.note { color: var(--text-secondary); font-size: 16px; }
.men-women, .pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); margin-top: var(--space-3); }
.men-women > div, .pair > div { background: var(--bg-surface); border-radius: 16px; padding: var(--space-4) var(--space-5); }
.men-women h4, .pair h4 { font: 600 16px/1.3 var(--font-text); margin-bottom: 6px; }
.men-women li { font-size: 16px; }
.pair p { font-size: 16px; line-height: 1.55; }
.why { font: 600 17px/1.3 var(--font-text); margin: var(--space-6) 0 var(--space-2); }

/* ---------- Duas: Arabic, transliteration, translation, source ---------- */
.dua { margin: var(--space-4) 0 var(--space-2); padding: 22px 26px 18px; background: var(--bg-surface); border-radius: var(--radius-card); }
.dua-ar { font: 400 30px/1.85 var(--font-arabic); direction: rtl; text-align: right; color: var(--text-primary); }
.dua-ar.is-long { font-size: 28px; }
.dua-tl { margin-top: 10px; color: var(--text-secondary); font-size: 16px; line-height: 1.55; }
.dua-en { margin-top: 6px; font-size: 17px; line-height: 1.55; }
.dua-src { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-hairline); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; align-items: center; font: 500 13px/1.4 var(--font-text); color: var(--text-secondary); }

/* ---------- Figures: geometry in SVG, labels in HTML so they stay readable at any width ---------- */
.fig { margin: var(--space-6) 0 var(--space-4); }
.fig-canvas { position: relative; width: 100%; }
.fig-canvas > svg { width: 100%; height: auto; }
.fig figcaption { margin-top: var(--space-3); font-size: 14px; line-height: 1.5; color: var(--text-secondary); max-width: 44em; }
.lbl { position: absolute; transform: translate(-50%, -50%); font: 500 13px/1.25 var(--font-text); color: var(--text-primary); white-space: nowrap; pointer-events: none; }
.lbl small { display: block; font-weight: 400; color: var(--text-secondary); }
.lbl.l { transform: translate(calc(-100% - 12px), -50%); text-align: right; }
.lbl.r { transform: translate(12px, -50%); }
.lbl.t { transform: translate(-50%, calc(-100% - 10px)); text-align: center; }
.lbl.b { transform: translate(-50%, 10px); text-align: center; }

/* Tawaf plan: numbered callouts at a fixed size, keyed beside the drawing */
.tawaf-fig { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: var(--space-6); align-items: center; }
.tawaf-fig figcaption { grid-column: 1 / -1; margin-top: 0; }
.callout {
  position: absolute; transform: translate(-50%, -50%); width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; background: var(--bg-canvas); box-shadow: inset 0 0 0 1.5px var(--display-gold);
  font: 600 13px/1 var(--font-text); color: var(--text-accent); pointer-events: none;
}
.fig-key { counter-reset: k; display: grid; gap: 12px; font-size: 15px; line-height: 1.45; }
.fig-key li { counter-increment: k; display: grid; grid-template-columns: 26px 1fr; gap: 12px; align-items: start; }
.fig-key li::before {
  content: counter(k); width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  box-shadow: inset 0 0 0 1.5px var(--display-gold); font: 600 13px/1 var(--font-text); color: var(--text-accent);
}
.fig-key b { font-weight: 600; }

/* Spacing between neighbours, instead of inline margins */
.rite > .bullets, .rite > .note { max-width: 38em; }
.rite-head + .sub { margin-top: 0; }
.miqat .fig { margin: 0; }
.miqat + .note { margin-top: var(--space-4); }
.rite-intro + .note { margin-top: var(--space-2); }
.pattern + .note { margin-top: var(--space-3); }
.pillars > div > p + p, .pillars ol + p { margin-top: var(--space-3); }
.ref-body > .bullets { margin-top: var(--space-5); max-width: 42em; }
.ar-inline { font: 400 22px/1.4 var(--font-arabic); white-space: nowrap; }
/* Arabic terms beside their English names: Amiri, muted, never smaller than 19px so the script stays legible */
.ar-term { unicode-bidi: isolate; font-family: var(--font-arabic); font-weight: 400; font-size: max(.72em, 19px); line-height: 1; letter-spacing: 0; color: var(--text-secondary); white-space: nowrap; margin-inline-start: .3em; }
h2 > .ar-term { font-size: .66em; margin-inline-start: .4em; }
.mnemonic { margin-top: var(--space-4); color: var(--text-secondary); font-size: 16px; }
.mnemonic .ar-term { margin-inline-start: 0; color: var(--text-primary); }

/* Link to the other guide, in the bar */
.bar-link { margin-left: var(--space-4); display: inline-flex; align-items: center; min-height: 48px; padding: 0 4px; font: 500 15px/1 var(--font-text); color: var(--text-secondary); text-decoration: none; }
.bar-link:hover { color: var(--text-primary); }

/* Hajj type switch: a segmented control; the chosen type gets the raised fill, as the current chip does */
.type-switch { margin: var(--space-8) 0 0; padding: 0; border: 0; min-width: 0; }
.type-switch legend { padding: 0; margin-bottom: var(--space-2); font: 600 15px/1.3 var(--font-text); }
.type-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border-radius: var(--radius-pill); background: var(--bg-surface); box-shadow: inset 0 0 0 1px var(--line-hairline); }
.type-options label { position: relative; cursor: pointer; }
.type-options input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.type-options span { display: grid; place-items: center; height: 48px; border-radius: var(--radius-pill); font: 500 15px/1 var(--font-text); color: var(--text-secondary); transition: background-color .25s, color .25s; }
.type-options input:checked + span { background: var(--bg-raised); color: var(--text-primary); font-weight: 600; }
.type-options input:focus-visible + span { outline: 2px solid var(--control-selected); outline-offset: 2px; }
.type-note { margin-top: var(--space-2); font-size: 14px; line-height: 1.45; color: var(--text-secondary); }

/* Steps that apply to one type only. Without the script every type shows, labelled. */
.print-only { display: none; }
.for { display: none; font: 600 13px/1.4 var(--font-text); color: var(--text-secondary); }   /* the switch already filters on screen; print labels every type */
p.for { margin-bottom: 4px; }
span.for { margin-right: 6px; }
body[data-hajj="tamattu"] [data-for]:not([data-for~="tamattu"]),
body[data-hajj="qiran"] [data-for]:not([data-for~="qiran"]),
body[data-hajj="ifrad"] [data-for]:not([data-for~="ifrad"]) { display: none; }
.types { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-3); }
.types > div { background: var(--bg-surface); border-radius: 16px; padding: var(--space-4) var(--space-5); transition: box-shadow .25s; }
.types h4 { font: 600 17px/1.3 var(--font-text); margin-bottom: 4px; }
.types p { font-size: 15px; line-height: 1.5; color: var(--text-secondary); }
body[data-hajj="tamattu"] [data-type-card="tamattu"],
body[data-hajj="qiran"] [data-type-card="qiran"],
body[data-hajj="ifrad"] [data-type-card="ifrad"] { box-shadow: inset 0 0 0 1.5px var(--control-selected); }

/* The four rites of the 10th, in their sunnah order */
.order { display: flex; flex-wrap: wrap; align-items: center; row-gap: 6px; margin-top: var(--space-4); font-size: 15px; color: var(--text-secondary); }
.order li { display: inline; }
.order li:not(:last-child)::after { content: ""; display: inline-block; vertical-align: middle; width: 18px; height: 2px; margin: 0 10px; background: var(--line-strong); }
.order b { color: var(--text-primary); font-weight: 600; margin-right: 4px; }

/* The three Jamarat, from Mina towards Makkah */
.jm { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-3); padding: var(--space-5); background: var(--bg-surface); border-radius: var(--radius-card); }
.jm::before { content: ""; position: absolute; left: calc(16.66% + 8px); right: calc(16.66% + 8px); top: calc(var(--space-5) + 7px); height: 2px; background: var(--line-strong); }
.jm li { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; }
.jm-mark { width: 16px; height: 16px; border-radius: 50%; background: var(--bg-surface); box-shadow: inset 0 0 0 2px var(--text-primary); margin-bottom: 6px; }
.jm li:last-child .jm-mark { background: var(--text-primary); }
.jm b { font: 600 17px/1.3 var(--font-text); }
.jm small { font-size: 13px; line-height: 1.35; color: var(--text-secondary); }
.jm em { margin-top: 6px; font: 500 14px/1.35 var(--font-text); font-style: normal; color: var(--text-primary); }
.numbered { counter-reset: n; display: grid; gap: 6px; }
.numbered li { counter-increment: n; display: grid; grid-template-columns: 26px 1fr; }
.numbered li::before { content: counter(n); font: 500 16px/1.65 var(--font-text); color: var(--text-secondary); }

/* Hajj sites map: land only, Arafah shaded, the day order as a dashed route */
.mm-ground { fill: var(--bg-surface); }
.mm-area { fill: var(--bg-raised); stroke: var(--text-secondary); stroke-width: 1.25; stroke-dasharray: 4 4; }
.mm-route { fill: none; stroke: var(--line-strong); stroke-width: 2; stroke-dasharray: 6 6; stroke-linejoin: round; }
.mm-label.mm-top, .mm-town.mm-top { transform: translate(-50%, calc(-100% - 10px)); text-align: center; }
.mm-label.mm-bottom, .mm-town.mm-bottom { transform: translate(-50%, 10px); text-align: center; }
.hajj-map .mm-makkah { font-size: 13px; }
.mm-label.mm-below-right { transform: translate(-6px, 10px); text-align: left; }

/* Miqat map */
.miqat { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-6); align-items: start; margin-top: var(--space-5); }
.mm-canvas { position: relative; width: 100%; border-radius: var(--radius-card); overflow: hidden; }
.mm-geo { width: 100%; height: 100%; }
.mm-sea { fill: var(--bg-raised); }
.mm-land { fill: var(--bg-surface); stroke: var(--display-gold); stroke-width: 1.25; stroke-linejoin: round; }
.mm-ray { stroke: var(--line-strong); stroke-width: 1.25; stroke-dasharray: 3 5; }
.mm-miqat { fill: var(--bg-canvas); stroke: var(--display-gold); stroke-width: 2.5; }
.mm-city { fill: var(--text-secondary); }
.mm-kaabah { fill: var(--text-accent); }
.mm-kaabah-ring { fill: none; stroke: var(--text-accent); stroke-width: 1.25; opacity: .5; }
.mm-scale { fill: none; stroke: var(--text-primary); stroke-width: 1.5; }
.mm-north { fill: var(--text-primary); }
.mm-label, .mm-town, .mm-scale-label, .mm-north-label, .mm-sea-label { position: absolute; pointer-events: none; white-space: nowrap; line-height: 1.2; }
.mm-label { font: 600 13px/1.2 var(--font-text); color: var(--text-primary); transform: translate(12px, -50%); }
/* A crisp knockout in the colour of the ground under each label, so the coastline never runs through a name */
.mm-label, .mm-town, .mm-scale-label { -webkit-text-stroke: 4px var(--bg-surface); paint-order: stroke fill; }
.mm-on-sea, .mm-scale-label { -webkit-text-stroke-color: var(--bg-raised); }
.mm-label small { display: block; font-weight: 400; font-size: 12px; color: var(--text-secondary); }
.mm-label.mm-left { transform: translate(calc(-100% - 12px), -50%); text-align: right; }
.mm-makkah { font-size: 14px; color: var(--text-accent); transform: translate(calc(-100% - 16px), -50%); }
.mm-town { font: 400 12px/1 var(--font-text); color: var(--text-secondary); transform: translate(8px, -50%); }
.mm-town.mm-left { transform: translate(calc(-100% - 8px), -50%); }
.mm-scale-label, .mm-north-label { font: 500 12px/1 var(--font-text); color: var(--text-primary); transform: translate(-50%, -50%); }
.mm-sea-label { font: 400 13px/1 var(--font-text); color: var(--text-secondary); letter-spacing: .08em; transform: translate(-50%, -50%) rotate(-62deg); }

.miqat-list { display: grid; gap: 0; }
.miqat-list > div { padding: 14px 0; }
.miqat-list > div + div { border-top: 1px solid var(--line-hairline); }
.miqat-list > div:first-child { padding-top: 0; }
.miqat-list dt { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-weight: 600; }
.miqat-list dt span[lang="ar"] { font: 400 22px/1.2 var(--font-arabic); font-weight: 400; color: var(--text-secondary); }
.miqat-list dd { font-size: 15px; line-height: 1.5; color: var(--text-secondary); margin-top: 2px; }
.miqat-list dd b { color: var(--text-primary); font-weight: 500; }

/* Tawaf plan */
.tw-geo .tw-circuit { fill: none; stroke: var(--line-strong); stroke-width: 1.5; }
.tw-geo .tw-arrow { fill: var(--display-gold); }
.tw-geo .tw-dua { fill: none; stroke: var(--display-gold); stroke-width: 6; stroke-linecap: round; opacity: .55; }
.tw-geo .tw-kaabah { fill: var(--text-primary); }
.tw-geo .tw-hijr { fill: none; stroke: var(--text-primary); stroke-width: 6; }
.tw-geo .tw-start { stroke: var(--display-gold); stroke-width: 2.5; stroke-dasharray: 6 5; }
.tw-geo .tw-stone { fill: var(--display-gold); stroke: var(--bg-canvas); stroke-width: 3; }
.tw-geo .tw-door { fill: var(--display-gold); }
.tw-geo .tw-maqam { fill: var(--bg-canvas); stroke: var(--display-gold); stroke-width: 2.5; }
.tw-geo .tw-yemeni { fill: var(--bg-canvas); stroke: var(--text-primary); stroke-width: 2.5; }
.tw-geo .tw-safa { fill: none; stroke: var(--text-secondary); stroke-width: 1.5; }
.tw-geo .tw-safa-head { fill: var(--text-secondary); }

/* Sa'ee legs */
.legs { margin-top: var(--space-5); background: var(--bg-surface); border-radius: var(--radius-card); padding: var(--space-5); }
.legs-ends { display: grid; grid-template-columns: 112px 1fr 112px; align-items: end; gap: 12px; margin-bottom: 10px; }
.legs-ends b { font: 400 24px/1 var(--font-display); color: var(--text-accent); }
.legs-ends b:last-child { text-align: right; }
.legs-ends span { text-align: center; font-size: 13px; color: var(--text-secondary); }
.legs ol { display: grid; gap: 8px; position: relative; }
.leg { position: relative; display: grid; grid-template-columns: 112px 1fr 112px; align-items: center; gap: 12px; height: 30px; font-size: 14px; }
.leg .bar-line { position: relative; height: 2px; background: var(--line-strong); }
.leg .bar-line::after { content: ""; position: absolute; top: -5px; width: 10px; height: 12px; background: var(--display-gold); }
.leg.to-m .bar-line::after { right: -2px; clip-path: polygon(0 0, 100% 50%, 0 100%); }
.leg.to-s .bar-line::after { left: -2px; clip-path: polygon(100% 0, 0 50%, 100% 100%); }
.leg .bar-line i { position: absolute; left: 34%; width: 22%; top: -3px; height: 8px; background: var(--bg-raised); border-radius: 2px; }
.leg .n { font: 600 16px/1 var(--font-text); color: var(--text-accent); }
.leg.to-m .n { text-align: left; }
.leg.to-s .n { grid-column: 3; text-align: right; }
.leg.to-s .bar-line { grid-column: 2; grid-row: 1; }
.leg .end { font-size: 13px; color: var(--text-secondary); }
.leg.to-m .end { grid-column: 3; text-align: right; }
.leg.to-s .end { grid-column: 1; grid-row: 1; }
.legs-green { display: grid; grid-template-columns: 112px 1fr 112px; gap: 12px; margin-top: 12px; font-size: 13px; color: var(--text-secondary); }
.legs-green span { grid-column: 2; padding-left: 34%; }
.pattern { display: flex; flex-wrap: wrap; align-items: center; row-gap: 4px; margin-top: var(--space-3); font-size: 15px; color: var(--text-secondary); }
.pattern li { display: inline-flex; align-items: center; }
.pattern li:not(:last-child)::after { content: ""; width: 18px; height: 2px; margin: 0 10px; background: var(--line-strong); }
.pattern li.d { color: var(--text-primary); font-weight: 600; }

/* ---------- End of the path ---------- */
.complete { position: relative; padding: 24px 0 96px; }
.complete::before { content: ""; position: absolute; left: calc(var(--rail) * -1 + 7px); top: 0; width: 17px; height: 17px; background: var(--display-gold); }
.complete img { width: 120px; height: auto; margin-bottom: var(--space-4); }
.complete h2 { font: 400 26px/1.25 var(--font-display); }
.complete p { margin-top: 6px; color: var(--text-secondary); }

/* ---------- Rulings (reference, after the path) ---------- */
.rulings { border-top: 1px solid var(--line-hairline); padding: 72px var(--gutter) 96px; }
.rulings-in { max-width: 1180px; margin: 0 auto; }
.rulings h2 { font: 400 clamp(34px, 3.2vw, 44px)/1.08 var(--font-display); }
.rulings > .rulings-in > p { margin-top: 10px; max-width: 40em; color: var(--text-secondary); }
.ref { margin-top: 56px; display: grid; grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); gap: clamp(24px, 4vw, 64px); }
.ref h3 { font: 400 26px/1.2 var(--font-display); }
.ref-aside { color: var(--text-secondary); font-size: 15px; margin-top: 8px; }
.ref-body > p { max-width: 42em; }
.ref-body > p + p { margin-top: 12px; }

.table-wrap { overflow-x: auto; margin-top: 4px; }
table { width: 100%; border-collapse: collapse; font-size: 16px; line-height: 1.5; }
th { text-align: left; font: 600 14px/1.3 var(--font-text); color: var(--text-secondary); padding: 0 16px 10px 0; border-bottom: 1px solid var(--line-strong); }
td { padding: 12px 16px 12px 0; border-bottom: 1px solid var(--line-hairline); vertical-align: top; }
td:first-child { color: var(--text-primary); }
.pillars { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.pillars > div { background: var(--bg-surface); border-radius: var(--radius-card); padding: var(--space-5); }
.pillars h4 { font: 600 17px/1.3 var(--font-text); }
.pillars p { font-size: 15px; color: var(--text-secondary); margin-top: 4px; }
.pillars ol { counter-reset: p; margin-top: var(--space-3); display: grid; gap: 6px; }
.pillars li { counter-increment: p; display: grid; grid-template-columns: 26px 1fr; }
.pillars li::before { content: counter(p); font: 500 16px/1.55 var(--font-text); color: var(--text-secondary); }
.cols { columns: 2; column-gap: 40px; }
.cols li { break-inside: avoid; }

.foot { border-top: 1px solid var(--line-hairline); padding: 40px var(--gutter) 56px; }
.foot-in { max-width: 1180px; margin: 0 auto; display: flex; gap: 16px; align-items: flex-start; font-size: 14px; color: var(--text-secondary); line-height: 1.55; }
.foot-in img { width: 36px; height: 36px; flex: none; }
.foot-text { display: grid; gap: 10px; }
.foot-in a { color: inherit; text-underline-offset: 3px; }

/* ---------- Narrow screens ---------- */
@media (max-width: 1023px) {
  .guide { grid-template-columns: minmax(0, 720px); gap: 0; }
  .side { padding-bottom: 0; }
  .side-sticky { position: static; }
  .route { display: none; }
  .chips {
    display: flex; gap: 6px; position: sticky; top: 64px; z-index: 30; overflow-x: auto; scrollbar-width: none;
    padding: 8px var(--gutter); background: var(--bg-canvas); border-bottom: 1px solid var(--line-hairline);
  }
  .chips::-webkit-scrollbar { display: none; }
  .chips a { flex: none; display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border-radius: var(--radius-pill); text-decoration: none; color: var(--text-secondary); font-size: 15px; font-weight: 500; }
  .chips a b { font: 600 14px/1 var(--font-text); color: var(--text-accent); }
  .chips a[aria-current="true"] { background: var(--bg-raised); color: var(--text-primary); }
  html { scroll-padding-top: 128px; }
  .miqat, .tawaf-fig, .types { grid-template-columns: 1fr; }
  .ref { grid-template-columns: 1fr; gap: 16px; }
}
@media (max-width: 640px) {
  .hajj-map .mm-minor { display: none; }
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; }
  table.stack tr { padding: 12px 0; border-bottom: 1px solid var(--line-hairline); }
  table.stack td { padding: 2px 0; border: 0; display: grid; grid-template-columns: 112px 1fr; gap: 8px; }
  table.stack td:first-child { font: 600 17px/1.4 var(--font-text); display: block; margin-bottom: 4px; }
  table.stack td:not(:first-child)::before { content: attr(data-label); color: var(--text-secondary); font-size: 14px; }
  :root { --rail: 40px; }
  .path-track, .path-fill { left: 8px; }
  .path-start { left: 4.5px; }
  .rite-node { width: 27px; height: 27px; font-size: 13px; left: calc(var(--rail) * -1 - 2px); }
  .step::before { left: calc(var(--rail) * -1 + 4px); }
  .complete::before { left: calc(var(--rail) * -1 + 1px); }
  .men-women, .pair, .pillars { grid-template-columns: 1fr; }
  .dua { padding: 18px 18px 14px; margin-left: calc(var(--rail) * -1 + 24px); }
  .dua-ar { font-size: 27px; }
  .dua-ar.is-long { font-size: 25px; }
  .cols { columns: 1; }
  .legs { padding: var(--space-4); }
  .legs-ends, .leg, .legs-green { grid-template-columns: 64px 1fr 64px; gap: 8px; }
  .lbl { font-size: 12px; }
  .lbl small { font-size: 12px; }
  .mm-label { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .path-fill { transform: none; }
  * { transition: none !important; }
}

.cover { display: none; }

@page { size: A4; margin: 14mm 12mm; }
@page :first { margin: 0; }
@media print {
  /* Paper is always Haram Ivory, whatever theme the reader was using on screen */
  :root, [data-theme] {
    --bg-canvas: #F6F0E4; --bg-surface: #FCF9F2; --bg-raised: #E7DAC2;
    --text-primary: #2B2620; --text-secondary: #6E6353; --text-accent: #7F612C;
    --display-gold: #A88446; --control-selected: #7F612C;
    --line-hairline: rgb(43 38 32 / .1); --line-strong: rgb(43 38 32 / .22);
    color-scheme: light;
  }
  [data-theme] .mark-light { display: block; }
  [data-theme] .mark-dark { display: none; }

  .cover {
    display: flex; flex-direction: column; align-items: center; justify-content: space-between;
    width: 210mm; height: 296mm; padding: 34mm 24mm 30mm; break-after: page;
    background: #F6F0E4; text-align: center;
  }
  .cover-seal { width: 74mm; height: auto; }
  .cover-title h2 { font: 400 46pt/1.04 var(--font-display); letter-spacing: -0.012em; color: #2B2620; }
  .cover-title p { margin-top: 8mm; font: 400 13pt/1.5 var(--font-text); color: #6E6353; }
  .cover-route { position: relative; display: grid; grid-template-columns: repeat(4, 1fr); width: 150mm; }
  .cover-route::before { content: ""; position: absolute; left: 12.5%; right: 12.5%; top: 6px; height: 2px; background: #A88446; }
  .cover-route li { position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; font: 500 11pt/1.2 var(--font-text); color: #2B2620; }
  .cover-route li::before { content: ""; width: 14px; height: 14px; border: 2px solid #A88446; background: #F6F0E4; box-sizing: border-box; }
  .cover-route li:first-child::before { background: #A88446; }
  .cover-route--7 { grid-template-columns: repeat(7, 1fr); width: 170mm; }
  .cover-route--7::before { left: 7.14%; right: 7.14%; }
  .cover-route--7 li { font-size: 9pt; }

  html, body { background: #fff; }
  body { font-size: 11pt; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .note, .pair p, .men-women li, .sub-lede, .miqat-list dd { font-size: 10pt; }
  .bar, .chips, .bar-tools, .skip, .path-fill, .type-switch { display: none !important; }
  body[data-hajj] [data-for] { display: revert !important; }
  p.for { display: block; }
  span.for { display: inline; }
  body[data-hajj] .order [data-for] { display: none !important; }
  .print-only { display: inline; }
  body[data-hajj] .types > div { box-shadow: none; }
  .guide { display: block; padding: 0; }
  .side { padding: 0 0 24px; }
  .side-sticky { position: static; }
  .route { display: none; }
  .path { padding-top: 8px; }
  .rite { padding-bottom: 32px; }
  .rite-head { break-after: avoid; }
  .sub, .step h3 { break-after: avoid; }
  .dua, .fig-canvas, .mm-canvas, .legs, .men-women > div, .pair > div, .pillars > div, .types > div, .jamarat, .order, tr { break-inside: avoid; }
  .miqat { grid-template-columns: 1fr 1fr; }
  .rulings { padding: 32px 0 0; }
  .ref { display: block; margin-top: 32px; }
  .ref > div:first-child { break-after: avoid; margin-bottom: 12px; }
  .ref h3, .rulings h2 { break-after: avoid; }
  .complete { break-inside: avoid; }
  .complete { padding-bottom: 32px; }
  .foot { padding: 24px 0 0; }
}
