/*
 * The blog: the list of posts and each post, on top of styles.css (.doc, .callout).
 * Pages are written by tools/build-blog.py, except the hand-made hifz guide.
 */

:root {
  --gold-ink: #85662a; /* gold dark enough to read as text on cream */
}

.doc .post-crumb { margin: 0 0 14px; font-size: 14px; font-weight: 500; }
.post-crumb a { color: var(--muted); }
.post-crumb a:hover { color: var(--green); }

.doc .lede { margin: 10px 0 10px; font-size: 19px; line-height: 1.5; color: var(--ink); max-width: 36em; }

/* Date, reading time, and where a post was first published. Spaced, not joined with dots. */
.doc .post-meta { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 0 0 28px; font-size: 14px; color: var(--muted); }
.doc .post-meta a { color: var(--green); text-decoration: underline; text-decoration-color: rgba(12, 43, 33, .3); text-underline-offset: 3px; }

/* Arabic inside English text: Amiri, a size up, kept in its own direction. */
.ar { font-family: var(--serif); font-size: 1.28em; line-height: 1; unicode-bidi: isolate; }

/* Long reading: a touch larger than the legal pages. */
.post > p, .post > ul li { font-size: 17px; line-height: 1.7; }
.post > h2 { margin-top: 44px; }

/* The ayah or hadith a post opens with, and its meaning. */
.post-verse {
  margin: 0 0 36px; padding: 22px 24px 18px; text-align: center;
  background: #fffdf7; border: 1px solid var(--line); border-radius: 16px;
}
.doc .verse-ar { margin: 0; font-family: var(--serif); font-size: clamp(26px, 5vw, 34px); line-height: 1.8; color: var(--green); }
.post-verse figcaption, .row-verse figcaption, .featured-verse figcaption { font-size: 14px; line-height: 1.5; color: var(--muted); }
.verse-ref { white-space: nowrap; color: var(--gold-ink); font-weight: 500; }

/* Hadith, ayat and notes inside a post. */
.quote-card {
  margin: 26px 0; padding: 18px 22px;
  background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--gold); border-radius: 12px;
}
.doc .quote-card p { margin: 0; }
.doc .quote-card .quote-label { margin: 0 0 6px; font-size: 13px; font-weight: 700; color: var(--green); }
.quote-card blockquote { margin: 0; font-family: var(--serif); font-size: 20px; line-height: 1.55; color: var(--ink); }
.quote-card footer { margin-top: 8px; font-size: 13.5px; color: var(--muted); }

/* Numbered steps: the content is a real sequence, so the numbers carry meaning. */
.doc .steps { list-style: none; counter-reset: step; margin: 18px 0 0; padding: 0; }
.doc .steps > li { counter-increment: step; position: relative; margin: 0 0 34px; padding-left: 50px; }
.doc .steps > li::before {
  content: counter(step);
  position: absolute; left: 0; top: 0;
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--gold); color: var(--green);
  font-weight: 700; font-size: 16px;
}
.doc .steps h3 { margin: 5px 0 6px; font-size: 18px; color: var(--green); }

.doc .aside { margin: 28px 0 0; font-size: 14px; color: var(--muted); }

.callout.bridge { margin-top: 40px; }
.callout.bridge p { margin: 0; }
.callout.bridge .store-badges { justify-content: flex-start; margin-top: 16px; }
.callout.bridge .store-badges img { height: 46px; }

/* ---- The list of posts ---- */

.blog-home h1 { font-size: clamp(40px, 7vw, 56px); }
.blog-home .lede { margin-bottom: 30px; }

