/* W13: Saudi Riyal sign, hero multi-domain proof, module chapters. Loaded last on all 12 pages. */

/* ---------- Saudi Riyal sign (U+20C1) ----------
   The official SAMA artwork (assets/currency/saudi-riyal-symbol.svg, unmodified) is used as a mask, so the
   sign takes the colour of the text around it, scales with its font size, and never depends on a font
   having the Unicode 17 glyph. Its box sits on the digits' baseline and is a little taller than them. */
.sar {
  display: inline-block; flex: none;
  inline-size: .7em; block-size: .78em;
  vertical-align: -.01em;
  background-color: currentColor;
  -webkit-mask: url("../currency/saudi-riyal-symbol.svg") center / contain no-repeat;
  mask: url("../currency/saudi-riyal-symbol.svg") center / contain no-repeat;
  print-color-adjust: exact; -webkit-print-color-adjust: exact;
}
@media (forced-colors: active) { .sar { forced-color-adjust: none; background-color: CanvasText; } }

/* Amount + sign travel as one unit. In RTL the DOM order (digits, sign) puts the sign to the left of the
   digits; in an LTR context the order is reversed so the sign stays on the left there too. */
.money { display: inline-flex; align-items: baseline; gap: .24em; white-space: nowrap; font-variant-numeric: tabular-nums; }
.money:dir(ltr) { flex-direction: row-reverse; }
.money > bdi { unicode-bidi: isolate; }
.th-sar { display: inline-flex; align-items: baseline; gap: .3em; white-space: nowrap; }
th .sar { opacity: .85; }
/* Hero canvas: amounts and their sign keep the existing type sizes */
.kpi-big.money { gap: .18em; }
.totals .money, .feed .money, .cart .money, .receipt__sum .money, .margin-strip .money { justify-content: flex-end; }
.margin-strip .money em { margin-inline-start: .3em; }
.win .hbar b .money { font-weight: 600; }

/* ---------- Approved brand (header + footer) ----------
   The approved wordmark is shown as supplied; the light plate keeps its navy «Cloudy» legible on dark chrome. */
