/* Crossmoji site: shared look. Nocturne Dark by default for dark, Daylight Light for light.
   Tokens come from the Landing page frames in Figma (home 950:5050 / 950:5653, utility 952:7572). */

:root {
  color-scheme: light dark;

  /* SF Pro for reading, SF Pro Rounded for headings and display accents */
  --font-text: -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-display: ui-rounded, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;

  /* Daylight Light */
  --bg-from: #e6e9f7;
  --bg-to: #cfd3e5;
  --aura: rgba(145, 132, 217, 0.18);
  --tile: rgba(99, 85, 173, 0.06);
  --tile-pulse: rgba(99, 85, 173, 0.2);
  --fade: rgba(222, 226, 242, 0.92);
  --text: #1f2128;
  --text-muted: rgba(41, 43, 49, 0.72);
  --foot: rgba(41, 43, 49, 0.76); /* 4.6:1 or more, over the darkest ground and the fixed tiles on a phone */
  --foot-copy: rgba(41, 43, 49, 0.76);
  --foot-dot: rgba(41, 43, 49, 0.38);
  --answer: rgba(41, 43, 49, 0.72);
  --back: rgba(41, 43, 49, 0.72);
  --accent: rgba(93, 82, 148, 0.92);
  --link: rgba(93, 82, 148, 0.96);
  --card-from: rgba(255, 255, 255, 0.86);
  --card-to: rgba(247, 248, 253, 0.82);
  --card-edge-from: rgba(255, 255, 255, 0.96);
  --card-edge-to: rgba(255, 255, 255, 0.42);
  --card-shadow: 0 24px 48px rgba(10, 13, 31, 0.1);
  --card-solid-from: rgba(255, 255, 255, 0.94);
  --card-solid-to: rgba(247, 248, 253, 0.92);
  --well: rgba(121, 108, 191, 0.09);
  --well-edge: rgba(121, 108, 191, 0.12);
  --item: rgba(255, 255, 255, 0.55);
  --item-edge: rgba(99, 85, 173, 0.12);
  --btn-bg: #1f2128;
  --btn-text: #ffffff;
  --ghost-bg: rgba(31, 33, 40, 0.05);
  --ghost-edge: rgba(31, 33, 40, 0.16);
  --focus: #6c56d9;
  --label: rgba(93, 82, 148, 0.92);

  /* the app's tile palette, light (Palette.swift, and the Lilac face in FaceLook.swift): the home
     board's tiles and the 404's */
  --plain-face: #f3f5fe;
  --plain-edge: #b2b6ca;
  --word-face: #d2ceff;
  --word-edge: #968ae0;
  --cur-face: #9184d9;
  --cur-edge: #796cbf;
  --cur-glow: rgba(121, 108, 191, 0.5);
  --cur-ink: #292b31; /* the cursor's letter: 4.4:1 on its face */
  --solved-ring: #9397ab;
  --solved-ink: #423a6a;
  --tile-ink: #292b31;
  --tile-num: rgba(41, 43, 49, 0.55);
  --glyph-outline: rgba(255, 255, 255, 0.65);
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Nocturne Dark */
    --bg-from: #22253e;
    --bg-to: #121420;
    --aura: rgba(121, 108, 191, 0.18);
    --tile: rgba(145, 132, 217, 0.05);
    --tile-pulse: rgba(145, 132, 217, 0.22);
    --fade: rgba(26, 28, 46, 0.92);
    --text: #f5f5fa;
    --text-muted: rgba(207, 210, 228, 0.78);
    --foot: rgba(207, 210, 228, 0.68);
    --foot-copy: rgba(207, 210, 228, 0.62); /* 4.8:1 on the lightest ground, #22253e */
    --foot-dot: rgba(207, 210, 228, 0.38);
    --answer: rgba(207, 210, 228, 0.74);
    --back: rgba(207, 210, 228, 0.72);
    --accent: #d4d0ff;
    --link: #d4d0ff;
    --label: rgba(212, 208, 255, 0.85);
    --card-from: rgba(39, 42, 62, 0.88);
    --card-to: rgba(26, 28, 42, 0.92);
    --card-edge-from: rgba(255, 255, 255, 0.2);
    --card-edge-to: rgba(255, 255, 255, 0.04);
    --card-shadow: 0 20px 44px rgba(5, 5, 15, 0.5);
    --card-solid-from: rgba(39, 42, 62, 0.95);
    --card-solid-to: rgba(26, 28, 42, 0.97);
    --well: rgba(14, 16, 26, 0.58);
    --well-edge: rgba(233, 233, 237, 0.08);
    --item: rgba(255, 255, 255, 0.03);
    --item-edge: rgba(255, 255, 255, 0.06);
    --btn-bg: #ffffff;
    --btn-text: #141624;
    --ghost-bg: rgba(255, 255, 255, 0.08);
    --ghost-edge: rgba(255, 255, 255, 0.14);
    --focus: #a89bf2;

    /* the app's tile palette, dark */
    --plain-face: #3f424d;
    --plain-edge: #292b31;
    --word-face: #6e63a7;
    --word-edge: #978dd5;
    --cur-face: #9184d9;
    --cur-edge: #bcb7ea;
    --cur-glow: rgba(145, 132, 217, 0.7);
    --cur-ink: #ffffff; /* the cursor's letter: 3.2:1 on its face, where --tile-ink would be 2.7:1 */
    --solved-ring: #3f424d;
    --solved-ink: #b5abfc;
    --tile-ink: #e9e9ed;
    --tile-num: rgba(233, 233, 237, 0.55);
    --glyph-outline: rgba(0, 0, 0, 0.65);
  }
}

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

