/* SyphonGo components (owner: W1, design system).
 *
 * The shared classes every page builds on:
 *   .parchment, .parchment--compact, .parchment--crest     cream panel in the gold 9-slice frame
 *   .title, .title--display, .title--page, .title--sm, .title--sparkle, .eyebrow, .lead
 *   .rule, .rule--sparkle, .sparkle                          gold lines with a diamond or a star
 *   .btn, .btn-download (+ --header, --hero, --banner, --primary), .btn-secondary, .link-more
 *   .ios-note                                                the "iOS · Coming soon" line
 *   .page-banner (+ __title, __lead)                         art strip and title plate of inner pages
 * and the header and footer of every page. Values come from tokens.css.
 */

/* ---- Parchment panel -------------------------------------------------------------------------
 * /assets/img/panel.png (400x360) is drawn as a 9-slice: 96 px from each edge is corner or edge, the
 * middle stretches, and the corners never scale out of proportion. Its outer 22 px are transparent
 * (shadow and flourishes), so the frame is drawn that much outside the element: the gold line sits on
 * the element's edge. --panel-scale sets how big the frame is drawn (0.5: 48 px corners). */
.parchment,
.site-header__bar,
.page-banner::before {
  --panel-scale: 0.5;
  border: 1px solid transparent;
  border-image-source: var(--panel-img);
  border-image-slice: 96 fill;
  border-image-width: calc(96px * var(--panel-scale));
  border-image-outset: calc(22px * var(--panel-scale));
  border-image-repeat: stretch;
}

.parchment {
  position: relative;
  padding: clamp(1.75rem, 1rem + 3vw, 3.25rem);
  color: var(--c-ink);
}

.parchment--compact {
  --panel-scale: 0.375;
  padding: clamp(1.25rem, 0.9rem + 1.5vw, 2rem);
}

@media (max-width: 600px) {
  .parchment {
    --panel-scale: 0.42;
  }

  .parchment--compact {
    --panel-scale: 0.34;
  }
}

/* A gold crest on the top edge, as on the home page's hero panel. Uses ::after. */
.parchment--crest::after {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: clamp(6.5rem, 5rem + 5vw, 9.5rem);
  aspect-ratio: 200 / 48;
  transform: translate(-50%, -62%);
  background: url("/assets/img/ui/crest.svg") center / contain no-repeat;
  pointer-events: none;
}

/* ---- Headings --------------------------------------------------------------------------------- */
.title {
  font-family: var(--font-heading);
  font-size: var(--fs-h2);
  font-weight: var(--fw-bold);
  line-height: var(--lh-heading);
  letter-spacing: -0.012em;
  color: var(--c-royal);
  text-shadow: var(--text-glow);
  text-wrap: balance;
}

.title--display {
  font-size: var(--fs-display);
  line-height: var(--lh-tight);
  letter-spacing: -0.02em;
}

.title--page {
  font-size: var(--fs-h1);
  line-height: var(--lh-tight);
  letter-spacing: -0.016em;
}

.title--sm {
  font-size: var(--fs-h3);
  letter-spacing: -0.005em;
}

/* Gold four-point stars on both sides of the title, inline so they follow it when it wraps. */
.title--sparkle::before,
.title--sparkle::after,
.sparkle {
  content: "";
  display: inline-block;
  width: 0.42em;
  height: 0.42em;
  vertical-align: 0.14em;
  background: url("/assets/img/ui/sparkle.svg") center / contain no-repeat;
}

.title--sparkle::before {
  margin-inline-end: 0.4em;
}

.title--sparkle::after {
  margin-inline-start: 0.4em;
}

.sparkle {
  width: 1em;
  height: 1em;
  vertical-align: -0.12em;
}

/* Small capitals in gold-brown between two sparkles: "YOUR ADVENTURE, ON THE GO". The sparkles are
   inline, so a line that has to wrap keeps them beside its first and last words. */
.eyebrow {
  display: inline-block;
  font-family: var(--font-body);
  font-size: var(--fs-eyebrow);
  font-weight: var(--fw-semibold);
  line-height: 1.35;
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  text-wrap: balance;
  color: var(--c-gold-brown);
}

.eyebrow::before,
.eyebrow::after {
  content: "";
  display: inline-block;
  width: 1.05em;
  height: 1.05em;
  vertical-align: -0.16em;
  background: url("/assets/img/ui/sparkle.svg") center / contain no-repeat;
}

.eyebrow::before {
  margin-inline-end: 0.7em;
}

/* The letter spacing already leaves a gap after the last letter. */
.eyebrow::after {
  margin-inline-start: calc(0.7em - var(--tracking-eyebrow));
}

@media (max-width: 480px) {
  .eyebrow {
    --tracking-eyebrow: 0.09em;
  }

  .eyebrow::before {
    margin-inline-end: 0.5em;
  }

  .eyebrow::after {
    margin-inline-start: calc(0.5em - var(--tracking-eyebrow));
  }
}

/* The same between sparkles, in sentence case: "Development preview". */
.eyebrow--soft {
  --tracking-eyebrow: 0.01em;
  font-size: clamp(1rem, 0.94rem + 0.3vw, 1.1875rem);
  font-weight: var(--fw-medium);
  text-transform: none;
}

.eyebrow--soft::before,
.eyebrow--soft::after {
  width: 0.7em;
  height: 0.7em;
  vertical-align: 0.02em;
}

