/*
  Simple Wins site. Colours from shared/tokens.json (the D3a "Ink" look):
  light first, dark under prefers-color-scheme. The brand accent is one
  variable (--accent, with --on-accent) because it is still provisional.
  Fonts are self-hosted Latin subsets of shared/fonts (SIL OFL); no request
  leaves this site.
*/

@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/fonts/bricolage-800.v1.woff2") format("woff2");
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/fonts/bricolage-700.v1.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Figtree";
  src: url("/fonts/figtree-400.v1.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Figtree";
  src: url("/fonts/figtree-600.v1.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

/* Fallbacks sized to the web fonts' metrics, so the swap does not move the
   text. Measured with fontTools against Arial (Bold for the display face). */
@font-face {
  font-family: "Bricolage fallback";
  src:
    local("Arial Bold"), local("Arial-BoldMT"), local("Helvetica Bold"),
    local("Helvetica-Bold"), local("Roboto Bold"), local("Roboto-Bold");
  font-weight: 700 800;
  size-adjust: 101%;
  ascent-override: 92%;
  descent-override: 26.7%;
  line-gap-override: 0%;
}

@font-face {
  font-family: "Figtree fallback";
  src:
    local("Arial"), local("ArialMT"), local("Helvetica"), local("Roboto"),
    local("Roboto-Regular");
  size-adjust: 100.2%;
  ascent-override: 94.8%;
  descent-override: 24.9%;
  line-gap-override: 0%;
}

:root {
  --background: #fff6ec;
  --surface: #ffffff;
  --ink: #2a1230;
  --muted: #6a566e;
  --line: #f0e2dd;
  --tint: #ffe0c2;
  --accent: #452b32;
  --on-accent: #ffffff;
  --body: #ff5f3a;
  --body-soft: #ffd9d0;
  --mind: #4f9dff;
  --mind-soft: #d2e5fe;
  --spirit: #3cc985;
  --spirit-soft: #c3f0d4;
  --people: #ffc130;
  --people-soft: #f7e0b6;

  /* The phone frame and the shadows under pictures. */
  --bezel: #1f1714;
  --bezel-ring: rgba(255, 255, 255, 0.14);
  --shadow-color: 42deg 30% 20%;
  --shadow:
    0 1px 2px hsl(var(--shadow-color) / 0.08),
    0 12px 24px -12px hsl(var(--shadow-color) / 0.22),
    0 32px 64px -32px hsl(var(--shadow-color) / 0.3);

  --display: "Bricolage Grotesque", "Bricolage fallback", sans-serif;
  --text: "Figtree", "Figtree fallback", sans-serif;

  /* Type scale: 17 px body, steps of about 1.25. */
  --step-0: 1.0625rem;
  --step-1: clamp(1.1875rem, 1.12rem + 0.3vw, 1.3125rem);
  --step-2: clamp(1.375rem, 1.2rem + 0.75vw, 1.75rem);
  --step-3: clamp(1.875rem, 1.35rem + 2.3vw, 3rem);
  --step-4: clamp(2.5rem, 1.6rem + 4.1vw, 4.75rem);

  --gutter: clamp(16px, 4vw, 40px);
  --section: clamp(72px, 9vw, 128px);
  --radius-small: 12px;
  --radius: 24px;
  --radius-large: 32px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #181311;
    --surface: #251d1a;
    --ink: #f7efe6;
    --muted: #cec3b9;
    --line: #362b26;
    --tint: #4a2b14;
    --accent: #eadbc8;
    --on-accent: #2a1a14;
    --body: #ff7656;
    --body-soft: #5a3025;
    --mind: #5fa6ff;
    --mind-soft: #253e5f;
    --spirit: #4bd091;
    --spirit-soft: #194730;
    --people: #ffc947;
    --people-soft: #4d3a0d;

    --bezel: #3a2e29;
    --bezel-ring: rgba(255, 255, 255, 0.1);
    --shadow-color: 20deg 40% 3%;
    --shadow:
      0 1px 2px hsl(var(--shadow-color) / 0.4),
      0 12px 24px -12px hsl(var(--shadow-color) / 0.5),
      0 32px 64px -32px hsl(var(--shadow-color) / 0.7);
  }
}

/* Base */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  /* Morning light at the top of every page, as on the app's Day won. */
  background:
    radial-gradient(
        ellipse 90% 640px at 12% -120px,
        var(--tint) 0%,
        transparent 72%
      )
      no-repeat,
    var(--background);
  color: var(--ink);
  font-family: var(--text);
  font-size: var(--step-0);
  line-height: 1.55;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}

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

img {
  max-width: 100%;
  height: auto;
}

picture {
  display: block;
}

h1,
h2,
h3 {
  font-family: var(--display);
  color: var(--ink);
  margin: 0;
  text-wrap: balance;
}

h1 {
  font-weight: 800;
  font-size: var(--step-4);
  line-height: 1;
  letter-spacing: -0.025em;
}

