/*
  One day in an old city. Four paintings are full plates (the library at sunrise, the dome, the
  lake at sunset, the columns at night) and parchment tablets sit between them. Text starts at
  the right; on a plate it stands on the painting's open sky, never on its subject.
*/
:root {
  --sky: #f5d98e;
  --parchment: #fbf2d8;
  --tablet: #f4e5b8;
  --ivory: #fffbea;
  --ink: #2a1905;
  --ink-soft: #5d4616;
  --bronze: #8a5708;
  --sun: #fff7dc;
  --umber: #1d1104;
  --dusk: #f1b382;
  --night: #070f2b;
  --star: #ecdfb4;
  --line: rgb(42 25 5 / 0.16);
  --error: #a3230b;

  /* Fustat: a Kufic face, the script Arabic was cut into stone with. Cinzel: Roman inscription
     capitals, for the figures and the Latin code. Both are letters made for a wall. */
  --font-arabic: 'Fustat', 'Geeza Pro', 'Segoe UI', Tahoma, sans-serif;
  --font-roman: 'Cinzel', 'Fustat', 'Times New Roman', serif;

  --gutter: clamp(16px, 4vw, 48px);
  --section: clamp(72px, 10vw, 140px);
  --radius-plate: clamp(20px, 3vw, 36px);
  --radius-field: 14px;

  color-scheme: light;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 96px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--parchment);
  color: var(--ink);
  font-family: var(--font-arabic);
  font-size: 1.0625rem;
  font-weight: 400;
  line-height: 1.9;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-arabic);
  font-weight: 800;
  line-height: 1.4;
  text-wrap: balance;
}

h2 {
  font-size: clamp(1.9rem, 3.6vw, 3.1rem);
}

h3 {
  font-size: 1.3rem;
  font-weight: 700;
}

p {
  margin: 0;
}

a {
  color: inherit;
  text-underline-offset: 0.3em;
  text-decoration-thickness: 1px;
}

img {
  display: block;
  max-width: 100%;
}

/* `hidden` must win over any `display` a class sets: the sent form is hidden this way. */
[hidden] {
  display: none !important;
}

::selection {
  background: #e9c25a;
  color: var(--ink);
}

:focus-visible {
  outline: 3px solid var(--bronze);
  outline-offset: 3px;
  border-radius: 6px;
}

.wrap {
  width: 100%;
  max-width: calc(1200px + 2 * var(--gutter));
  margin-inline: auto;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: fixed;
  top: 12px;
  inset-inline-start: 12px;
  z-index: 100;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--sun);
  transform: translateY(-200%);
}

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

/* --- Buttons --- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  padding: 0 30px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1.4;
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn--ink {
  background: var(--ink);
  color: var(--sun);
  box-shadow: 0 12px 26px -8px rgb(42 25 5 / 0.5);
}

.btn--line {
  color: var(--ink);
  box-shadow: inset 0 0 0 1.5px var(--ink);
}

.btn--small {
  min-height: 44px;
  padding: 0 22px;
  font-size: 0.95rem;
  box-shadow: none;
}

.btn--wide {
  width: 100%;
}

.btn[disabled] {
  opacity: 0.6;
  cursor: progress;
}

@media (hover: hover) {
  .btn--ink:hover {
    background: #3d2609;
  }

  .btn--line:hover {
    background: rgb(42 25 5 / 0.08);
  }
}

/* --- The bar that floats over every plate --- */

.nav {
  position: fixed;
  inset: 0 0 auto;
  z-index: 50;
  padding: calc(12px + env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) 0
    max(12px, env(safe-area-inset-left, 0px));
  pointer-events: none;
}

.nav__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1120px;
  margin-inline: auto;
  padding: 8px;
  padding-inline-start: 18px;
  border: 1px solid rgb(255 255 255 / 0.5);
  border-radius: 999px;
  background: rgb(251 242 216 / 0.66);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  backdrop-filter: blur(18px) saturate(1.4);
  box-shadow: 0 14px 34px -14px rgb(42 25 5 / 0.35);
  pointer-events: auto;
}

/* Where a browser cannot blur what is behind, the bar is solid. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .nav__bar {
    background: var(--parchment);
  }
}

.nav__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-block: 9px;
  font-weight: 800;
  font-size: 1.05rem;
  line-height: 1.4;
  text-decoration: none;
  white-space: nowrap;
}

/* The file is cut to its artwork (scripts/images.mjs), so its box is the controller itself. */
.nav__brand img {
  width: 40px;
  height: auto;
}

.nav__links {
  display: flex;
  gap: clamp(16px, 2.6vw, 36px);
  font-size: 0.98rem;
  font-weight: 500;
}

.nav__links a {
  padding-block: 6px;
  text-decoration: none;
  white-space: nowrap;
}

@media (hover: hover) {
  .nav__links a:hover {
    text-decoration: underline;
  }
}

@media (max-width: 859px) {
  .nav__links {
    display: none;
  }
}

/* --- 1. The library at sunrise --- */

.hero {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  min-height: clamp(620px, 94svh, 940px);
  background: var(--sky);
  overflow: hidden;
}