.lead {
  font-size: var(--fs-lead);
  line-height: var(--lh-snug);
  color: var(--c-ink);
  text-wrap: pretty;
}

/* ---- Ornaments and dividers ------------------------------------------------------------------- */
/* A thin gold line with a diamond in the middle, as under the mock-up's headings. Works on <hr> or an
   empty element (give that aria-hidden="true"). */
.rule {
  display: block;
  width: min(100%, 18rem);
  height: 12px;
  margin: var(--space-4) auto;
  border: 0;
  background:
    url("/assets/img/ui/diamond.svg") center / 11px 11px no-repeat,
    var(--gold-rule) center / 100% 1px no-repeat;
}

.rule--sparkle {
  height: 18px;
  background:
    url("/assets/img/ui/sparkle.svg") center / 16px 16px no-repeat,
    var(--gold-rule) center / 100% 1px no-repeat;
}

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

.rule--start {
  margin-inline: 0 auto;
  background-position: 0.5rem center, 0 center;
  background-image:
    url("/assets/img/ui/diamond.svg"),
    linear-gradient(90deg, #d6aa5a, #e9c477 40%, rgb(214 170 90 / 0));
}

/* A vertical gold hairline (between the columns of a strip). */
.vrule {
  align-self: stretch;
  width: 1px;
  min-height: 3rem;
  background: linear-gradient(180deg, rgb(214 170 90 / 0), #d6aa5a 20%, #d6aa5a 80%, rgb(214 170 90 / 0));
}

/* ---- Arched parchment edge ---------------------------------------------------------------------
 * <!--#include partials/edge-arch.html -->: where art meets the parchment (the foot of the home hero and
 * of the page banners), and the footer's crown. A gentle arch, highest in the middle, outlined by a gold
 * double rim, with a gold crest on its highest point and a scroll at each end. The rim and the fill
 * stretch with the width (an inline SVG with preserveAspectRatio="none", its strokes keep their weight);
 * the crest and the scrolls are images of their own and never stretch.
 *
 * The curve. In the edge's box (W wide, --edge-h tall; x and y from its top left corner, in px) the
 * centre of the gold rim runs along
 *     y(x)  = --edge-rim-offset + --edge-arch-h * (1 - 2x/W)^2
 *     y'(x) = -4 * --edge-arch-h / W * (1 - 2x/W)                      (its slope)
 * a parabola, the quadratic Bezier M0,125 Q500,-75 1000,125 in the SVG's 1000 x 150 viewBox: at
 * --edge-rim-offset in the middle and --edge-arch-h lower at both ends. The rim is 4.5 px wide, centred
 * on y(x), so its top is at y(x) - 2.25 px; a thin second line runs 5 px under it. The three numbers are
 * registered lengths (tokens.css), so a script gets them in px:
 *     parseFloat(getComputedStyle(edge).getPropertyValue('--edge-arch-h'))
 * With the tokens' ratios (offset = dip / 4, height = dip * 1.5) that is y(x) = H/6 + 2H/3 * (1 - 2x/W)^2
 * for an edge H px tall.
 *
 * In an art section (.home-hero, .page-banner) the edge comes last in the section, and the art (.edge-cut)
 * and any animation layer in the section are cut along the same curve, so the page's own parchment shows
 * under the arch: no seam, and nothing that moves shows under the rim. The edge is content (z-index 2),
 * so the rim and its ornaments lie over the animation layers. The footer wears it as its crown, filled
 * with the footer's parchment (Footer, below). */
.edge-arch {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  height: var(--edge-h);
  /* The crest rises above the box; nothing may stick out at the sides. */
  overflow-x: clip;
  pointer-events: none;
  container-type: inline-size;
}

.edge-arch__line {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* The thin second line: a fixed 5 px under the rim, whatever the arch's size. */
.edge-arch__line--inner {
  translate: 0 5px;
}

.edge-arch__line path {
  fill: none;
  vector-effect: non-scaling-stroke;
}

.edge-arch__fill {
  stroke: none;
}

.edge-arch__rim {
  stroke: #9b641a;
  stroke-width: 4.5px;
}

.edge-arch__rim-core {
  stroke: #e3aa45;
  stroke-width: 2.5px;
}

.edge-arch__rim-lit {
  stroke: #fff0b8;
  stroke-width: 0.8px;
  opacity: 0.9;
}

.edge-arch__rim-inner {
  stroke: #c98d34;
  stroke-width: 1.25px;
  opacity: 0.85;
}

/* The crest, centred on the arch's highest point. */
.edge-arch__crest {
  position: absolute;
  top: var(--edge-rim-offset);
  left: 50%;
  width: clamp(6rem, 3rem + 8.5vw, 11.5rem);
  aspect-ratio: 200 / 48;
  translate: -50% -50%;
  background: url("/assets/img/ui/edge-crest.svg") center / contain no-repeat;
}

/* The scrolls at the ends: the rim's end (x = 0 or W, y = offset + dip) is the point (0 or 64, 12) of
   their 64 x 64 picture, and they turn about it with the rim's slope there, atan(4 * dip / W). */
.edge-arch__curl {
  --curl: clamp(1.75rem, 1rem + 2.4vw, 3.5rem);
  position: absolute;
  top: calc(var(--edge-rim-offset) + var(--edge-arch-h));
  width: var(--curl);
  height: var(--curl);
  translate: 0 calc(var(--curl) * -0.1875);
  background: center / contain no-repeat;
}

.edge-arch__curl--start {
  left: 0;
  transform-origin: 0 calc(var(--curl) * 0.1875);
  rotate: calc(-1 * atan2(4 * var(--edge-arch-h), 100cqw));
  background-image: url("/assets/img/ui/edge-curl-start.svg");
}

.edge-arch__curl--end {
  right: 0;
  transform-origin: 100% calc(var(--curl) * 0.1875);
  rotate: atan2(4 * var(--edge-arch-h), 100cqw);
  background-image: url("/assets/img/ui/edge-curl-end.svg");
}

/* The cut: the art keeps everything above the rim's curve at its foot (a mask in two parts: all of it
   down to the edge, and edge-cut.svg, the area above the curve, across the edge's height). An animation
   layer in a section with an edge is cut the same way. */
.edge-cut,
:has(> .edge-arch) > .fx-layer {
  -webkit-mask:
    linear-gradient(#000 0 0) top / 100% calc(100% - var(--edge-h) + 2px) no-repeat,
    url("/assets/img/ui/edge-cut.svg") bottom / 100% var(--edge-h) no-repeat;
  mask:
    linear-gradient(#000 0 0) top / 100% calc(100% - var(--edge-h) + 2px) no-repeat,
    url("/assets/img/ui/edge-cut.svg") bottom / 100% var(--edge-h) no-repeat;
}

/* ---- Buttons ---------------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6em;
  min-height: 44px;
  padding: 0.55em 1.25em;
  border: 0;
  border-radius: var(--radius-m);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: var(--fw-semibold);
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur) var(--ease-out),
    filter var(--dur) ease,
    background-color var(--dur) ease,
    color var(--dur) ease;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  cursor: not-allowed;
}

/* Parchment button with a gold edge, for secondary actions ("Read the guide"). */
.btn-secondary {
  border: 1px solid var(--c-gold-line);
  background: linear-gradient(180deg, var(--c-parchment-hi), #f6e6c3);
  color: var(--c-royal);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.8), 0 2px 0 rgb(155 106 30 / 0.25), var(--shadow-soft);
}

.btn-secondary:hover {
  color: var(--c-royal-hover);
  background: linear-gradient(180deg, #fffdf6, #f8ebcc);
  transform: translateY(-1px);
}

.btn-secondary:active {
  transform: translateY(1px);
  box-shadow: inset 0 1px 2px rgb(155 106 30 / 0.25);
}

/* "View all changes ->": a text link with a small arrow that moves on hover. */
.link-more {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  min-height: 44px;
  font-weight: var(--fw-semibold);
  color: var(--c-royal);
  text-decoration: none;
}

.link-more::after {
  content: "";
  width: 1em;
  height: 1em;
  background: currentColor;
  -webkit-mask: url("/assets/img/ui/arrow.svg") center / contain no-repeat;
  mask: url("/assets/img/ui/arrow.svg") center / contain no-repeat;
  transition: transform var(--dur) var(--ease-out);
}

.link-more:hover {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.link-more:hover::after {
  transform: translateX(3px);
}

/* The download button: glossy green in a gold frame with bevelled corners, a white download icon and a
 * chevron. The markup comes from renderers/downloads.py:
 *   <a|button class="btn btn-download btn-download--VARIANT">
 *     <span class="btn-download__icon">svg</span><span class="btn-download__label">…</span>
 *     <span class="btn-download__chevron">svg</span></a|button>
 * VARIANT (header, hero, banner, primary) only sets the size. */
.btn-download {
  --btn-h: 3.5rem;
  --btn-fs: 1.125rem;
  --btn-px: 1.5rem;
  --btn-icon: 1.4em;
  --btn-frame: 2px;
  position: relative;
  isolation: isolate;
  min-height: var(--btn-h);
  padding: 0.35em var(--btn-px);
  gap: 0.6em;
  border: var(--btn-frame) solid transparent;
  border-radius: 10px;
  corner-shape: bevel;
  font-size: var(--btn-fs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.005em;
  color: var(--c-on-green);
  text-shadow: 0 1px 0 var(--c-green-text-shadow), 0 0 8px rgb(8 60 16 / 0.45);
  /* Glossy: a bright top that falls into a deeper green under the middle. From a quarter of the height
     down, where the label is, the white text keeps at least 4.5:1. */
  background:
    radial-gradient(60% 55% at 50% 10%, rgb(170 245 150 / 0.2), rgb(170 245 150 / 0) 70%) padding-box,
    linear-gradient(180deg, #4cbd4e 0%, #1c8b2c 16%, #117a26 47%, #0a6b21 53%, #05621c 80%, #0b731f 100%) padding-box,
    var(--gold-trim) border-box;
  box-shadow:
    inset 0 0 0 1px rgb(6 52 14 / 0.75),
    inset 0 2px 0 1px rgb(200 255 180 / 0.22),
    inset 0 -3px 6px rgb(0 40 8 / 0.25),
    0 2px 0 #8a5f17,
    0 10px 20px -8px rgb(30 60 10 / 0.6);
}

/* The thin inner gold line of the frame. */
.btn-download::after {
  content: "";
  position: absolute;
  inset: 3px;
  z-index: -1;
  border: 1px solid rgb(250 220 130 / 0.5);
  border-radius: 7px;
  corner-shape: bevel;
  pointer-events: none;
}

/* The big sizes carry the mock-up's small gold jewels on the frame: diamonds in the middle of the top
   and bottom edges, sparkles at both ends. */
.btn-download--hero::before,
.btn-download--banner::before,
.btn-download--primary::before {
  content: "";
  position: absolute;
  inset: calc(-4.5px - var(--btn-frame) / 2) calc(-6px - var(--btn-frame) / 2);
  z-index: 1;
  background:
    url("/assets/img/ui/diamond.svg") 50% 0 / 9px 9px no-repeat,
    url("/assets/img/ui/diamond.svg") 50% 100% / 9px 9px no-repeat,
    url("/assets/img/ui/sparkle.svg") 0 50% / 12px 12px no-repeat,
    url("/assets/img/ui/sparkle.svg") 100% 50% / 12px 12px no-repeat;
  pointer-events: none;
}

.btn-download:hover {
  color: #ffffff;
  filter: brightness(1.07) saturate(1.06);
  transform: translateY(-1px);
  box-shadow:
    inset 0 0 0 1px rgb(6 52 14 / 0.75),
    inset 0 2px 0 1px rgb(200 255 180 / 0.3),
    inset 0 -3px 6px rgb(0 40 8 / 0.25),
    0 3px 0 #8a5f17,
    0 14px 26px -8px rgb(30 60 10 / 0.6);
}

.btn-download:active {
  filter: brightness(0.97);
  transform: translateY(1px);
  box-shadow:
    inset 0 0 0 1px rgb(6 52 14 / 0.8),
    inset 0 3px 8px rgb(0 40 8 / 0.45),
    0 1px 0 #8a5f17,
    0 4px 10px -6px rgb(30 60 10 / 0.6);
}

.btn-download:focus-visible {
  outline: 3px solid var(--c-royal);
  outline-offset: 4px;
}

.btn-download__icon {
  display: inline-flex;
  flex: none;
  width: var(--btn-icon);
  height: var(--btn-icon);
  filter: drop-shadow(0 1px 0 var(--c-green-text-shadow));
}

.btn-download__chevron {
  display: inline-flex;
  flex: none;
  width: 0.78em;
  height: 0.78em;
  margin-inline-start: 0.2em;
  filter: drop-shadow(0 1px 0 var(--c-green-text-shadow));
}

.btn-download__icon svg,
.btn-download__chevron svg {
  width: 100%;
  height: 100%;
}

.btn-download__label {
  text-wrap: balance;
}

/* Disabled ("Beta download coming soon"): the same shape and gold frame, but flat pale sage, no gloss,
   no lift and no chevron, with dark text that stays readable. */
.btn-download:disabled,
.btn-download[aria-disabled="true"] {
  color: #3f4d33;
  text-shadow: 0 1px 0 rgb(255 255 245 / 0.65);
  background:
    linear-gradient(180deg, #f1f2e1 0%, #e3e7cd 55%, #d8ddbf 100%) padding-box,
    linear-gradient(180deg, #ecdcae, #cdb274 50%, #e0ca91) border-box;
  box-shadow:
    inset 0 0 0 1px rgb(110 120 80 / 0.28),
    inset 0 1px 0 1px rgb(255 255 250 / 0.6),
    0 1px 0 rgb(150 120 60 / 0.4),
    0 6px 14px -8px rgb(70 60 20 / 0.35);
  filter: none;
  transform: none;
}

.btn-download:disabled::after,
.btn-download[aria-disabled="true"]::after {
  border-color: rgb(190 165 100 / 0.45);
}

.btn-download:disabled .btn-download__icon,
.btn-download[aria-disabled="true"] .btn-download__icon {
  color: #5d6c4c;
  filter: none;
}

.btn-download:disabled .btn-download__chevron,
.btn-download[aria-disabled="true"] .btn-download__chevron {
  display: none;
}

.btn-download:disabled::before,
.btn-download[aria-disabled="true"]::before {
  opacity: 0.55;
  filter: saturate(0.5);
}

/* Sizes. */
.btn-download--header {
  --btn-h: 2.75rem;
  --btn-fs: 0.9375rem;
  --btn-px: 1rem;
  --btn-icon: 1.3em;
  gap: 0.5em;
}

/* Hero and banner: "Beta download coming soon" stays on one line from a 360 px phone up. */
.btn-download--hero {
  --btn-frame: 3px;
  --btn-h: clamp(3.5rem, 3rem + 1.4vw, 4.25rem);
  --btn-fs: clamp(1rem, 0.86rem + 0.6vw, 1.4375rem);
  --btn-px: clamp(1rem, 0.7rem + 1.5vw, 2.25rem);
  --btn-icon: 1.45em;
  min-width: min(100%, 22rem);
}

.btn-download--banner {
  --btn-frame: 3px;
  --btn-h: clamp(3.4rem, 3rem + 1.1vw, 4rem);
  --btn-fs: clamp(1rem, 0.88rem + 0.45vw, 1.3125rem);
  --btn-px: clamp(1rem, 0.7rem + 1.3vw, 2rem);
  --btn-icon: 1.45em;
  min-width: min(100%, 20rem);
}

.btn-download--primary {
  --btn-h: 3.5rem;
  --btn-fs: clamp(1rem, 0.9rem + 0.4vw, 1.125rem);
  --btn-px: clamp(1rem, 0.7rem + 1.2vw, 1.75rem);
  min-width: min(100%, 18rem);
}

/* ---- iOS line ----------------------------------------------------------------------------------- */
/* <p class="ios-note"><span class="ios-note__icon">apple</span><span class="ios-note__label">…</span></p>,
   between two short gold lines. */
.ios-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55em;
  font-size: var(--fs-small);
  line-height: 1.3;
  color: var(--c-ink-muted);
}

.ios-note::before,
.ios-note::after {
  content: "";
  flex: 0 1 4.5rem;
  min-width: 1.25rem;
  height: 5px;
  margin-inline: 0.35em;
  background:
    radial-gradient(circle, var(--c-gold) 0 2px, rgb(0 0 0 / 0) 2.5px) right center / 5px 5px no-repeat,
    linear-gradient(90deg, rgb(214 170 90 / 0), var(--c-gold-line)) left center / calc(100% - 5px) 1px no-repeat;
}

.ios-note::after {
  transform: scaleX(-1);
}

.ios-note__icon {
  display: inline-flex;
  flex: none;
  width: 1.1em;
  height: 1.1em;
  margin-top: -0.12em;
  color: #4a4038;
}

.ios-note__icon svg {
  width: 100%;
  height: 100%;
}

.ios-note__label {
  white-space: nowrap;
}

/* ---- Header ------------------------------------------------------------------------------------
 * A parchment bar in the gold frame that floats over the top of the page art (absolute, not sticky).
 * The first section of every page starts under it: pad it by var(--header-h). */
.site-header {
  position: absolute;
  top: var(--header-offset);
  left: 0;
  right: 0;
  z-index: var(--z-header);
  padding-inline: var(--gutter);
}

.site-header__bar {
  --panel-scale: 0.34;
  position: relative;
  display: flex;
  align-items: center;
  gap: clamp(0.75rem, 1.6vw, 1.75rem);
  max-width: var(--header-max);
  height: var(--header-bar-h);
  margin-inline: auto;
  padding-inline: clamp(0.9rem, 1.6vw, 1.75rem);
}

.site-header__logo {
  flex: none;
  display: block;
  margin-block: -0.75rem;
  border-radius: var(--radius-s);
  line-height: 0;
}

/* As in the mock-up the wordmark is a little taller than the bar it sits on. */
.site-header__logo img {
  width: auto;
  height: calc(var(--header-bar-h) * 1.2);
  filter: drop-shadow(0 2px 2px rgb(60 40 10 / 0.18));
}

.site-header__menu {
  flex: 1;
  display: flex;
  align-items: center;
  gap: clamp(0.75rem, 1.6vw, 1.75rem);
  min-width: 0;
}

.site-nav {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(0.75rem, 2.4vw, 2.75rem);
  min-width: 0;
}

/* The tall gold sparkles between the logo, the links and the button. */
.site-nav::before,
.site-nav::after {
  content: "";
  flex: none;
  width: 11px;
  height: 26px;
  background: url("/assets/img/ui/sparkle-tall.svg") center / contain no-repeat;
}

.site-nav::before {
  margin-inline-end: auto;
}

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

.site-nav__list {
  display: flex;
  align-items: center;
  gap: clamp(0.5rem, 2.6vw, 2.75rem);
}

.site-nav__link {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding-inline: 0.35rem;
  font-size: clamp(1rem, 0.94rem + 0.2vw, 1.125rem);
  font-weight: 450;
  color: var(--c-navy);
  text-decoration: none;
  white-space: nowrap;
}

.site-nav__link:hover {
  color: var(--c-royal);
}

/* The current page: royal blue, with a gold line and diamond under it. Hover shows a fainter line. */
.site-nav__link::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 3.4rem;
  height: 11px;
  transform: translateX(-50%) scaleX(0.4);
  opacity: 0;
  background:
    url("/assets/img/ui/diamond.svg") center / 11px 11px no-repeat,
    linear-gradient(90deg, rgb(207 149 54 / 0), var(--c-gold) 22%, var(--c-gold) 78%, rgb(207 149 54 / 0)) center / 100% 1.5px no-repeat;
  transition: transform var(--dur) var(--ease-out), opacity var(--dur) ease;
  pointer-events: none;
}

.site-nav__link:hover::after {
  opacity: 0.55;
  transform: translateX(-50%) scaleX(1);
}

.site-nav__link[aria-current="page"] {
  color: var(--c-royal);
}

.site-nav__link[aria-current="page"]::after {
  opacity: 1;
  transform: translateX(-50%) scaleX(1);
}

.site-header__cta {
  flex: none;
  display: flex;
  align-items: center;
}

/* The Menu button, shown below 900 px when JavaScript runs. */
.site-header__toggle {
  display: none;
  align-items: center;
  gap: 0.55rem;
  min-width: 44px;
  min-height: 44px;
  margin-inline-start: auto;
  padding: 0 0.9rem;
  border: 1px solid var(--c-gold-line);
  border-radius: var(--radius-m);
  background: linear-gradient(180deg, var(--c-parchment-hi), #f4e3bd);
  box-shadow: inset 0 1px 0 #ffffff, 0 2px 0 rgb(155 106 30 / 0.25);
  color: var(--c-navy);
  font-weight: var(--fw-semibold);
  font-size: 1rem;
}

.site-header__toggle:hover {
  color: var(--c-royal);
}

.site-header__toggle-icon {
  position: relative;
  display: block;
  width: 20px;
  height: 14px;
}

.site-header__toggle-icon::before,
.site-header__toggle-icon::after,
.site-header__toggle-icon > span {
  content: "";
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition: transform var(--dur) var(--ease-out), opacity var(--dur) ease, top var(--dur) var(--ease-out);
}

.site-header__toggle-icon::before { top: 0; }
.site-header__toggle-icon > span { top: 6px; }
.site-header__toggle-icon::after { top: 12px; }

.site-header.is-open .site-header__toggle-icon::before {
  top: 6px;
  transform: rotate(45deg);
}

.site-header.is-open .site-header__toggle-icon > span {
  opacity: 0;
}

.site-header.is-open .site-header__toggle-icon::after {
  top: 6px;
  transform: rotate(-45deg);
}

/* From 1200 px down the bar tightens: no sparkles, a smaller wordmark and closer links. */
@media (max-width: 1200px) {
  .site-nav::before,
  .site-nav::after {
    display: none;
  }

  .site-nav__link {
    font-size: 1rem;
  }

  .site-header__logo {
    margin-block: 0;
  }

  /* Room for the longest header button: "Download for Android" once downloads open, or the full
     "Beta download coming soon". */
  .site-header__logo img {
    height: calc(var(--header-bar-h) * 0.85);
  }

  .site-nav__list {
    gap: clamp(0.5rem, 1.6vw, 1.25rem);
  }

  .site-nav__link {
    padding-inline: 0.25rem;
  }

  .btn-download--header {
    --btn-fs: 0.875rem;
    --btn-px: 0.875rem;
  }
}

@media (max-width: 900px) {
  .site-header__logo img {
    height: 3.6rem;
  }

  .js .site-header__toggle {
    display: inline-flex;
  }

  /* The compact menu: a parchment panel under the bar, the links one per row, then the button. */
  .js .site-header__menu {
    --panel-scale: 0.4;
    position: absolute;
    top: calc(100% + 0.75rem);
    left: 0;
    right: 0;
    z-index: var(--z-menu);
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-4);
    padding: var(--space-5) clamp(1rem, 4vw, 1.75rem) var(--space-6);
    border: 1px solid transparent;
    border-image-source: var(--panel-img);
    border-image-slice: 96 fill;
    border-image-width: calc(96px * var(--panel-scale));
    border-image-outset: calc(22px * var(--panel-scale));
    border-image-repeat: stretch;
  }

  .js .site-header.is-open .site-header__menu {
    display: flex;
  }

  .js .site-nav {
    flex-direction: column;
    align-items: stretch;
  }

  .js .site-nav__list {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }

  .js .site-nav__link {
    display: flex;
    min-height: 3rem;
    padding: 0.5rem 0.75rem 0.5rem 2rem;
    border-bottom: 1px solid var(--c-on-parchment-line);
    font-size: 1.125rem;
  }

  .js .site-nav__link::after {
    left: 0.5rem;
    bottom: auto;
    top: 50%;
    width: 11px;
    transform: translateY(-50%);
    background: url("/assets/img/ui/diamond.svg") center / 11px 11px no-repeat;
  }

  .js .site-nav__link:hover::after {
    transform: translateY(-50%);
  }

  .js .site-nav__link[aria-current="page"]::after {
    transform: translateY(-50%);
  }

  .js .site-header__cta .btn-download {
    width: 100%;
  }

  /* Without JavaScript nothing collapses: the logo gets a row of its own and the links one under it.
     The bar is taller, and so is --header-h, so the page art still starts below it. The header's
     download button is left out there; every page has its own. */
  html:not(.js) {
    --header-bar-h: 6.75rem;
  }

  html:not(.js) .site-header__bar {
    flex-wrap: wrap;
    align-content: center;
    justify-content: center;
    row-gap: 0;
  }

  html:not(.js) .site-header__logo img {
    height: 3.25rem;
  }

  html:not(.js) .site-header__menu {
    flex-basis: 100%;
    justify-content: center;
  }

  html:not(.js) .site-nav__list {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0 clamp(0.25rem, 2.5vw, 1.5rem);
  }

  html:not(.js) .site-nav__link {
    padding-inline: 0.2rem;
    font-size: clamp(0.8125rem, 3.6vw, 0.9375rem);
  }

  html:not(.js) .site-header__cta {
    display: none;
  }
}

/* The narrowest phones fit three links on the first row: give the second row room. */
@media (max-width: 345px) {
  html:not(.js) {
    --header-bar-h: 8.75rem;
  }
}

/* ---- Footer ------------------------------------------------------------------------------------
 * As in the mock-up, one compact row from 981 px up: logo, links, and at the end the tagline with the
 * (c) line under it. About 64 px tall. From 980 px down the same pieces stack, centred.
 * Its crown is the arched parchment edge (<!--#include partials/edge-arch.html -->, its first child):
 * it stands on the footer's top edge, in the margin above it, filled with the footer's own parchment
 * (a solid colour, so the two meet without a seam). Under a page that is nothing but its banner (the
 * 404) the footer has no margin, and the crown lies over the foot of the banner's art. */
.site-footer {
  --footer-top: #f8ecd2;
  position: relative;
  margin-top: calc(var(--edge-h) + var(--space-4));
  padding: 0.625rem var(--gutter);
  background: linear-gradient(180deg, var(--footer-top), #f5e6c6);
  color: var(--c-ink);
}

.site-footer > .edge-arch {
  bottom: calc(100% - 1px);
}

.site-footer > .edge-arch .edge-arch__fill {
  fill: var(--footer-top);
}

/* A pale castle in the bottom right corner, lower than the footer is tall. From 1600 px up it stands
   beside the content; below that it is behind the row's end, and at this opacity the tagline over it
   keeps 4.5:1 and the (c) line 4.8:1. */
.site-footer::after {
  content: "";
  position: absolute;
  right: max(0px, calc((100% - var(--container-max)) / 2 - 8.5rem));
  bottom: 0;
  width: 8rem;
  aspect-ratio: 260 / 120;
  background: url("/assets/img/ui/castle.svg") center bottom / contain no-repeat;
  opacity: 0.4;
  pointer-events: none;
}

.site-footer__inner {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: var(--space-2) clamp(1.25rem, 2.6vw, 2.5rem);
  max-width: var(--container-max);
  margin-inline: auto;
}

.site-footer__logo {
  flex: none;
  display: block;
  line-height: 0;
  border-radius: var(--radius-s);
}

.site-footer__logo img {
  width: auto;
  height: 2.75rem;
}

.site-footer__nav {
  display: flex;
  align-items: center;
  gap: clamp(0.9rem, 2vw, 1.75rem);
}

.site-footer__nav::before {
  content: "";
  flex: none;
  width: 9px;
  height: 22px;
  background: url("/assets/img/ui/sparkle-tall.svg") center / contain no-repeat;
}

.site-footer__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0 clamp(0.6rem, 1.8vw, 1.75rem);
}

.site-footer__links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding-inline: 0.25rem;
  font-size: 0.9375rem;
  color: var(--c-ink);
  text-decoration: none;
  white-space: nowrap;
}

.site-footer__links a:hover {
  color: var(--c-royal);
  text-decoration: underline;
}

.site-footer__links a[aria-current="page"] {
  color: var(--c-royal);
}

/* The row's end: the tagline, and the (c) line right under it. */
.site-footer__end {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin-inline-start: auto;
}

.site-footer__tagline {
  display: flex;
  align-items: center;
  gap: 0.55em;
  font-size: clamp(1.0625rem, 0.95rem + 0.35vw, 1.3125rem);
  font-style: italic;
  line-height: 1.25;
  color: var(--c-gold-brown);
  white-space: nowrap;
}

.site-footer__tagline::before,
.site-footer__tagline::after {
  content: "";
  flex: none;
  width: 0.75em;
  height: 0.75em;
  background: url("/assets/img/ui/sparkle.svg") center / contain no-repeat;
}

.site-footer__end .site-footer__copy {
  margin: 0.125rem 1.3em 0 0;
  font-size: 0.75rem;
  line-height: 1.3;
  color: var(--c-ink-muted);
}

/* Between 981 and 1100 px the row still fits, with less air. */
@media (max-width: 1100px) {
  .site-footer__inner {
    column-gap: 1.25rem;
  }

  .site-footer__links {
    column-gap: 0.6rem;
  }
}

/* From 980 px down: stacked and centred, with the castle small in the corner, clear of the text. */
@media (max-width: 980px) {
  .site-footer {
    padding: var(--space-5) var(--gutter) var(--space-4);
  }

  .site-footer::after {
    right: 0;
    width: 6.5rem;
    opacity: 0.5;
  }

  .site-footer__inner {
    flex-direction: column;
    text-align: center;
  }

  .site-footer__logo img {
    height: 3.5rem;
  }

  .site-footer__nav::before {
    display: none;
  }

  .site-footer__links {
    justify-content: center;
    column-gap: clamp(0.5rem, 3vw, 1.5rem);
  }

  .site-footer__links a {
    font-size: 1rem;
  }

  .site-footer__end {
    align-items: center;
    margin-inline: auto;
  }

  .site-footer__tagline {
    font-size: 1.25rem;
  }

  .site-footer__end .site-footer__copy {
    margin: var(--space-2) 0 0;
  }
}

/* ---- Page banner (downloads, changelog, guide, 404) ---------------------------------------------
 * <section class="page-banner">
 *   <!--#include partials/page-banner-art.html -->
 *   <h1 class="page-banner__title">…</h1><p class="page-banner__lead">…</p>[<p class="page-banner__actions">…</p>]
 *   <!--#include partials/edge-arch.html -->
 * </section>
 * A strip of the hero art under the floating header, with the title on a parchment plate, ending in the
 * arched parchment edge: the art (a picture of the hero's own files) is cut along the arch and the page's
 * parchment carries on under it. It is an art section (base.css, Layers): the art is z-index 0, an
 * .fx-layer that a script appends lies over it (cut along the arch too), and the plate, the text, the
 * crest and the edge lie over that (z-index 2). So the section is no stacking context, and the art, the
 * edge and a script's layer (aria-hidden or .fx-layer) never take a place in the grid.
 * The children fill one row each of the middle column. The plate is the section's ::before, absolutely
 * positioned on the rows they fill (a grid area is its containing block) and reaching --plate-top above
 * the first and --plate-bottom below the last; ::after is the crest on its top edge. The bottom padding
 * keeps the plate clear of the arch and its crest. */
.page-banner {
  --plate-top: clamp(2rem, 3.5vw, 2.75rem);
  --plate-bottom: clamp(1.75rem, 3.5vw, 2.75rem);
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) min(100%, 42rem) minmax(0, 1fr);
  grid-template-rows: repeat(6, auto);
  align-content: center;
  min-height: clamp(21rem, 16rem + 14vw, 30rem);
  padding:
    calc(var(--header-h) + clamp(2rem, 4vw, 3.5rem) + var(--plate-top))
    var(--gutter)
    calc(var(--edge-h) + clamp(1.5rem, 3vw, 2.5rem) + var(--plate-bottom));
  text-align: center;
}

@media (max-width: 700px) {
  .page-banner {
    min-height: 0;
  }
}

/* The art: the hero's landscape picture, or its portrait one on phones and upright screens (the
   picture's <source media>), covering the section; the sky's colour shows until it loads. */
.page-banner__art {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: #9cc3e6;
}

.page-banner__art img {
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: 50% 38%;
}

@media (max-width: 700px), (max-aspect-ratio: 3/4) {
  .page-banner__art img {
    object-position: 50% 58%;
  }
}

.page-banner > :not(.fx-layer, [aria-hidden="true"]) {
  grid-column: 2;
  position: relative;
  z-index: 2;
  padding-inline: clamp(1.25rem, 4vw, 3rem);
}

/* The parchment plate. An absolutely positioned grid child needs both lines of each axis: with only a
   start line its box would run on to the section's edge. */
.page-banner::before {
  content: "";
  position: absolute;
  grid-column: 2 / 3;
  grid-row: 1 / -1;
  inset: calc(-1 * var(--plate-top)) 0 calc(-1 * var(--plate-bottom));
  z-index: 2;
  filter: drop-shadow(0 10px 18px rgb(60 40 10 / 0.22));
}

/* The crest on the plate's top edge. */
.page-banner::after {
  content: "";
  position: absolute;
  grid-column: 2 / 3;
  grid-row: 1 / 2;
  top: calc(-1 * var(--plate-top));
  left: 50%;
  z-index: 2;
  width: clamp(6.5rem, 5rem + 5vw, 9.5rem);
  aspect-ratio: 200 / 48;
  transform: translate(-50%, -62%);
  background: url("/assets/img/ui/crest.svg") center / contain no-repeat;
  pointer-events: none;
}

.page-banner__title {
  font-size: var(--fs-h1);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
  letter-spacing: -0.016em;
  color: var(--c-royal);
  text-shadow: var(--text-glow);
}

.page-banner__lead {
  font-size: var(--fs-lead);
  line-height: var(--lh-snug);
  color: var(--c-ink);
  text-wrap: balance;
}

/* A small gold rule between the title and the lead. */
.page-banner__lead::before {
  content: "";
  display: block;
  width: min(100%, 9rem);
  height: 12px;
  margin: var(--space-3) auto var(--space-3);
  background:
    url("/assets/img/ui/diamond.svg") center / 11px 11px no-repeat,
    var(--gold-rule) center / 100% 1px no-repeat;
}

/* Buttons and links on the plate, under the lead: <p|div class="page-banner__actions">. Put nothing
   but the links in it (no &emsp; or other spacing characters: the gap spaces them). */
.page-banner__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-3) var(--space-5);
  padding-top: var(--space-5);
}

/* A page that is nothing but its banner (the 404) lets the art run down to the footer instead of
   leaving an empty band of parchment between them on a tall screen. There the footer's arched crown is
   the edge: the banner's own edge and its cut give way, and the crown lies over the art's foot. */
main:has(> .page-banner:only-child) {
  display: flex;
  flex-direction: column;
}

main > .page-banner:only-child {
  flex: 1 0 auto;
}

main > .page-banner:only-child > .edge-arch {
  display: none;
}

main > .page-banner:only-child > .edge-cut,
main > .page-banner:only-child > .fx-layer {
  -webkit-mask: none;
  mask: none;
}

@media (max-aspect-ratio: 3/4) {
  main > .page-banner:only-child .page-banner__art img {
    object-position: 50% 50%;
  }
}

main:has(> .page-banner:only-child) + .site-footer {
  margin-top: 0;
}

/* ---- Forced colours (Windows contrast themes) --------------------------------------------------
 * The theme replaces text colours but would keep the cream panel image behind them, so the panels drop
 * their image and get a plain system-colour border, and the buttons a visible one. */
@media (forced-colors: active) {
  .parchment,
  .site-header__bar,
  .page-banner::before,
  .js .site-header__menu {
    border: 1px solid CanvasText;
    border-image: none;
    background: Canvas;
  }

  .btn-download,
  .btn-secondary,
  .site-header__toggle {
    border: 2px solid ButtonText;
  }

  .btn-download:disabled,
  .btn-download[aria-disabled="true"] {
    border-color: GrayText;
    color: GrayText;
  }

  .btn-download::before,
  .btn-download::after,
  .parchment--crest::after,
  .page-banner::after {
    display: none;
  }

  .site-nav__link[aria-current="page"] {
    text-decoration: underline;
  }
}

/* ---- Print -------------------------------------------------------------------------------------- */
@media print {
  .skip-link,
  .site-header__toggle,
  .site-header__cta,
  .site-footer::after {
    display: none !important;
  }

  .site-header {
    position: static;
  }

  body {
    background: #ffffff;
  }

  .page-banner {
    min-height: 0;
    padding-top: calc(var(--space-5) + var(--plate-top));
  }

  .page-banner__art,
  .edge-arch {
    display: none;
  }
}
