/*
  Night Earth, for the web. The tokens are docs/DESIGN.md section 2; the
  type is section 3. Three rules carried over from the app:

  1. Light means "been there". The accent is only ever a 1 px line or text.
  2. The globe is always underneath. Content sits on a sheet over it.
  3. Few words, mono numbers.

  No scripts, no requests to other sites: fonts and images are in ../fonts
  and ../img.
*/

/* The app's name, for the wordmark in every page header. Each page's <title>
   is the only other place it is written. */
:root {
  --app-name: "Around the World";
}

@font-face {
  font-family: "Space Grotesk";
  src: url("../fonts/SpaceGrotesk-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Space Grotesk";
  src: url("../fonts/SpaceGrotesk-Medium.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("../fonts/JetBrainsMono-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("../fonts/JetBrainsMono-Medium.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  --space: #050811;
  --surface: #0c1222;
  --line: #1b2540;
  --line-strong: #2a3759;
  --text: #e6edf7;
  --text2: #727e9d; /* 4.94:1 on space, 4.61:1 on surface */
  --rim: #2e8bc9;
  --accent: #1fd8c8;
  --accent-dashed: rgba(31, 216, 200, 0.6);

  --sans: "Space Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas,
    "Liberation Mono", monospace;

  --pad: clamp(20px, 5vw, 48px);
  --wrap: 1080px;
  --measure: 60ch;
  --radius: 10px;
  --sheet-radius: 16px;
  /* How far the sheet rides up over the foot of the globe. */
  --overlap: clamp(36px, 8vw, 104px);
}

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

html {
  background: var(--space);
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 300px;
  color: var(--text);
  font: 400 1.0625rem/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  /* A sparse, still star field on space. Two tiles of different sizes, so
     the repeat does not read as a pattern. */
  background-color: var(--space);
  background-image:
    radial-gradient(1px 1px at 12% 22%, rgba(255, 255, 255, 0.55) 50%, transparent 51%),
    radial-gradient(1px 1px at 71% 9%, rgba(255, 255, 255, 0.4) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 38% 64%, rgba(255, 255, 255, 0.35) 50%, transparent 51%),
    radial-gradient(1px 1px at 88% 78%, rgba(255, 255, 255, 0.5) 50%, transparent 51%),
    radial-gradient(1px 1px at 55% 41%, rgba(255, 255, 255, 0.3) 50%, transparent 51%),
    radial-gradient(1px 1px at 23% 87%, rgba(255, 255, 255, 0.45) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 93% 33%, rgba(255, 255, 255, 0.3) 50%, transparent 51%),
    radial-gradient(1px 1px at 6% 55%, rgba(255, 255, 255, 0.35) 50%, transparent 51%);
  background-size:
    620px 540px, 620px 540px, 620px 540px, 620px 540px,
    910px 770px, 910px 770px, 910px 770px, 910px 770px;
}

h1,
h2,
h3,
p,
ul,
ol,
dl,
dd,
figure {
  margin: 0;
  padding: 0;
}

h1,
h2,
h3 {
  font-weight: 500;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2.5rem, 1.15rem + 6.4vw, 5.25rem);
  line-height: 1.02;
  letter-spacing: -0.028em;
}

h2 {
  font-size: clamp(1.625rem, 1.3rem + 1.5vw, 2.25rem);
  line-height: 1.14;
  letter-spacing: -0.015em;
}

h3 {
  font-size: 1.0625rem;
  line-height: 1.4;
}

p,
li,
dd {
  max-width: var(--measure);
  text-wrap: pretty;
}

a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
}
a:hover {
  color: var(--accent);
}
a:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
  border-radius: 4px;
}