html {
  min-height: 100%;
  background:
    radial-gradient(ellipse 560px 480px at 50% 8%, var(--aura), transparent 72%),
    radial-gradient(ellipse at 50% 30%, var(--bg-from) 0%, var(--bg-to) 100%) fixed;
  background-color: var(--bg-to);
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font: 400 16px/1.5 var(--font-text);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}

/* ---------- Ground: a freeform criss-cross of tiles, faded toward the middle,
   with two tiles that pulse. All CSS. The four layers sit behind the page. ---------- */

html::before,
body::before,
html::after,
body::after {
  content: "";
  position: fixed;
  pointer-events: none;
}

/* left cluster */
html::before {
  z-index: -4;
  top: 98px;
  left: 12px;
  width: 44px;
  height: 44px;
  border-radius: 11px;
  background: var(--tile);
  box-shadow:
    0 54px 0 var(--tile), 0 108px 0 var(--tile), 0 162px 0 var(--tile),
    54px 108px 0 var(--tile), 108px 108px 0 var(--tile), 162px 108px 0 var(--tile), 216px 108px 0 var(--tile),
    108px 0 0 var(--tile), 108px 54px 0 var(--tile), 108px 162px 0 var(--tile), 108px 216px 0 var(--tile),
    216px 0 0 var(--tile), 216px 54px 0 var(--tile), 216px 162px 0 var(--tile),
    0 540px 0 var(--tile), 54px 540px 0 var(--tile), 108px 540px 0 var(--tile), 162px 540px 0 var(--tile),
    108px 432px 0 var(--tile), 108px 486px 0 var(--tile), 108px 594px 0 var(--tile), 108px 648px 0 var(--tile),
    162px 648px 0 var(--tile), 216px 648px 0 var(--tile), 270px 648px 0 var(--tile);
}