.brand__plate { display: inline-flex; align-items: center; padding: 5px 12px 5px 10px; border-radius: 12px; background: #f7f9fe; box-shadow: 0 0 0 1px rgb(255 255 255 / .6) inset, 0 6px 18px -10px rgb(0 0 0 / .6); }
.brand__img { display: block; width: auto; height: 40px; }
.brand--sm .brand__img { height: 36px; }
.site-header.is-light .brand__plate { box-shadow: 0 0 0 1px var(--line-2); }
@media (max-width: 640px) { .brand__img { height: 32px; } .brand__plate { padding: 4px 9px 4px 8px; border-radius: 10px; } }
/* Hero product window: the approved icon replaces the W11A approximation. */
.app__brand i { background-image: url("../../brand/approved/favicon-32.png?v=w13"); }

/* ---------- Hero: six moments, not only the POS loop ---------- */
.hero-proof { position: relative; margin-top: clamp(1rem, .6rem + 1.2vw, 1.75rem); }
.hero-proof__k { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: 0 0 .6rem; color: var(--text-2); font-size: var(--fs-sm); font-weight: 500; }
.hero-proof__list { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .5rem; margin: 0; padding: 0; list-style: none; }
.hero-proof__list a {
  display: grid; gap: .2rem; align-content: start; height: 100%; padding: .7rem .8rem .75rem;
  border-radius: 14px; border: 1px solid var(--line-2); background: rgb(12 21 48 / .72);
  color: var(--text-2); text-decoration: none; transition: border-color var(--dur-1), background var(--dur-1), transform var(--dur-2) var(--ease-out);
}
.hero-proof__list a:hover, .hero-proof__list a:focus-visible { border-color: var(--blue-400); background: var(--surface-1); }
.hero-proof__list small { color: var(--blue-300); font-size: var(--fs-meta); font-weight: 600; }
.hero-proof__rt { color: var(--warn); font-weight: 500; }
.hero-proof__list b { color: var(--text-1); font-family: var(--font-num); font-size: clamp(1.05rem, .95rem + .4vw, 1.3rem); font-weight: 700; line-height: 1.35; }
.hero-proof__list b .num { white-space: nowrap; }
.hero-proof__list span { font-size: var(--fs-meta); line-height: 1.6; }
@media (prefers-reduced-motion: no-preference) {
  .hero-proof__list a:hover { transform: translateY(-3px); }
  .hero.is-entering .hero-proof__list li { animation: e-proof .6s var(--ease-out) both; animation-delay: calc(1.6s + var(--n, 0) * 70ms); }
  .hero-proof__list li:nth-child(2) { --n: 1; } .hero-proof__list li:nth-child(3) { --n: 2; } .hero-proof__list li:nth-child(4) { --n: 3; }
  .hero-proof__list li:nth-child(5) { --n: 4; } .hero-proof__list li:nth-child(6) { --n: 5; }
}
@keyframes e-proof { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (max-width: 1180px) { .hero-proof__list { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  .hero-proof__list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .4rem; }
  .hero-proof__list a { padding: .6rem .65rem; }
}

/* ---------- Module chapters (#chapters) ---------- */
.ch-section { position: relative; padding-block: clamp(3rem, 2rem + 4vw, 6rem); background:
  radial-gradient(60% 40% at 85% 0%, rgb(47 123 255 / .10), transparent 70%), var(--bg-0); }
.ch-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: clamp(1.5rem, 1rem + 2vw, 3rem); align-items: start; }

/* Index + data thread: a rail that fills as the reader moves through the chapters (--ch-p 0…1). */
.ch-index { position: sticky; top: calc(var(--header-h) + 28px); }
.ch-index ol { position: relative; display: grid; gap: .25rem; margin: 0; padding: 0; list-style: none; }
.ch-index ol::before, .ch-index ol::after { content: ""; position: absolute; inset-inline-start: 15px; top: 16px; bottom: 16px; width: 2px; border-radius: 2px; }
.ch-index ol::before { background: var(--line-2); }
.ch-index ol::after { background: linear-gradient(180deg, var(--blue-300), var(--blue-500)); transform-origin: top; transform: scaleY(var(--ch-p, 0)); transition: transform .2s linear; }
.ch-index a { position: relative; z-index: 1; display: flex; align-items: center; gap: .7rem; min-height: 44px; padding: .2rem 0; color: var(--text-3); font-size: var(--fs-sm); text-decoration: none; transition: color var(--dur-1); }
.ch-index a span { display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--line-3); background: var(--bg-0); color: var(--text-3); font-family: var(--font-num); font-size: .75rem; font-weight: 600; transition: background var(--dur-2), border-color var(--dur-2), color var(--dur-2), box-shadow var(--dur-2); }
.ch-index a:hover { color: var(--text-1); }
.ch-index a[aria-current] { color: var(--text-1); font-weight: 600; }
.ch-index a[aria-current] span { background: var(--blue-500); border-color: var(--blue-300); color: #fff; box-shadow: 0 0 0 5px rgb(47 123 255 / .18); }

.ch-list { display: grid; gap: 0; min-width: 0; }
.ch { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 1.25rem clamp(1.5rem, 1rem + 2vw, 3rem); align-items: start; padding-block: clamp(2rem, 1.5rem + 2vw, 3.5rem); border-top: 1px solid var(--line-1); scroll-margin-top: calc(var(--header-h) + 16px); }
.ch:first-child { border-top: 0; padding-top: .5rem; }
.ch-copy { display: grid; gap: 1rem; min-width: 0; align-content: start; }
.ch-k { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem; margin: 0; color: var(--blue-300); font-size: var(--fs-sm); font-weight: 600; }
.ch-k svg { width: 20px; height: 20px; }
.ch-n { font-family: var(--font-num); color: var(--text-3); font-weight: 500; letter-spacing: .04em; }
.ch h3 { margin: 0; color: var(--text-1); font-family: var(--font-display); font-weight: 600; font-size: clamp(1.45rem, 1.1rem + 1.3vw, 2.2rem); line-height: 1.4; text-wrap: balance; }
.ch-scene { margin: 0; color: var(--text-2); font-size: var(--fs-lead); line-height: var(--lh-lead); max-width: var(--measure-wide); }
.ch-decision { display: grid; gap: .35rem; padding: .95rem 1.1rem; border-radius: 16px; background: linear-gradient(135deg, rgb(47 123 255 / .16), rgb(47 123 255 / .05)); border: 1px solid rgb(82 148 255 / .35); }
.ch-decision > small { color: var(--blue-200); font-size: var(--fs-meta); font-weight: 600; }
.ch-decision p { margin: 0; color: var(--text-1); font-size: 1.08rem; font-weight: 500; line-height: 1.9; }
.ch-decision .money { color: #fff; font-weight: 700; }
.ch-owner { color: var(--text-2); font-size: var(--fs-meta); }
.ch-owner b { color: var(--text-1); font-weight: 600; }

.ch-steps { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; counter-reset: chs; }
.ch-steps li { counter-increment: chs; position: relative; display: grid; gap: .1rem; padding: .6rem 0 .6rem 0; padding-inline-start: 2.6rem; border-top: 1px solid var(--line-1); }
.ch-steps li:first-child { border-top: 0; }
.ch-steps li::before { content: counter(chs); position: absolute; inset-inline-start: 0; top: .7rem; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2); color: var(--blue-300); font-family: var(--font-num); font-size: .78rem; font-weight: 600; }
.ch-steps small { color: var(--blue-300); font-size: var(--fs-meta); font-weight: 600; }
.ch-steps p { margin: 0; color: var(--text-1); line-height: 1.85; }

.ch-flow { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; margin: 0; }
.ch-flow > div { padding: .65rem .8rem; border-radius: 12px; background: var(--surface-1); border: 1px solid var(--line-1); }
.ch-flow__guard { grid-column: 1 / -1; border-color: rgb(63 214 156 / .3) !important; background: rgb(63 214 156 / .07) !important; }
.ch-flow dt { color: var(--text-3); font-size: var(--fs-meta); font-weight: 600; }
.ch-flow__guard dt { color: var(--ok); }
.ch-flow dd { margin: .15rem 0 0; color: var(--text-1); font-size: var(--fs-sm); line-height: 1.75; }
.ch .nd-mods .pf-chip { background: transparent; }
.ch-cta { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1.25rem; padding-top: .2rem; }

/* Visual: sticky beside its copy; the document chain this chapter moves, then the screen. */
.ch-visual { position: sticky; top: calc(var(--header-h) + 24px); display: grid; gap: .7rem; margin: 0; min-width: 0; }
.ch-token { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; margin: 0; padding: 0; list-style: none; }
.ch-token li { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .6rem; border-radius: 999px; background: var(--surface-1); border: 1px solid var(--line-2); color: var(--text-2); font-size: var(--fs-meta); }
.ch-token li + li::before { content: "←"; margin-inline-end: .35rem; color: var(--blue-400); }
.ch-screen { border-radius: var(--r-lg); }
.ch-visual figcaption { color: var(--text-3); font-size: var(--fs-micro); }
.ch-handoff { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .6rem; margin: .5rem 0 0; padding-top: .9rem; border-top: 1px dashed var(--line-2); color: var(--text-2); font-size: var(--fs-sm); }
.ch-handoff a { color: var(--blue-300); font-weight: 600; text-decoration: none; }
.ch-handoff a:hover { text-decoration: underline; }

/* Active chapter: its rail node lights, its token chain and screen come forward. */
.ch.is-active .ch-token li { border-color: rgb(82 148 255 / .45); color: var(--text-1); }
.ch.is-active .ch-k .ch-n { color: var(--blue-300); }

@media (prefers-reduced-motion: no-preference) {
  /* Measured depth: inactive screens sit 16px back and 12px low; the active one comes to 0. */
  .ch-screen { transform: perspective(1200px) translate3d(0, 12px, -16px) rotateX(2deg); transform-origin: 50% 100%; transition: transform .8s var(--ease-out), box-shadow .8s var(--ease-out), filter .8s; filter: saturate(.85); }
  .ch.is-active .ch-screen { transform: perspective(1200px) translate3d(0, 0, 0) rotateX(0); filter: none; box-shadow: 0 30px 70px -30px rgb(47 123 255 / .45); }
  .ch-token li { transition: border-color .5s, color .5s; }
  /* One-shot staggered entrance for chapters that start below the fold (JS adds .is-pending, then .is-seen). */
  .ch-section.is-armed .ch.is-pending .ch-copy > *, .ch-section.is-armed .ch.is-pending .ch-visual { opacity: 0; }
  .ch-section.is-armed .ch.is-seen .ch-copy > * { animation: ch-in .6s var(--ease-out) both; }
  .ch-section.is-armed .ch.is-seen .ch-copy > :nth-child(2) { animation-delay: 60ms; }
  .ch-section.is-armed .ch.is-seen .ch-copy > :nth-child(3) { animation-delay: 120ms; }
  .ch-section.is-armed .ch.is-seen .ch-copy > :nth-child(4) { animation-delay: 180ms; }
  .ch-section.is-armed .ch.is-seen .ch-copy > :nth-child(n+5) { animation-delay: 240ms; }
  .ch-section.is-armed .ch.is-seen .ch-steps li { animation: ch-in .5s var(--ease-out) both; animation-delay: calc(240ms + var(--i) * 80ms); }
  .ch-section.is-armed .ch.is-seen .ch-visual { animation: ch-in-depth .9s var(--ease-out) 120ms both; }
}
@keyframes ch-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes ch-in-depth { from { opacity: 0; transform: perspective(1200px) translate3d(0, 16px, -16px); } to { opacity: 1; transform: none; } }

@media (max-width: 1100px) {
  .ch-layout { grid-template-columns: minmax(0, 1fr); }
  .ch-index { display: none; }
  /* The thread moves to the chapter list itself. */
  .ch-list { position: relative; padding-inline-start: 1.1rem; }
  .ch-list::before, .ch-list::after { content: ""; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 2px; border-radius: 2px; }
  .ch-list::before { background: var(--line-2); }
  .ch-list::after { background: linear-gradient(180deg, var(--blue-300), var(--blue-500)); transform-origin: top; transform: scaleY(var(--ch-p, 0)); }
}
@media (max-width: 900px) {
  .ch { grid-template-columns: minmax(0, 1fr); }
  .ch-visual { position: static; }
}
@media (max-width: 560px) {
  .ch-flow { grid-template-columns: minmax(0, 1fr); }
  .ch-steps li { padding-inline-start: 2.3rem; }
  .ch-decision { padding: .8rem .9rem; }
  .ch-decision p { font-size: 1rem; }
}
@media (prefers-reduced-motion: reduce) {
  .ch-index ol::after, .ch-list::after, .ch-index a span, .hero-proof__list a { transition: none; }
}
@media print {
  .ch-index { display: none; }
  .ch-visual { position: static; }
  .ch-section.is-armed .ch .ch-copy > *, .ch-section.is-armed .ch .ch-visual { opacity: 1 !important; animation: none !important; }
}
