/* ==========================================================================
   Midad website: the whole design system in one file.
   Hand-written. No framework, no reset from elsewhere, no web fonts.
   Documented in ../STYLE.md.

   The page is complete with this file alone. assets/site.js adds the class
   "motion" to <html> (unless the reader asks for reduced motion); every rule
   that pins, stacks or animates sits in section 17 behind that class.

   Contents
     1. Tokens (light, then dark)
     2. Base
     3. Layout helpers
     4. Skip link and focus
     5. Site header
     6. Devices: phone, tablet, foldable
     7. Figures, captions and the shelf
     8. The sky (home page opening)
     9. Sections, promises
    10. Chapters: Prayer, Quran, Hadith
    11. Themes
    12. On every screen: foldable, iPad, languages
    13. Card, badge, button, switches
    14. The closing night (Get)
    15. Inner pages: page head, document, prose (Privacy, Support, Sources, 404)
    16. Site footer and Company block
    17. Motion (only with html.motion, on screens)
    18. Arabic and right-to-left
    19. Reduced motion, forced colours
    20. Print
   ========================================================================== */

/* 1. Tokens --------------------------------------------------------------- */

:root {
  color-scheme: light dark;

  /* Colour: paper, ink, one gold, lapis for links only. The app's own Paper palette. */
  --page: #FBF8F1;
  --card: #F2ECDF;
  --ink: #101B2D;
  --muted: #5B6577;
  --gold: #825C15;
  --hairline: #E2D9C6;
  --link: #1F4E8C;
  --caption: #485264;                     /* captions under devices: a little inkier than --muted */
  --shadow: 0 1px 2px rgb(16 27 45 / 0.06), 0 12px 32px -12px rgb(16 27 45 / 0.22);
  /* The device's shadow is kept short, so that it has gone before the caption beneath a device begins. */
  --device-shadow: 0 2px 5px rgb(16 27 45 / 0.16), 0 14px 22px -12px rgb(16 27 45 / 0.42), 0 22px 26px -22px rgb(16 27 45 / 0.5);

  /* The sky, sampled from the app's Today screen. Text on it is always --on-sky. */
  --on-sky: #F3EEE2;
  --night-1: #070B1E;
  --night-2: #0D1632;
  --night-3: #1A284E;
  /* Dusk, for the hairline under the inner pages' header. */
  --dusk-1: #14213F;
  --dusk-2: #2B3A66;
  --dusk-3: #7A4C56;
  --dusk-4: #B5764F;

  /* Type. */
  --serif: ui-serif, "New York", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Segoe UI", sans-serif;
  /* Arabic has one voice: the system's own Arabic, the face of the app's Arabic interface (SF Arabic on Apple
     devices, Segoe UI on Windows, Noto on Android). Nothing is named after system-ui on purpose: Chrome on a Mac
     stops at the first named face that has Arabic letters (Geeza Pro, Tahoma, Times New Roman) and never reaches
     the system's. */
  --arabic-ui: system-ui, -apple-system, sans-serif;
  --arabic-text: var(--arabic-ui);

  --step--1: clamp(0.8125rem, 0.79rem + 0.12vw, 0.875rem);   /* captions, labels */
  --step-0: clamp(1.0625rem, 1.03rem + 0.16vw, 1.1875rem);   /* body */
  --step-1: clamp(1.25rem, 1.19rem + 0.3vw, 1.4375rem);      /* h3, lede */
  --step-2: clamp(1.5rem, 1.36rem + 0.7vw, 2rem);            /* card titles, h2 in prose */
  --step-3: clamp(1.875rem, 1.6rem + 1.35vw, 2.75rem);       /* section h2, page h1 */
  --step-4: clamp(2.5rem, 1.9rem + 3vw, 4.5rem);             /* chapter titles */

  /* Space. */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;
  --space-9: 6rem;
  --section: clamp(4.5rem, 3rem + 7vw, 9rem);

  /* Measure and frame. */
  --measure: 34rem;                       /* about 65 characters of body serif */
  --wrap: 68rem;
  --gutter: clamp(1.25rem, 0.5rem + 3.75vw, 3rem);
  /* The pages run edge to edge under the notch (viewport-fit=cover), so a dark band is never framed by two
     bars of paper on a phone held sideways; the gutter keeps text clear of the notch and the corners. */
  --gutter: max(clamp(1.25rem, 0.5rem + 3.75vw, 3rem), env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
  --radius: 1rem;
  --radius-l: 1.75rem;
  --radius-s: 0.5rem;
  --header: 3.75rem;

  /* One device size for every phone on the page. */
  --phone: 17.5rem;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #0F1622;
    --card: #182233;
    --ink: #F3EEE2;
    --muted: #A9B1C2;
    --gold: #D9B36A;
    --hairline: #2A3447;
    --link: #8FB4E8;
    --caption: #A9B1C2;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 14px 36px -12px rgb(0 0 0 / 0.7);
    --device-shadow: 0 2px 5px rgb(0 0 0 / 0.5), 0 14px 22px -12px rgb(0 0 0 / 0.8), 0 22px 26px -22px rgb(0 0 0 / 0.85);
  }
}

/* A very wide window gets a wider page; the reading measure does not change. */
@media (min-width: 100em) {
  :root {
    --wrap: 78rem;
  }
}

/* 2. Base ----------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-block-start: var(--space-5);
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--step-0);
  line-height: 1.6;
  overflow-wrap: break-word;
  overflow-x: clip;                       /* clip, not hidden: sticky children keep working */
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.012em;
  text-wrap: balance;
}

p, ul, ol, dl, dd, figure, blockquote, address, fieldset {
  margin: 0;
}

fieldset {
  min-inline-size: 0;
  padding: 0;
  border: 0;
}

legend {
  padding: 0;
}

p, li, dd, figcaption {
  text-wrap: pretty;
}

address {
  font-style: normal;
}

img, svg, picture {
  display: block;
  max-inline-size: 100%;
}

img {
  block-size: auto;
}

/* Lapis is for links, and only for links. */
a {
  color: var(--link);
  text-decoration-line: underline;
  text-decoration-thickness: 0.0625em;
  text-underline-offset: 0.2em;
}

a:hover {
  text-decoration-thickness: 0.125em;
}

strong, b {
  font-weight: 600;
}

/* 3. Layout helpers ------------------------------------------------------- */

