@font-face {
  font-family: 'Atkinson Hyperlegible';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/AtkinsonHyperlegible_400Regular.ttf') format('truetype');
}

@font-face {
  font-family: 'Atkinson Hyperlegible';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/AtkinsonHyperlegible_700Bold.ttf') format('truetype');
}

/*
 * One typeface (the app's), ink on cool paper, one accent taken from the app icon.
 * Category hues come from src/ui/theme/calmCare.ts and are used only where they
 * mark a record category.
 */
:root {
  color-scheme: light dark;
  --paper: #f5f8f8;
  --ink: #203238;
  --ink-muted: #53666a;
  --rule: #cbd9d9;
  --link: #2c6e73;
  --accent: #b8405a;
  --medications: #1c8559;
  --vaccinations: #7450c2;
  --allergies: #cc4f27;
  --measurements: #0b8194;
  --documents: #56647f;
  --report: #2d69b3;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #131c1e;
    --ink: #e7eeef;
    --ink-muted: #a9b9bc;
    --rule: #2f4246;
    --link: #7cc3c8;
    --accent: #f08ca0;
    --medications: #5bc794;
    --vaccinations: #ab90ec;
    --allergies: #f08a66;
    --measurements: #4dc2d4;
    --documents: #a3b0c9;
    --report: #7fa9e3;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 2rem;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family:
    'Atkinson Hyperlegible',
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    sans-serif;
  font-size: 1.125rem;
  line-height: 1.55;
}

a {
  color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

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

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

/* Page frame: a side rail and one reading column */
.page {
  max-width: 68rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.rail {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  margin-bottom: 3rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand img {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.55rem;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  font-size: 1rem;
}

.site-nav a {
  color: var(--ink-muted);
  text-decoration: none;
}

.site-nav a:hover {
  color: var(--ink);
  text-decoration: underline;
}

.site-nav a[aria-current='page'] {
  color: var(--ink);
  font-weight: 700;
}

.toc {
  display: none;
}

@media (min-width: 60rem) {
  .page {
    display: grid;
    grid-template-columns: 13rem minmax(0, 1fr);
    column-gap: 5.5rem;
    padding-top: 4rem;
    padding-bottom: 5rem;
  }

  .rail {
    display: block;
    position: sticky;
    top: 4rem;
    align-self: start;
    max-height: calc(100vh - 5rem);
    margin-bottom: 0;
    overflow-y: auto;
  }

  .site-nav {
    flex-direction: column;
    gap: 0.35rem;
    margin-top: 2rem;
  }

  .toc {
    display: block;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--rule);
    font-size: 0.9rem;
    line-height: 1.35;
  }

  .toc ol {
    margin: 0;
    padding-left: 1.6em;
    color: var(--ink-muted);
  }

  .toc li + li {
    margin-top: 0.5rem;
  }

  .toc a {
    color: var(--ink-muted);
    text-decoration: none;
  }

  .toc a:hover {
    color: var(--ink);
    text-decoration: underline;
  }
}

/* Reading column */
.doc {
  max-width: 46rem;
}

.doc h1 {
  margin: 0 0 1.5rem;
  font-size: clamp(2.4rem, 8vw, 3.8rem);
  line-height: 1.02;
  letter-spacing: -0.03em;
}

.doc h2 {
  position: relative;
  margin: 3.5rem 0 0.75rem;
  font-size: 1.45rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.doc p,
.doc ul {
  max-width: 38rem;
  margin: 0 0 1rem;
}

.doc ul {
  padding-left: 1.1em;
}

.doc li + li {
  margin-top: 0.4rem;
}

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

.doc .lede {
  max-width: 34rem;
  margin-bottom: 2.5rem;
  font-size: clamp(1.3rem, 3.6vw, 1.6rem);
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.doc .meta {
  margin: -0.75rem 0 2rem;
  color: var(--ink-muted);
  font-size: 1rem;
}

.num {
  color: var(--accent);
}

@media (min-width: 60rem) {
  /* Section numbers hang in the margin between the rail and the text. */
  .num {
    position: absolute;
    right: 100%;
    margin-right: 0.9rem;
  }
}

/* Privacy policy: what lives where */
.data-map {
  width: 100%;
  margin: 0 0 1rem;
  border-collapse: collapse;
  font-size: 1rem;
  line-height: 1.4;
}

.data-map caption {
  padding-bottom: 0.75rem;
  font-size: 1.125rem;
  font-weight: 700;
  text-align: left;
}

.data-map th,
.data-map td {
  padding: 0.8rem 1.25rem 0.8rem 0;
  border-top: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}

.data-map thead th {
  border-top: 2px solid var(--ink);
  color: var(--ink-muted);
  font-weight: 400;
}

.data-map tbody tr:last-child > * {
  border-bottom: 2px solid var(--ink);
}

.data-map tbody th {
  width: 38%;
}

@media (max-width: 40rem) {
  .data-map thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .data-map,
  .data-map caption,
  .data-map tbody,
  .data-map tr,
  .data-map th,
  .data-map td {
    display: block;
    width: auto;
  }

  .data-map tbody tr {
    padding: 0.9rem 0;
    border-top: 1px solid var(--rule);
  }

  .data-map tbody tr:first-child {
    border-top: 2px solid var(--ink);
  }

  .data-map tbody tr:last-child {
    border-bottom: 2px solid var(--ink);
  }

  .data-map tbody th,
  .data-map tbody td,
  .data-map tbody tr:last-child > * {
    width: auto;
    padding: 0;
    border: 0;
  }

  .data-map tbody td {
    margin-top: 0.3rem;
  }

  .data-map tbody td::before {
    content: attr(data-label) ': ';
    color: var(--ink-muted);
  }
}

/* Support: the address is the page */
.doc .mail {
  max-width: none;
  margin: 0 0 1.25rem;
  font-size: clamp(1.55rem, 6.4vw, 2.9rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.mail a {
  color: var(--ink);
  text-decoration-color: var(--accent);
  text-decoration-thickness: 0.09em;
  text-underline-offset: 0.16em;
}

.mail a:hover {
  text-decoration-thickness: 0.14em;
}

/* Question and answer rows, also used for the record list on the home page */
.faq {
  margin: 1.25rem 0 0;
}

.qa {
  padding: 1.1rem 0;
  border-top: 1px solid var(--rule);
}

.qa dt {
  margin-bottom: 0.35rem;
  font-weight: 700;
  line-height: 1.3;
}

.qa dd {
  margin: 0;
}

.qa dd p:last-child {
  margin-bottom: 0;
}

@media (min-width: 44rem) {
  .qa {
    display: grid;
    grid-template-columns: 15rem minmax(0, 1fr);
    column-gap: 2rem;
  }

  .qa dt {
    margin-bottom: 0;
  }
}

.records dt::before {
  content: '';
  display: inline-block;
  width: 0.6em;
  height: 0.6em;
  margin-right: 0.55em;
  border-radius: 50%;
  background: var(--dot, var(--ink));
}

.records .medications {
  --dot: var(--medications);
}

.records .vaccinations {
  --dot: var(--vaccinations);
}

.records .allergies {
  --dot: var(--allergies);
}

.records .measurements {
  --dot: var(--measurements);
}

.records .documents {
  --dot: var(--documents);
}

.records .report {
  --dot: var(--report);
}

.doc .soon {
  margin: -1rem 0 0;
  font-weight: 700;
}

/* Footer */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  margin-top: 5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  color: var(--ink-muted);
  font-size: 0.95rem;
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
}

.site-footer a {
  color: var(--ink-muted);
}