h2 {
  font-weight: 800;
  font-size: var(--step-3);
  line-height: 1.06;
  letter-spacing: -0.02em;
}

h3 {
  font-weight: 700;
  font-size: var(--step-1);
  line-height: 1.2;
  letter-spacing: -0.005em;
}

p,
ul,
ol {
  margin: 0 0 16px;
}

p {
  text-wrap: pretty;
}

ul {
  padding-left: 1.2em;
}

li {
  margin-bottom: 8px;
}

a {
  color: var(--ink);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-thickness: 2px;
}

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

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

.small {
  font-size: 0.875rem;
}

.lede {
  font-size: var(--step-1);
  line-height: 1.5;
}

/* Layout */

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

.wrap.narrow {
  max-width: calc(720px + 2 * var(--gutter));
}

.skip {
  position: absolute;
  left: 12px;
  top: -100px;
  z-index: 10;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  text-decoration: none;
}

.skip:focus {
  top: 12px;
}

/* Header */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-block: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  color: var(--ink);
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.2rem;
  text-decoration: none;
}

.brand span {
  white-space: nowrap;
}

.brand img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
}

.top nav {
  display: flex;
  gap: 4px;
}

.top nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}

.top nav a:hover,
.top nav a[aria-current="page"] {
  background: var(--surface);
}

.top nav a:active {
  background: var(--line);
}

/* Buttons. The App Store slot is a span before release and a link on
   release day (see store/site/README.md); both look the same. */

.store-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 26px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  font-size: 1.0625rem;
  text-decoration: none;
  white-space: nowrap;
}

a.store-button:hover {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

a.store-button:active {
  transform: translateY(1px);
}

/* Pictures: a phone frame for the hero, rounded crops of the top of the
   screen elsewhere. The screenshots are never drawn on. */

.device {
  padding: 3.4cqi;
  border-radius: 15.5cqi;
  background: var(--bezel);
  box-shadow:
    inset 0 0 0 1px var(--bezel-ring),
    var(--shadow);
}

.device img {
  display: block;
  width: 100%;
  border-radius: 12.5cqi;
}

.crop {
  position: relative;
  width: 100%;
  max-width: 300px;
  aspect-ratio: 1206 / 2000;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

/* A hairline over the picture's edge, so a light screen keeps an edge on
   a light page. */
.crop::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px var(--line);
  pointer-events: none;
}

.crop picture,
.crop img {
  display: block;
  width: 100%;
  height: 100%;
}

.crop img {
  object-fit: cover;
  object-position: top;
}

/* Hero */

.hero {
  display: grid;
  gap: 48px;
  padding-block: clamp(24px, 5vw, 64px) var(--section);
}

.hero-copy {
  max-width: 620px;
}

.hero h1 {
  margin-bottom: 20px;
}

.promise {
  font-family: var(--display);
  font-weight: 700;
  font-size: var(--step-2);
  line-height: 1.2;
  margin-bottom: 16px;
}

.hero .lede {
  max-width: 34em;
  margin-bottom: 32px;
}

.get {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
}

.get p {
  margin: 0;
  color: var(--muted);
}

.hero-shot {
  container-type: inline-size;
  width: min(100%, 300px);
  margin-inline: auto;
}

@media (min-width: 900px) {
  .hero {
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    align-items: center;
    gap: 64px;
  }

  .hero-shot {
    width: min(100%, 320px);
  }
}

/* Sections */

main > section,
.fair {
  padding-block: 0 var(--section);
}

main > section h2,
.fair h2 {
  max-width: 20ch;
  margin-bottom: 20px;
}

.problem p {
  max-width: 30em;
  margin: 0;
  font-size: var(--step-2);
  line-height: 1.4;
  color: var(--muted);
}

/* How a day works: a real sequence, so it is numbered. */

.steps {
  display: grid;
  gap: 56px;
  margin: 48px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.step {
  margin: 0;
  counter-increment: step;
}

.step .crop {
  margin-bottom: 28px;
}

.step h3 {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.step h3::before {
  content: counter(step);
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 1rem;
  font-weight: 800;
}

.step p {
  max-width: 30em;
  margin: 0;
  color: var(--muted);
}

/* On phones the pictures stay short enough that the words lead. */
@media (max-width: 599px) {
  .crop {
    max-width: 250px;
  }
}

@media (min-width: 600px) {
  .steps {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(24px, 4vw, 56px);
  }
}

/* What is different: a band of deeper morning light. */

.fair {
  padding-top: var(--section);
  background: color-mix(in srgb, var(--tint) 30%, var(--background));
  margin-bottom: var(--section);
}

.fair .crop {
  aspect-ratio: 1206 / 2060;
  background: var(--background);
}

.rows {
  display: grid;
  gap: 64px;
  margin-top: 40px;
}

.row {
  display: grid;
  gap: 24px;
}

.row h3 {
  font-size: var(--step-2);
  margin-bottom: 12px;
}

.row p {
  max-width: 30em;
  margin: 0;
  color: var(--muted);
  font-size: var(--step-1);
  line-height: 1.5;
}

@media (min-width: 760px) {
  .rows {
    max-width: 880px;
    gap: 72px;
  }

  .row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 280px);
    align-items: start;
    gap: clamp(40px, 6vw, 80px);
  }

  .row-copy {
    padding-top: 56px;
  }

  .row:nth-child(even) {
    grid-template-columns: minmax(0, 280px) minmax(0, 1fr);
  }

  .row:nth-child(even) .row-copy {
    order: 2;
  }
}

/* Everywhere */

.anywhere {
  display: grid;
  gap: 24px;
}

.anywhere-copy p {
  max-width: 34em;
  margin: 0;
  font-size: var(--step-1);
  line-height: 1.5;
  color: var(--muted);
}

/* The widgets at about their real size on a phone (the crops are 3x). */
.tile {
  width: 100%;
  margin: 0;
  overflow: hidden;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.tile.widgets {
  max-width: 364px;
}

.tile.lock {
  max-width: 298px;
}

.tile img {
  display: block;
  width: 100%;
}

@media (min-width: 700px) {
  .anywhere {
    grid-template-columns: minmax(0, 364fr) minmax(0, 298fr);
    gap: 24px;
    align-items: center;
    justify-items: start;
  }

  .anywhere-copy {
    grid-column: 1 / -1;
    margin-bottom: 16px;
  }
}

@media (min-width: 1100px) {
  .anywhere {
    grid-template-columns: minmax(0, 1fr) 364px 298px;
    gap: 32px;
  }

  .anywhere-copy {
    grid-column: auto;
    margin: 0 24px 0 0;
  }
}

/* Private by design */

.private {
  border-top: 1px solid var(--line);
  padding-top: var(--section);
}

.nos {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 32px;
  margin: 8px 0 20px;
  padding: 0;
  list-style: none;
  font-family: var(--display);
  font-weight: 700;
  font-size: var(--step-1);
  line-height: 1.3;
}

.nos li {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin: 0;
}

.nos li::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--ink);
}