.wrap {
  inline-size: 100%;
  max-inline-size: calc(var(--wrap) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.measure {
  max-inline-size: var(--measure);
}

/* A name with a hyphen in it (al-Bukhari, Attribution-NoDerivatives) never breaks at the hyphen. */
.nb {
  white-space: nowrap;
}

.visually-hidden {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* 4. Skip link and focus -------------------------------------------------- */

/* When it has the focus, the skip link is a bar across the top of the page: it covers the header's row
   whole, so it never lies half over a word. */
.skip-link {
  position: absolute;
  inset-block-start: var(--space-2);
  inset-inline: var(--space-2);
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  min-block-size: 2.75rem;
  padding-inline: var(--space-4);
  border-radius: var(--radius-s);
  background: var(--page);
  color: var(--link);
  font-family: var(--sans);
  font-size: var(--step--1);
  font-weight: 600;
  box-shadow: 0 0 0 1px var(--hairline), var(--shadow);
  white-space: nowrap;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 3px;
  border-radius: 0.25rem;
}

/* On the sky and on the closing night, the focus ring is the sky's own ink. */
.site-header--sky :focus-visible,
.sky :focus-visible,
.get :focus-visible {
  outline-color: var(--on-sky);
}

:target {
  scroll-margin-block-start: var(--space-5);
}

/* 5. Site header ---------------------------------------------------------- */

.site-header {
  position: relative;
  z-index: 5;
  background: var(--page);
  font-family: var(--sans);
  font-size: 0.9375rem;
  line-height: 1.2;
}

/* The horizon: a hairline of the dusk sky under the header of every inner page. */
.site-header::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  inset-block-end: 0;
  block-size: 2px;
  background: linear-gradient(to right, var(--dusk-1), var(--dusk-2) 45%, var(--dusk-3) 80%, var(--dusk-4));
}

[dir="rtl"] .site-header::after {
  background: linear-gradient(to left, var(--dusk-1), var(--dusk-2) 45%, var(--dusk-3) 80%, var(--dusk-4));
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  column-gap: var(--space-4);
  min-block-size: var(--header);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  min-block-size: 2.75rem;
  min-inline-size: 2.75rem;
  color: var(--ink);
  text-decoration: none;
}

.brand__mark {
  inline-size: 2rem;
  block-size: 2rem;
  border-radius: 22.5%;
}

.brand__name {
  font-family: var(--serif);
  font-size: 1.3125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.site-nav {
  margin-inline-start: auto;
}

.site-nav ul {
  display: flex;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav a,
.lang-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-block-size: 2.75rem;       /* 44 px target */
  min-inline-size: 2.75rem;
  padding-inline: 0.5rem;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}

.site-nav a:hover,
.lang-link:hover,
.brand:hover .brand__name {
  text-decoration: underline;
  text-decoration-thickness: 0.0625em;
  text-underline-offset: 0.3em;
}

/* The page you are on: a gold underline. */
.site-nav a[aria-current="page"] {
  text-decoration: underline;
  text-decoration-color: var(--gold);
  text-decoration-thickness: 0.125em;
  text-underline-offset: 0.4em;
}

.lang-link {
  margin-inline-end: -0.5rem;
}

/* One row at every width, and the name is always in it: links draw closer on a phone, and under 26em the
   third link (Sources) is left to the footer. If a reader's own text spacing makes the row too long, it wraps. */
@media (max-width: 29.99em) {
  .site-header {
    font-size: 0.875rem;
  }

  .site-header__inner {
    flex-wrap: wrap;
    column-gap: var(--space-1);
  }

  .brand {
    gap: 0.5rem;
  }

  .brand__name {
    font-size: 1.1875rem;
  }

  .site-nav a,
  .lang-link {
    padding-inline: 0.3125rem;
  }

  .lang-link {
    margin-inline-end: -0.3125rem;
  }
}

@media (max-width: 25.99em) {
  .site-nav li:nth-child(n + 3) {
    display: none;
  }
}

@media (min-width: 40em) {
  .site-nav a,
  .lang-link {
    padding-inline: 0.75rem;
  }

  .lang-link {
    margin-inline-end: -0.75rem;
  }
}

/* The header as it lies over the home page's sky. */
.site-header--sky {
  position: absolute;
  inset-inline: 0;
  inset-block-start: 0;
  background: none;
}

.site-header--sky::after {
  content: none;
}

.site-header--sky .brand__mark {
  box-shadow: 0 0 0 1px rgb(243 238 226 / 0.16);
}

.site-header--sky .brand,
.site-header--sky .site-nav a,
.site-header--sky .lang-link {
  color: var(--on-sky);
}

/* 6. Devices: phone, tablet, foldable -------------------------------------- */

/* Drawn here, not downloaded: a dark body, a thin lit rim, true corner radii
   (elliptical percentages work out circular at each device's proportions).
   The screenshot inside is never touched; the camera housing lies over the
   status bar's own gap, as it does on the device. */
.phone,
.tablet,
.duo__slab {
  position: relative;
  background: linear-gradient(150deg, #33363d 0%, #121317 34%, #0b0c0f 66%, #24262c 100%);
  box-shadow:
    inset 0 0 0 1px rgb(255 255 255 / 0.2),
    inset 0 0 0 2px rgb(0 0 0 / 0.55),
    var(--device-shadow);
}

.phone {
  inline-size: 100%;
  padding: 2.9%;
  border-radius: 16.4% / 7.8%;
}

.phone img {
  inline-size: 100%;
  border-radius: 14.3% / 6.58%;
  background: var(--card);
}

/* A whole screen keeps the screen's shape before its picture arrives. A cut one (below) takes its shape from its
   own width and height attributes, so it holds its height from the first layout too. */
.phone:not(.phone--cut) img {
  aspect-ratio: 1320 / 2868;
}

/* If a picture cannot load, its description is set where the picture would be, in ink on the card colour. */
.phone img,
.tablet img,
.duo__slab img {
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--step--1);
  line-height: 1.4;
}

.phone::after {
  content: "";
  position: absolute;
  inset-block-start: 2.72%;
  inset-inline-start: 36.6%;
  inline-size: 26.8%;
  block-size: 3.62%;
  border-radius: 999px;
  background: #050506;
}

/* A screenshot cropped in the gap after a whole hadith: the frame ends at the
   picture's own edge and stands on a line, so nothing is painted in below. */
.phone--cut {
  padding-block-end: 0;
  border-end-start-radius: 0;
  border-end-end-radius: 0;
  border-radius: 16.4% 16.4% 0 0 / 9.1% 9.1% 0 0;
}

.phone--cut img {
  border-radius: 14.3% 14.3% 0 0 / 7.7% 7.7% 0 0;
}

.phone--cut::before {
  content: "";
  position: absolute;
  z-index: 1;
  inset-inline: -9%;
  inset-block-end: 0;
  block-size: 1px;
  background: var(--hairline);
}

.tablet {
  inline-size: 100%;
  padding: 2.2%;
  border-radius: 3.9% / 5.1%;
}

/* The iPad is never taller than the window (and never tiny in a short one). */
.pad .shot {
  inline-size: min(100%, max(22rem, calc((100vh - 9rem) * 1.3)));
  margin-inline: auto;
}

/* Under 48em the Quran on iPad (Side by Side) is a little over twice the window's width, in a sideways shelf of
   its own (critique F7). The shelf runs right to left in both languages (the device inside does not), so it starts
   at the screen's right half, where the Arabic column is, with the tablet's right edge in view and its left edge out
   of it; swiped to its other end, the English column. At 210 percent each column fits the window whole, so the two
   rest stops (the snap points are the tablet's two edges) never cut a verse or its translation. The verse rows of
   the capture run from 2.4 to 47.6 percent (English) and 56.8 to 97.7 percent (Arabic) of its width. Today and the
   Study Desk stay whole tablets. From 48em the wrapper does nothing. */
@media (max-width: 47.99em) {
  .pad__scroll {
    direction: rtl;
    margin-inline: calc(var(--gutter) * -1);
    padding-inline: var(--gutter);
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: var(--gutter);
    scrollbar-width: none;
  }

  .pad__scroll::-webkit-scrollbar {
    display: none;
  }

  .pad__scroll > .tablet {
    direction: ltr;
    inline-size: 210%;
  }

  .pad__scroll > .tablet::before,
  .pad__scroll > .tablet::after {
    content: "";
    position: absolute;
    inset-block: 0;
    inline-size: 1px;
    pointer-events: none;
  }

  .pad__scroll > .tablet::before {
    left: 0;
    scroll-snap-align: end;
  }

  .pad__scroll > .tablet::after {
    right: 0;
    scroll-snap-align: start;
  }

  .pad__scroll:focus-visible {
    outline: 2px solid var(--link);
    outline-offset: -2px;
  }

  /* The stage's drawn shadow is sized for a whole tablet in the window, so it stays out of the shelf, and the
     tablets are not stacked: the one chosen stands alone, so the shelf's taller iPad leaves no gap under the
     other two. */
  .pad__stage::before {
    display: none;
  }

  @supports selector(:has(a)) {
    .pad__stage > .shot {
      display: none;
    }

    .pad:has(#pad-parallel:checked) .pad__shot--parallel,
    .pad:has(#pad-desk:checked) .pad__shot--desk,
    .pad:has(#pad-today:checked) .pad__shot--today {
      display: grid;
    }

    .pad__stage :is(.pad__shot--today, .pad__shot--desk) .tablet {
      box-shadow:
        inset 0 0 0 1px rgb(255 255 255 / 0.2),
        inset 0 0 0 2px rgb(0 0 0 / 0.55),
        var(--device-shadow);
    }
  }
}

.tablet img {
  inline-size: 100%;
  aspect-ratio: 2752 / 2064;
  border-radius: 1.8% / 2.4%;
  background: var(--card);
}

/* The foldable. Without motion it is two drawings: closed, and open flat.
   Physical left and right on purpose: a device does not mirror with the language.

   The numbers are the device's own, in capture pixels. Each page of the inner screen is 1426 by 2007 with
   165 px corners on its two outer corners and none at the fold; the cover screen is 1398 by 2034 with 177 px
   corners on its outer side, 8 px on the hinge side, and a camera 120 px across centred at 1272, 150, above the
   clock. One half is 1 by 1.4235 with an even bezel of 2.72% of its width; on the cover the hinge side is the
   wider spine. Body corners are the screen's radius plus the bezel, so the two stay concentric. */
.duo {
  direction: ltr;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-areas:
    ". outer outer ."
    "left left right right";
  row-gap: var(--space-6);
  justify-items: stretch;
}

.duo__body,
.duo__cover {
  display: contents;
}

/* Each slab fills its own grid area, so its percentages (bezel, radii, camera) are of its own width.
   The lit rim is drawn on the three outer sides only: nothing is drawn along the fold. */
.duo__slab {
  aspect-ratio: 1 / 1.4235;
  background: #101114;      /* one flat tone, so the two halves read as one body when open */
  box-shadow: var(--device-shadow);
}

.duo__slab::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid rgb(255 255 255 / 0.2);
  border-radius: inherit;
  pointer-events: none;
}

.duo__slab picture,
.duo__slab img {
  inline-size: 100%;
  block-size: 100%;
}

.duo__slab img {
  background: var(--card);
}

/* The cover: flat and nearly square at the hinge, fully rounded on the outer side. */
.duo__slab--outer {
  grid-area: outer;
  padding: 2.72% 2.72% 2.72% 3.18%;
  border-radius: 1.6% 14.6% 14.6% 1.6% / 1.1% 10.3% 10.3% 1.1%;
}

.duo__slab--outer img {
  border-radius: 0.57% 12.66% 12.66% 0.57% / 0.39% 8.7% 8.7% 0.39%;
}

/* The hinge spine, along the cover's flat edge. */
.duo__slab--outer::before {
  content: "";
  position: absolute;
  inset-block: 0;
  left: 0;
  inline-size: 3.18%;
  border-radius: 50% 0 0 50% / 1.1% 0 0 1.1%;
  background: linear-gradient(to right, #4a4d55 0%, #1a1b20 45%, #08090b 100%);
}

/* The cover camera, in the gap the status column leaves above the clock. */
.duo__hole {
  position: absolute;
  inset-block-start: 6.09%;
  left: 84.76%;
  inline-size: 8.09%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, #16171c 0%, #050506 58%);
  box-shadow: 0 0 0 1px rgb(255 255 255 / 0.06);
}

/* The two pages meet flush; each one's shadow is cut off along the fold so it does not fall on the other. */
.duo__slab--left {
  grid-area: left;
  padding: 2.72% 0 2.72% 2.72%;
  border-radius: 14% 0 0 14% / 9.82% 0 0 9.82%;
  clip-path: inset(-8rem 0 -8rem -8rem);
}

.duo__slab--left::after {
  border-right: 0;
}

.duo__slab--left img {
  border-radius: 11.57% 0 0 11.57% / 8.22% 0 0 8.22%;
}

.duo__slab--right {
  grid-area: right;
  margin-left: -1px;      /* the right page runs a hair under the left, so no line of background shows at the fold */
  padding: 2.72% 2.72% 2.72% 0;
  border-radius: 0 14% 14% 0 / 0 9.82% 9.82% 0;
  clip-path: inset(-8rem -8rem -8rem -2px);
}

.duo__slab--right::after {
  border-left: 0;
}

.duo__slab--right img {
  border-radius: 0 11.57% 11.57% 0 / 0 8.22% 8.22% 0;
}

.duo__shade,
.duo__spine,
.duo__edge,
.duo__rim {
  display: none;
}

@media (min-width: 48em) {
  .duo {
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 0.16fr) minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "outer . left right";
    align-items: center;
    row-gap: 0;
  }
}

/* Said only where the foldable is a shelf, so a reader who does not swipe knows it opens. */
.fold__hint {
  display: none;
}

@media (max-width: 29.99em) {
  .fold__hint {
    display: inline;
  }
}

/* On a phone the foldable is a shelf of three stops, each as wide as the window allows, so the screens can be
   read: the closed device, then the open one a page at a time. A page reaches from one gutter to the far edge
   of the window, so at rest the fold lies exactly on that edge and no page is ever shown in part; the capture
   has nothing on the fold itself (see the manifest). Lengths come from the figure's own width (cqi). */
@media (max-width: 29.99em) {
  .fold__figure {
    container-type: inline-size;
  }

  .duo {
    --duo-page: calc(100cqi + var(--gutter));
    display: flex;
    align-items: center;
    margin-inline: calc(-1 * var(--gutter));
    padding-block: var(--space-3) var(--space-6);
    padding-left: var(--gutter);
    padding-right: calc(var(--gutter) - 1px);
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }

  .duo::-webkit-scrollbar {
    display: none;
  }

  .duo:focus-visible {
    outline-offset: -4px;
  }

  .duo__slab {
    flex: 0 0 auto;
    inline-size: var(--duo-page);
    margin: 0;
    scroll-snap-align: start;
  }

  /* The closed device stands in the middle of the window, a gutter narrower than a page, so that only the
     edge of the open device's body shows beside it, and only the edge of its own beside the open one. */
  .duo__slab--outer {
    inline-size: calc(var(--duo-page) - var(--gutter));
    margin-right: calc(var(--gutter) - var(--duo-page) * 0.02);
    scroll-snap-align: center;
  }

  .duo__slab--left {
    order: 1;
    scroll-margin-left: var(--gutter);
  }

  .duo__slab--right {
    order: 2;
    margin-left: -1px;
    scroll-margin-left: -1px;
  }
}

/* 7. Figures, captions and the shelf ---------------------------------------- */

.shot {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  row-gap: var(--space-5);      /* the caption starts clear of the device's shadow */
}

.shot__caption {
  color: var(--caption);
  font-family: var(--sans);
  font-size: var(--step--1);
  line-height: 1.45;
}

/* Says plainly that a screen was captured in the other language's interface. */
.shot__lang {
  display: inline-block;
  padding: 0 0.6em;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  white-space: nowrap;
}

/* The shelf: screens in a row, moved by the reader's own finger, keys or trackpad. A screen is never shown in
   part: at rest the window holds whole screens only (one, or two from 37.5em), and all that shows of the next
   is the edge of its device, a sliver thinner than the bezel, so no line of a capture is ever seen cut. Each
   caption carries a count ("2 / 6"). Lengths come from the shelf's own width (cqi), so a scroll bar or a
   narrow column cannot let a screen slip into view. */
.shelf {
  container-type: inline-size;
  display: flex;
  margin-inline: calc(-1 * var(--gutter));
  padding-block: var(--space-3) var(--space-8);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.shelf::-webkit-scrollbar {
  display: none;
}

.shelf > * {
  --item: min(72cqi, var(--phone), calc((100vh - 3rem) * 0.4756));
  --peek: calc(var(--item) * 0.02);
  --pad: calc((100cqi - var(--item)) / 2);
  flex: 0 0 auto;
  inline-size: min(72vw, var(--phone));      /* where there are no container units: one screen, no neighbour */
  inline-size: var(--item);
  margin-inline-end: 100vw;
  margin-inline-end: calc(var(--pad) - var(--peek));
  scroll-snap-align: center;
}

/* In a short window (a phone on its side) a screen is never taller than the window either: the phone is sized
   so the whole of it can be in view at once. */
@supports (block-size: 100svh) {
  .shelf > * {
    --item: min(72cqi, var(--phone), calc((100svh - 3rem) * 0.4756));
  }
}

/* A caption keeps inside its device's edges, so the next screen's caption does not show beside the sliver. */
.shelf > .shot > figcaption {
  padding-inline: 0.75rem;
}

.shelf > :first-child,
.themes__plate + .shot {
  margin-inline-start: 14vw;
  margin-inline-start: var(--pad);
}

.shelf > :last-child {
  margin-inline-end: 14vw;
  margin-inline-end: var(--pad);
}

@media (min-width: 37.5em) {
  .shelf > * {
    --pad: calc((100cqi - 2 * var(--item) + var(--peek)) / 3);
    scroll-snap-align: start;
    scroll-margin-inline-start: var(--pad);
  }
}

/* A phone held sideways: the screens are sized from the window's height, so three stand in a row, not two far apart. */
@media (min-width: 37.5em) and (max-height: 29.99em) {
  .shelf > * {
    --pad: calc((100cqi - 3 * var(--item) + 2 * var(--peek)) / 4);
  }
}

.shelf:focus-visible {
  outline-offset: -4px;
}

/* The count under each screen of a shelf. Only the screen's own number is a counter; the total is written in
   (--shots), because a shelf is a size container, and WebKit keeps a counter set on a container from the
   elements inside it ("1 / 0"). The count is drawn on every shelf that sets --shots, and only there: where it is
   not set (shelf--1) the content below is invalid, so no count is drawn. A new total needs only its two lines. */
.shelf--2 { --shots: "2"; }
.shelf--3 { --shots: "3"; }
.shelf--4 { --shots: "4"; }
.shelf--5 { --shots: "5"; }
.shelf--6 { --shots: "6"; }

html:lang(ar) .shelf--2 { --shots: "٢"; }
html:lang(ar) .shelf--3 { --shots: "٣"; }
html:lang(ar) .shelf--4 { --shots: "٤"; }
html:lang(ar) .shelf--5 { --shots: "٥"; }
html:lang(ar) .shelf--6 { --shots: "٦"; }

.shelf {
  counter-reset: shot 0;
}

.shelf > .shot {
  counter-increment: shot;
}

.shelf > .shot > figcaption::before {
  content: counter(shot) " / " var(--shots);
  display: block;
  margin-block-end: 0.25rem;
  font-family: var(--sans);
  font-size: var(--step--1);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

html:lang(ar) .shelf > .shot > figcaption::before {
  content: counter(shot, arabic-indic) " / " var(--shots);
  letter-spacing: 0;
}

/* 8. The sky (home page opening) -------------------------------------------- */

/* Without motion this is one still dawn: the headline, then the Today screen
   at each stage of the day on a shelf. Cream on the sky passes 4.5:1 down to
   the mauve; the last stretch, where it pales to the page, is kept clear of text. */
.sky {
  --phone-h: clamp(20rem, calc(100vh - 7rem), 42rem);
  --phone-w: calc(var(--phone-h) * 0.4756);
  position: relative;
  padding-block-end: 9rem;
  background: linear-gradient(
    to bottom,
    #141C3A 0,
    #1D2447 16rem,
    #272B57 28rem,
    #3D3662 calc(100% - 20rem),
    #503F68 calc(100% - 9rem),
    #7F657E calc(100% - 5rem),
    #BCA8AE calc(100% - 2rem),
    var(--page) 100%
  );
  color: var(--on-sky);
}

@supports (block-size: 100svh) {
  .sky {
    --phone-h: clamp(20rem, calc(100svh - 7rem), 42rem);
  }
}

@media (min-width: 60em) {
  .sky {
    --phone-h: clamp(20rem, calc(100vh - 9rem), 50rem);
  }

  @supports (block-size: 100svh) {
    .sky {
      --phone-h: clamp(20rem, calc(100svh - 9rem), 50rem);
    }
  }
}

@media (prefers-color-scheme: dark) {
  .sky {
    background: linear-gradient(
      to bottom,
      #141C3A 0,
      #1D2447 16rem,
      #272B57 28rem,
      #3D3662 calc(100% - 20rem),
      #453A62 calc(100% - 9rem),
      #2C2944 calc(100% - 4rem),
      var(--page) 100%
    );
  }
}

.sky__bg {
  display: none;
}

.sky__intro {
  position: relative;
  padding-block-start: calc(var(--header) + clamp(1rem, 3.5vh, 2.75rem));
  text-align: center;
}

/* The line is the page's h1: one bold sentence, one quiet one. */
.sky__title {
  font-size: min(3.25rem, calc((100vw - 2 * var(--gutter)) / 7.9));
  line-height: 1.04;
  letter-spacing: -0.022em;
}

.sky__line {
  display: block;
}

.sky__line--quiet {
  font-weight: 400;
}

@media (min-width: 48em) {
  /* From here the bold sentence holds one line, in Georgia as well as New York. */
  .sky__title {
    font-size: min(4.75rem, 10.5vh, calc((100vw - 2 * var(--gutter)) / 14.4));
  }

  .sky__line {
    white-space: nowrap;
  }
}

.sky__note {
  max-inline-size: 31rem;
  margin-block-start: clamp(0.75rem, 2vh, 1.25rem);
  margin-inline: auto;
  font-family: var(--sans);
  font-size: var(--step-0);
  line-height: 1.5;
  text-wrap: balance;
}

.sky__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-2) var(--space-5);
  margin-block-start: clamp(1rem, 2.4vh, 1.5rem);
  font-family: var(--sans);
}

/* A statement, not a control: the store button's place before launch. */
.sky__status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-block-size: 2.75rem;
  font-size: 0.9375rem;
}

/* On launch day the statement becomes the store link. */
a.sky__status {
  color: var(--on-sky);
  text-underline-offset: 0.3em;
}

.sky__status::before,
.get__soon::before {
  content: "";
  flex: none;
  inline-size: 0.4375rem;
  block-size: 0.4375rem;
  border: 1.5px solid currentColor;
  transform: rotate(45deg);
}

.sky__day {
  position: relative;
  margin-block-start: clamp(1.5rem, 4vh, 2.75rem);
}

/* One quiet line that says why the city changes from screen to screen. */
.sky__key {
  max-inline-size: 22rem;
  margin-inline: auto;
  font-family: var(--sans);
  font-size: 0.9375rem;
  line-height: 1.4;
  text-align: center;
  text-wrap: balance;
}

.sky__stage {
  position: relative;
  margin-block-start: var(--space-4);
}

.sky__stage.shelf {
  padding-block-end: var(--space-5);
}

/* Until its picture arrives, each screen is its own sky's colour, not a blank card. */
.sky__frame:nth-child(1) img { background: #272B57; }
.sky__frame:nth-child(2) img { background: #225384; }
.sky__frame:nth-child(3) img { background: #1B5489; }
.sky__frame:nth-child(4) img { background: #283761; }
.sky__frame:nth-child(5) img { background: #422E59; }
.sky__frame:nth-child(6) img { background: #0D1632; }

.sky__frame img {
  color: var(--on-sky);
}

/* Without motion, wide: the six screens stand in two rows of three, so the whole day is in view. */
@media (min-width: 60em) {
  .sky__stage.shelf {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, var(--phone)));
    justify-content: center;
    gap: var(--space-7) clamp(2rem, 6vw, 5rem);
    margin-inline: 0;
    padding-block-start: var(--space-5);
    overflow: visible;
  }
}

.sky__label {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  column-gap: 0.4em;
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.3;
  text-align: center;
}

.sky__label::before {
  flex: 0 0 100%;
}

.sky__when {
  font-family: var(--serif);
  font-size: var(--step-1);
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* A few stars, as on the app's own night sky. They belong to the night stages, so they come and go with them,
   and they keep clear of the band where small text sits. */
.sky::before,
.get::before,
.sky__bg > :is(.sky--fajr, .sky--maghrib, .sky--isha)::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 33.4% 7.1%, rgb(243 238 226 / 0.3) 0, rgb(243 238 226 / 0.3) 0.5px, transparent 1.2px),
    radial-gradient(circle at 80.2% 5.5%, rgb(243 238 226 / 0.8) 0, rgb(243 238 226 / 0.8) 0.5px, transparent 1.2px),
    radial-gradient(circle at 88.5% 8.8%, rgb(243 238 226 / 0.3) 0, rgb(243 238 226 / 0.3) 0.75px, transparent 1.45px),
    radial-gradient(circle at 42.3% 9.5%, rgb(243 238 226 / 0.8) 0, rgb(243 238 226 / 0.8) 0.75px, transparent 1.45px),
    radial-gradient(circle at 8.6% 18.3%, rgb(243 238 226 / 0.4) 0, rgb(243 238 226 / 0.4) 0.9px, transparent 1.6px),
    radial-gradient(circle at 92.1% 18.6%, rgb(243 238 226 / 0.65) 0, rgb(243 238 226 / 0.65) 0.5px, transparent 1.2px),
    radial-gradient(circle at 94.8% 4.3%, rgb(243 238 226 / 0.4) 0, rgb(243 238 226 / 0.4) 0.6px, transparent 1.2999999999999998px),
    radial-gradient(circle at 42.4% 17.6%, rgb(243 238 226 / 0.8) 0, rgb(243 238 226 / 0.8) 0.6px, transparent 1.2999999999999998px),
    radial-gradient(circle at 55.7% 21.4%, rgb(243 238 226 / 0.3) 0, rgb(243 238 226 / 0.3) 0.9px, transparent 1.6px),
    radial-gradient(circle at 56.7% 8.1%, rgb(243 238 226 / 0.3) 0, rgb(243 238 226 / 0.3) 0.9px, transparent 1.6px),
    radial-gradient(circle at 69.9% 18.2%, rgb(243 238 226 / 0.8) 0, rgb(243 238 226 / 0.8) 0.6px, transparent 1.2999999999999998px),
    radial-gradient(circle at 49.7% 17.4%, rgb(243 238 226 / 0.5) 0, rgb(243 238 226 / 0.5) 0.75px, transparent 1.45px),
    radial-gradient(circle at 58.0% 15.2%, rgb(243 238 226 / 0.5) 0, rgb(243 238 226 / 0.5) 0.6px, transparent 1.2999999999999998px),
    radial-gradient(circle at 77.7% 62.9%, rgb(243 238 226 / 0.4) 0, rgb(243 238 226 / 0.4) 0.5px, transparent 1.2px),
    radial-gradient(circle at 57.0% 61.7%, rgb(243 238 226 / 0.5) 0, rgb(243 238 226 / 0.5) 0.75px, transparent 1.45px),
    radial-gradient(circle at 30.1% 64.9%, rgb(243 238 226 / 0.3) 0, rgb(243 238 226 / 0.3) 0.9px, transparent 1.6px),
    radial-gradient(circle at 42.3% 63.3%, rgb(243 238 226 / 0.4) 0, rgb(243 238 226 / 0.4) 0.75px, transparent 1.45px),
    radial-gradient(circle at 42.6% 64.7%, rgb(243 238 226 / 0.3) 0, rgb(243 238 226 / 0.3) 0.9px, transparent 1.6px);
  pointer-events: none;
}

.sky__bg > .sky--maghrib::before {
  opacity: 0.5;
}

/* None in the header's row, where a star beside a word of the nav reads as a stray comma. */
.sky::before {
  inset-block-start: var(--header);
}

@media screen and (min-height: 30em) and (min-width: 60em) {
  html.motion .sky__bg > :is(.sky--fajr, .sky--maghrib, .sky--isha)::before {
    inset-block-start: var(--header);
  }
}

/* Narrow, with motion, the time of day and the key stand above the phone near the top of the window: no star
   above the phone's top edge, so none sits on a word (or in the header's row). */
@media screen and (min-height: 30em) and (max-width: 59.99em) {
  html.motion .sky__bg > :is(.sky--fajr, .sky--maghrib, .sky--isha)::before {
    --clear: calc(max(0.5rem, (100vh - var(--phone-h) - var(--label-h) - var(--key-h)) / 2) + var(--label-h) + var(--key-h) + 1rem);
    -webkit-mask-image: linear-gradient(to bottom, transparent var(--clear), #000 calc(var(--clear) + 1.5rem));
    mask-image: linear-gradient(to bottom, transparent var(--clear), #000 calc(var(--clear) + 1.5rem));
  }
}

/* 9. Sections, promises ------------------------------------------------------ */

.section {
  padding-block: var(--section);
}

.section--tint {
  background: var(--card);
}

.section__head {
  max-inline-size: 40rem;
  margin-block-end: var(--space-7);
}

.section__title {
  font-size: var(--step-3);
}

.section__lede {
  max-inline-size: var(--measure);
  margin-block-start: var(--space-4);
  font-size: var(--step-1);
  line-height: 1.45;
}

/* A quiet label with the lozenge that ends a surah in the app. Never uppercase. */
.eyebrow {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--gold);
  font-family: var(--sans);
  font-size: var(--step-1);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.005em;
}

.eyebrow::before {
  content: "";
  flex: none;
  inline-size: 0.5rem;
  block-size: 0.5rem;
  border: 1.5px solid currentColor;
  transform: rotate(45deg);
}

.section__more {
  margin-block-start: var(--space-6);
  font-family: var(--sans);
  font-size: 1rem;
}

/* A link that stands alone gets a full 44 px target, however short its word. */
.section__more a,
.standalone-link {
  display: inline-flex;
  align-items: center;
  min-block-size: 2.75rem;
  min-inline-size: 2.75rem;
}

.promises-band {
  padding-block-start: clamp(3.5rem, 2.5rem + 4.5vw, 6.5rem);
}

.promises-band .section__head {
  margin-block-end: var(--space-6);
}

/* Three promises, as three equal columns once there is room. */
.promises {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  margin: 0;
  padding: 0;
  list-style: none;
}

.promise {
  padding-block: var(--space-5);
  border-block-start: 1px solid var(--hairline);
}

.promise__title {
  font-size: clamp(1.3125rem, 1.05rem + 0.6vw, 1.625rem);
  line-height: 1.2;
}

.promise__body {
  max-inline-size: var(--measure);
  margin-block-start: var(--space-3);
}

@media (min-width: 56em) {
  .promises {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: var(--space-7);
  }

  .promise {
    padding-block: var(--space-5) 0;
    border-block-start: 1px solid var(--ink);
  }

  .promise__title {
    min-block-size: 2.4em;      /* two lines, so the three bodies start level */
  }
}

/* 10. Chapters: Prayer, Quran, Hadith ---------------------------------------- */

.inside {
  padding-block: 0 var(--section);
}

.inside__head {
  padding-block-end: var(--space-2);
}

.chapter {
  padding-block-start: clamp(3rem, 2rem + 5vw, 6rem);
}

.chapter + .chapter {
  margin-block-start: clamp(3rem, 2rem + 5vw, 6rem);
  border-block-start: 1px solid var(--hairline);
}

.chapter__title {
  font-size: var(--step-4);
  line-height: 1;
  letter-spacing: -0.025em;
}

.chapter__stage {
  margin-block-start: var(--space-5);
}

.steps {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  row-gap: var(--space-5);
  margin: 0;
  padding: 0;
  list-style: none;
}

.step {
  max-inline-size: var(--measure);
  padding-inline-start: 1.625rem;
}

/* The lozenge again; it fills while its screen is the one showing. */
.step__term::before,
.step__term::after,
.points > li::before {
  content: "";
  position: absolute;
  inset-inline-start: 0.125rem;
  inset-block-start: 0.5em;
  inline-size: 0.4375rem;
  block-size: 0.4375rem;
  border: 1.5px solid var(--gold);
  transform: rotate(45deg);
}

.step__term::before,
.step__term::after {
  inset-inline-start: -1.5rem;
}

.step__term::after {
  background: var(--gold);
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}

/* The step whose screen is showing: beside a pinned phone, or the screen swiped to on a phone's shelf. */
.steps > .step.is-now > .step__term::after {
  opacity: 1;
}

/* A title is one run of text (a span inside it, such as .nb, must not split it into pieces with gaps between),
   and the Plus badge sits in that run, a little more than a word space after the last word. */
.step__term {
  position: relative;
  display: block;
  font-family: var(--sans);
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.4;
}

.step__term .badge {
  margin-inline-start: 0.25rem;
}

.step__text {
  display: block;
  margin-block-start: 0.125rem;
}

.step__more {
  display: grid;
  row-gap: var(--space-4);
  margin: var(--space-5) 0 0;
  padding: 0;
  list-style: none;
}

.step__more .step__term {
  font-size: 1rem;
}

.chapter__more {
  margin-block-start: var(--space-5);
}

/* Without motion, wide: the words in two columns, then every screen in a row. */
@media (min-width: 60em) {
  .chapter__stage.shelf {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(0, var(--phone)));
    gap: var(--space-7) var(--space-6);
    margin-inline: 0;
    padding: var(--space-6) 0 0;
    overflow: visible;
  }

  /* In a row or a grid every screen is in view at once: no shelf spacing and no count. */
  :is(.chapter__stage, .sky__stage).shelf > * {
    inline-size: auto;
    margin-inline: 0;
  }

  :is(.chapter__stage, .sky__stage).shelf > .shot > figcaption::before {
    content: none;
  }

  :is(.chapter__stage, .sky__stage).shelf > .shot > figcaption {
    padding-inline: 0;
  }

  .steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: var(--space-7);
    margin-block-start: var(--space-7);
  }
}

/* A chapter with a single screen (until its second capture arrives), wherever its phone does not hold its
   place: the phone stands beside the points instead of at the start of an empty row. */
@media (min-width: 37.5em) and (max-width: 59.99em) {
  .chapter:has(> .shelf--1) {
    display: grid;
    grid-template-columns: min(var(--phone), 42%) minmax(0, 1fr);
    column-gap: var(--space-7);
  }

  .chapter:has(> .shelf--1) > .chapter__head {
    grid-column: 1 / -1;
  }

  .chapter:has(> .shelf--1) > .chapter__stage {
    grid-column: 1;
    grid-row: 2 / span 2;      /* the phone's extra height is shared by the two rows, so the points and the link, as one group, are centred on it */
    display: block;
    margin: var(--space-6) 0 0;
    padding: 0 0 var(--space-5);
    overflow: visible;
  }

  .chapter:has(> .shelf--1) > .chapter__stage > .shot {
    inline-size: auto;
    margin: 0;
  }

  .chapter:has(> .shelf--1) > .chapter__stage > .shot > figcaption {
    padding-inline: 0;
  }

  .chapter:has(> .shelf--1) > .steps {
    grid-column: 2;
    grid-row: 2;
    align-self: end;
    grid-template-columns: minmax(0, 1fr);
    margin-block-start: var(--space-6);
  }

  .chapter:has(> .shelf--1) > .chapter__more {
    grid-column: 2;
    grid-row: 3;
    align-self: start;
  }
}

@media (min-width: 60em) {
  html:not(.motion) .chapter:has(> .shelf--1) {
    display: grid;
    grid-template-columns: var(--phone) minmax(0, 1fr);
    column-gap: var(--space-8);
  }

  html:not(.motion) .chapter:has(> .shelf--1) > .chapter__head {
    grid-column: 1 / -1;
  }

  html:not(.motion) .chapter:has(> .shelf--1) > .chapter__stage {
    grid-column: 1;
    grid-row: 2 / span 2;      /* the phone's extra height is shared by the two rows, so the points and the link, as one group, are centred on it */
    display: block;
    margin: var(--space-6) 0 0;
    padding: 0 0 var(--space-5);
  }

  html:not(.motion) .chapter:has(> .shelf--1) > .chapter__stage > .shot {
    margin: 0;
  }

  html:not(.motion) .chapter:has(> .shelf--1) > .steps {
    grid-column: 2;
    grid-row: 2;
    align-self: end;
    grid-template-columns: minmax(0, 1fr);
    margin-block-start: var(--space-6);
  }

  html:not(.motion) .chapter:has(> .shelf--1) > .chapter__more {
    grid-column: 2;
    grid-row: 3;
    align-self: start;
  }
}

/* 11. Themes ------------------------------------------------------------------ */

/* On a phone the picker sits under the picture it changes; from 60em the words and the picker stand beside it. */
.themes__inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  row-gap: var(--space-6);
}

.themes .section__head {
  margin-block-end: 0;
}

.themes__figure {
  order: 1;
}

.swatches {
  order: 2;
}

/* Until the browser can tie the picker to the picture (:has), the picker is
   left out and the five pages stand side by side instead. */
.swatches {
  display: none;
}

.themes__plate {
  display: none;
}

.themes__note {
  color: var(--muted);
  font-family: var(--sans);
  font-size: var(--step--1);
  line-height: 1.45;
}

@supports selector(:has(a)) {
  .swatches {
    display: flex;
    justify-content: space-between;
    justify-self: center;
    inline-size: min(100%, 23rem);
  }

  .swatches__legend {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .swatches__input {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    opacity: 0;
    pointer-events: none;
    scroll-margin-block: 8rem;      /* a swatch reached by keyboard comes fully into view */
  }

  .swatches__label {
    display: grid;
    justify-items: center;
    align-content: start;
    row-gap: 0.5rem;
    min-block-size: 2.75rem;
    min-inline-size: 2.75rem;
    padding: 0.375rem 0.125rem;
    white-space: nowrap;
    border-radius: 0.75rem;
    color: var(--muted);
    font-family: var(--sans);
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.2;
    text-align: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  /* The chip is a small page: the theme's paper, two lines of its ink, its gold. */
  .swatches__chip {
    position: relative;
    inline-size: 2.5rem;
    block-size: 3.125rem;
    border-radius: 0.5rem;
    background:
      linear-gradient(var(--chip-gold), var(--chip-gold)) 70% 78% / 0.3125rem 0.3125rem no-repeat,
      linear-gradient(var(--chip-ink), var(--chip-ink)) 50% 30% / 60% 0.1875rem no-repeat,
      linear-gradient(var(--chip-ink), var(--chip-ink)) 50% 48% / 60% 0.1875rem no-repeat,
      var(--chip-page);
    box-shadow: 0 0 0 1px rgb(127 127 127 / 0.35);
  }

  .swatches__chip::after {
    content: "";
    position: absolute;
    inset: -0.3125rem;
    border: 2px solid var(--gold);
    border-radius: 0.75rem;
    opacity: 0;
    transition: opacity 0.25s var(--ease);
  }

  .swatches__label--paper { --chip-page: #FBF8F1; --chip-ink: #101B2D; --chip-gold: #825C15; }

  /* Paper follows the device, so in dark appearance its chip and its plate are the dark paper. */
  @media (prefers-color-scheme: dark) {
    .swatches__label--paper { --chip-page: #0F1622; --chip-ink: #F3EEE2; --chip-gold: #D9B36A; }
  }
  .swatches__label--sepia { --chip-page: #F3EAD6; --chip-ink: #3A2A1C; --chip-gold: #775010; }
  .swatches__label--sand { --chip-page: #EEEBE5; --chip-ink: #1F1D1A; --chip-gold: #765513; }
  .swatches__label--night { --chip-page: #161D2B; --chip-ink: #DAD4C6; --chip-gold: #D4AE66; }
  .swatches__label--black { --chip-page: #000000; --chip-ink: #E6E1D5; --chip-gold: #D9B36A; }

  .swatches__input:checked + .swatches__label {
    color: var(--ink);
    font-weight: 600;
  }

  .swatches__input:checked + .swatches__label .swatches__chip::after {
    opacity: 1;
  }

  .swatches__input:focus-visible + .swatches__label {
    outline: 2px solid var(--link);
    outline-offset: 2px;
  }

  /* One phone on a plate that takes the chosen paper's colour. */
  .themes__stage.shelf {
    position: relative;
    display: grid;
    justify-items: center;
    margin-inline: 0;
    padding: clamp(2rem, 6vw, 4rem) var(--space-5);
    overflow: hidden;
    border-radius: var(--radius-l);
    scroll-snap-type: none;
  }

  .themes__stage.shelf > * {
    margin: 0;
  }

  .themes__stage.shelf > .shot > figcaption::before {
    content: none;
  }

  .themes__plate {
    display: block;
  }

  .themes__plate,
  .themes__plate > span {
    position: absolute;
    inset: 0;
    inline-size: auto;
  }

  .themes__plate > span {
    opacity: 0;
    transition: opacity 0.6s var(--ease);
  }

  /* Each theme's own page colour, from the app. */
  .themes__plate > span:nth-child(1) { background: #FBF8F1; opacity: 1; }
  .themes__plate > span:nth-child(2) { background: #F3EAD6; }
  .themes__plate > span:nth-child(3) { background: #EEEBE5; }
  .themes__plate > span:nth-child(4) { background: #161D2B; }
  .themes__plate > span:nth-child(5) { background: #000000; }

  @media (prefers-color-scheme: dark) {
    .themes__plate > span:nth-child(1) { background: #0F1622; }
  }

  .themes__stage > .shot {
    position: relative;
    grid-area: 1 / 1;
    inline-size: min(100%, var(--theme-phone, var(--phone)));
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.6s var(--ease), visibility 0s 0.6s;
  }

  .themes__stage > .shot .shot__caption {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  /* Only the shown phone casts a shadow, so five stacked ones do not add up. */
  .themes__stage .phone {
    box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.2), inset 0 0 0 2px rgb(0 0 0 / 0.55);
  }

  .themes__stage::after {
    content: "";
    grid-area: 1 / 1;
    align-self: start;
    inline-size: min(100%, var(--theme-phone, var(--phone)));
    position: relative;
    aspect-ratio: 1 / 2.1024;
    border-radius: 16.4% / 7.8%;
    box-shadow: 0 22px 44px -18px rgb(0 0 0 / 0.45), 0 52px 80px -44px rgb(0 0 0 / 0.45);
    pointer-events: none;
  }

  .themes:has(#theme-paper:checked) .themes__shot--paper,
  .themes:has(#theme-sepia:checked) .themes__shot--sepia,
  .themes:has(#theme-sand:checked) .themes__shot--sand,
  .themes:has(#theme-night:checked) .themes__shot--night,
  .themes:has(#theme-black:checked) .themes__shot--black {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.6s var(--ease), visibility 0s;
  }

  .themes:has(#theme-sepia:checked) .themes__plate > span:nth-child(2),
  .themes:has(#theme-sand:checked) .themes__plate > span:nth-child(3),
  .themes:has(#theme-night:checked) .themes__plate > span:nth-child(4),
  .themes:has(#theme-black:checked) .themes__plate > span:nth-child(5) {
    opacity: 1;
  }
}

/* On a phone held sideways the plate's phone fits the window's height, as the shelves' phones do. */
@media (max-height: 29.99em) {
  .themes {
    --theme-phone: min(var(--phone), calc((100vh - 3rem) * 0.4756));
  }

  @supports (block-size: 100svh) {
    .themes {
      --theme-phone: min(var(--phone), calc((100svh - 3rem) * 0.4756));
    }
  }

  @supports selector(:has(a)) {
    .themes__stage.shelf {
      padding-block: 0.75rem;
    }
  }
}

@media (min-width: 60em) {
  /* Beside the words the phone is sized from the window, like the chapters' phone: as large as theirs in a tall
     window, and small enough in a short one (a laptop with its browser bars) that the whole plate is in view. */
  .themes {
    --theme-phone: clamp(13rem, calc((100vh - 9.5rem) * 0.4756), 21rem);
  }

  @supports (block-size: 100svh) {
    .themes {
      --theme-phone: clamp(13rem, calc((100svh - 9.5rem) * 0.4756), 21rem);
    }
  }

  @supports selector(:has(a)) {
    .themes__stage.shelf {
      padding-block: clamp(1.5rem, 4vh, 4rem);
    }
  }

  .themes__inner {
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    grid-template-rows: 1fr 1fr;
    column-gap: var(--space-8);
    row-gap: var(--space-6);
  }

  .themes__head {
    grid-area: 1 / 1;
    align-self: end;
  }

  .swatches {
    grid-area: 2 / 1;
    align-self: start;
    justify-self: start;
    margin-inline-start: -0.375rem;
  }

  .themes__figure {
    grid-area: 1 / 2 / 3 / 3;
    align-self: center;
  }
}

/* 12. On every screen: foldable, iPad, languages ------------------------------- */

.screens {
  padding-block-end: 0;
}

.fold {
  padding-block: var(--space-6) var(--space-8);
}

.fold__figure,
.pad {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  row-gap: var(--space-5);
}

.fold__figure .shot__caption,
.pad .shot__caption {
  max-inline-size: var(--measure);
}

.pad .shot__caption {
  margin-inline: auto;
  text-align: center;
}

.pad {
  padding-block-end: var(--section);
}

.pad__stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  row-gap: var(--space-8);
}

.segmented {
  display: none;
}

@supports selector(:has(a)) {
  /* The app's own segmented control, for choosing which iPad layout to look at. */
  .segmented {
    display: inline-flex;
    justify-self: center;
    max-inline-size: 100%;
    padding: 0.25rem;
    border-radius: 999px;
    background: var(--card);
    box-shadow: inset 0 0 0 1px var(--hairline);
    font-family: var(--sans);
    font-size: 0.9375rem;
    font-weight: 500;
    line-height: 1.2;
  }

  .segmented__legend {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .segmented__input {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    opacity: 0;
    pointer-events: none;
  }

  .segmented__label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-block-size: 2.75rem;
    padding-inline: clamp(0.75rem, 3.2vw, 1.25rem);
    border-radius: 999px;
    color: var(--muted);
    text-align: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  @media (max-width: 23.99em) {
    .segmented {
      font-size: 0.8125rem;
    }

    .segmented__label {
      padding-inline: 0.625rem;
    }
  }

  .segmented__input:checked + .segmented__label {
    background: var(--ink);
    color: var(--page);
    font-weight: 600;
  }

  .segmented__input:focus-visible + .segmented__label {
    outline: 2px solid var(--link);
    outline-offset: 2px;
  }

  .pad__stage {
    row-gap: 0;
  }

  /* Two different screens are never shown together: the screen that leaves goes dark first (0.12 s), then the
     new one comes up (0.18 s). The frame itself does not move; its shadow is drawn once, by the stage. */
  .pad__stage > .shot {
    grid-area: 1 / 1;
    visibility: hidden;
    transition: visibility 0s 0.12s;
  }

  .pad__stage .tablet {
    box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.2), inset 0 0 0 2px rgb(0 0 0 / 0.55);
  }

  /* Between two screens the tablet shows blank paper for a moment, not its dark body. */
  .pad__stage .tablet picture {
    border-radius: 1.8% / 2.4%;
    background: var(--card);
  }

  .pad__stage::before {
    content: "";
    grid-area: 1 / 1;
    align-self: start;
    justify-self: center;
    inline-size: min(100%, max(22rem, calc((100vh - 9rem) * 1.3)));
    aspect-ratio: 1 / 0.761;
    border-radius: 3.9% / 5.1%;
    box-shadow: var(--device-shadow);
    pointer-events: none;
  }

  .pad__stage > .shot :is(img, .shot__caption) {
    opacity: 0;
    transition: opacity 0.12s linear;
  }

  .pad:has(#pad-parallel:checked) .pad__shot--parallel,
  .pad:has(#pad-desk:checked) .pad__shot--desk,
  .pad:has(#pad-today:checked) .pad__shot--today {
    visibility: visible;
    transition: visibility 0s;
  }

  .pad:has(#pad-parallel:checked) .pad__shot--parallel :is(img, .shot__caption),
  .pad:has(#pad-desk:checked) .pad__shot--desk :is(img, .shot__caption),
  .pad:has(#pad-today:checked) .pad__shot--today :is(img, .shot__caption) {
    opacity: 1;
    transition: opacity 0.18s var(--ease) 0.12s;
  }
}

/* Devices, languages, text size, appearance: four points beside two phones. */
.everywhere {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  row-gap: var(--space-7);
  padding-block: var(--section);
  border-block-start: 1px solid var(--hairline);
}

.points {
  display: grid;
  row-gap: var(--space-5);
  margin: 0;
  padding: 0;
  list-style: none;
}

.points > li {
  position: relative;
  max-inline-size: var(--measure);
  padding-inline-start: 1.625rem;
}

.points__term {
  display: block;
  font-family: var(--sans);
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.4;
}

.points__text {
  display: block;
  margin-block-start: 0.125rem;
}

.points--plain {
  row-gap: var(--space-2);
}

.points--plain > li::before {
  inset-block-start: 0.62em;
}

/* Two phones side by side, whole: English in light appearance, Arabic in dark, the second standing a step lower. */
.pair__phones {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: clamp(0.75rem, 4vw, 2rem);
  align-items: start;
  max-inline-size: 33rem;
  margin-inline: auto;
}

.pair__phones > .phone:last-child {
  margin-block-start: 16%;
}

.pair .shot__caption {
  margin-block-start: var(--space-6);
  text-align: center;
}

@media (min-width: 60em) {
  .everywhere {
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    column-gap: var(--space-8);
    align-items: center;
  }
}

/* 13. Card, badge, button ------------------------------------------------------- */

/* A card sets one self-contained thing apart from the reading flow. */
.card {
  display: flex;
  flex-direction: column;
  padding: clamp(1.5rem, 1rem + 2.4vw, 2.75rem);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-l);
  background: var(--card);
}

.section--tint .card {
  background: var(--page);
}

.card__title {
  font-size: var(--step-2);
}

.card__lede {
  margin-block: var(--space-3) var(--space-5);
  font-size: var(--step-1);
  line-height: 1.4;
}

.card > .points {
  margin-block-end: var(--space-6);
}

.card__foot {
  margin-block-start: auto;
  padding-block-start: var(--space-5);
  border-block-start: 1px solid var(--hairline);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.5;
}

.card__foot > * + * {
  margin-block-start: var(--space-3);
}

.card__fine {
  color: var(--muted);
}

/* The Plus card carries the gold hairline. */
.card--plus {
  border-color: color-mix(in srgb, var(--gold) 55%, var(--hairline));
}

/* The three prices, as a small ledger. */
.prices__label {
  color: var(--muted);
  font-size: var(--step--1);
  font-weight: 600;
}

.prices {
  margin: 0;
}

.card__foot > .prices {
  margin-block-start: var(--space-1);
}

.prices > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  column-gap: var(--space-4);
  padding-block: 0.5rem;
  border-block-end: 1px solid var(--hairline);
}

.prices > div:last-child {
  border-block-end: 0;
}

.prices dd {
  margin: 0;
  color: var(--ink);
  font-size: 1.0625rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: end;
  white-space: nowrap;
}

.card-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-5);
}

@media (min-width: 48em) {
  .card-pair {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

.badge {
  display: inline-block;
  padding: 0.1875rem 0.5rem;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.01em;
  vertical-align: 0.12em;
  white-space: nowrap;
}

.badge--gold {
  border-color: currentColor;
  color: var(--gold);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-block-size: 3rem;
  padding: 0.625rem 1.5rem;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: var(--page);
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
}

a.button:hover {
  background: transparent;
  color: var(--ink);
}

/* On the sky and the night: cream, filled. */
.button--on-sky {
  border-color: var(--on-sky);
  background: var(--on-sky);
  color: #101B2D;
}

a.button--on-sky:hover {
  background: transparent;
  color: var(--on-sky);
}

/* 14. The closing night (Get) ------------------------------------------------------ */

/* The day ends where it began: Isha's sky, paling to the page at the horizon.
   The words stay above the pale stretch. */
.get {
  background: linear-gradient(
    to bottom,
    var(--night-1) 0%,
    var(--night-2) 38%,
    var(--night-3) calc(100% - 11rem),
    #474E74 calc(100% - 5.5rem),
    #A59EAE calc(100% - 2rem),
    var(--page) 100%
  );
  color: var(--on-sky);
  text-align: center;
}

@media (prefers-color-scheme: dark) {
  .get {
    background: linear-gradient(to bottom, var(--night-1) 0%, var(--night-2) 38%, var(--night-3) calc(100% - 11rem), #1C2940 calc(100% - 4rem), var(--page) 100%);
  }
}

.get {
  position: relative;
}

.get__inner {
  position: relative;
  display: grid;
  justify-items: center;
  row-gap: var(--space-5);
  padding-block: var(--section) calc(var(--section) + 7rem);
}

.get__mark {
  inline-size: 5.5rem;
  block-size: 5.5rem;
  border-radius: 22.5%;
  box-shadow: 0 0 0 1px rgb(243 238 226 / 0.16), 0 24px 48px -16px rgb(0 0 0 / 0.7);
}

.get__title {
  font-size: min(var(--step-4), 9.5vw);      /* one line on a phone */
  line-height: 1;
  letter-spacing: -0.025em;
}

.get__note {
  max-inline-size: 31rem;
  font-family: var(--sans);
  line-height: 1.5;
  text-wrap: balance;
}

/* The lozenge is inline, so when the line wraps it stays with the first word. */
.get__soon::before {
  display: inline-block;
  margin-inline-end: 0.75rem;
  vertical-align: 0.14em;
}

.get__soon {
  max-inline-size: 100%;
  margin-block-start: var(--space-3);
  text-wrap: balance;
  color: #E8C98A;
  font-size: var(--step-1);
  font-weight: 600;
  line-height: 1.3;
}

.get__name {
  margin-block-start: var(--space-6);
  color: #C5CAD6;
  font-size: var(--step-0);
}

/* 15. Inner pages: page head, document, prose (Privacy, Support, Sources, 404) ------- */

/* An inner page is a page head and a document (.doc) made of parts (.part).
   Up to 60em everything shares one reading column, centred. From 60em the
   page takes the footer's own two columns, 5 to 7: every heading stands in
   the first (the page's title too), and holds its place while its text, in
   the second, scrolls by, as the phone does beside a chapter on the home
   page. None of it needs script. */
.page-head,
.doc {
  max-inline-size: var(--measure);
  margin-inline: auto;
}

.page-head {
  padding-block: clamp(2.75rem, 1.5rem + 6vw, 6.5rem) clamp(2rem, 1.55rem + 2vw, 3rem);
}

/* The page's title is set like a chapter's on the home page. */
.page-head__title {
  font-size: var(--step-4);
  line-height: 1;
  letter-spacing: -0.025em;
}

/* Beside its text, the title holds one line: two short words must fit the first column. */
@media (min-width: 60em) {
  .page-head__title {
    font-size: min(var(--step-4), 4.3vw, 3.5rem);
  }
}

/* What stands beside the title: a lede, the summary (In Short) or the contents. */
.page-head__intro {
  margin-block-start: var(--space-6);
}

.page-head__intro > :nth-child(n + 2) {
  margin-block-start: var(--space-4);
}

.page-head__lede {
  font-size: var(--step-1);
  line-height: 1.45;
}

.page-head__note {
  max-inline-size: var(--measure);
}

.page-head__meta {
  margin-block-start: var(--space-4);
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.9375rem;
  line-height: 1.4;
}

.doc {
  --part-pad: clamp(2rem, 1.55rem + 2vw, 3rem);
  padding-block-end: var(--section);
}

/* A part: a heading (.part__side) and what it heads (.part__body). The id a
   link points at is on the part, not on the heading, because the heading may
   be held in place. A jump lands with the heading where it holds. */
.part {
  padding-block: var(--part-pad);
  border-block-start: 1px solid var(--hairline);
  scroll-margin-block-start: calc(-1 * var(--part-pad));
}

.part:first-child {
  border-block-start-color: var(--ink);
}

.part__title {
  font-size: var(--step-2);
}

/* A quiet label for what comes before the sections: the summary, the contents.
   The lozenge is inline so the label keeps a text baseline. */
.part__label {
  color: var(--gold);
  font-family: var(--sans);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0;
}

.part__label::before {
  content: "";
  display: inline-block;
  inline-size: 0.4375rem;
  block-size: 0.4375rem;
  margin-inline: 0.125rem 0.625rem;
  border: 1.5px solid currentColor;
  vertical-align: 0.08em;
  transform: rotate(45deg);
}

.part__body {
  margin-block-start: var(--space-4);
}

.part__label + .jump,
.part__title + .jump {
  margin-block-start: var(--space-4);
}

.part__side:has(.jump) + .part__body {
  margin-block-start: var(--space-6);
}

@media (min-width: 60em) {
  .page-head,
  .doc {
    max-inline-size: none;
  }

  /* The first lines of the two columns share a baseline: the title and its lede, a heading and its text. */
  .page-head,
  .part {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    column-gap: var(--space-7);
    align-items: first baseline;
  }

  .page-head__intro,
  .part__body,
  .part__side:has(.jump) + .part__body {
    margin-block-start: 0;
  }

  /* A part whose body needs the whole width (the Sources table). */
  .part--wide {
    display: block;
  }

  .part--wide > .part__body {
    margin-block-start: var(--space-5);
  }
}

/* The heading holds its place beside its text, where the window is tall enough to spare the room. */
@media (min-width: 60em) and (min-height: 32em) {
  .part:not(.part--wide) > .part__side {
    position: sticky;
    inset-block-start: var(--space-5);
  }
}

/* The summary that opens a page (In Short): set as a lede, each point with the lozenge. */
.lead {
  display: grid;
  row-gap: var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: var(--step-1);
  line-height: 1.45;
}

.lead > li {
  position: relative;
  max-inline-size: var(--measure);
  padding-inline-start: 1.625rem;
}

.lead > li::before {
  content: "";
  position: absolute;
  inset-inline-start: 0.125rem;
  inset-block-start: 0.52em;
  inline-size: 0.4375rem;
  block-size: 0.4375rem;
  border: 1.5px solid var(--gold);
  transform: rotate(45deg);
}

/* Contents: links to a long page's parts. One column on a small phone, two wherever two fit. */
.toc,
.jump {
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--sans);
  line-height: 1.3;
}

.toc {
  columns: 2 9rem;
  column-gap: var(--space-5);
  font-size: 1rem;
}

/* On a phone the titles wrap to two or three lines, and two columns of them never line up: one column. */
@media (max-width: 29.99em) {
  .toc {
    columns: auto;
  }

  /* The part's own rule follows the last entry: one line there, not two. */
  .toc > li:last-child > a {
    border-block-end: 0;
  }
}

.toc > li,
.jump > li {
  break-inside: avoid;
}

/* Navigation: lapis, and underlined only under the pointer. Each link is a
   block with padding (not a flex box, which would drop the spaces around a
   Latin run inside Arabic), at least 44 px tall. */
.toc a,
.jump a {
  display: block;
  padding-block: 0.75rem;
  padding-block: max(0.5rem, (2.75rem - 1lh) / 2);
  text-decoration: none;
  overflow-wrap: break-word;
}

.toc a:hover,
.jump a:hover {
  text-decoration: underline;
  text-decoration-thickness: 0.0625em;
  text-underline-offset: 0.25em;
}

.toc a {
  border-block-end: 1px solid var(--hairline);
}

/* The questions under one heading: a short list of jumps, on a hairline rail. */
.jump {
  max-inline-size: 22rem;
  border-inline-start: 1px solid var(--hairline);
  font-size: 0.9375rem;
}

.jump a {
  padding-inline-start: var(--space-4);
}

/* Where the browser can tell which target the reader has reached (CSS scroll
   markers), the held list marks that question in gold. Elsewhere, nothing. */
@supports (scroll-target-group: auto) {
  @media (min-width: 60em) and (min-height: 32em) {
    main {
      scroll-target-group: auto;
    }

    .jump a:target-current {
      margin-inline-start: -1px;
      border-inline-start: 2px solid var(--gold);
      padding-inline-start: calc(var(--space-4) - 1px);
      color: var(--ink);
    }
  }
}

/* Prose: the reading text inside a part. */
.prose {
  max-inline-size: var(--measure);
  line-height: 1.65;
}

.prose > * + * {
  margin-block-start: 1.15em;
}

.prose h3 {
  margin-block-start: 1.9em;
  font-size: var(--step-1);
  line-height: 1.25;
}

.prose h4 {
  margin-block-start: 1.6em;
  font-family: var(--sans);
  font-size: 1rem;
  letter-spacing: 0;
}

.prose h3 + *,
.prose h4 + * {
  margin-block-start: 0.85em;
}

.prose ul,
.prose ol {
  padding-inline-start: 1.5em;
}

.prose li + li {
  margin-block-start: 0.45em;
}

/* The bullet is the lozenge. The list keeps its own marker, unseen, so that it
   stays a list to a screen reader (a list with no marker can lose that). */
.prose ul > li {
  position: relative;
}

.prose ul > li::marker {
  color: transparent;
}

.prose ul > li::before {
  content: "";
  position: absolute;
  inset-inline-start: -1.3em;
  inset-block-start: 0.6em;
  inset-block-start: calc(0.5lh - 0.21875rem);
  inline-size: 0.4375rem;
  block-size: 0.4375rem;
  border: 1.5px solid var(--gold);
  transform: rotate(45deg);
}

.prose ol > li::marker {
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.9em;
  font-variant-numeric: tabular-nums;
}

/* A Latin company name on a line of its own, on an Arabic page: the line is left to right, but it
   still starts at the page's start, under the Arabic heading ("end" of a left-to-right line is the right). */
[dir="rtl"] p.company__name[dir="ltr"] {
  text-align: end;
}

/* The Company block inside a part: its addresses sit in lines of text, so they are set as text
   (the footer's stand alone and keep their 44 px). */
.prose address > ul {
  margin-block-start: 0.85em;
}

.prose address li a {
  display: inline;
}

/* A list of short names (the twelve calculation methods) runs in two columns where two fit. */
.prose ul.cols {
  columns: 2 11rem;
  column-gap: var(--space-6);
  margin-block-end: -0.45em;
}

/* The space between items is inside each item, so the second column starts level with the first
   (Safari keeps a top margin at the head of a column). */
.prose .cols > li {
  margin-block-start: 0;
  padding-block-end: 0.45em;
  break-inside: avoid;
}

.prose hr {
  block-size: 1px;
  margin-block: 2.25em;
  border: 0;
  background: var(--hairline);
}

.prose small,
.prose .fine {
  color: var(--muted);
  font-family: var(--sans);
  font-size: var(--step--1);
  line-height: 1.5;
}

.prose code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.88em;
}

/* Long addresses must not push a 320 px page sideways. A web address written
   out (.url) with a path is marked up in pieces, the host and then each
   segment, with a <wbr> between them: it breaks after a slash, never inside a
   word or at a hyphen. (A piece is kept whole by its own span; <wbr> inside
   one nowrap run does not break in Safari.) */
.prose a,
.table--stack a {
  overflow-wrap: anywhere;
}

.url__part {
  white-space: nowrap;
}

/* Questions and answers. Each question is a heading (h3.qa__q) with an id, so a screen reader can move from
   one to the next; its answer is the div.qa__a after it. A jump lands a little above the question. */
.qa > .qa__q {
  /* A jump lands the question on the baseline of the heading held beside it. */
  scroll-margin-block-start: calc((var(--step-2) * 1.12 - var(--step-1) * 1.25) / 2 + (var(--step-2) - var(--step-1)) * 0.35);
  margin-block-start: 2.1em;
  font-size: var(--step-1);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.qa > .qa__q:first-child {
  margin-block-start: 0;
}

.qa > .qa__a {
  margin-block-start: 0.65em;
  margin-inline-start: 0;
}

.qa > .qa__a > * + * {
  margin-block-start: 0.9em;
}

/* A quiet callout: one thing worth not missing. A gold rule, no fill. */
.callout {
  padding-block: 0.15em;
  padding-inline-start: 1.1em;
  border-inline-start: 2px solid var(--gold);
}

.callout > * + * {
  margin-block-start: 0.65em;
}

.callout__title {
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
}

/* Tables. Wrap every table in .table-wrap: it scrolls sideways on its own, so
   the page never does. */
.table-wrap {
  max-inline-size: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.prose table,
.table--stack {
  inline-size: 100%;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 0.9375rem;
  line-height: 1.5;
}

.prose caption {
  padding-block: 0.75em;
  color: var(--muted);
  font-size: var(--step--1);
  text-align: start;
}

.prose th,
.prose td {
  min-inline-size: 7.5rem;
  padding: 0.75em 1em;
  padding-inline-start: 0;
  border-block-end: 1px solid var(--hairline);
  text-align: start;
  vertical-align: top;
}

.prose th:last-child,
.prose td:last-child {
  padding-inline-end: 0;
}

.prose thead th {
  color: var(--muted);
  font-size: var(--step--1);
  font-weight: 600;
  white-space: nowrap;
}

.prose tbody th {
  font-weight: 600;
}

/* .table--stack is a ledger of named things, each with two or three short
   facts (the Sources table). It is never squeezed into narrow columns: up to
   60em each row is a block, the name and then each fact under its label
   (cells need data-label); from 60em it is three columns on the page's own
   grid, the names standing where the headings stand. The roles in the markup
   keep it a table to a screen reader whichever way it is laid out. */
.table--stack,
.table--stack thead,
.table--stack tbody,
.table--stack tr,
.table--stack th,
.table--stack td {
  display: block;
  min-inline-size: 0;
  padding: 0;
  border: 0;
  text-align: start;
}

.table--stack tr {
  padding-block: 1.25rem;
  border-block-end: 1px solid var(--hairline);
}

.table--stack tbody tr:last-child {
  border-block-end: 0;
  padding-block-end: 0;
}

.table--stack tbody tr:first-child {
  padding-block-start: 0;
}

.table--stack tbody th {
  font-family: var(--serif);
  font-size: var(--step-0);
  font-weight: 600;
  line-height: 1.35;
  text-wrap: balance;
}

.table--stack thead th {
  color: var(--muted);
  font-size: var(--step--1);
  font-weight: 600;
}

@media (max-width: 59.99em) {
  .table--stack thead {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .table--stack td {
    margin-block-start: 0.625rem;
  }

  .table--stack td[data-label]::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: var(--step--1);
    font-weight: 600;
  }
}

/* An address is the one thing to press in its row. It stays in its sentence, and its target is made 44 px
   tall by padding, which on an inline box enlarges what can be pressed without moving any line. */
.table--stack td a.url {
  padding-block: 0.8125rem;
}

@media (min-width: 60em) {
  .table--stack tr {
    display: grid;
    grid-template-columns: calc((100% - var(--space-7)) * 5 / 12) minmax(0, 1fr) minmax(0, 1fr);
    column-gap: var(--space-7);
    align-items: first baseline;
  }

  .table--stack thead tr {
    padding-block: 0 0.75rem;
    border-block-end-color: var(--ink);
  }

  .table--stack tbody tr:first-child {
    padding-block-start: 1.25rem;
  }

  .table--stack tbody th {
    font-size: var(--step-1);
    line-height: 1.3;
  }
}

/* The 404 page: one centred statement and the ways out, laid out like the home page's closing band, on paper. */
.lost {
  display: grid;
  align-items: center;
  min-block-size: min(46rem, 100vh - var(--header) - 14rem);
}

.lost__inner {
  display: grid;
  justify-items: center;
  row-gap: var(--space-5);
  padding-block: var(--section);
  text-align: center;
}

.lost__mark {
  inline-size: 5.5rem;
  block-size: 5.5rem;
  border-radius: 22.5%;
  box-shadow: var(--shadow);
}

@media (prefers-color-scheme: dark) {
  .lost__mark {
    box-shadow: 0 0 0 1px rgb(243 238 226 / 0.16), var(--shadow);
  }
}

.lost__title {
  font-size: var(--step-4);
  line-height: 1;
  letter-spacing: -0.025em;
}

.lost__note {
  max-inline-size: 30rem;
  font-size: var(--step-1);
  line-height: 1.45;
  text-wrap: balance;
}

.lost__actions {
  margin-block-start: var(--space-3);
}

.lost__links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0 var(--space-5);
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--sans);
  font-size: 1rem;
}

.lost__links a {
  justify-content: center;
}

/* 16. Site footer and Company block ------------------------------------------------ */

.site-footer {
  border-block-start: 1px solid var(--hairline);
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.9375rem;
  line-height: 1.5;
}

.get + .site-footer,
main:has(> .get:last-child) + .site-footer {
  border-block-start: 0;
}

.site-footer__inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  row-gap: var(--space-4);
  padding-block: var(--space-7);
}

.site-footer__promise {
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--step-1);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.company__name {
  color: var(--ink);
  font-weight: 600;
}

.company a {
  overflow-wrap: anywhere;
}

.company a,
.site-footer__nav a {
  display: inline-flex;
  align-items: center;
  min-block-size: 2.75rem;
}

.site-footer__nav ul {
  display: flex;
  flex-wrap: wrap;
  column-gap: var(--space-4);
  margin: 0;
  margin-inline-start: -0.25rem;
  padding: 0;
  list-style: none;
}

.site-footer__nav a {
  justify-content: center;
  min-inline-size: 2.75rem;
  padding-inline: 0.25rem;
  color: var(--ink);
  text-decoration: none;
}

.site-footer__nav a:hover {
  text-decoration: underline;
  text-underline-offset: 0.3em;
}

.site-footer__legal {
  max-inline-size: 44rem;
  padding-block-start: var(--space-5);
  border-block-start: 1px solid var(--hairline);
  font-size: var(--step--1);
}

.site-footer__legal > * + * {
  margin-block-start: var(--space-2);
}

@media (min-width: 48em) {
  .site-footer__inner {
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    column-gap: var(--space-7);
    row-gap: var(--space-2);
  }

  .site-footer__promise {
    grid-column: 1;
    grid-row: 1 / span 2;
  }

  .company,
  .site-footer__nav {
    grid-column: 2;
  }

  .site-footer__legal {
    grid-column: 1 / -1;
    max-inline-size: none;
    margin-block-start: var(--space-5);
  }
}

/* 17. Motion (only with html.motion, on screens) ------------------------------------- */

/* Two rules for everything in this section. Only opacity and transform are ever animated. And two different
   screens are never blended while the reader is still: what the page's own scrolling drives directly is colour
   (the sky) and movement (the foldable); a change of screen is a step, taken at a threshold with a short timed
   fade, so that a reader who stops anywhere sees one clean screen. */

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(1.25rem); }
  to { opacity: 1; transform: none; }
}

@keyframes duo-open {
  from { transform: rotateY(0deg); }
  to { transform: rotateY(-180deg); }
}

/* Which side of the cover shows. The swap is spelled out, not left to backface-visibility,
   because WebKit's snapshots (and any flattened rendering) draw both sides. */
@keyframes duo-front {
  0%, 55.5% { opacity: 1; }
  55.6%, 100% { opacity: 0; }
}

@keyframes duo-back {
  0%, 55.5% { opacity: 0; }
  55.6%, 100% { opacity: 1; }
}

/* The closed device is drawn a little larger and stands in the middle: the half that holds it is moved to the
   centre first, then enlarged about the centre, so it stays centred at any size. */
@keyframes duo-settle {
  from { transform: scale(var(--duo-zoom)) translateX(-25%); }
  to { transform: none; }
}

/* A script that is allowed but slow must not flash six phones before it stacks them. */
@keyframes sky-failsafe {
  to { visibility: visible; }
}

@media screen and (scripting: enabled) and (prefers-reduced-motion: no-preference) and (min-height: 30em) {
  html:not(.motion) .sky__frame:nth-child(n + 2) {
    visibility: hidden;
    animation: sky-failsafe 1ms 4s forwards;
  }
}

@media screen and (min-height: 30em) {
  /* The living sky. The band is taller than the window; its sky and the phone hold still while the page
     scrolls. The sky's colour is scrubbed: --p is the progress through the band (written by the script where
     the browser has no scroll timelines), --s is where a stage's colour begins to arrive and --d how long it
     takes. The phone and its label are stepped: the script marks the stage that has been reached (.is-now) and
     those before it (.is-on) at the thresholds in the band's data-stages, each of which falls three quarters of
     the way through its colour's arrival. */
  html.motion .sky {
    --d: 0.11;
    --label-h: 2.5rem;
    --key-h: 3rem;
    --phone-h: clamp(18rem, calc(100vh - 9.5rem), 42rem);
    min-block-size: 330vh;
    padding-block-end: 4.5rem;
    background: none;
  }

  html.motion .sky::before {
    content: none;
  }

  /* The sky keeps its own height in the flow (so it leaves with the band, not after it);
     the words are drawn back up over it. */
  html.motion .sky__bg {
    position: sticky;
    inset-block-start: 0;
    display: block;
    block-size: 100vh;
    overflow: hidden;
  }

  html.motion .sky__intro {
    margin-block-start: -100vh;
  }

  @supports (block-size: 100svh) {
    html.motion .sky {
      --phone-h: clamp(18rem, calc(100svh - 9.5rem), 42rem);
      min-block-size: 330svh;
    }

    html.motion .sky__bg {
      block-size: 100lvh;
    }

    html.motion .sky__intro {
      margin-block-start: -100lvh;
    }
  }

  html.motion .sky__bg > span {
    position: absolute;
    inset: 0;
    background: linear-gradient(
      to bottom,
      var(--c1) 0%,
      var(--c2) 30%,
      var(--c3) 52%,
      var(--c4) 68%,
      var(--c5) 79%,
      var(--h1) 87%,
      var(--h2) 93%,
      var(--page) 100%
    );
    opacity: clamp(0, calc((var(--p, 0) - var(--s)) / var(--d)), 1);
  }

  /* Each stage's colours are one column of pixels from its capture: five stops of sky and two of horizon.
     (Isha's last stop is warmed a little by hand, so the night does not end in a grey fog.) */
  html.motion .sky__bg > .sky--fajr { --s: -1; --c1: #141C3A; --c2: #1D2447; --c3: #272B57; --c4: #3D3662; --c5: #503F68; --h1: #7F657E; --h2: #BCA8AE; }
  html.motion .sky__bg > .sky--morning { --c1: #163862; --c2: #1C4571; --c3: #225384; --c4: #2E5F8F; --c5: #386894; --h1: #718191; --h2: #B5B5B1; }
  html.motion .sky__bg > .sky--dhuhr { --c1: #123C6E; --c2: #17487A; --c3: #1B5489; --c4: #235F96; --c5: #2A679D; --h1: #5182AF; --h2: #9DB7CB; }
  html.motion .sky__bg > .sky--asr { --c1: #14213F; --c2: #1E2C4E; --c3: #283761; --c4: #494264; --c5: #644962; --h1: #946D72; --h2: #C8ADA4; }
  html.motion .sky__bg > .sky--maghrib { --c1: #1E1A3E; --c2: #2F244A; --c3: #422E59; --c4: #623956; --c5: #7C3F4D; --h1: #9F635F; --h2: #CAA69A; }
  html.motion .sky__bg > .sky--isha { --c1: #070B1E; --c2: #0A1127; --c3: #0D1632; --c4: #141F42; --c5: #1A284E; --h1: #474E74; --h2: #A59EAE; }

  /* In the dark the horizon dims into the night page, as it does in the app's own dark captures. */
  @media (prefers-color-scheme: dark) {
    html.motion .sky__bg > .sky--fajr { --h1: #59405D; --h2: #3F3043; }
    html.motion .sky__bg > .sky--morning { --h1: #4B5D70; --h2: #393D45; }
    html.motion .sky__bg > .sky--dhuhr { --h1: #2C5F8F; --h2: #21405F; }
    html.motion .sky__bg > .sky--asr { --h1: #6F4951; --h2: #4D3539; }
    html.motion .sky__bg > .sky--maghrib { --h1: #7A3F3E; --h2: #4D2F2E; }
    html.motion .sky__bg > .sky--isha { --h1: #1D2B4F; --h2: #1B2340; }
  }

  /* Six stages: the phone steps at 25, 39, 53, 67 and 81 percent of the band (data-stages in the page). */
  html.motion .sky--6 .sky__bg > span:nth-child(2) { --s: 0.17; }
  html.motion .sky--6 .sky__bg > span:nth-child(3) { --s: 0.31; }
  html.motion .sky--6 .sky__bg > span:nth-child(4) { --s: 0.45; }
  html.motion .sky--6 .sky__bg > span:nth-child(5) { --s: 0.59; }
  html.motion .sky--6 .sky__bg > span:nth-child(6) { --s: 0.73; }

  /* The day holds its place: the line that explains it, and the six screens stacked where one stands. */
  html.motion .sky__day {
    position: sticky;
    inset-block-start: max(0.5rem, calc((100vh - var(--phone-h) - var(--label-h) - var(--key-h)) / 2));
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: var(--label-h) var(--key-h) auto;
    margin-block-start: clamp(1rem, 3vh, 2rem);
  }

  /* The day lets go together with the sky, not after it: its margin carries it down to the sky's lower edge,
     so the two leave the window as one (the sky is a large-window tall, the day is placed in the small one). */
  html.motion .sky__day {
    margin-block-end: max(0px, calc(100vh - max(0.5rem, (100vh - var(--phone-h) - var(--label-h) - var(--key-h)) / 2) - var(--phone-h) - var(--label-h) - var(--key-h)));
  }

  @supports (block-size: 100svh) {
    html.motion .sky__day {
      inset-block-start: max(0.5rem, calc((100svh - var(--phone-h) - var(--label-h) - var(--key-h)) / 2));
      margin-block-end: max(0px, calc(100lvh - max(0.5rem, (100svh - var(--phone-h) - var(--label-h) - var(--key-h)) / 2) - var(--phone-h) - var(--label-h) - var(--key-h)));
    }
  }

  html.motion .sky__key {
    grid-area: 2 / 1;
    align-self: center;
    z-index: 1;
    margin-block: 0;
  }

  html.motion .sky__stage.shelf {
    grid-area: 1 / 1 / 4 / 2;
    display: grid;
    grid-template-columns: auto;
    gap: 0;
    justify-content: center;
    margin: 0;
    padding: 0;
    overflow: visible;
    scroll-snap-type: none;
  }

  html.motion .sky__frame {
    grid-area: 1 / 1;
    grid-template-rows: var(--label-h) var(--key-h) auto;
    row-gap: 0;
    inline-size: var(--phone-w);
    margin: 0;
  }

  html.motion .sky__frame .phone {
    grid-row: 3;
  }

  /* Until the reader first scrolls, the screens after the second are not in the page at all, so the first view
     does not fetch six captures to show one (the script adds .is-awake on the first scroll). */
  html.motion .sky__stage:not(.is-awake) > .sky__frame:nth-child(n + 3) {
    display: none;
  }

  html.motion .sky__frame .sky__label {
    grid-row: 1;
    align-content: center;
    white-space: nowrap;
  }

  html.motion .sky__stage > .sky__frame > .sky__label::before {
    content: none;
  }

  /* One shadow for the stack, cast by the first phone. */
  html.motion :is(.sky__frame, .chapter__stage > .shot):nth-child(n + 2) .phone {
    box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.2), inset 0 0 0 2px rgb(0 0 0 / 0.55);
  }

  /* The step. A screen that has been reached lies over the ones before it, so going forward the new screen
     comes up over the old one and the frame never empties; the label goes first and its successor follows. */
  html.motion .sky__frame .phone {
    opacity: 0;
    transition: opacity 0.28s var(--ease);
  }

  html.motion .sky__frame:first-child .phone,
  html.motion .sky__frame.is-on .phone {
    opacity: 1;
  }

  html.motion .sky__frame .sky__label {
    opacity: 0;
    transition: opacity 0.12s linear;
  }

  html.motion .sky__stage:not(.is-live) > .sky__frame:first-child .sky__label,
  html.motion .sky__frame.is-now .sky__label {
    opacity: 1;
    transition: opacity 0.2s var(--ease) 0.12s;
  }

  @supports (animation-timeline: view()) {
    html.motion .sky {
      view-timeline: --sky block;
    }

    html.motion .sky__bg > span {
      opacity: 1;
      animation: fade-in linear both;
      animation-timeline: --sky;
    }

    html.motion .sky__bg > span:first-child {
      animation: none;
    }

    html.motion .sky--6 .sky__bg > span:nth-child(2) { animation-range: contain 17% contain 28%; }
    html.motion .sky--6 .sky__bg > span:nth-child(3) { animation-range: contain 31% contain 42%; }
    html.motion .sky--6 .sky__bg > span:nth-child(4) { animation-range: contain 45% contain 56%; }
    html.motion .sky--6 .sky__bg > span:nth-child(5) { animation-range: contain 59% contain 70%; }
    html.motion .sky--6 .sky__bg > span:nth-child(6) { animation-range: contain 73% contain 84%; }
  }
}

@media screen and (min-height: 30em) and (max-width: 59.99em) {
  /* Narrow: the label, the key and the phone stand in one column. The key's row leaves air above the phone,
     and the label may stand wider than the phone rather than wrap, so a long city name never runs into the key. */
  html.motion .sky {
    --key-h: 3.25rem;
    --phone-h: clamp(18rem, calc(100vh - 9.75rem), 42rem);
  }

  @supports (block-size: 100svh) {
    html.motion .sky {
      --phone-h: clamp(18rem, calc(100svh - 9.75rem), 42rem);
    }
  }

  html.motion .sky__stage > .sky__frame > .sky__label {
    flex-wrap: nowrap;
    inline-size: max-content;
    justify-self: center;
  }
}

/* The narrowest phones set the key on two lines (English from about 368 px, Arabic, which is shorter, from about
   340): its row grows to hold them with the same air. */
@media screen and (min-height: 30em) and (max-width: 22.99em) {
  html:lang(en).motion .sky {
    --key-h: 3.75rem;
    --phone-h: clamp(18rem, calc(100vh - 10.25rem), 42rem);
  }

  @supports (block-size: 100svh) {
    html:lang(en).motion .sky {
      --phone-h: clamp(18rem, calc(100svh - 10.25rem), 42rem);
    }
  }
}

@media screen and (min-height: 30em) and (max-width: 21.24em) {
  html:lang(ar).motion .sky {
    --key-h: 4.25rem;
    --phone-h: clamp(18rem, calc(100vh - 10.75rem), 42rem);
  }

  @supports (block-size: 100svh) {
    html:lang(ar).motion .sky {
      --phone-h: clamp(18rem, calc(100svh - 10.75rem), 42rem);
    }
  }
}

@media screen and (min-height: 30em) and (min-width: 60em) {
  /* Wide: the time of day and the city stand together on one side of the phone, the line that explains them on
     the other. The day and each of its frames are laid out on the same three columns. */
  html.motion .sky {
    --label-h: 0rem;
    --key-h: 0rem;
    --phone-h: clamp(20rem, calc(100vh - 8.5rem), 50rem);
  }

  @supports (block-size: 100svh) {
    html.motion .sky {
      --phone-h: clamp(20rem, calc(100svh - 8.5rem), 50rem);
    }
  }

  html.motion .sky__day,
  html.motion .sky__frame {
    grid-template-columns: minmax(0, 1fr) var(--phone-w) minmax(0, 1fr);
    grid-template-rows: auto;
    column-gap: clamp(2rem, 4.5vw, 4.5rem);
    align-items: center;
  }

  html.motion .sky__key {
    grid-area: 1 / 3;
    justify-self: start;
    max-inline-size: 15rem;
    margin: 0;
    font-size: var(--step-0);
    line-height: 1.45;
    text-align: start;
  }

  html.motion .sky__stage.shelf {
    grid-area: 1 / 1 / 2 / 4;
    grid-template-columns: minmax(0, 1fr);
  }

  html.motion .sky__frame {
    inline-size: auto;
  }

  html.motion .sky__frame .phone {
    grid-area: 1 / 2;
  }

  html.motion .sky__frame .sky__label {
    grid-area: 1 / 1;
    display: grid;
    justify-items: end;
    row-gap: 0.375rem;
    text-align: end;
  }

  html.motion .sky__when {
    font-size: var(--step-4);
    line-height: 1;
    letter-spacing: -0.025em;
  }

  html.motion .sky__where {
    font-size: var(--step-2);
    line-height: 1.2;
  }

  /* Beside the phone the words sit at its middle, which at the top of the page is down in the pale horizon,
     where cream cannot be read. So the first label and the key arrive as the phone rises to its place (words
     fading in with the scroll are not a change of screen). */
  html.motion .sky__frame:first-child :is(.sky__when, .sky__where),
  html.motion .sky__key {
    opacity: clamp(0, calc((var(--p, 0) - 0.08) / 0.06), 1);
  }

  @supports (animation-timeline: view()) {
    html.motion .sky__frame:first-child :is(.sky__when, .sky__where),
    html.motion .sky__key {
      opacity: 1;
      animation: fade-in linear both;
      animation-timeline: --sky;
      animation-range: contain 8% contain 14%;
    }
  }

  /* A phone that holds its place while its chapter is read. The script marks the step whose title has risen
     past the reading line (.is-now) and the screens up to it (.is-on). */
  html.motion .chapter {
    --stage-h: clamp(26rem, calc(100vh - 7rem), 50rem);
    --stage-w: calc((var(--stage-h) - 5rem) * 0.4756);
    display: grid;
    grid-template-columns: minmax(0, 37rem) var(--stage-w);
    grid-template-rows: auto 1fr;
    justify-content: space-between;
    column-gap: var(--space-7);
  }

  html.motion .chapter--flip {
    grid-template-columns: var(--stage-w) minmax(0, 37rem);
  }

  html.motion .steps > .step {
    max-inline-size: none;
  }

  html.motion .chapter__head {
    grid-area: 1 / 1;
  }

  html.motion .chapter--flip .chapter__head {
    grid-area: 1 / 2;
  }

  html.motion .chapter__stage.shelf {
    grid-area: 1 / 2 / 3 / 3;
    position: sticky;
    inset-block-start: calc((100vh - var(--stage-h)) / 2);
    align-self: start;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    block-size: var(--stage-h);
    margin: 0;
    padding: 0;
    overflow: visible;
  }

  html.motion .chapter--flip .chapter__stage.shelf {
    grid-area: 1 / 1 / 3 / 2;
  }

  html.motion .chapter__stage > .shot {
    grid-area: 1 / 1;
    inline-size: auto;
    margin: 0;
  }

  html.motion .chapter__stage > .shot > figcaption::before {
    content: none;
  }

  /* A step between two different screens: quick, and never held half way. */
  html.motion .chapter__stage > .shot .phone {
    opacity: 0;
    transition: opacity 0.25s var(--ease);
  }

  html.motion .chapter__stage > .shot:first-child .phone,
  html.motion .chapter__stage > .shot.is-on .phone {
    opacity: 1;
  }

  html.motion .chapter__stage > .shot .shot__caption {
    opacity: 0;
    transition: opacity 0.12s linear;
  }

  html.motion .chapter__stage:not(.is-live) > .shot:first-child .shot__caption,
  html.motion .chapter__stage > .shot.is-now .shot__caption {
    opacity: 1;
    transition: opacity 0.2s var(--ease) 0.12s;
  }

  /* The steps: each tall enough to be read alone beside its screen, and no taller. The space under the last
     one lets the phone hold until that step has been read. */
  html.motion .steps {
    grid-area: 2 / 1;
    grid-template-columns: minmax(0, 1fr);
    row-gap: 0;
    margin-block-start: 0;
    padding-block-end: 16vh;
  }

  html.motion .chapter--flip .steps {
    grid-area: 2 / 2;
  }

  html.motion .steps > .step {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-block-size: 44vh;
    padding-block: var(--space-5);
  }

  /* The first step starts a fixed distance under the chapter's title, however long it is, so the three
     chapters open alike. */
  html.motion .steps > .step:first-child {
    justify-content: flex-start;
    min-block-size: 36vh;
    padding-block-start: var(--space-7);
  }

  html.motion .steps > .step > .step__term {
    font-family: var(--serif);
    font-size: var(--step-2);
    line-height: 1.15;
    letter-spacing: -0.015em;
  }

  html.motion .steps > .step > .step__term .badge {
    font-size: max(0.8125rem, 0.42em);
    letter-spacing: 0.01em;
    vertical-align: 0.42em;
  }

  html.motion .steps > .step > .step__term::before,
  html.motion .steps > .step > .step__term::after {
    inset-block-start: 0.42em;
  }

  html.motion .steps > .step > .step__text {
    margin-block-start: var(--space-3);
    font-size: var(--step-1);
    line-height: 1.45;
  }

  html.motion .chapter__more {
    grid-column: 1;
    margin-block-start: -12vh;
  }

  html.motion .chapter--flip .chapter__more {
    grid-column: 2;
  }

  @supports (block-size: 100svh) {
    html.motion .chapter {
      --stage-h: clamp(26rem, calc(100svh - 7rem), 50rem);
    }

    html.motion .chapter__stage.shelf {
      inset-block-start: calc((100svh - var(--stage-h)) / 2);
    }
  }
}

@media screen and (min-height: 30em) and (min-width: 48em) {
  /* The foldable opens as the page moves: the cover turns on the hinge, and the whole device slides back to
     the centre as it does. Under 48em it stays in its still form, where its screens can be read. --o is how far
     it has opened, from 0 to 1, over the stretch from 8 to 84 percent of the band. */
  html.motion .fold {
    --duo-zoom: 1.12;
    --o: clamp(0, calc((var(--p, 0) - 0.08) / 0.76), 1);
    min-block-size: 205vh;
    padding-block: 0;
  }

  /* The pin also clips: while closed, the device's empty left half reaches past the page edge,
     which on a right-to-left page would otherwise let the whole page scroll sideways. */
  html.motion .fold__pin {
    position: sticky;
    inset-block-start: 0;
    display: grid;
    align-content: center;
    min-block-size: 100vh;
    padding-block: var(--space-6);
    overflow: hidden;
  }

  @supports (block-size: 100svh) {
    html.motion .fold {
      min-block-size: 205svh;
    }

    html.motion .fold__pin {
      min-block-size: 100svh;
    }
  }

  html.motion .fold__figure {
    row-gap: calc(var(--space-7) + 0.5rem);
    justify-items: center;
  }

  html.motion .fold__figure .shot__caption {
    text-align: center;
  }

  /* Every length of the device comes from its width, so it is the same object at every size:
     its thickness, and how far away it is seen from. It is seen from the reader's left, a little
     above the middle, so the spine shows while it is closed and the cover never turns quite edge-on. */
  html.motion .duo {
    --duo-w: min(calc(100vw - 2 * var(--gutter)), 54rem, calc((100vh - 15rem) * 1.405));
    --t: calc(var(--duo-w) * 0.018);
    position: relative;
    display: block;
    inline-size: var(--duo-w);
    aspect-ratio: 2 / 1.4235;
    margin-block: calc((var(--duo-zoom) - 1) * 36%);      /* room for the closed device, drawn larger */
    perspective: calc(var(--duo-w) * 2.8);
    perspective-origin: -10% 40%;
  }

  html.motion .duo__body {
    position: absolute;
    inset: 0;
    display: block;
    transform-style: preserve-3d;
    transform: scale(calc(var(--duo-zoom) - (var(--duo-zoom) - 1) * var(--o))) translateX(calc(-25% * (1 - var(--o))));
  }

  /* One half stays where it is (the right page). The other, the cover, turns on the hinge between them:
     closed, it lies over the fixed half with the cover screen outward; open, it lies flat beside it. */
  html.motion .duo__cover {
    position: absolute;
    inset-block: 0;
    left: 50%;
    display: block;
    inline-size: 50%;
    transform-origin: 0 50%;
    transform-style: preserve-3d;
    transform: rotateY(calc(var(--o) * -180deg));
  }

  html.motion .duo__slab {
    position: absolute;
    inset-block: 0;
    inline-size: 100%;
    aspect-ratio: auto;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
  }

  /* The fixed half. Its percentages are of the whole body here, twice its own width, so the bezel is halved. */
  html.motion .duo__slab--right {
    left: 50%;
    inline-size: 50%;
    padding: 1.36% 1.36% 1.36% 0;
  }

  /* Shadows lie on the ground, under what is resting on it. The fixed half always rests, so its shadow is
     always there (the closed device's shadow); the cover casts none while it is in the air, and the shadow
     under its page arrives only as it comes down, over the last eighth of the turn. */
  html.motion .duo__slab {
    box-shadow: none;
    clip-path: none;
  }

  html.motion .duo__slab--right::before,
  html.motion .duo__body::before {
    content: "";
    position: absolute;
    box-shadow: var(--device-shadow);
    pointer-events: none;
  }

  html.motion .duo__slab--right::before {
    inset: 0;
    border-radius: 1.6% 14.6% 14.6% 1.6% / 1.1% 10.3% 10.3% 1.1%;
  }

  html.motion .duo__body::before {
    inset-block: 0;
    left: 0;
    inline-size: 50%;
    border-radius: 14% 0 0 14% / 9.82% 0 0 9.82%;
    clip-path: inset(-6rem 0 -6rem -6rem);
    opacity: clamp(0, calc((var(--o) - 0.88) / 0.12), 1);
  }

  /* The cover screen is on the outside of the turning half, one thickness out. */
  html.motion .duo__slab--outer {
    left: 0;
    transform: translateZ(var(--t));
    opacity: clamp(0, calc((0.555 - var(--o)) * 1000), 1);
  }

  /* The left page is on its inside: it faces away until the cover has turned past the line of sight. */
  html.motion .duo__slab--left {
    left: -1px;
    inline-size: calc(100% + 1px);      /* a hair past the hinge, so the two pages leave no gap when flat */
    transform: rotateY(180deg);
    opacity: clamp(0, calc((var(--o) - 0.555) * 1000), 1);
  }

  /* The cover's thickness. Fifteen slices of its own outline, rounded corners and all, are stacked between its
     two faces, so from any angle its edge is a solid body with round corners, as the device's is. */
  html.motion .duo__rim {
    position: absolute;
    inset: 0;
    display: block;
    transform-style: preserve-3d;
  }

  html.motion .duo__rim > i {
    position: absolute;
    inset: 0;
    border-radius: 1.6% 14.6% 14.6% 1.6% / 1.1% 10.3% 10.3% 1.1%;
    background: linear-gradient(to right, #17181c 0%, #101114 60%, #2b2d33 97%, #4a4d55 100%);
  }

  /* Fifteen slices, a sixteenth of the thickness apart: under one CSS pixel at the largest size, so the
     rounded corners read as one smooth body, not a stack of plates, while the cover is near edge-on. */
  html.motion .duo__rim > i {
    transform: translateZ(calc(var(--t) * var(--k) / 16));
  }

  html.motion .duo__rim > i:nth-child(1) { --k: 1; }
  html.motion .duo__rim > i:nth-child(2) { --k: 2; }
  html.motion .duo__rim > i:nth-child(3) { --k: 3; }
  html.motion .duo__rim > i:nth-child(4) { --k: 4; }
  html.motion .duo__rim > i:nth-child(5) { --k: 5; }
  html.motion .duo__rim > i:nth-child(6) { --k: 6; }
  html.motion .duo__rim > i:nth-child(7) { --k: 7; }
  html.motion .duo__rim > i:nth-child(8) { --k: 8; }
  html.motion .duo__rim > i:nth-child(9) { --k: 9; }
  html.motion .duo__rim > i:nth-child(10) { --k: 10; }
  html.motion .duo__rim > i:nth-child(11) { --k: 11; }
  html.motion .duo__rim > i:nth-child(12) { --k: 12; }
  html.motion .duo__rim > i:nth-child(13) { --k: 13; }
  html.motion .duo__rim > i:nth-child(14) { --k: 14; }
  html.motion .duo__rim > i:nth-child(15) { --k: 15; }

  /* The flat walls, for the moment a face is seen exactly edge-on: the spine at the hinge (in two halves, one
     on each side of it, both behind the screen when it is open flat) and the straight middle of the free edge. */
  html.motion .duo__spine,
  html.motion .duo__edge,
  html.motion .duo__cover::before {
    position: absolute;
    display: block;
    transform-origin: 0 50%;
    transform: rotateY(-90deg);
    background: linear-gradient(to right, #3d4047 0%, #17181c 30%, #0a0b0d 70%, #2b2d33 100%);
  }

  html.motion .duo__spine {
    inset-block: 0.6%;
    left: 50%;
    inline-size: var(--t);
    transform: translateZ(calc(var(--t) * -1)) rotateY(-90deg);
  }

  html.motion .duo__cover::before {
    content: "";
    inset-block: 0.6%;
    left: 0;
    inline-size: var(--t);
  }

  html.motion .duo__spine,
  html.motion .duo__cover::before {
    opacity: clamp(0, calc((1 - var(--o)) / 0.12), 1);
  }

  /* It runs a little into the corners, so it meets the slices where they begin to round. */
  html.motion .duo__edge {
    inset-block: 9%;
    left: 100%;
    inline-size: var(--t);
  }

  /* The inner screen is dark while the device is shut and lights from the fold outward as it opens. */
  html.motion .duo__shade {
    position: absolute;
    inset: 0;
    display: block;
    border-radius: inherit;
    background: linear-gradient(to left, rgb(0 0 0 / 0.28), rgb(0 0 0 / 0.82));
    opacity: calc(1 - var(--o));
    pointer-events: none;
  }

  html.motion .duo__slab--right .duo__shade {
    background: linear-gradient(to right, rgb(0 0 0 / 0.28), rgb(0 0 0 / 0.82));
  }

  @supports (block-size: 100svh) {
    html.motion .duo {
      --duo-w: min(calc(100vw - 2 * var(--gutter)), 54rem, calc((100svh - 15rem) * 1.405));
    }
  }

  @supports (animation-timeline: view()) {
    html.motion .fold {
      view-timeline: --fold block;
    }

    html.motion .duo__body {
      transform: none;
      animation: duo-settle linear both;
      animation-timeline: --fold;
      animation-range: contain 8% contain 84%;
    }

    html.motion .duo__cover {
      transform: none;
      animation: duo-open linear both;
      animation-timeline: --fold;
      animation-range: contain 8% contain 84%;
    }

    html.motion .duo__slab--outer,
    html.motion .duo__slab--left {
      opacity: 1;
      animation: duo-front linear both;
      animation-timeline: --fold;
      animation-range: contain 8% contain 84%;
    }

    html.motion .duo__slab--left {
      animation-name: duo-back;
    }

    html.motion .duo__shade {
      opacity: 1;
      animation: fade-out linear both;
      animation-timeline: --fold;
      animation-range: contain 8% contain 84%;
    }

    html.motion .duo__body::before {
      opacity: 1;
      animation: fade-in linear both;
      animation-timeline: --fold;
      animation-range: contain 74.9% contain 84%;
    }

    html.motion .duo__spine,
    html.motion .duo__cover::before {
      opacity: 1;
      animation: fade-out linear both;
      animation-timeline: --fold;
      animation-range: contain 74.9% contain 84%;
    }
  }
}

@media screen {
  /* Quiet arrivals. With scroll timelines the reader's own scrolling brings each
     thing in; otherwise the script marks it (.is-in) as it enters. The arrival is a fixed stretch of scrolling
     (9rem; 14rem for a tall figure), not the element's own height, so a card taller than the window is whole
     before its heading reaches the middle and is never read half faded. */
  html.motion [data-reveal] {
    opacity: 0;
    transform: translateY(1.25rem);
    transition: opacity 0.8s var(--ease), transform 0.8s var(--ease);
  }

  html.motion [data-reveal].is-in {
    opacity: 1;
    transform: none;
  }

  @supports (animation-timeline: view()) {
    html.motion [data-reveal] {
      opacity: 1;
      transform: none;
      transition: none;
      animation: rise linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 9rem;
    }

    html.motion [data-reveal="tall"] {
      animation-range: entry 0% entry 14rem;
    }
  }
}

/* 18. Arabic and right-to-left -------------------------------------------------------- */

/* Everything above uses logical properties, so an Arabic page needs only
   lang="ar" and dir="rtl" on <html> for layout. These rules give Arabic its own
   type: larger, looser, never letter-spaced, never italic, never uppercase. */
[lang="ar"] {
  font-family: var(--arabic-text);
  letter-spacing: 0;
  font-style: normal;
  text-transform: none;
}

html:lang(ar) {
  --step--1: clamp(0.9375rem, 0.91rem + 0.12vw, 1rem);       /* never under 15 px */
  --step-0: clamp(1.1875rem, 1.15rem + 0.2vw, 1.3125rem);
  --step-1: clamp(1.375rem, 1.3rem + 0.36vw, 1.625rem);
  --step-2: clamp(1.625rem, 1.46rem + 0.8vw, 2.25rem);
  --step-3: clamp(2rem, 1.7rem + 1.5vw, 3rem);
  --step-4: clamp(2.625rem, 2rem + 3.2vw, 4.75rem);
  --measure: 36rem;
}

/* body sets the Latin serif for the English pages, which would otherwise override what <html> hands down. */
html:lang(ar) body {
  font-family: var(--arabic-text);
  line-height: 1.85;
}

/* Titles, labels and everything that is interface are set in the same face (one voice: see STYLE.md); they are
   named here because their own rules above choose a Latin face. */
html:lang(ar) :is(h1, h2, h3, h4, .brand__name, .site-header, .site-footer, .button, .badge, .eyebrow,
  .shot__caption, .sky__note, .sky__actions, .sky__label, .sky__when, .sky__key, .step__term, .points__term,
  .swatches__label, .segmented, .themes__note, .card__foot, .section__more, .get__note, .get__soon,
  .page-head__meta, .qa > .qa__q, .callout__title, .toc, .jump, .lost__links, .skip-link, .site-footer__promise,
  .phone img, .tablet img, .duo__slab img) {
  font-family: var(--arabic-ui);
}

/* The large step titles beside a pinned phone are Arabic too, not the Latin serif. */
html:lang(ar).motion .steps > .step > .step__term {
  font-family: var(--arabic-ui);
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0;
}

html:lang(ar) :is(.prose table, .table--stack, .table--stack tbody th) {
  font-family: var(--arabic-ui);
}

html:lang(ar) :is(h1, h2, h3, h4, .promise__title, .site-footer__promise, .qa > .qa__q) {
  line-height: 1.35;
  letter-spacing: 0;
  font-weight: 700;
}

html:lang(ar) :is(.chapter__title, .get__title, .page-head__title, .lost__title) {
  line-height: 1.25;
}

/* From 48em the first clause holds one line. Below that it breaks once, before «والحديث،», as the English breaks
   after "Quran", so the headline is as large as the English one on a phone; each half is a span.nb, so it can
   break nowhere else. (The system Arabic runs wider at small sizes than at large ones: 11.6 is for the small end.) */
html:lang(ar) .sky__title {
  font-size: min(4.5rem, 10.5vh, calc((100vw - 2 * var(--gutter)) / 11.6));
  line-height: 1.28;
}

html:lang(ar) .sky__line {
  white-space: nowrap;
}

@media (max-width: 47.99em) {
  html:lang(ar) .sky__title {
    font-size: min(4.5rem, 10.5vh, calc((100vw - 2 * var(--gutter)) / 7.9));
  }

  html:lang(ar) .sky__line {
    white-space: normal;
  }
}

html:lang(ar) :is(.sky__when, .card__title) {
  letter-spacing: 0;
  line-height: 1.3;
}

/* The name too: Arabic is never letter-spaced, and the Latin wordmark's tightening is not for it. */
html:lang(ar) .brand__name {
  letter-spacing: 0;
}

/* Ledes are balanced, so a two-word end («كما تحب.») is never left on a line of its own. */
html:lang(ar) :is(.card__lede, .section__lede) {
  text-wrap: balance;
}

html:lang(ar) :is(.sky__note, .get__note, .card__foot, .site-footer) {
  line-height: 1.7;
}

html:lang(ar) .site-header {
  font-size: 1.0625rem;
}

html:lang(ar) .site-footer {
  font-size: 1rem;
}

html:lang(ar) :is(.step__term, .points__term) {
  font-size: 1.1875rem;
  line-height: 1.6;
}

html:lang(ar) .step__more .step__term {
  font-size: 1.125rem;
}

html:lang(ar) .swatches__label {
  font-size: 0.9375rem;
}

/* The Plus badge keeps its own size wherever it stands; beside a large step title it grows a little with it. */
html:lang(ar) .badge,
html:lang(ar) .badge[lang="en"] {
  font-size: 0.9375rem;
}

html:lang(ar).motion .steps > .step > .step__term .badge {
  font-size: max(0.9375rem, 0.42em);
}

html:lang(ar) :is(.sky__key, .prices__label) {
  font-size: 1rem;
  line-height: 1.6;
}

/* Beside the phone on a wide screen the line is body size, as in English (the rule above would otherwise win:
   it is as specific as the motion rule and comes later). */
@media screen and (min-height: 30em) and (min-width: 60em) {
  html:lang(ar).motion .sky__key {
    font-size: var(--step-0);
    line-height: 1.6;
  }
}

html:lang(ar) .eyebrow {
  letter-spacing: 0;
}

html:lang(ar) :is(.segmented, .section__more, .sky__status) {
  font-size: 1.0625rem;
}

html:lang(ar) :is(.step__term, .points > li)::before,
html:lang(ar) .step__term::after {
  inset-block-start: 0.62em;
}

html:lang(ar) .points--plain > li::before {
  inset-block-start: 0.86em;
}

/* A 1.85 line height needs more air between items than within them. */
html:lang(ar) :is(.points, .step__more) {
  row-gap: var(--space-5);
}

html:lang(ar) .points--plain {
  row-gap: var(--space-3);
}

html:lang(ar) .prose {
  line-height: 1.95;
}

html:lang(ar) .prose li + li {
  margin-block-start: 0.7em;
}

html:lang(ar) .prose ul.cols {
  margin-block-end: -0.7em;
}

html:lang(ar) .prose .cols > li {
  margin-block-start: 0;
  padding-block-end: 0.7em;
}

/* Inner pages: the lists of links, the labels and the table are interface, so
   they take the interface sizes (nothing under 15 px) and a looser line. */
html:lang(ar) :is(.page-head__lede, .lead, .lost__note) {
  line-height: 1.75;
}

html:lang(ar) .page-head__meta {
  font-size: 1rem;
}

html:lang(ar) .part__label {
  font-size: 1.0625rem;
}

html:lang(ar) :is(.toc, .lost__links) {
  font-size: 1.0625rem;
  line-height: 1.5;
}

html:lang(ar) .jump {
  font-size: 1rem;
  line-height: 1.5;
}

html:lang(ar) .lead > li::before {
  inset-block-start: 0.74em;
}

html:lang(ar) .qa > .qa__q {
  scroll-margin-block-start: calc((var(--step-2) - var(--step-1)) * 1.025);
}

html:lang(ar) .qa > .qa__a + .qa__q {
  margin-block-start: 2.3em;
}

html:lang(ar) .table--stack {
  font-size: 1rem;
  line-height: 1.75;
}

html:lang(ar) .table--stack tbody th {
  font-size: var(--step-0);
  line-height: 1.6;
}

@media (min-width: 60em) {
  html:lang(ar) .table--stack tbody th {
    font-size: 1.3125rem;
    line-height: 1.55;
  }
}

@media (max-width: 29.99em) {
  html:lang(ar) .site-header {
    font-size: 0.9375rem;
  }
}

@media (max-width: 23.99em) {
  html:lang(ar) .segmented {
    font-size: 0.9375rem;
  }
}

/* Latin set inside Arabic (Midad Plus, sunnah.com, an email address) and
   Arabic set inside English keep their own face and direction. Latin beside
   Arabic is set a little smaller, so the two look the same size. */
html:lang(ar) [lang="en"] {
  font-family: var(--sans);
  font-size: 0.92em;
}

/* Not in small print, though: nothing on an Arabic page goes under 15 px. */
html:lang(ar) :is(.site-footer, .shot__caption, .themes__note, .card__foot, .swatches__label, .segmented,
  .page-head__meta, .prose table, .table--stack, .toc, .jump, .lost__links, .prose small, .sky__status,
  .sky__key) [lang="en"] {
  font-size: 1em;
}


/* The language link names the other language in that language. */
.lang-link:lang(ar),
.site-footer__nav a:lang(ar),
.lost__links a:lang(ar) {
  font-family: var(--arabic-ui);
  font-size: 1.0625rem;
}

html:lang(ar) .lang-link:lang(en),
html:lang(ar) .site-footer__nav a:lang(en) {
  font-size: 0.9375rem;
}

/* 19. Reduced motion, forced colours ---------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
  }

  /* A shelf still comes to rest on a whole screen: the snap only finishes the reader's own swipe, and without
     it a shelf could be left showing a screen in part. */
}

@media (forced-colors: active) {
  .prose ul > li::before {
    content: none;
  }

  .prose ul > li::marker {
    color: CanvasText;
  }

  .lead > li::before,
  .part__label::before {
    border-color: CanvasText;
  }

  .step__term::before,
  .points > li::before,
  .eyebrow::before {
    border-color: CanvasText;
  }

  .button {
    border-color: ButtonText;
  }

  .phone,
  .tablet,
  .duo__slab {
    border: 1px solid CanvasText;
  }

  .segmented__input:checked + .segmented__label,
  .swatches__input:checked + .swatches__label {
    outline: 2px solid Highlight;
  }
}

/* 20. Print (written for the Privacy page; safe for every page) -------------------------- */

@media print {
  :root {
    --page: #fff;
    --card: #fff;
    --ink: #000;
    --muted: #333;
    --gold: #000;
    --hairline: #bbb;
    --link: #000;
    --shadow: none;
    --device-shadow: none;
    --measure: none;
  }

  /* The Arabic measure is set on html:lang(ar), so it is lifted there too. */
  html:lang(ar) {
    --measure: none;
  }

  @page {
    margin: 2cm;
  }

  html {
    font-size: 11pt;
  }

  body {
    background: #fff;
    color: #000;
    line-height: 1.5;
  }

  .skip-link,
  .site-nav,
  .lang-link,
  .site-footer__nav,
  .site-footer__promise,
  nav.part,
  nav.page-head__intro,
  .jump,
  .lost__actions,
  .lost__links,
  .sky__actions,
  .sky__bg,
  .swatches,
  .segmented {
    display: none !important;
  }

  .wrap {
    max-inline-size: none;
    padding-inline: 0;
  }

  .site-header,
  .site-header--sky,
  .sky,
  .get {
    position: static;
    border: 0;
    background: none;
    color: #000;
  }

  .site-header::after,
  .sky::before,
  .get::before {
    content: none;
  }

  .site-header--sky .brand,
  .get__soon,
  .get__name {
    color: #000;
  }

  .sky {
    padding-block-end: 1em;
  }

  .sky__intro {
    padding-block-start: 1em;
  }

  .shelf {
    flex-wrap: wrap;
    margin-inline: 0;
    padding-inline: 0;
    overflow: visible;
  }

  .shelf > *,
  .shelf > :first-child,
  .shelf > :last-child,
  .sky__frame {
    inline-size: 30%;
    margin-inline: 0 3%;
    margin-block-end: 1em;
  }

  .page-head {
    padding-block: 1.5em 1em;
  }

  .page-head__title,
  .lost__title {
    font-size: 26pt;
  }

  .doc {
    padding-block-end: 1em;
  }

  /* On paper a part is its heading and then its text, in one column. */
  .part {
    display: block;
    padding-block: 1.1em;
  }

  .part > .part__side {
    position: static;
  }

  .part > .part__body {
    margin-block-start: 0.6em;
  }

  .part__label {
    color: #000;
  }

  .lost {
    min-block-size: 0;
  }

  .lost__inner {
    padding-block: 2em;
  }

  h1, h2, h3, h4, dt {
    break-after: avoid;
  }

  p, li, dd {
    orphans: 3;
    widows: 3;
  }

  tr, figure, .callout, .card, address, .part__side, .lead > li {
    break-inside: avoid;
  }

  .part__side {
    break-after: avoid;
  }

  .table-wrap {
    overflow: visible;
  }

  /* Print where a link goes, since paper cannot follow it; not when its text is the address already. */
  .prose a[href^="http"]:not(.url)::after,
  .table--stack a[href^="http"]:not(.url)::after {
    content: " (" attr(href) ")";
    font-family: var(--sans);
    font-size: 0.85em;
    overflow-wrap: anywhere;
  }

  /* The footer stays in one piece: its last two lines are never alone on a page. */
  .site-footer {
    font-size: 9pt;
    break-inside: avoid;
  }

  .site-footer__legal {
    max-inline-size: none;
  }

  .site-footer__inner {
    display: block;
    padding-block: 1em 0;
  }
}