.mono,
code {
  font-family: var(--mono);
  font-size: 0.92em;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

.quiet {
  color: var(--text2);
  font-size: 0.875rem;
  line-height: 1.5;
}

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

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

/* Skip link: off screen until it has focus. */
.skip {
  position: absolute;
  left: var(--pad);
  top: -4rem;
  z-index: 10;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
}
.skip:focus {
  top: 12px;
}

/* ---------- Header ---------- */

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 20px;
  padding-block: 14px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  font-weight: 500;
  text-decoration: none;
}
.brand:hover {
  color: var(--text);
}
.brand .wordmark::before {
  content: var(--app-name);
}

.top nav ul {
  display: flex;
  gap: 4px 22px;
  list-style: none;
}
.top nav a {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  color: var(--text2);
  text-decoration-color: transparent;
}
.top nav a:hover,
.top nav a[aria-current="page"] {
  color: var(--text);
  text-decoration-color: var(--accent);
}

/* ---------- Image slots ----------
   Every slot is an <img> with its width and height set, drawn over a
   stand-in made of the globe drawing. The stand-in shows while a slot is
   empty (a transparent placeholder file) and, in browsers that allow it,
   covers the broken-image mark if a file is missing altogether. */

.slot {
  position: relative;
  display: block;
  max-width: 100%;
  height: auto;
  color: transparent; /* the alt text is for people who cannot see the slot */
  font-size: 0;
  object-fit: cover;
  background-color: var(--space);
  background-repeat: no-repeat;
}
.slot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: inherit;
}

/* The app icon: space, the globe a little below centre. */
.slot-icon {
  width: 32px;
  aspect-ratio: 1;
  border-radius: 22.5%;
  border: 1px solid var(--line);
  background-image: url("../img/globe.svg");
  background-position: 50% 62%;
  background-size: 86% auto;
}

/* The hero: the globe alone. The mask fades the square render into the page
   so its corners never show. */