.private p {
  max-width: 34em;
  margin: 0;
  font-size: var(--step-1);
  line-height: 1.5;
  color: var(--muted);
}

.private p a {
  color: var(--ink);
}

/* Closing line. Before release it carries no button: the one App Store
   slot is in the hero. */

.close {
  text-align: center;
}

.close h2 {
  margin: 0 auto 12px;
}

.close p {
  margin: 0;
  font-size: var(--step-1);
  color: var(--muted);
}

/* Document pages (privacy, support, 404) */

.doc {
  padding: 16px 0 56px;
}

.doc h1 {
  font-size: clamp(2.1rem, 1.6rem + 2.2vw, 3rem);
  line-height: 1.05;
  margin-bottom: 16px;
}

.doc h2 {
  font-size: clamp(1.3rem, 1.15rem + 0.6vw, 1.6rem);
  line-height: 1.15;
  margin: 40px 0 12px;
}

.doc .lede {
  padding: 20px 22px;
  border-radius: var(--radius);
  background: var(--surface);
}

.panel {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 4px 22px;
  margin: 16px 0 8px;
}

details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 12px 0;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}

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

details summary::after {
  content: "+";
  flex: none;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--background);
  font-family: var(--display);
  font-weight: 700;
}

details summary:hover::after {
  background: var(--line);
}

details[open] summary::after {
  content: "\2212";
}

details p {
  margin: 0 0 14px;
}

details + details {
  border-top: 1px solid var(--line);
}

/* Footer */

.foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
  padding-block: 28px 40px;
  border-top: 1px solid var(--line);
}

.foot nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0 20px;
}

.foot nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.foot p {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.wrap.narrow .foot {
  margin-top: 24px;
}

@media (max-width: 380px) {
  .top nav a {
    padding: 0 8px;
  }

  .top {
    gap: 4px;
  }

  .brand {
    gap: 8px;
    font-size: 1.05rem;
  }

  .brand img {
    width: 32px;
    height: 32px;
  }

  .store-button {
    white-space: normal;
  }
}

/* The smallest phones (320 px): the name and both links on one line. */
@media (max-width: 360px) {
  .top {
    gap: 8px;
  }

  .brand {
    font-size: 0.95rem;
  }

  .top nav {
    gap: 0;
  }

  .top nav a {
    padding: 0 6px;
    font-size: 0.95rem;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .top nav a,
  details summary::after {
    transition: background-color 0.15s ease;
  }

  html {
    scroll-behavior: smooth;
  }
}

@media (forced-colors: active) {
  .store-button,
  .panel,
  .device,
  .crop,
  .tile {
    border: 1px solid CanvasText;
  }
}