.hero__art {
  position: absolute;
  inset: 0;
  z-index: -3;
}

.hero__art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* On a screen narrower than the painting, keep the open sky and let the library's far end go. */
  object-position: 20% 50%;
}

/* A veil of light on the open sky, where the words stand. */
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -2;
  background: radial-gradient(52% 60% at 22% 36%, rgb(255 245 208 / 0.62), transparent 72%);
}

/* The floor of the painting runs out into the page. */
.hero::after {
  content: '';
  position: absolute;
  inset: auto 0 0;
  z-index: -1;
  height: 24%;
  background: linear-gradient(to bottom, transparent, var(--parchment) 92%);
}

/* The sun behind the hills, breathing. The one thing on the page that moves by itself. */
.hero__sun {
  position: absolute;
  top: 58%;
  left: 27%;
  z-index: -2;
  width: 56vmax;
  height: 56vmax;
  border-radius: 50%;
  background: radial-gradient(circle, rgb(255 248 214 / 0.75) 0%, rgb(255 236 170 / 0.28) 26%, transparent 60%);
  transform: translate(-50%, -50%);
  mix-blend-mode: screen;
  opacity: 0.55;
}

/* The library fills the painting's right half at every width, so the words are placed by the
   screen, not by the page's column: they end before 44% of the way across. */
.hero__inner {
  max-width: none;
  padding-block: 132px 190px;
}

.hero__copy {
  width: min(36rem, 38vw);
  margin-right: auto;
  margin-left: clamp(0px, 5vw, 110px);
}

.hero h1 {
  font-size: clamp(2.6rem, 5.6vw, 5.2rem);
  line-height: 1.3;
}

.hero__lead {
  max-width: 31em;
  margin-top: 20px;
  font-size: clamp(1.08rem, 1.45vw, 1.3rem);
  font-weight: 500;
  line-height: 1.95;
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 34px;
}

