/*
  Cuprila design tokens.
  Every colour, size and spacing the app uses is a token here. Values come from the mascot
  kit (copper #CF7B4E) and the wireframes' wf.css and wf-web.css.
*/
:root {
  color-scheme: light;

  /* Brand */
  --copper: #cf7b4e;
  --copper-edge: #a85b33;

  /* Surfaces and text */
  --paper: #f4f1eb;
  --surface: #ffffff;
  --surface-soft: #f1eee8;
  --line: #e6e1d8;
  --line-strong: #d9d4cc;
  --ink: #1f1d1a;
  --ink-2: #5a534b;
  --ink-3: #6b655e;
  --ink-muted: #8a8178;
  --ink-placeholder: #757575;
  --edge: #8a8178; /* the border of a bordered control */
  --btn-danger: #a8362b; /* white on it is 6.5 to 1 */
  --btn-wait: #e6e1d8;
  --btn-wait-ink: #5a534b; /* 5.8 to 1 on the waiting ground */
  --scrim: rgb(31 29 26 / 40%); /* behind a sheet or a dialog */

  /* The jar's glass and label; its coins and bands are art and keep their own colours. */
  --jar-glass: #f3f1ec;
  --jar-rim: #b5b0a6;
  --jar-shine: rgb(255 255 255 / 75%);
  --jar-shadow: rgb(42 31 26 / 8%);
  --jar-label: #fbf3ea;
  --jar-label-edge: #e4cdb5;
  --jar-label-ink: #26221e;

  /* Day states (shape carries meaning; colour only reinforces it) */
  --day-saved: var(--copper);
  --day-excused: var(--copper-edge);
  --day-ahead: var(--line);

  /* Type. Nunito for the Latin-script languages, self-hosted subsets; every other script falls
     back to the platform's own face (docs/languages.md). */
  --font-system:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans',
    sans-serif;
  --font-sans: Nunito, 'Nunito Vi', var(--font-system);
  /* Six sizes, each with one job, the same on phone and web (board v2-rules). */
  --fs-hero: 4.5rem; /* 72: the hero, one per screen */
  --fs-total: 2.25rem; /* 36: the total when it is not the hero */
  --fs-main: 1.75rem; /* 28: the screen's main line */
  --fs-title: 1.25rem; /* 20: a title, or a second figure */
  --fs-text: 1rem; /* 16: text, labels, buttons, rows */
  --fs-cap: 0.8125rem; /* 13: captions, chips, the header line */
  --fw-text: 500;
  --fw-bold: 700;
  --fw-black: 800;
  --lh-tight: 1.15;
  --lh-body: 1.5;
  --lh-ui: normal; /* the boards set no line height on controls */
  --lh-sub: 1.45;
  --lh-cap: 1.4;

  /* Space and shape */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --radius-s: 10px;
  --radius-m: 14px;
  --radius-pill: 999px;
  --tap: 44px; /* minimum touch target */
  --gutter: 20px;

  /* Motion (reduced-motion variant below) */
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --dur-fast: 120ms;
}

/* The dark theme: the same tokens, second values (Settings › Appearance, `public/theme.js`).
   The same declarations stand twice: for a device set to dark with no choice made in the app,
   and for the choice "Dark". Keep the two lists identical (`theme.test.ts` checks). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;

    /* --copper stays #cf7b4e */
    --copper-edge: #e9a57c;

    --paper: #121110;
    --surface: #1b1917;
    --surface-soft: #282521;
    --line: #35312c;
    --line-strong: #4a453e;
    --ink: #f3efe8;
    --ink-2: #cbc3b8;
    --ink-3: #b5ada2;
    --ink-muted: #958c81;
    --ink-placeholder: #a0988d;
    --edge: #958c81;
    --btn-danger: #f0897a; /* the ground's colour on it is 7.1 to 1 */
    --btn-wait: #35312c;
    --btn-wait-ink: #b5ada2; /* 5.8 to 1 on the waiting ground */

    --scrim: rgb(0 0 0 / 60%);
    --jar-glass: #26231f;
    --jar-rim: #7a7268;
    --jar-shine: rgb(255 255 255 / 12%);
    --jar-shadow: rgb(0 0 0 / 40%);
    --jar-label: #3a2f26;
    --jar-label-edge: #5c4a3b;
    --jar-label-ink: #f3efe8;
  }
}

:root[data-theme='dark'] {
  color-scheme: dark;

  /* --copper stays #cf7b4e */
  --copper-edge: #e9a57c;

  --paper: #121110;
  --surface: #1b1917;
  --surface-soft: #282521;
  --line: #35312c;
  --line-strong: #4a453e;
  --ink: #f3efe8;
  --ink-2: #cbc3b8;
  --ink-3: #b5ada2;
  --ink-muted: #958c81;
  --ink-placeholder: #a0988d;
  --edge: #958c81;
  --btn-danger: #f0897a; /* the ground's colour on it is 7.1 to 1 */
  --btn-wait: #35312c;
  --btn-wait-ink: #b5ada2; /* 5.8 to 1 on the waiting ground */

  --scrim: rgb(0 0 0 / 60%);
  --jar-glass: #26231f;
  --jar-rim: #7a7268;
  --jar-shine: rgb(255 255 255 / 12%);
  --jar-shadow: rgb(0 0 0 / 40%);
  --jar-label: #3a2f26;
  --jar-label-edge: #5c4a3b;
  --jar-label-ink: #f3efe8;
}

