/* SPDX-License-Identifier: AGPL-3.0-or-later */
/* The methodology page (methodology.html): a long reading page in the Calm
   palette, Dusk in the dark, set in the default theme's Onest (precached, so
   it works offline). With #en, #uk or #ru in the address, or a section of
   one, only that language shows; without, English. Script-free (CSP). */

@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/onest/onest-latin-400.woff2") format("woff2");
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/onest/onest-cyrillic-400.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/onest/onest-latin-500.woff2") format("woff2");
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/onest/onest-cyrillic-500.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/onest/onest-latin-600.woff2") format("woff2");
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/onest/onest-cyrillic-600.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

/* Calm (shared/theme/presets.ts) by day, Dusk at night */
:root {
  color-scheme: light dark;
  --ground: #e4edf1;
  --surface: #f7fafb;
  --ink: #1e2a26;
  --muted: #4e5853;
  --line: #c9d3d8;
  --accent: #4f46e5;
  --on-accent: #ffffff;
  --accent-soft: #e3e3fb;
  --accent-ink: #3f38c9;
  --chip: #e9eff2;
  --bloom: rgb(79 70 229 / 0.16);
  --radius: 20px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #14172b;
    --surface: #1e2238;
    --ink: #eceef8;
    --muted: #a3a8c3;
    --line: #31365a;
    --accent: #8ea2ff;
    --on-accent: #10132a;
    --accent-soft: #2b3160;
    --accent-ink: #b9c5ff;
    --chip: #282c48;
    --bloom: rgb(142 162 255 / 0.14);
  }
}

* {
  box-sizing: border-box;
}

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

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

body {
  margin: 0;
  padding: 0 16px 48px;
  background:
    radial-gradient(
    ellipse 900px 420px at 50% -120px,
    var(--bloom),
    transparent 70%
  ),
    var(--ground);
  background-repeat: no-repeat;
  color: var(--ink);
  font: 400 1rem/1.65 "Onest", system-ui, -apple-system, "Segoe UI", Roboto,
    sans-serif;
}

/* ---- Header: the mark (back to the app) and the language switch ---- */

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  max-width: 1120px;
  margin: 0 auto;
  padding: 12px 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 12px;
  color: var(--ink);
  font-weight: 600;
  font-size: 1.125rem;
  letter-spacing: 0.01em;
  text-decoration: none;
}

.brand:hover span {
  text-decoration: underline;
  text-underline-offset: 3px;
}

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

.lang {
  display: inline-flex;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
}

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

.lang a:hover {
  background: var(--chip);
}