@media (max-width: 899px) {
  /* A tall screen: the words on plain sky, the painting rising under them. */
  .hero {
    flex-direction: column;
    align-items: stretch;
    min-height: 0;
  }

  .hero::before,
  .hero__sun {
    display: none;
  }

  .hero__inner {
    order: 1;
    padding-block: 118px 0;
    text-align: center;
  }

  .hero__copy {
    width: auto;
    margin-inline: 0;
  }

  .hero__lead {
    margin-inline: auto;
  }

  .hero__actions {
    justify-content: center;
  }

  .hero__art {
    position: relative;
    inset: auto;
    z-index: -3;
    order: 2;
    display: block;
    height: clamp(320px, 92vw, 600px);
    margin-top: 4px;
    -webkit-mask-image: linear-gradient(to bottom, transparent, #000 30%);
    mask-image: linear-gradient(to bottom, transparent, #000 30%);
  }

  .hero__art img {
    object-position: 66% 100%;
  }

  .hero::after {
    height: 16%;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .hero__sun {
    animation: sun-breath 7s ease-in-out infinite alternate;
  }

  @supports (animation-timeline: scroll()) {
    @media (min-width: 900px) {
      .hero__art img {
        animation: plate-drift linear both;
        animation-timeline: scroll(root);
        animation-range: 0 100vh;
      }
    }
  }

  @keyframes plate-drift {
    to {
      transform: translateY(9%) scale(1.06);
    }
  }

  /* The one staged moment: the words of the hero arrive in order. Their resting state is
     visible, so a browser that skips the animation still shows them. */
  .hero__copy > * {
    animation: words-arrive 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  }

  .hero__copy > :nth-child(2) {
    animation-delay: 0.12s;
  }

  .hero__copy > :nth-child(3) {
    animation-delay: 0.24s;
  }

  @keyframes words-arrive {
    from {
      opacity: 0;
      transform: translateY(18px);
    }
  }

  @keyframes sun-breath {
    to {
      opacity: 0.95;
      transform: translate(-50%, -50%) scale(1.08);
    }
  }
}

/* --- 2. The rates --- */

.rates {
  position: relative;
  z-index: 2;
  margin-top: -92px;
}

.rates__tablet {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0;
  padding: clamp(18px, 3vw, 34px) clamp(4px, 1.5vw, 20px);
  list-style: none;
  border-radius: var(--radius-plate);
  background: var(--ivory);
  box-shadow:
    0 0 0 1px rgb(138 87 8 / 0.12),
    0 40px 70px -34px rgb(74 45 6 / 0.55);
}

.rates__tablet li {
  display: grid;
  justify-items: center;
  align-content: start;
  padding-inline: clamp(6px, 2vw, 24px);
  text-align: center;
}

.rates__tablet li + li {
  border-inline-start: 1px solid var(--line);
}

.rates__figure {
  font-family: var(--font-roman);
  font-size: clamp(2rem, 5.2vw, 4rem);
  font-weight: 600;
  line-height: 1.15;
}

.rates__name {
  margin-top: 6px;
  font-size: clamp(0.92rem, 1.5vw, 1.15rem);
  font-weight: 700;
  line-height: 1.6;
}

.rates__note {
  color: var(--ink-soft);
  font-size: clamp(0.82rem, 1.2vw, 0.95rem);
  line-height: 1.7;
}

@media (max-width: 899px) {
  .rates {
    margin-top: -56px;
  }
}

/* --- A few lines before the numbers --- */

.intro {
  max-width: calc(58rem + 2 * var(--gutter));
  padding-block: var(--section) calc(var(--section) * 0.8);
  text-align: center;
}

.intro p {
  font-size: clamp(1.3rem, 2.3vw, 2rem);
  font-weight: 500;
  line-height: 1.9;
  text-wrap: pretty;
}

.intro p + p {
  margin-top: 1.1em;
  color: var(--ink-soft);
}

/* --- 3. Under the dome --- */

.calc__plate {
  position: relative;
  isolation: isolate;
  display: grid;
  min-height: 600px;
  overflow: hidden;
  border-radius: var(--radius-plate);
  background: var(--umber);
  color: var(--sun);
}

.calc__art {
  position: absolute;
  inset: 0;
  z-index: -2;
}

.calc__art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: left top;
}

/* Darker toward the right, where the numbers are; the eye of the dome stays lit on the left. */
.calc__plate::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(to left, rgb(29 17 4 / 0.93) 0%, rgb(29 17 4 / 0.82) 40%, rgb(29 17 4 / 0.2) 74%, transparent 100%);
}

.calc__body {
  align-self: center;
  width: min(100%, 43rem);
  padding: clamp(28px, 5vw, 68px);
}

.calc__input {
  margin-top: 28px;
}

.calc__input label {
  display: block;
  color: var(--star);
  font-size: 1rem;
  font-weight: 500;
}

.calc__amount {
  display: block;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.5;
}

.calc__amount bdi {
  font-family: var(--font-roman);
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 600;
}

/* Each digit of a moving figure stands in a cell of one width, so the figure does not shiver as
   its digits change. The face has no figures of equal width of its own: its 1 is 0.38em wide
   and its 0 is 0.63em, `tabular-nums` or not. */
.calc .digit {
  display: inline-block;
  width: 0.62em;
  text-align: center;
}

.calc input[type='range'] {
  --fill: 50%;
  display: block;
  width: 100%;
  height: 44px;
  margin: 4px 0 0;
  background: transparent;
  direction: rtl;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.calc input[type='range']::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 4px;
  background: linear-gradient(to left, var(--sun) var(--fill), rgb(255 247 220 / 0.26) var(--fill));
}

.calc input[type='range']::-moz-range-track {
  height: 4px;
  border-radius: 4px;
  background: rgb(255 247 220 / 0.26);
}

.calc input[type='range']::-moz-range-progress {
  height: 4px;
  border-radius: 4px;
  background: var(--sun);
}

/* The handle is a coin. */
.calc input[type='range']::-webkit-slider-thumb {
  width: 30px;
  height: 30px;
  margin-top: -13px;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #fff5cc, #e6bb4c 52%, #a37312);
  box-shadow:
    0 0 0 5px rgb(255 247 220 / 0.16),
    0 6px 14px rgb(0 0 0 / 0.5);
  -webkit-appearance: none;
  appearance: none;
}

.calc input[type='range']::-moz-range-thumb {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #fff5cc, #e6bb4c 52%, #a37312);
  box-shadow:
    0 0 0 5px rgb(255 247 220 / 0.16),
    0 6px 14px rgb(0 0 0 / 0.5);
}

.calc input[type='range']:focus-visible {
  outline: 0;
}

.calc input[type='range']:focus-visible::-webkit-slider-thumb {
  box-shadow:
    0 0 0 3px var(--umber),
    0 0 0 6px var(--sun);
}

.calc input[type='range']:focus-visible::-moz-range-thumb {
  box-shadow:
    0 0 0 3px var(--umber),
    0 0 0 6px var(--sun);
}

/* One label under each stop of the handle, whose centre travels 15px inside each end. */
.calc__ticks {
  display: flex;
  justify-content: space-between;
  margin: 0;
  padding: 0 15px;
  list-style: none;
  color: rgb(236 223 180 / 0.8);
  font-family: var(--font-roman);
  font-size: clamp(0.68rem, 1.1vw, 0.82rem);
  line-height: 1.6;
  direction: rtl;
}

.calc__ticks li {
  display: flex;
  justify-content: center;
  width: 0;
  white-space: nowrap;
}

/* Each amount takes a press (app.js); the padding is the room a finger needs. */
.calc__ticks span {
  margin-block: -8px;
  padding: 12px 8px;
  cursor: pointer;
  transition: color 0.2s ease;
}

@media (hover: hover) {
  .calc__ticks span:hover {
    color: var(--sun);
  }
}

.calc__results {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(16px, 3vw, 40px);
  margin-top: 34px;
}

.calc__result {
  padding-top: 18px;
  border-top: 1px solid rgb(255 247 220 / 0.3);
}

.calc__kind {
  color: var(--star);
  font-size: 0.98rem;
  font-weight: 500;
  line-height: 1.7;
}

.calc__kind bdi {
  display: block;
  font-family: var(--font-roman);
  font-size: 1.05rem;
  text-align: right;
}

/* One line that never wraps: a figure that grows must not change the plate's height. */
.calc__profit {
  display: flex;
  align-items: baseline;
  gap: 0 10px;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.calc__profit strong {
  font-family: var(--font-roman);
  font-size: clamp(2.3rem, 5.4vw, 3.9rem);
  font-weight: 600;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.calc__result a {
  display: inline-block;
  padding-block: 8px;
  color: var(--star);
  font-size: 0.95rem;
}

.calc__payout {
  margin-top: 30px;
  color: rgb(255 247 220 / 0.86);
  font-size: 0.98rem;
}

@media (max-width: 519px) {
  .calc__results {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 759px) {
  .calc__plate {
    min-height: 0;
  }

  .calc__art img {
    object-position: 12% top;
  }

  .calc__plate::before {
    background: linear-gradient(to bottom, rgb(29 17 4 / 0.05) 0%, rgb(29 17 4 / 0.86) 36%, rgb(29 17 4 / 0.95) 100%);
  }

  .calc__body {
    padding-top: 46vw;
  }
}

/* --- 4. The partner's own code --- */

.coupon {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: center;
  gap: clamp(28px, 6vw, 88px);
  padding-block: var(--section);
}

.coupon__copy > p {
  margin-top: 14px;
  font-size: clamp(1.1rem, 1.5vw, 1.3rem);
  font-weight: 500;
}

@media (max-width: 759px) {
  .coupon {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* --- Fields, shared by the code try-out and the sign-up form --- */

.field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.field > label:not(.choice, .pledge),
.field legend {
  display: block;
  margin-bottom: 8px;
  padding: 0;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.7;
}

.field input[type='text'],
.field input[type='tel'] {
  display: block;
  width: 100%;
  min-height: 54px;
  padding: 0 16px;
  border: 1px solid rgb(42 25 5 / 0.22);
  border-radius: var(--radius-field);
  background: var(--ivory);
  color: var(--ink);
  font: inherit;
  font-weight: 500;
}

.field input[dir='ltr'] {
  font-family: var(--font-roman);
  letter-spacing: 0.04em;
  text-align: right;
}

.field input::placeholder {
  color: rgb(93 70 22 / 0.55);
}

.field input[type='text']:focus-visible,
.field input[type='tel']:focus-visible {
  border-color: var(--bronze);
  outline: 3px solid rgb(138 87 8 / 0.35);
  outline-offset: 0;
  border-radius: var(--radius-field);
}

.field input[aria-invalid='true'] {
  border-color: var(--error);
}

.field--inline {
  max-width: 22rem;
  margin-top: 26px;
}

@media (max-width: 759px) {
  .field--inline {
    margin-bottom: 22px;
  }
}

/* What a field turned away, said for a moment. It hangs in the gap under the field, so nothing
   below moves when it comes and goes. */
.field {
  position: relative;
}

.field__hint {
  position: absolute;
  inset: 100% 0 auto;
  margin-top: 2px;
  color: var(--bronze);
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.35;
  pointer-events: none;
}

.form input {
  scroll-margin-block: 150px 40px;
}

.field input.is-refusing {
  border-color: var(--bronze);
  animation: refuse 0.28s ease;
}

@keyframes refuse {
  25% {
    transform: translateX(3px);
  }

  75% {
    transform: translateX(-3px);
  }
}

.field__error {
  margin-top: 6px;
  color: var(--error);
  font-size: 0.92rem;
  font-weight: 600;
}

/* --- 5. Three steps --- */

.how h2,
.faq h2 {
  text-align: center;
}

.how__steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(20px, 3.4vw, 56px);
  margin: clamp(32px, 5vw, 64px) 0 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.how__steps li {
  padding-top: 22px;
  border-top: 2px solid var(--ink);
  counter-increment: step;
}

.how__steps li::before {
  content: counter(step);
  display: block;
  margin-bottom: 10px;
  color: var(--bronze);
  font-family: var(--font-roman);
  font-size: clamp(3.2rem, 6.4vw, 5.4rem);
  font-weight: 500;
  line-height: 1.05;
}

.how__steps p {
  margin-top: 8px;
  color: var(--ink-soft);
}

@media (max-width: 759px) {
  .how__steps {
    grid-template-columns: minmax(0, 1fr);
  }

  .how__steps li {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: 20px;
  }

  .how__steps li::before {
    grid-row: span 2;
    min-width: 0.9em;
    margin: 0;
  }
}

/* --- 7. Questions --- */

.faq {
  max-width: calc(54rem + 2 * var(--gutter));
}

.faq__list {
  margin-top: clamp(24px, 4vw, 44px);
  border-top: 1px solid var(--line);
}

.faq details {
  border-bottom: 1px solid var(--line);
}

.faq summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 4px;
  font-size: clamp(1.08rem, 1.5vw, 1.25rem);
  font-weight: 700;
  line-height: 1.7;
  list-style: none;
  cursor: pointer;
}

.faq summary::-webkit-details-marker {
  display: none;
}

.faq summary::after {
  content: '+';
  flex: none;
  color: var(--bronze);
  font-family: var(--font-roman);
  font-size: 1.7rem;
  font-weight: 500;
  line-height: 1;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.faq details[open]:not(.is-closing) summary::after {
  transform: rotate(45deg);
}

.faq details p {
  max-width: 62ch;
  padding: 0 4px 26px;
  color: var(--ink-soft);
}

.faq details b {
  margin-inline-end: 0.5em;
  color: var(--bronze);
  font-weight: 800;
}

/* --- 8. Sunset over the lake --- */

.apply {
  position: relative;
  isolation: isolate;
  margin-top: var(--section);
  padding-block: clamp(120px, 15vw, 210px) clamp(170px, 22vw, 330px);
  background: var(--dusk);
  overflow: hidden;
}

.apply__art {
  position: absolute;
  inset: 0;
  z-index: -3;
}

.apply__art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 26% 50%;
}

/* The page's parchment gives way to the evening sky. */
.apply::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  z-index: -2;
  height: 20%;
  background: linear-gradient(to bottom, var(--parchment), transparent);
}

/* And the evening to the night of the last plate. */
.apply::after {
  content: '';
  position: absolute;
  inset: auto 0 0;
  z-index: -1;
  height: 38%;
  background: linear-gradient(to bottom, transparent, rgb(7 15 43 / 0.7) 62%, var(--night));
}

.apply__column {
  width: min(100%, 34rem);
}

.apply h2 {
  color: #3b1c06;
}

.apply__lead {
  margin-top: 8px;
  color: #4a2609;
  font-size: clamp(1.1rem, 1.5vw, 1.3rem);
  font-weight: 600;
}

.form,
.form__done {
  margin-top: 28px;
  padding: clamp(20px, 3.4vw, 38px);
  border-radius: var(--radius-plate);
  background: rgb(255 251 234 / 0.95);
  box-shadow:
    inset 0 0 0 1px rgb(255 255 255 / 0.7),
    0 50px 90px -40px rgb(74 28 4 / 0.75);
}

.form {
  position: relative;
  display: grid;
  gap: 26px;
}

.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 11px 14px;
  border: 1px solid rgb(42 25 5 / 0.18);
  border-radius: var(--radius-field);
  background: var(--ivory);
  font-weight: 500;
  line-height: 1.7;
  cursor: pointer;
}

.choice + .choice {
  margin-top: 8px;
}

.choice:has(input:checked) {
  border-color: var(--ink);
  background: #fff3cf;
}

.choice:has(input:focus-visible) {
  outline: 3px solid rgb(138 87 8 / 0.35);
}

.choice input,
.pledge input {
  flex: none;
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--ink);
}

.choice input:focus-visible {
  outline: 0;
}

.pledge {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 0;
  font-size: 0.98rem;
  font-weight: 500;
  line-height: 1.9;
  cursor: pointer;
}

.pledge input {
  margin-top: 7px;
}

.pledge__note {
  margin-top: 8px;
  padding-inline-start: 32px;
  color: var(--bronze);
  font-weight: 700;
}

.form__trap {
  position: absolute;
  inset-inline-start: -200vw;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.form__status {
  color: var(--error);
  font-weight: 600;
  text-align: center;
}

.form__done h3 {
  font-size: 1.7rem;
  font-weight: 800;
}

.form__done p {
  margin-top: 6px;
  color: var(--ink-soft);
  font-size: 1.1rem;
}

@media (max-width: 759px) {
  .apply__art img {
    object-position: 18% 0;
  }
}

/* --- 9. Night --- */

.foot {
  position: relative;
  isolation: isolate;
  background: var(--night);
  color: var(--star);
  overflow: hidden;
}

.foot__art {
  position: absolute;
  inset: 0;
  z-index: -3;
}

.foot__art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 30% 62%;
}

.foot::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  z-index: -2;
  height: 30%;
  background: linear-gradient(to bottom, var(--night), transparent);
}

.foot::after {
  content: '';
  position: absolute;
  inset: auto 0 0;
  z-index: -1;
  height: 34%;
  background: linear-gradient(to bottom, transparent, rgb(7 15 43 / 0.94) 78%);
}

.foot__inner {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 48px;
  min-height: clamp(600px, 62vw, 940px);
  padding-block: clamp(110px, 14vw, 200px) calc(28px + env(safe-area-inset-bottom, 0px));
}

.foot__line {
  max-width: 9.5em;
  color: var(--sun);
  font-size: clamp(2.7rem, 7.6vw, 6.6rem);
  font-weight: 800;
  line-height: 1.3;
  text-wrap: balance;
}

.foot__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 18px 32px;
  padding-top: 22px;
  border-top: 1px solid rgb(236 223 180 / 0.22);
  font-size: 0.98rem;
}