/* The newest post, as a large card. */
.featured {
  position: relative; overflow: hidden; display: block;
  margin: 0 0 44px; padding: 30px 32px 30px; border-radius: 24px;
  background: var(--green); color: var(--cream);
  box-shadow: 0 1px 0 rgba(12, 43, 33, .04);
  transition: transform 200ms var(--ease), box-shadow 200ms var(--ease);
}
.featured:hover { text-decoration: none; }
.featured:active { transform: scale(.99); }
.featured:focus-visible { border-radius: 24px; outline-offset: 4px; }
.featured > * { position: relative; }
.featured .featured-star {
  position: absolute; right: -70px; bottom: -80px; width: 280px; height: 280px;
  color: var(--gold-bright); opacity: .14; pointer-events: none;
}
.featured-verse { margin: 0 0 22px; text-align: right; }
.doc .featured-verse .verse-ar { color: var(--gold-bright); font-size: clamp(28px, 5vw, 38px); line-height: 1.7; }
.featured-verse figcaption { color: rgba(246, 241, 230, .62); }
.featured-verse .verse-ref { color: var(--gold-bright); }
.doc .featured h2 { margin: 0 0 10px; font-family: var(--serif); font-size: clamp(28px, 4.6vw, 38px); line-height: 1.2; color: var(--cream); }
.doc .featured-summary { margin: 0 0 14px; font-size: 17px; line-height: 1.55; color: var(--cream-dim); max-width: 34em; }
.doc .featured .post-meta { margin: 0; color: rgba(246, 241, 230, .62); }
.featured-go {
  display: inline-flex; margin-top: 22px; padding: 10px 20px; border-radius: 999px;
  background: var(--gold); color: var(--green); font-weight: 700; font-size: 15px;
  transition: background 200ms;
}