/* right cluster, drawn leftwards from the right edge */
body::before {
  z-index: -3;
  top: 98px;
  right: 12px;
  width: 44px;
  height: 44px;
  border-radius: 11px;
  background: var(--tile);
  box-shadow:
    -54px 0 0 var(--tile), -108px 0 0 var(--tile),
    0 54px 0 var(--tile), 0 108px 0 var(--tile), 0 162px 0 var(--tile), 0 216px 0 var(--tile),
    -54px 216px 0 var(--tile), -108px 216px 0 var(--tile),
    0 540px 0 var(--tile), -54px 540px 0 var(--tile), -108px 540px 0 var(--tile),
    -54px 432px 0 var(--tile), -54px 486px 0 var(--tile), -54px 594px 0 var(--tile), -54px 648px 0 var(--tile),
    0 648px 0 var(--tile);
}

/* the radial fade: the middle of the ground stays calm, the tiles live at the edges */
html::after {
  z-index: -2;
  inset: 0;
  background: radial-gradient(ellipse 62% 58% at 50% 42%, var(--fade) 0%, var(--fade) 35%, transparent 100%);
}

/* the pulsing tiles */
body::after {
  z-index: -1;
  top: 98px;
  left: 66px;
  width: 44px;
  height: 44px;
  border-radius: 11px;
  background: var(--tile-pulse);
  box-shadow: 108px 540px 0 var(--tile-pulse), calc(100vw - 230px) 216px 0 var(--tile-pulse);
  animation: tile-pulse 8s ease-in-out infinite;
}

/* a slow breath, never a blink: the tiles never fade out, nor come up to full strength */
@keyframes tile-pulse {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 0.72; }
}

/* below this width the two clusters would meet, so only the left one stays. The lower pulse
   tile moves up the cluster to y = 314, above where the footer is on a phone, so no footer
   link is read over it (home.css does the same). */
@media (max-width: 720px) {
  body::before { display: none; }
  body::after { box-shadow: 54px 216px 0 var(--tile-pulse); }
}

@media (prefers-reduced-motion: reduce) {
  body::after { animation: none; opacity: 0.5; }
}

/* ---------- Page frame ---------- */

.page {
  flex: 1;
  width: 100%;
  max-width: 722px;
  margin: 0 auto;
  padding: 28px 16px 24px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}
/* on the reading pages the header lines up with the card's edges */
.site-header:has(+ .card) { max-width: 680px; margin-inline: auto; }

/* a 44px tap height; the negative margin keeps the header the height it was */
.brand { display: inline-flex; align-items: center; min-height: 44px; margin-block: -8px; border-radius: 8px; }
.brand img { display: block; height: 28px; width: auto; }

.back {
  font-size: 13px;
  font-weight: 500;
  color: var(--back);
  text-decoration: none;
}
.back:hover { color: var(--text); text-decoration: underline; }
/* a 44px tap height on the reading pages, pulled into the card's right edge so nothing shifts */
.page .back {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 8px;
  margin-inline-end: -8px;
  border-radius: 8px;
}
.page .back:focus-visible { outline-offset: 0; }

a { color: var(--link); border-radius: 4px; }
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}
.brand:focus-visible { border-radius: 8px; }
.card a { overflow-wrap: anywhere; }
.card a:focus-visible { outline-offset: 2px; }
/* jump targets (/privacy's sections, its top) take focus so VoiceOver moves with the jump; a tap
   or click shows no ring, and the page wrapper never does */
[tabindex="-1"]:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }
[tabindex="-1"]:focus:not(:focus-visible), .page:focus { outline: none; }

/* ---------- Reading card ---------- */

.card {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 32px 36px;
  border-radius: 28px;
  background: linear-gradient(180deg, var(--card-from), var(--card-to));
  position: relative;
  box-shadow: var(--card-shadow);
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  padding: 1.25px;
  border-radius: inherit;
  background: linear-gradient(180deg, var(--card-edge-from), var(--card-edge-to));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  pointer-events: none;
}

.card h1, .card h2, .card h3 { font-family: var(--font-display); }
.card h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.2;
  font-weight: 860;
  letter-spacing: -0.01em;
}
.card .lede { margin: 6px 0 0; font-size: 15px; color: var(--text-muted); }
.card h2 { margin: 0; font-size: 16px; font-weight: 700; color: var(--accent); }
.card p { margin: 0; }