.foot__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-block: 6px;
  color: var(--sun);
  font-weight: 800;
  text-decoration: none;
}

.foot__brand img {
  width: auto;
  height: 32px;
}

.foot__links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
}

.foot__links a {
  padding-block: 10px;
  text-decoration: none;
}

@media (hover: hover) {
  .foot__links a:hover {
    text-decoration: underline;
  }
}

.foot__rights {
  color: rgb(236 223 180 / 0.78);
}

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

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation: none !important;
  }
}

/* ==========================================================================
   Life. Everything below either answers the visitor or is small and slow.
   All of it is off under `prefers-reduced-motion` (the rule above this block).
   ========================================================================== */

/* --- The bar draws itself in to the logo alone once the page is scrolling down --- */

.nav__bar {
  width: var(--nav-open, 100%);
  overflow: hidden;
  white-space: nowrap;
  transition:
    width 0.6s cubic-bezier(0.3, 0.8, 0.2, 1),
    padding 0.6s cubic-bezier(0.3, 0.8, 0.2, 1),
    transform 0.6s cubic-bezier(0.3, 0.8, 0.2, 1),
    background-color 0.4s ease;
}

.nav__brand,
.nav__links,
.nav .btn {
  flex: none;
}

.nav__brand span,
.nav__links,
.nav .btn {
  transition:
    opacity 0.3s ease 0.18s,
    visibility 0s linear 0s;
}