/* Every other post: words on the left, its Arabic line on the right. */
.doc .post-rows { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.doc .post-rows li { margin: 0; border-bottom: 1px solid var(--line); }
.post-row {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(170px, 34%); gap: 32px; align-items: center;
  margin: 0 -14px; padding: 28px 14px; border-radius: 14px; color: inherit;
  transition: background 200ms var(--ease);
}
.post-row:hover { text-decoration: none; }
.post-row:active { background: #fffdf7; }
.post-row:focus-visible { border-radius: 14px; }
.doc .post-row h2 { margin: 0 0 8px; font-family: var(--serif); font-size: 25px; line-height: 1.25; color: var(--green); }
.doc .row-summary { margin: 0 0 10px; font-size: 15.5px; line-height: 1.55; color: #33403a; }
.doc .post-row .post-meta { margin: 0; }
.row-verse { margin: 0; text-align: right; }
.doc .row-verse .verse-ar { font-size: 26px; line-height: 1.7; transition: color 200ms; }
.row-verse figcaption { font-size: 13px; line-height: 1.45; }

@media (hover: hover) and (pointer: fine) {
  .featured:hover { transform: translateY(-2px); box-shadow: 0 18px 40px rgba(12, 43, 33, .25); }
  .featured:hover .featured-go { background: var(--gold-bright); }
  .post-row:hover { background: #fffdf7; }
  .post-row:hover h2 { text-decoration: underline; text-decoration-color: rgba(12, 43, 33, .3); text-underline-offset: 4px; }
  .doc .post-row:hover .verse-ar { color: var(--gold-ink); }
}

@media (max-width: 640px) {
  .post-row { grid-template-columns: 1fr; gap: 12px; margin: 0 -8px; padding: 24px 8px; }
  .row-verse { order: -1; }
  .doc .row-verse .verse-ar { font-size: 24px; }
  .featured { padding: 24px 20px 24px; border-radius: 20px; }
  .featured:focus-visible { border-radius: 20px; }
  .featured .featured-star { width: 200px; height: 200px; right: -60px; bottom: -60px; }
}

@media (max-width: 520px) {
  .doc .lede { font-size: 17px; }
  .post > p, .post > ul li { font-size: 16px; }
  .post-verse { padding: 18px 16px 14px; }
  .quote-card { padding: 16px 16px; }
  .quote-card blockquote { font-size: 18px; }
  .doc .steps > li { padding-left: 44px; }
  .doc .steps > li::before { width: 30px; height: 30px; font-size: 15px; }
  .callout.bridge .store-badges { justify-content: center; }
}

/* ---- The wudu guide: how each madhab classes an act ---- */

.chip {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 30px; padding: 4px 10px; border-radius: 8px;
  font-size: 13.5px; font-weight: 700; line-height: 1.2; text-align: center;
}
.chip.req { background: var(--green); color: var(--cream); }
.chip.sun { background: #f2e4c0; color: #5b4414; box-shadow: inset 0 0 0 1px #d8bd7a; }
.chip.rec { background: #fff; color: var(--green); box-shadow: inset 0 0 0 1px #cfc5ad; }
.chip.no { background: transparent; color: #6d7871; font-weight: 600; outline: 1px dashed #bdb39c; outline-offset: -1px; }

.doc .legend { list-style: none; margin: 16px 0 10px; padding: 0; display: grid; gap: 10px; }
.doc .legend li { display: grid; grid-template-columns: 128px 1fr; gap: 14px; align-items: center; margin: 0; font-size: 15px; }
.doc .legend .chip { width: 100%; }

.doc .mnote { margin: 8px 0 0; font-size: 14px; line-height: 1.5; color: var(--muted); }

.mrow { margin: 16px 0 0; }
.doc .mrow-label { margin: 0 0 6px; font-size: 14px; font-weight: 700; color: var(--ink); }
.doc .mgrid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.doc .mcell { display: flex; flex-direction: column; gap: 4px; margin: 0; }
.mcell .mname { font-size: 12px; font-weight: 600; color: var(--muted); }
.mcell .chip { width: 100%; }

/* The steps: a real sequence, so numbered. */
.doc .wsteps { list-style: none; counter-reset: ws; margin: 20px 0 0; padding: 0; }
.doc .wstep { counter-increment: ws; margin: 0 0 40px; padding: 0 0 36px; border-bottom: 1px solid var(--line); }
.doc .wstep h3 {
  display: flex; align-items: baseline; gap: 12px;
  margin: 0 0 12px; font-family: var(--serif); font-size: 26px; line-height: 1.25; color: var(--green);
}
.doc .wstep h3::before {
  content: counter(ws); flex: none; width: 34px; height: 34px; border-radius: 50%;
  background: var(--gold); color: var(--green); font: 700 16px/34px var(--sans); text-align: center;
  transform: translateY(-3px);
}
.wstep-pic { margin: 0 0 14px; max-width: 480px; }
.wstep-pic img, .wstep-pic svg { display: block; width: 100%; height: auto; border-radius: 16px; }
.doc .wstep > p { font-size: 17px; line-height: 1.7; }
.doc .evidence { margin: 14px 0 0; font-size: 13.5px; line-height: 1.55; color: var(--muted); }
.evidence span { font-weight: 700; color: var(--ink); }
.evidence a, .refs a { color: var(--green); text-decoration: underline; text-decoration-color: rgba(12, 43, 33, .3); text-underline-offset: 3px; }

/* Words to say: Arabic, then how to say it, then what it means. */
.say-card { margin: 0; padding: 22px 24px; border-radius: 16px; background: var(--green); text-align: center; }
.doc .say-ar { margin: 0; font-family: var(--serif); font-size: clamp(24px, 4.4vw, 30px); line-height: 1.9; color: var(--gold-bright); }
.doc .say-tr { margin: 8px 0 0; font-size: 15px; font-style: italic; color: var(--cream-dim); }
.doc .say-en { margin: 6px 0 0; font-size: 14.5px; color: rgba(246, 241, 230, .7); }
.say-card.small { padding: 26px 24px; }
.say-card.small .say-ar { font-size: clamp(34px, 6vw, 44px); line-height: 1.6; }

/* Every act in one table; it scrolls sideways on a phone. */
.mtable-wrap { margin: 16px 0 0; overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
.mtable { width: 100%; border-collapse: collapse; font-size: 14px; }
.mtable th, .mtable td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.mtable thead th { background: #fffdf7; font-size: 13px; font-weight: 700; color: var(--muted); }
.mtable tbody th[scope="row"] { min-width: 190px; font-weight: 600; color: var(--ink); }
.mtable tr.group th { padding-top: 14px; background: #faf6ec; font-family: var(--serif); font-size: 17px; color: var(--green); }
.mtable .chip { width: 100%; min-height: 26px; font-size: 12.5px; }
.mtable tr:last-child th, .mtable tr:last-child td { border-bottom: 0; }

.refs h3 { margin: 18px 0 4px; font-size: 16px; color: var(--green); }
.doc .refs p { margin: 0; font-size: 14.5px; line-height: 1.6; }

@media (max-width: 520px) {
  .doc .legend li { grid-template-columns: 1fr; gap: 6px; }
  .doc .legend .chip { width: auto; justify-self: start; min-width: 120px; }
  .doc .mgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .doc .wstep h3 { font-size: 22px; }
  .doc .wstep > p { font-size: 16px; }
  .say-card { padding: 18px 16px; }
}

/* How much water: rows of 1-litre bottles. */
.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.water { margin: 18px 0 22px; padding: 20px 22px 18px; background: #fff; border: 1px solid var(--line); border-radius: 16px; }
.doc .water-key { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: 0 0 6px; font-size: 13.5px; color: var(--muted); }
.key-btl { display: inline-flex; }
.key-btl .btl { width: 12px; height: 24px; }
.water h3 { margin: 18px 0 8px; font-size: 13px; font-weight: 700; color: var(--muted); }
.doc .wrows { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.doc .wrow { margin: 0; padding: 0 0 0 12px; border-left: 3px solid transparent; }
.doc .wrow.is-sunnah { border-left-color: var(--gold); }
.doc .wrow-label { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; margin: 0 0 6px; font-size: 15px; }
.wrow-label strong { color: var(--ink); }
.wrow.is-sunnah .wrow-label strong { color: var(--green); }
.wrow-label span { color: var(--muted); font-size: 14px; }
.btls { display: flex; flex-wrap: wrap; gap: 3px; }
.btl { width: 18px; height: 36px; flex: none; }
.btl .w1 { fill: #4fa3d9; }
.btl .w2 { fill: #bfe0f3; }
.btl .btl-o { fill: none; stroke: #6d7871; stroke-width: 1.4; }
.water figcaption { margin-top: 16px; font-size: 13px; line-height: 1.5; color: var(--muted); }

@media (max-width: 520px) {
  .water { padding: 16px 14px 14px; }
  .btl { width: 15px; height: 30px; }
}

/* The order of ghusl at a glance: numbered tiles with object icons (no figures). */
.doc .flow { list-style: none; margin: 16px 0 8px; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; counter-reset: fl; }
.doc .flow li {
  counter-increment: fl; position: relative; margin: 0;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 14px 8px 12px; border-radius: 14px; background: #fff; border: 1px solid var(--line);
  text-align: center; font-size: 13.5px; font-weight: 600; line-height: 1.3; color: var(--ink);
}
.doc .flow li::before {
  content: counter(fl); position: absolute; top: 8px; left: 8px;
  width: 22px; height: 22px; border-radius: 50%; background: var(--gold); color: var(--green);
  font: 700 12px/22px var(--sans); text-align: center;
}
.flow svg { width: 40px; height: 40px; color: var(--green); }
.flow .fl-water { fill: #7cc0e6; }

/* The minimum for ghusl to count, per madhab. */
.doc .minimum { list-style: none; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.doc .minimum li { margin: 0; padding: 14px 16px; border-radius: 14px; background: #fff; border: 1px solid var(--line); font-size: 15px; line-height: 1.5; }
.minimum strong { display: block; margin-bottom: 4px; font-family: var(--serif); font-size: 19px; color: var(--green); }

@media (max-width: 520px) {
  .doc .flow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .doc .minimum { grid-template-columns: 1fr; }
}

/* Yes / conditional answers (does ghusl count as wudu?) */
.chip.yes { background: #e2f1e7; color: #1a5a38; box-shadow: inset 0 0 0 1px #b7dcc4; }
.chip.cond { background: #fff6df; color: #6b5220; box-shadow: inset 0 0 0 1px #e6cf95; }

/* ---- The madhab filter above the table (blog/madhab-filter.js) ---- */

.post [hidden] { display: none !important; }

/* Hidden until the script runs: without JS the page simply shows every madhab. */
.mf { display: none; }
.js .mf {
  display: block; margin: 18px 0 14px; padding: 16px 18px 14px;
  background: #fff; border: 1px solid var(--line); border-radius: 16px;
}
.mf-row { display: grid; grid-template-columns: 62px minmax(0, 1fr); gap: 8px 10px; align-items: start; }
.mf-row + .mf-row { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.doc .mf-label { margin: 0; padding-top: 10px; font-size: 14px; font-weight: 700; color: var(--green); }
.mf-opts { display: flex; flex-wrap: wrap; gap: 7px; }

/* A tick in a circle, so it reads as something you can tick more than one of. */
.mf-opt {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 0 12px 0 9px; border-radius: 999px;
  font: 600 14px/1.1 var(--sans); color: var(--ink);
  background: var(--paper); border: 1px solid #cfc5ad; cursor: pointer;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, transform 160ms var(--ease);
}
.mf-opt:active { transform: scale(.97); }
.mf-opt[aria-pressed="true"] { background: var(--green); border-color: var(--green); color: var(--cream); }
.mf-tick { width: 18px; height: 18px; flex: none; }
.mf-tick circle { fill: none; stroke: #b9ae95; stroke-width: 1.5; transition: fill 150ms ease, stroke 150ms ease; }
.mf-tick path { fill: none; stroke: var(--green); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transition: opacity 150ms ease; }
.mf-opt[aria-pressed="true"] .mf-tick circle { fill: var(--gold-bright); stroke: var(--gold-bright); }
.mf-opt[aria-pressed="true"] .mf-tick path { opacity: 1; }
@media (hover: hover) and (pointer: fine) {
  .mf-opt[aria-pressed="false"]:hover { border-color: var(--green); }
}
@media (pointer: coarse) {
  .mf-opt { min-height: 44px; }
}

.doc .mf-status { margin: 12px 0 0; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.doc .mf-empty { margin: 16px 0 0; padding: 14px 16px; border-radius: 14px; background: #fff; border: 1px dashed #cfc5ad; font-size: 15px; color: var(--muted); }

/* Above the steps, once something is picked: what's hidden, and a way back to the toggles. */
.doc .mf-note {
  margin: 12px 0 22px; padding: 10px 14px; border-radius: 12px;
  background: #fff; border: 1px solid var(--line); font-size: 14.5px; line-height: 1.5; color: var(--ink);
}
.mf-note a { font-weight: 700; white-space: nowrap; text-decoration: underline; text-decoration-color: rgba(12, 43, 33, .3); text-underline-offset: 3px; }

/* A group whose acts are all filtered out says so, instead of leaving a gap. */
.doc .mf-none { margin: 14px 0 0; padding: 10px 14px; border-radius: 10px; background: #faf6ec; font-size: 14px; line-height: 1.5; color: var(--muted); }

/* A picked madhab's ruling that isn't one of the picked kinds: faded, kept for comparing. */
.chip { transition: background-color 150ms ease, color 150ms ease, box-shadow 150ms ease; }
.is-dim .chip { background: transparent; color: #8a948e; font-weight: 600; box-shadow: inset 0 0 0 1px var(--line); outline: 0; }

/* Fewer madhabs picked: fewer boxes per act, and a narrower table. */
.post[data-n="1"] .mgrid { grid-template-columns: minmax(0, 1fr); max-width: 230px; }
.post[data-n="2"] .mgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 460px; }
.post[data-n="3"] .mgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.post[data-n="1"] .minimum, .post[data-n="2"] .minimum { grid-template-columns: 1fr; }
.mtable { min-width: calc(190px + var(--cols, 4) * 112px); }
.mtable .chip { max-width: 220px; }
.mtable tr.group a { color: inherit; }
.mtable tr.group a:hover { text-decoration: underline; text-decoration-color: rgba(12, 43, 33, .3); text-underline-offset: 4px; }

@media (max-width: 520px) {
  .js .mf { padding: 14px 14px 12px; }
  .mf-row { grid-template-columns: 1fr; gap: 6px; }
  .doc .mf-label { padding-top: 0; }
  .mtable { min-width: calc(132px + var(--cols, 4) * 104px); }
  .mtable tbody th[scope="row"] { min-width: 132px; }
}