/* the recessed summary card at the top of /privacy and /delete; /support uses it for the email row */
.summary {
  padding: 18px 22px;
  border-radius: 18px;
  background: var(--well);
  border: 1px solid var(--well-edge);
}
.summary-label { font-size: 12px; font-weight: 600; color: var(--label); }

.contact {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.email-address {
  display: block;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  overflow-wrap: anywhere;
}
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* the copy button keeps one width for Copy email, Copied and Selected */
[data-copy-email] { min-width: 8.5em; }
/* shown when the copy fell back to selecting the address */
.copy-hint { flex-basis: 100%; font-size: 13px; line-height: 1.45; color: var(--text-muted); }

/* ---------- Reading text: /terms and /delete (.reading), /privacy (.policy) ---------- */

.reading section { display: flex; flex-direction: column; gap: 8px; }
.reading p, .reading li, .policy p, .policy li { font-size: 15px; line-height: 1.55; }
.reading ul, .reading ol, .policy ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.reading .summary p { margin-top: 4px; }
.reading .summary ul { margin-top: 8px; }

/* /delete's steps: numbered on small tiles in the summary well's colours. role="list" on the
   list, as Safari drops a list's semantics for VoiceOver once its markers are gone. */
.reading .steps { list-style: none; padding-left: 0; gap: 10px; counter-reset: step; }
.steps li { position: relative; padding-left: 34px; counter-increment: step; }
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0.08em;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: var(--well);
  border: 1px solid var(--well-edge);
  font: 700 12px/1 var(--font-display);
  font-variant-numeric: tabular-nums;
  color: var(--label);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  font: 600 13px/1 var(--font-display);
  text-decoration: none;
  cursor: pointer;
  background: var(--btn-bg);
  color: var(--btn-text);
}
.btn-ghost {
  background: var(--ghost-bg);
  border-color: var(--ghost-edge);
  color: var(--text);
  font-weight: 500;
}
.btn:hover { filter: brightness(1.08); }

/* ---------- FAQ ---------- */

.faq { display: flex; flex-direction: column; gap: 12px; }
.faq-item {
  padding: 14px 18px;
  border-radius: 14px;
  background: var(--item);
  border: 1px solid var(--item-edge);
}
.faq-item h3 { margin: 0 0 5px; font-size: 14px; font-weight: 600; }
.faq-item p { font-size: 13px; line-height: 1.45; color: var(--answer); }
.faq-item p + p { margin-top: 6px; }

/* ---------- 404: a small card in the middle of the page, under three of the app's tiles ---------- */

/* a column, so the card's auto margins centre it in the room under the header; the header's own
   auto margins (site-header above) then shrink it to the logo and centre it over the card */
.page--center { display: flex; flex-direction: column; }
.card--compact { max-width: 460px; margin: auto; align-items: center; text-align: center; }
.card--compact .lede { text-wrap: balance; }
.card--compact .actions { justify-content: center; }

/* Drawn as the home board draws a tile (home.css, after TileMetrics.swift): the edge colour fills
   the rounded square, the face sits over it a lip shorter, and the letter is centred in the face
   with the app's hairline. The middle tile is the cursor, with its glow at rest. These tiles
   carry no clue number, so the letter is centred in the whole face. */
.nf-tiles {
  --s: 56px;
  --lip: max(2px, calc(var(--s) * 0.07));
  isolation: isolate;
  display: flex;
  gap: calc(var(--s) * 3 / 28);
  margin-bottom: 4px;
}
.nf-tile {
  position: relative;
  width: var(--s);
  height: var(--s);
  border-radius: max(3px, calc(var(--s) * 0.12));
  background: var(--plain-edge);
  --face: var(--plain-face);
  --ink: var(--tile-ink);
}
.nf-tile::before {
  content: "";
  position: absolute;
  inset: 0 0 var(--lip);
  border-radius: inherit;
  background: var(--face);
}
.nf-tile.cursor {
  background: var(--cur-edge);
  --face: var(--cur-face);
  --ink: var(--cur-ink);
}
/* the glow, under all three tiles as the home board's is (.glow-at), so it never washes over a
   neighbour's face */