/* A sheet's backdrop inherits nothing in Safari before 17.4, so `var(--scrim)` does not reach
   it there: it carries the scrim's two values itself, under the same selectors. */
::backdrop {
  --scrim: rgb(31 29 26 / 40%);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) ::backdrop {
    --scrim: rgb(0 0 0 / 60%);
  }
}

:root[data-theme='dark'] ::backdrop {
  --scrim: rgb(0 0 0 / 60%);
}

/* Scripts that fill the line or stack marks above and below it need about 1.5× the Latin line
   height, Thai 1.6× and Burmese 1.7×; the layout allows it everywhere. Spaced-out capitals mean
   nothing in them, and spacing pulls their joined letters apart. */
html:is(
  [lang^='zh'],
  [lang='ja'],
  [lang='ko'],
  [lang='hi'],
  [lang='mr'],
  [lang='ne'],
  [lang='bn'],
  [lang='te'],
  [lang='ta'],
  [lang='kn'],
  [lang='ml'],
  [lang='am'],
  [lang='th'],
  [lang='my']
) {
  --lh-tight: 1.35;
  --lh-body: 1.7;
  --lh-ui: 1.5;
  --lh-sub: var(--lh-body);
  --lh-cap: var(--lh-body);
}

html[lang='th'] {
  --lh-tight: 1.45;
  --lh-body: 1.8;
  --lh-ui: 1.6;
}

html[lang='my'] {
  --lh-tight: 1.55;
  --lh-body: 1.9;
  --lh-ui: 1.7;
}

/* Chinese, Japanese and Korean share characters that each writes its own way, so each names
   its own faces, here and on a language's name inside another language's page. The other
   scripts have one form, and the platform's fallback finds its face for them. Vietnamese puts
   its own Nunito file first (see base.css). */
:lang(vi) {
  --font-sans: 'Nunito Vi', Nunito, var(--font-system);
}

:lang(zh) {
  --font-sans:
    Nunito, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans CJK SC',
    'Noto Sans SC', var(--font-system);
}

:lang(zh-Hant) {
  --font-sans:
    Nunito, 'PingFang TC', 'Microsoft JhengHei', 'Noto Sans CJK TC', 'Noto Sans TC',
    var(--font-system);
}

:lang(ja) {
  --font-sans:
    Nunito, 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Yu Gothic UI', Meiryo,
    'Noto Sans CJK JP', 'Noto Sans JP', var(--font-system);
}

:lang(ko) {
  --font-sans:
    Nunito, 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans CJK KR', 'Noto Sans KR',
    var(--font-system);
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-fast: 0ms;
  }
}

/*
  cuprila.com: the home page and the legal pages. The app's tokens come first in the built file
  (`site/src/build.ts`); these rules use them, so light and dark follow the app's. Nunito for the
  Latin scripts, the platform's own face for the others, as in the app (docs/languages.md).
*/
@font-face {
  font-family: 'Nunito Vi';
  src: url('/fonts/nunito-vi-1.woff2') format('woff2');
  font-weight: 500 800;
  font-display: swap;
  unicode-range:
    U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+1EA0-1EF9;
}
@font-face {
  font-family: Nunito;
  src: url('/fonts/nunito-sym-1.woff2') format('woff2');
  font-weight: 500 800;
  font-display: swap;
  unicode-range: U+20A1-20BD;
}
@font-face {
  font-family: Nunito;
  src: url('/fonts/nunito-ext-1.woff2') format('woff2');
  font-weight: 500 800;
  font-display: swap;
  unicode-range: U+0100-017E, U+0218-021B;
}
@font-face {
  font-family: Nunito;
  src: url('/fonts/nunito-west-1.woff2') format('woff2');
  font-weight: 500 800;
  font-display: swap;
  unicode-range:
    U+00A1-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2009, U+2013, U+2018,
    U+201A, U+201E, U+2022, U+2032-2033, U+2044, U+2122, U+2212, U+2215;
}
@font-face {
  font-family: Nunito;
  src: url('/fonts/nunito-1.woff2') format('woff2');
  font-weight: 500 800;
  font-display: swap;
}

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

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

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  font-weight: var(--fw-text);
  line-height: var(--lh-body);
  overflow-wrap: anywhere;
}

a {
  color: var(--copper-edge);
  font-weight: var(--fw-black);
}

a:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--copper);
  outline-offset: 2px;
}

.bar {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) clamp(var(--space-4), 4vw, 48px);
  border-bottom: 2px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--ink);
  font-size: 1.5rem;
  text-decoration: none;
}

.tools {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}

.pill summary,
.open {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 var(--space-4);
  border: 2px solid var(--jar-label-edge);
  border-radius: var(--radius-pill);
  color: var(--ink);
  font-size: 0.9375rem;
  font-weight: var(--fw-black);
  line-height: var(--lh-ui);
  text-decoration: none;
  cursor: pointer;
}