/* The language on screen: the one the address names, else English */
body:has(#en:target, #en :target) .lang a[href="#en"],
body:has(#uk:target, #uk :target) .lang a[href="#uk"],
body:has(#ru:target, #ru :target) .lang a[href="#ru"],
body:not(:has(main :target)) .lang a[href="#en"] {
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 500;
}

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

/* A phone: the mark and the languages are a bar at the bottom, under the
   thumb, the languages last, at the right edge (ui.md §4.5);
   the page keeps room for it, and a focused link scrolls clear of it */
@media (max-width: 899px) {
  html {
    scroll-padding-bottom: 96px;
  }

  body {
    padding-bottom: 120px;
  }

  .top {
    position: fixed;
    z-index: 1;
    right: 0;
    bottom: 0;
    left: 0;
    flex-wrap: nowrap;
    max-width: none;
    padding: 8px 16px max(8px, env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--line);
    box-shadow: 0 -8px 24px rgb(0 0 0 / 0.06);
  }

  .top .lang {
    background: var(--ground);
  }

  /* The sign-in screen's language switch, in size */
  .lang a {
    padding: 0 0.625rem;
    font-size: 0.875rem;
  }
}

/* A narrow phone: the mark alone (its name stays for screen readers), so
   the bar stays one row */
@media (max-width: 359px) {
  .top {
    gap: 8px;
    padding-right: 12px;
    padding-left: 12px;
  }

  .brand span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .lang a {
    padding: 0 0.5rem;
    font-size: 0.8125rem;
  }
}

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

/* ---- One language at a time ---- */

main:has(:target) > article:not(:target):not(:has(:target)) {
  display: none;
}

main:not(:has(:target)) > article:not(#en) {
  display: none;
}

main {
  max-width: 1120px;
  margin: 0 auto;
}

/* Arriving at #en, #uk or #ru (every link from the app) keeps the header,
   with its language switch, in view: the page stays at its top */
main > article {
  scroll-margin-top: 160px;
}

/* ---- Opening ---- */

.hero {
  max-width: 46rem;
  padding: 40px 0 32px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent-ink);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0 0 16px;
  font-size: clamp(2rem, 1.4rem + 2.6vw, 3rem);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.lead {
  margin: 0 0 16px;
  font-size: 1.1875rem;
  line-height: 1.55;
  text-wrap: pretty;
}

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

/* ---- Contents beside the text on a wide screen ---- */

.layout {
  display: grid;
  gap: 16px;
}

@media (min-width: 1100px) {
  .layout {
    grid-template-columns: 248px minmax(0, 1fr);
    gap: 32px;
    align-items: start;
  }

  .toc {
    position: sticky;
    top: 16px;
  }

  .back {
    display: none !important;
  }
}

.toc {
  padding: 16px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.toc h2 {
  margin: 0 8px 8px;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

.toc a {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 4px 8px;
  border-radius: 12px;
  color: var(--ink);
  line-height: 1.3;
  text-decoration: none;
}

.toc a:hover {
  background: var(--chip);
}

.toc .n {
  flex: none;
  width: 1.75rem;
  color: var(--accent-ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.content {
  display: grid;
  gap: 16px;
  min-width: 0;
}

/* ---- Sections ---- */

.part {
  padding: 28px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  scroll-margin-top: 16px;
}

@media (min-width: 720px) {
  .part {
    padding: 36px 40px;
  }
}

.part > * {
  max-width: 44rem;
}

.part > .legend,
.part > .cards,
.part > .fields,
.part > .tiles {
  max-width: none;
}

h2 {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 0 0 16px;
  font-size: clamp(1.375rem, 1.2rem + 0.8vw, 1.75rem);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

h2 .n {
  color: var(--accent-ink);
  font-variant-numeric: tabular-nums;
}

.topic {
  margin-top: 28px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
  scroll-margin-top: 16px;
}

h2 + .topic,
.intro + .topic {
  margin-top: 8px;
  padding-top: 0;
  border-top: 0;
}

h3 {
  margin: 0 0 8px;
  font-size: 1.1875rem;
  font-weight: 600;
  line-height: 1.3;
  text-wrap: balance;
}

h3 .n {
  margin-right: 8px;
  color: var(--muted);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

h4 {
  margin: 20px 0 6px;
  font-size: 1rem;
  font-weight: 600;
}

p,
ul,
ol {
  margin: 0 0 12px;
  text-wrap: pretty;
}

/* A phone's short line and long Ukrainian and Russian words: break them
   where the language allows (never the contents, the opening or field
   names) */
@media (max-width: 599px) {
  :lang(uk) .content :is(p, li),
  :lang(ru) .content :is(p, li) {
    hyphens: auto;
    -webkit-hyphens: auto;
  }
}

ul,
ol {
  padding-left: 1.25rem;
}

li {
  margin-bottom: 6px;
}

li::marker {
  color: var(--muted);
}

strong {
  font-weight: 600;
}

cite,
.term {
  font-style: italic;
}

/* ---- Evidence pills and field chips ---- */

.tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0 0 12px;
}

.ev {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.75rem;
  height: 1.5rem;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1;
}

.ev-a {
  background: var(--accent);
  color: var(--on-accent);
}

.ev-b {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.ev-c {
  border: 1.5px dashed var(--muted);
  color: var(--muted);
}

code {
  hyphens: none;
  -webkit-hyphens: none;
  padding: 1px 6px;
  background: var(--chip);
  border-radius: 6px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.875em;
  overflow-wrap: anywhere;
}

.tags code {
  padding: 2px 8px;
  border: 1px solid var(--line);
  background: transparent;
}

/* Visually hidden, read aloud */
.vh {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---- Legend (§0) ---- */

.legend {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 720px) {
  .legend {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.legend li {
  margin: 0;
  padding: 16px;
  background: var(--ground);
  border-radius: 14px;
}

.legend .ev {
  margin-bottom: 8px;
}

.legend p {
  margin: 0;
  font-size: 0.9375rem;
}

/* ---- Callouts: dated notes, the limits ---- */

.note {
  margin: 16px 0;
  padding: 14px 16px;
  background: var(--ground);
  border-left: 4px solid var(--accent);
  border-radius: 4px 12px 12px 4px;
}

.note p:last-child,
.note ul:last-child {
  margin-bottom: 0;
}

.note time {
  display: inline-block;
  margin-right: 6px;
  padding: 1px 8px;
  background: var(--accent-soft);
  border-radius: 999px;
  color: var(--accent-ink);
  font-size: 0.8125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.warn {
  border-left-color: var(--muted);
}

/* ---- Cards: rejected options (§3), the field map (§4) ---- */

.cards,
.fields {
  display: grid;
  gap: 12px;
  margin: 0 0 12px;
}

@media (min-width: 720px) {
  .cards,
  .fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.cards > div,
.fields > div {
  padding: 16px;
  background: var(--ground);
  border-radius: 14px;
}

.cards dt {
  margin-bottom: 6px;
  font-weight: 600;
  line-height: 1.35;
}

.cards dd,
.fields dd {
  margin: 0;
  font-size: 0.9375rem;
}

.fields dt {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.fields dt code {
  padding: 3px 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 0.875rem;
}

.fields dd + dd {
  margin-top: 8px;
}

.k {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ---- Phases (§5.4) ---- */

.phases {
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
  counter-reset: phase;
}

.phases li {
  position: relative;
  margin: 0;
  padding: 0 0 16px 48px;
  counter-increment: phase;
}

.phases li::before {
  content: counter(phase);
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 50%;
  color: var(--on-accent);
  font-weight: 600;
}

.phases li::after {
  content: "";
  position: absolute;
  top: 36px;
  bottom: 4px;
  left: 15px;
  width: 2px;
  background: var(--line);
}

.phases li:last-child::after {
  display: none;
}

.when {
  display: block;
  font-weight: 600;
}

/* ---- Minimum amounts (§5.5) ---- */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  gap: 12px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}

.tiles li {
  margin: 0;
  padding: 16px;
  background: var(--ground);
  border-radius: 14px;
}

.num {
  display: block;
  margin-bottom: 4px;
  color: var(--accent-ink);
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

/* ---- External anchors (§5.6) ---- */

.anchors {
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}

.anchors li {
  display: grid;
  grid-template-columns: 6.5rem minmax(0, 1fr);
  gap: 12px;
  margin: 0;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.anchors li:last-child {
  border-bottom: 0;
}

.scale {
  font-weight: 600;
}

.dir {
  color: var(--accent-ink);
  font-weight: 600;
}

/* ---- References (§7) ---- */

.refs {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.9375rem;
}

/* A reference: the title upright, the journal in italics */
.refs cite {
  font-style: normal;
}

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

.refs li {
  hyphens: manual;
  -webkit-hyphens: manual;
  margin: 0 0 8px;
  padding-left: 1.5rem;
  text-indent: -1.5rem;
}

/* ---- Back to the contents on a phone ---- */

.back {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.9375rem;
}

/* A phone: a link on its own line ends at the right edge (§4.1) */
@media (max-width: 899px) {
  .back {
    display: flex;
    width: fit-content;
    margin-left: auto;
  }
}

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

/* The project's address in the footer: a full-size target (ui.md §10) */
.foot .project {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

/* ---- Paper ---- */

@media print {
  body {
    padding: 0;
    background: #ffffff;
    color: #000000;
  }

  .top,
  .toc,
  .back {
    display: none;
  }

  .layout {
    display: block;
  }

  .part {
    padding: 0;
    margin-bottom: 24px;
    border: 0;
    break-inside: auto;
  }

  .cards > div,
  .fields > div,
  .legend li,
  .tiles li,
  .note {
    break-inside: avoid;
  }
}