.nf-tile.cursor::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 calc(var(--s) * 15 / 39) var(--cur-glow);
}
.nf-tile span {
  position: absolute;
  left: 0;
  right: 0;
  top: calc((var(--s) - var(--lip)) / 2);
  translate: 0 -50%;
  text-align: center;
  font: 600 calc(var(--s) * 0.65)/1 var(--font-display);
  color: var(--ink);
  -webkit-text-stroke: 0.055em var(--glyph-outline);
  paint-order: stroke fill;
}
@supports (text-box: trim-both cap alphabetic) {
  .nf-tile span { text-box: trim-both cap alphabetic; }
}

/* ---------- Footer (every page) ---------- */

.site-footer {
  padding: 8px 16px 28px;
  text-align: center;
  font-size: 13px;
}
.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 26px;
}
.site-footer a { position: relative; color: var(--foot); text-decoration: none; }
.site-footer a:hover { color: var(--text); text-decoration: underline; }
/* the page you are on: quiet, but not the same as the links beside it */
.site-footer a[aria-current="page"] { color: var(--text); font-weight: 600; }
.site-footer a:focus-visible { outline-offset: 2px; border-radius: 8px; }
/* the dot sits outside the link's box: not tappable, not inside the focus ring */
.site-footer nav a + a::before {
  content: "\00b7";
  position: absolute;
  left: -14px;
  color: var(--foot-dot);
  pointer-events: none;
}
.site-footer small { display: block; margin-top: 8px; font-size: 12px; color: var(--foot-copy); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Phones and narrow windows ---------- */

@media (max-width: 720px) {
  /* 44px tap height for the footer links; the padding keeps the same gap between the words */
  .site-footer nav { gap: 0 18px; }
  .site-footer a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 4px;
  }
  .site-footer nav a + a::before { left: -11px; top: 50%; transform: translateY(-50%); }
  .btn { min-height: 44px; }
  /* inline links in the text: the tap area grows, the look and the focus ring do not */
  .card p a, .card li a { position: relative; }
  .card p a::after, .card li a::after { content: ""; position: absolute; inset: -13px -4px; }
  .card .toc a::after, .card .to-top a::after { content: none; }
  /* a page-long blur costs a phone more than it is worth: the card gets a firmer fill instead */
  .card {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: linear-gradient(180deg, var(--card-solid-from), var(--card-solid-to));
  }
  /* the ground stays one screen tall and does not repaint as the page scrolls */
  html {
    background-image:
      linear-gradient(transparent 70%, var(--bg-to)),
      radial-gradient(ellipse 560px 480px at 50% 8%, var(--aura), transparent 72%),
      radial-gradient(ellipse at 50% 30%, var(--bg-from) 0%, var(--bg-to) 100%);
    background-attachment: scroll;
    background-size: 100% 100vh;
    background-repeat: no-repeat;
  }
}

/* wrapped onto two lines, the middle dots would strand at a line start */
@media (max-width: 360px) {
  .site-footer nav a + a::before { display: none; }
}

/* iOS repaints a fixed background on every scroll frame, at any width */
@supports (-webkit-touch-callout: none) {
  html {
    background-image:
      linear-gradient(transparent 70%, var(--bg-to)),
      radial-gradient(ellipse 560px 480px at 50% 8%, var(--aura), transparent 72%),
      radial-gradient(ellipse at 50% 30%, var(--bg-from) 0%, var(--bg-to) 100%);
    background-attachment: scroll;
    background-size: 100% 100vh;
    background-repeat: no-repeat;
  }
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

@media (max-width: 480px) {
  .card { padding: 24px 20px; border-radius: 24px; }
  .card h1 { font-size: 28px; }
  .nf-tiles { --s: 48px; }
  .summary { padding: 16px; }
}