/* A circle, as wide as the bar is tall (8 + 44 + 8 + two 1px borders), with the 40px logo dead
   centre: 1px border + 10px + 40px + 10px + 1px. */
.nav.is-small .nav__bar {
  width: 62px;
  padding-inline: 10px;
  transform: translateY(-2px);
  cursor: pointer;
}

.nav.is-small .nav__brand span,
.nav.is-small .nav__links,
.nav.is-small .btn {
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.15s ease,
    visibility 0s linear 0.15s;
}

.nav__links a {
  position: relative;
}

.nav__links a::after {
  content: '';
  position: absolute;
  inset: auto 0 2px;
  height: 1.5px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.35s cubic-bezier(0.3, 0.8, 0.2, 1);
}

@media (hover: hover) {
  .nav__links a:hover {
    text-decoration: none;
  }

  .nav__links a:hover::after {
    transform: scaleX(1);
  }
}

/* --- Parts rise into place as they come into view. Only once a script has said it will
       bring them in: without it they are simply there. --- */

[data-rise='1'] {
  --i: 1;
}

[data-rise='2'] {
  --i: 2;
}

.motion [data-rise] {
  opacity: 0;
  transform: translateY(28px);
  transition:
    opacity 0.9s ease,
    transform 0.9s cubic-bezier(0.2, 0.7, 0.2, 1);
  transition-delay: calc(var(--i, 0) * 110ms);
}

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