.pill summary::after {
  content: '▾';
  margin-inline-start: var(--space-1);
}

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

.langs {
  position: absolute;
  inset-inline-end: var(--space-4);
  top: 100%;
  z-index: 1;
  width: max-content;
  max-width: calc(100vw - 2 * var(--space-4));
  max-height: 60vh;
  overflow-y: auto;
  margin: var(--space-2) 0 0;
  padding: var(--space-2);
  list-style: none;
  background: var(--surface);
  border: 2px solid var(--line-strong);
  border-radius: var(--radius-m);
  columns: 2;
}

.langs a {
  display: block;
  padding: var(--space-2) var(--space-3);
  color: var(--ink);
  font-weight: var(--fw-bold);
  text-decoration: none;
}

.langs a[aria-current] {
  color: var(--copper-edge);
  font-weight: var(--fw-black);
}

.home .open {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--surface);
}

.foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-3) 28px;
  margin-top: auto;
  padding: var(--space-5) var(--space-4);
  border-top: 2px solid var(--line);
  color: var(--ink-3);
  font-size: 0.9375rem;
  font-weight: var(--fw-bold);
}

.foot nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-3) 28px;
}

/* The home page (board legal-5). */
.hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-10) 90px;
  max-width: 1000px;
  margin: 0 auto;
  padding: clamp(var(--space-8), 8vw, 120px) var(--space-5);
}

.coin {
  width: min(240px, 60vw);
  height: auto;
}

.pitch {
  flex: 1 1 320px;
  max-width: 560px;
}

.pitch h1 {
  margin: 0 0 var(--space-4);
  font-size: clamp(2.25rem, 6vw, 3.25rem);
  font-weight: var(--fw-black);
  line-height: var(--lh-tight);
}

.pitch p {
  margin: 0 0 var(--space-5);
}

.what {
  font-size: 1.25rem;
}

.google {
  color: var(--ink-2);
}

.cta {
  display: inline-flex;
  align-items: center;
  min-height: 52px;
  padding: 0 var(--space-8);
  background: var(--copper);
  border: 2px solid var(--copper-edge);
  border-radius: var(--radius-pill);
  /* Dark on copper in both themes: white on copper is 3.1 to 1, under the 4.5 text needs. */
  color: #1f1d1a;
  font-size: 1.125rem;
  text-decoration: none;
}

/* The legal pages (boards legal-6 and legal-7). */
.page {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-8) 60px;
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-4) var(--space-10);
}

.toc {
  position: sticky;
  top: 0;
  flex: 0 1 240px;
  max-height: 100dvh;
  overflow-y: auto;
  font-size: 0.9375rem;
}

/* On a phone the text comes first and the list of sections follows it, as the board draws. */
@media (max-width: 860px) {
  .toc {
    position: static;
    order: 1;
    max-height: none;
  }
}

.toc h2 {
  margin: var(--space-6) 0 var(--space-2);
  font-size: 0.9375rem;
  font-weight: var(--fw-black);
}

.toc ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.toc a {
  display: block;
  padding: var(--space-1) 0;
  color: var(--ink-3);
  font-weight: var(--fw-bold);
  text-decoration: none;
}

.text {
  flex: 1 1 520px;
  min-width: 0;
  max-width: 720px;
}

.text h1 {
  margin: var(--space-4) 0 var(--space-2);
  font-size: clamp(1.875rem, 5vw, 2.5rem);
  font-weight: var(--fw-black);
  line-height: var(--lh-tight);
}

.effective {
  margin: 0 0 var(--space-6);
  color: var(--ink-3);
}

.text h2 {
  margin: var(--space-8) 0 var(--space-2);
  font-size: 1.375rem;
  font-weight: var(--fw-black);
  line-height: var(--lh-tight);
  scroll-margin-top: var(--space-4);
}

.text p,
.text li {
  margin: 0 0 var(--space-3);
}

.text ul {
  padding-inline-start: var(--space-6);
}

.note {
  margin: var(--space-4) 0 0;
  padding: 14px 18px;
  background: var(--jar-label);
  border: 2px solid var(--jar-label-edge);
  border-radius: var(--radius-m);
  color: var(--jar-label-ink);
  font-weight: var(--fw-bold);
}

.note p {
  margin: 0;
}

.table {
  overflow-x: auto;
  margin: 0 0 var(--space-4);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

th,
td {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line-strong);
  text-align: start;
  vertical-align: top;
}

th {
  background: var(--surface-soft);
  font-weight: var(--fw-black);
}

/* Not found. */
.gone {
  margin: auto;
  padding: var(--space-10) var(--space-5);
  text-align: center;
}

.gone h1 {
  margin: var(--space-4) 0;
  font-size: var(--fs-main);
}

@media print {
  .bar,
  .toc,
  .foot nav {
    display: none;
  }

  body {
    background: #fff;
    color: #000;
    font-size: 11pt;
  }

  .page {
    display: block;
    padding: 0;
  }

  a {
    color: inherit;
  }

  .text h2 {
    break-after: avoid;
  }
}