.slot-hero {
  width: 100%;
  aspect-ratio: 1;
  background-image: url("../img/globe.svg");
  background-position: center;
  background-size: 100% auto;
  -webkit-mask-image: radial-gradient(closest-side, #000 96%, transparent 100%);
  mask-image: radial-gradient(closest-side, #000 96%, transparent 100%);
}

/* A phone screenshot. The stand-in is a diagram of the screen it will show:
   the globe, the sheet that covers part of it, and the sheet's rows. */
.slot-shot {
  width: 100%;
  aspect-ratio: 660 / 1434;
  border-radius: 22px;
  border: 1px solid var(--line-strong);
  --sheet: 100%;
  background-image:
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 27px,
      var(--line) 27px,
      var(--line) 28px
    ),
    linear-gradient(
      to bottom,
      transparent var(--sheet),
      var(--line-strong) var(--sheet),
      var(--line-strong) calc(var(--sheet) + 1px),
      rgba(12, 18, 34, 0.9) calc(var(--sheet) + 1px)
    ),
    url("../img/globe.svg");
  background-position: 50% 100%, center, 50% 34%;
  background-size: 78% calc(100% - var(--sheet) - 30px), 100% 100%, 168% auto;
}
.shot-half .slot-shot {
  --sheet: 56%;
}
.shot-full .slot-shot {
  --sheet: 9%;
}

/* ---------- Home: hero ---------- */

.hero {
  display: grid;
  align-items: center;
  gap: clamp(8px, 4vw, 56px);
  padding-block: clamp(20px, 6vw, 72px) 0;
}

.hero-copy .lede {
  margin-top: clamp(16px, 2.4vw, 28px);
  max-width: 26ch;
  font-size: clamp(1.1875rem, 1rem + 0.9vw, 1.5rem);
  line-height: 1.35;
  color: var(--text);
}

.stores {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: clamp(24px, 3.4vw, 40px);
  list-style: none;
}

/* A store link that has nowhere to go yet. Dashed, like "Want to go". */
.store {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  min-width: 132px;
  min-height: 56px;
  padding: 8px 16px;
  border: 1px dashed var(--accent-dashed);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  line-height: 1.25;
}
.store[href] {
  border-style: solid;
  border-color: var(--accent);
}
.store .state {
  color: var(--text2);
  font-size: 0.8125rem;
}

.hero-copy .quiet {
  margin-top: 16px;
}

.hero-globe {
  justify-self: center;
  width: min(100% + 2 * var(--pad), 640px);
  margin-inline: calc(-1 * var(--pad));
}

@media (min-width: 900px) {
  .hero {
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  }
  .hero-globe {
    width: 100%;
    max-width: 640px;
    margin-inline: 0;
  }
  /* Side by side, only the globe goes under the sheet. */
  .hero-copy {
    padding-bottom: calc(var(--overlap) + 40px);
  }
}

/* ---------- Inner pages: the planet's horizon ---------- */

.horizon {
  height: clamp(132px, 24vw, 230px);
  background: url("../img/globe.svg") 50% -46px / max(1180px, 150vw) auto no-repeat;
}

/* ---------- The sheet ---------- */

.sheet {
  position: relative;
  margin-top: calc(-1 * var(--overlap));
  padding-block: 44px 0;
  border-top: 1px solid var(--line-strong);
  border-radius: var(--sheet-radius) var(--sheet-radius) 0 0;
  /* Dark glass where it meets the globe, solid under the text. */
  background: linear-gradient(to bottom, rgba(12, 18, 34, 0.8), var(--surface) 88px);
}
.horizon + .sheet {
  margin-top: -44px;
}
/* The drag handle. Nothing drags; it says "sheet". */
.sheet::before {
  content: "";
  position: absolute;
  top: 10px;
  left: 50%;
  width: 36px;
  height: 4px;
  margin-left: -18px;
  border-radius: 2px;
  background: var(--line-strong);
}

.block {
  padding-block: clamp(36px, 6vw, 72px);
}
.block + .block {
  border-top: 1px solid var(--line);
}
.block > h2 + * {
  margin-top: clamp(16px, 2.4vw, 24px);
}
.block p + p {
  margin-top: 0.9em;
}

.idea p {
  font-size: clamp(1.0625rem, 1rem + 0.5vw, 1.3125rem);
  line-height: 1.5;
}

/* ---------- What it does: five rows ---------- */

.does {
  margin-top: clamp(20px, 3vw, 36px);
  list-style: none;
}
.does > li {
  display: grid;
  gap: 20px;
  max-width: none;
  padding-block: 28px;
  border-top: 1px solid var(--line);
}
.does > li:first-child {
  border-top: 0;
  padding-top: 0;
}
.does > li:last-child {
  padding-bottom: 0;
}
.does h3 + p {
  margin-top: 6px;
  color: var(--text2);
}
.shot {
  width: min(58vw, 208px);
}

@media (min-width: 700px) {
  .does > li {
    grid-template-columns: minmax(0, 1fr) 208px;
    align-items: center;
    gap: 48px;
    padding-block: 36px;
  }
  .shot {
    width: 208px;
  }
}
@media (min-width: 1060px) {
  /* Wide screens: the five screens stand side by side, each over its words.
     The words still come first in the document. */
  .does {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 32px;
  }
  .does > li {
    display: flex;
    flex-direction: column-reverse;
    justify-content: flex-end;
    gap: 20px;
    padding-block: 0;
    border-top: 0;
  }
  .does h3 + p {
    font-size: 0.9375rem;
    line-height: 1.5;
  }
  .shot {
    width: 100%;
  }
}

/* ---------- The privacy promise ---------- */

.promise {
  display: grid;
  gap: 32px;
}
.promise .checks {
  display: grid;
  gap: 0;
  margin-top: 24px;
  list-style: none;
}
.promise .checks li {
  padding-block: 14px;
  border-top: 1px solid var(--line);
}
.promise .checks li:last-child {
  border-bottom: 1px solid var(--line);
}
.promise .more {
  margin-top: 24px;
}
@media (min-width: 700px) {
  .promise {
    grid-template-columns: minmax(0, 1fr) 208px;
    align-items: center;
    gap: 48px;
  }
}
@media (min-width: 1000px) {
  .promise {
    grid-template-columns: minmax(0, 1fr) 248px;
    gap: 96px;
  }
  .promise .shot {
    width: 248px;
  }
}

/* ---------- Prose pages: privacy and support ---------- */

.prose {
  padding-block: clamp(20px, 4vw, 44px) clamp(36px, 6vw, 72px);
}
.prose h1 {
  font-size: clamp(2.125rem, 1.5rem + 3.2vw, 3.5rem);
  line-height: 1.06;
}
.prose .dated {
  margin-top: 14px;
}
.prose .summary {
  margin-top: clamp(20px, 3vw, 32px);
  font-size: clamp(1.125rem, 1rem + 0.6vw, 1.375rem);
  line-height: 1.45;
}
.prose section {
  margin-top: clamp(36px, 5vw, 56px);
  padding-top: clamp(28px, 4vw, 40px);
  border-top: 1px solid var(--line);
  scroll-margin-top: 16px;
}
.prose h2 {
  font-size: clamp(1.375rem, 1.2rem + 0.8vw, 1.75rem);
}
.prose h3 {
  margin-top: 28px;
}
.prose p,
.prose ul,
.prose ol,
.prose dl {
  margin-top: 14px;
}
.prose ul,
.prose ol {
  padding-left: 1.3em;
}
.prose li + li {
  margin-top: 8px;
}
.prose li::marker {
  color: var(--text2);
  font-family: var(--mono);
  font-size: 0.86em;
}

/* "On this page". */
.toc {
  margin-top: clamp(20px, 3vw, 32px);
}
.toc ul {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 22px;
  margin-top: 6px;
  padding-left: 0;
  list-style: none;
}
.toc li + li {
  margin-top: 0;
}
.toc a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

/* Something the owner still has to fill in. Dashed: not there yet. */
.placeholder {
  max-width: var(--measure);
  padding: 14px 16px;
  border: 1px dashed var(--accent-dashed);
  border-radius: var(--radius);
}

/* ---------- Footer ---------- */

/* Outside <main>, so it is the page's footer landmark, but drawn as the
   last part of the sheet. */
.foot {
  background: var(--surface);
}
.foot .wrap {
  padding-block: 32px 44px;
}
.foot .wrap::before {
  content: "";
  display: block;
  margin-bottom: 28px;
  border-top: 1px solid var(--line);
}
.foot nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 22px;
  list-style: none;
}
.foot nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}
.foot .credits {
  margin-top: 12px;
}
.foot .credits + .credits {
  margin-top: 8px;
}
.foot .credits a {
  color: var(--text2);
}
.foot .credits a:hover {
  color: var(--accent);
}

/* ---------- Preferences ---------- */

/* The one moment of motion: the globe arrives. Nothing else moves. */
@media (prefers-reduced-motion: no-preference) {
  .hero-globe .slot-hero {
    animation: arrive 900ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
  }
  @keyframes arrive {
    from {
      opacity: 0;
      transform: scale(0.965);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }
  a,
  .store {
    transition: color 150ms, border-color 150ms, text-decoration-color 150ms;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .sheet {
    background: var(--surface);
  }
}

@media (prefers-contrast: more) {
  :root {
    --text2: #a9b4cf;
    --line: #3a4a6b;
    --line-strong: #5a6a8e;
    --accent-dashed: var(--accent);
  }
}

@media (forced-colors: active) {
  .slot,
  .sheet,
  .store,
  .placeholder {
    border: 1px solid CanvasText;
  }
  .slot {
    color: CanvasText;
    font-size: 0.875rem;
  }
}

@media print {
  body {
    background: #fff;
    color: #000;
  }
  .sheet {
    margin-top: 0;
    background: none;
    border: 0;
  }
  .horizon,
  .hero-globe,
  .shot,
  .skip {
    display: none;
  }
  a,
  .quiet,
  .does h3 + p {
    color: #000;
  }
}