/* The rule over each step draws from the right as the step arrives. */
.how__steps li {
  border-top: 0;
  background: linear-gradient(var(--ink), var(--ink)) top right / 100% 2px no-repeat;
}

.motion .how__steps li {
  background-size: 0% 2px;
  transition:
    opacity 0.9s ease,
    transform 0.9s cubic-bezier(0.2, 0.7, 0.2, 1),
    background-size 1.1s cubic-bezier(0.3, 0.8, 0.2, 1);
  transition-delay: calc(var(--i, 0) * 110ms);
}

.motion .how__steps li.is-in {
  background-size: 100% 2px;
}

/* --- A painting still on its way is held back, then fades in over its blurred copy --- */

.hero__art img,
.calc__art img,
.apply__art img,
.foot__art img {
  transition: opacity 0.9s ease;
}

img.is-arriving {
  opacity: 0;
}

/* --- Motes in the hero's light, stars over the footer --- */

.hero__motes,
.foot__stars {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.hero__motes {
  z-index: -1;
}

/* Stars show only where the painting is sky: behind the columns, never in front of them. The
   mask is laid over the canvas exactly as the painting is laid in its frame, so its size and
   position must stay the same as `.foot__art img`'s (cover, 30% 62%). */
.foot__stars {
  z-index: -2;
  -webkit-mask: url(assets/img/columns-night-sky.webp) 30% 62% / cover no-repeat;
  mask: url(assets/img/columns-night-sky.webp) 30% 62% / cover no-repeat;
}

@media (max-width: 899px) {
  .hero__motes {
    display: none;
  }
}

/* --- A painting inside a plate moves a little against the page --- */

@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) {
    .calc__art img,
    .apply__art img {
      animation: plate-pass linear both;
      animation-timeline: view();
      animation-range: entry 0% exit 100%;
    }

    @keyframes plate-pass {
      from {
        transform: translateY(-4%) scale(1.1);
      }

      to {
        transform: translateY(4%) scale(1.1);
      }
    }
  }
}

/* --- A question opens and closes: app.js runs the answer's height and opacity --- */

.faq__answer {
  overflow: hidden;
}

/* --- 4. The ticket ---
   A coupon as people know one: dark paper, gold print, a stub torn along a dotted line. */

.ticket {
  justify-self: center;
  width: min(100%, 30rem);
  filter: drop-shadow(0 34px 40px rgb(74 45 6 / 0.42));
  rotate: -4deg;
}

/* Under the pointer nothing lifts, tilts, grows or shines anywhere on the page (the owner reads
   those as machine-made). The ticket catches the light only when its name changes. */

.ticket__paper {
  --notch: 15px;
  --tear: 30%;

  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--tear);
  min-height: clamp(180px, 22vw, 232px);
  overflow: hidden;
  border-radius: 18px;
  background:
    radial-gradient(120% 140% at 85% 0%, rgb(255 226 150 / 0.16), transparent 55%),
    linear-gradient(135deg, #3a2409, #1d1104 70%);
  color: #f1d58a;
  /* A bite out of the top and the bottom edge where the stub tears off. */
  -webkit-mask:
    radial-gradient(circle var(--notch) at var(--tear) 0, #0000 calc(100% - 1px), #000) top / 100% 51% no-repeat,
    radial-gradient(circle var(--notch) at var(--tear) 100%, #0000 calc(100% - 1px), #000) bottom / 100% 51% no-repeat;
  mask:
    radial-gradient(circle var(--notch) at var(--tear) 0, #0000 calc(100% - 1px), #000) top / 100% 51% no-repeat,
    radial-gradient(circle var(--notch) at var(--tear) 100%, #0000 calc(100% - 1px), #000) bottom / 100% 51% no-repeat;
}

/* A fine gold frame just inside the paper's edge. */
.ticket__paper::before {
  content: '';
  position: absolute;
  inset: 9px;
  border: 1px solid rgb(241 213 138 / 0.3);
  border-radius: 11px;
  pointer-events: none;
}

/* Light crosses the print when the name changes. */
.ticket__paper::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgb(255 244 205 / 0.3) 50%, transparent 60%);
  transform: translateX(120%);
  pointer-events: none;
}

.ticket.is-lit .ticket__paper::after {
  animation: ticket-light 0.9s ease;
}

@keyframes ticket-light {
  from {
    transform: translateX(120%);
  }

  to {
    transform: translateX(-120%);
  }
}

.ticket__main {
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 2px;
  min-width: 0;
  padding: 26px clamp(20px, 3vw, 34px);
}

.ticket__label {
  color: rgb(241 213 138 / 0.78);
  font-size: 0.95rem;
  font-weight: 500;
}

.ticket__code {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-family: var(--font-roman);
  font-size: clamp(1.7rem, 4.4vw, 3rem);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0.1em;
  color: #f7e3a6;
}

.ticket__store {
  margin-top: 6px;
  color: rgb(241 213 138 / 0.66);
  font-size: 0.9rem;
  font-weight: 500;
}

.ticket__stub {
  display: grid;
  align-content: center;
  justify-items: center;
  border-right: 2px dashed rgb(241 213 138 / 0.38);
  text-align: center;
}

.ticket__off {
  font-family: var(--font-roman);
  font-size: clamp(1.9rem, 4.4vw, 3rem);
  font-weight: 600;
  line-height: 1.2;
  color: #f7e3a6;
}

.ticket__offword {
  color: rgb(241 213 138 / 0.78);
  font-size: 0.95rem;
  font-weight: 600;
}

/* --- 6. Why this store --- */

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

.why > h2 {
  text-align: center;
}

.why__grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: clamp(14px, 1.8vw, 22px);
  margin-top: clamp(28px, 4vw, 52px);
}

.why__card,
.why__tips {
  grid-column: span 4;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: clamp(22px, 2.6vw, 34px);
  border-radius: var(--radius-plate);
}

.why__card {
  background: var(--ivory);
  box-shadow:
    0 0 0 1px rgb(138 87 8 / 0.1),
    0 30px 50px -36px rgb(74 45 6 / 0.5);
}

.why__card--support {
  grid-column: span 7;
}

.why__card--bot {
  grid-column: span 5;
  background: linear-gradient(160deg, #33200a, var(--umber));
  color: var(--sun);
  box-shadow: 0 30px 50px -30px rgb(29 17 4 / 0.8);
}

.why__head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.why__icon {
  flex: none;
  width: 52px;
  height: 52px;
  padding: 11px;
  border-radius: 50%;
  background: #f6e7bd;
  color: var(--bronze);
}

.why__card--bot .why__icon {
  background: rgb(255 247 220 / 0.1);
  color: #f1d58a;
}

.why__card h3,
.why__tips h3 {
  font-size: clamp(1.3rem, 1.9vw, 1.6rem);
  font-weight: 800;
}

.why__card > p {
  color: var(--ink-soft);
}

.why__card--bot > p {
  color: rgb(255 247 220 / 0.8);
}

.why__card a:not(.why__chip) {
  color: inherit;
  font-weight: 700;
}

.why__card--support > p,
.why__card--bot > p {
  max-width: 34em;
}

/* The store's own rating, counted from its public reviews. */
.why__rating {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 22px;
  margin-top: 6px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.why__score {
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: var(--ink-soft);
  font-weight: 600;
}

.why__score bdi {
  color: var(--ink);
  font-family: var(--font-roman);
  font-size: clamp(3rem, 6vw, 4.6rem);
  font-weight: 600;
  line-height: 1.1;
}

.why__stars {
  display: flex;
  gap: 3px;
  color: #d99a14;
  direction: ltr;
}

.why__stars svg {
  width: 22px;
  height: 22px;
}

.why__count {
  margin-top: 2px;
  color: var(--ink-soft);
  font-weight: 600;
}

.why__count bdi {
  color: var(--ink);
  font-family: var(--font-roman);
  font-size: 1.15rem;
  font-weight: 700;
}

/* What customers wrote, one at a time. Every one keeps its place in a single cell, so the card
   is as tall as the longest and never changes height. */
.why__quotes {
  display: grid;
  margin-top: auto;
}

.why__quote {
  grid-area: 1 / 1;
  align-self: start;
  margin: 0;
  padding: 16px 20px;
  border-radius: 18px;
  background: #fdf3d3;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition:
    opacity 0.6s ease,
    transform 0.6s ease,
    visibility 0s linear 0.6s;
}

.why__quote.is-on {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition:
    opacity 0.6s ease,
    transform 0.6s ease,
    visibility 0s;
}

.why__quote blockquote {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 600;
  line-height: 1.9;
}

.why__quote figcaption {
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

/* The bot answering, as it does. */
.chat {
  display: grid;
  justify-items: start;
  gap: 10px;
  margin-top: auto;
  padding: 16px;
  border-radius: 20px;
  background: rgb(255 247 220 / 0.07);
  box-shadow: inset 0 0 0 1px rgb(255 247 220 / 0.1);
}

.chat__head {
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgb(255 247 220 / 0.75);
  font-size: 0.95rem;
  font-weight: 600;
}

.chat__head svg {
  width: 20px;
  height: 20px;
  color: #7cc4f0;
}

.chat__msg,
.chat__typing {
  grid-area: 2 / 1;
  padding: 10px 16px;
  border-radius: 16px 16px 16px 4px;
  background: var(--sun);
  color: var(--ink);
  font-weight: 600;
  line-height: 1.7;
}

.chat__msg b {
  margin-inline-start: 8px;
  font-family: var(--font-roman);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.chat__typing {
  display: none;
  gap: 5px;
  padding-block: 16px;
}

.chat__typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-soft);
}

/* The loop: three dots, then the code. Only when a script has started it. */
.chat.is-live .chat__typing {
  display: flex;
}

.chat.is-live .chat__msg {
  transition:
    opacity 0.35s ease,
    transform 0.35s cubic-bezier(0.3, 0.8, 0.2, 1);
}

.chat.is-live.is-typing .chat__msg {
  opacity: 0;
  transform: translateY(6px) scale(0.96);
  transition: none;
}

.chat.is-live:not(.is-typing) .chat__typing {
  opacity: 0;
}

.chat.is-live.is-typing .chat__typing i {
  animation: chat-dot 1s ease-in-out infinite;
}

.chat.is-live.is-typing .chat__typing i:nth-child(2) {
  animation-delay: 0.15s;
}

.chat.is-live.is-typing .chat__typing i:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes chat-dot {
  0%,
  60%,
  100% {
    opacity: 0.35;
    transform: none;
  }

  30% {
    opacity: 1;
    transform: translateY(-4px);
  }
}

.why__chip {
  align-self: start;
  margin-top: auto;
  padding: 8px 18px;
  border-radius: 999px;
  background: #f6e7bd;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  transition: background-color 0.2s ease;
}

@media (hover: hover) {
  .why__chip:hover {
    background: #efd898;
  }
}

.why__fact {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-top: auto;
  color: var(--ink-soft);
  font-weight: 600;
}

.why__fact bdi {
  color: var(--ink);
  font-family: var(--font-roman);
  font-size: clamp(2.2rem, 3.6vw, 3rem);
  font-weight: 600;
  line-height: 1.1;
}

.why__tips {
  gap: 0;
  background: var(--tablet);
}

.why__tips ul {
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.why__tips li {
  padding-block: 14px;
  border-top: 1px solid var(--line);
  font-size: clamp(1.08rem, 1.5vw, 1.25rem);
  font-weight: 700;
  line-height: 1.6;
}

.why__tips li:last-child {
  padding-bottom: 0;
}

@media (max-width: 999px) {
  .why__card--support,
  .why__card--bot {
    grid-column: span 12;
  }

  .why__card,
  .why__tips {
    grid-column: span 6;
  }

  .why__tips {
    grid-column: span 12;
  }
}

@media (max-width: 599px) {
  .why__card,
  .why__tips {
    grid-column: span 12;
  }
}

/* --- Small things that make it easier to use --- */

/* The bronze ring cannot be seen on the dark plates: there it is the light of the page. */
.calc :focus-visible,
.why__card--bot :focus-visible,
.foot :focus-visible {
  outline-color: var(--sun);
}

@media (hover: hover) {
  .faq summary {
    transition: color 0.2s ease;
  }

  .faq summary:hover {
    color: var(--bronze);
  }
}

