/*
 * EasyNeurology: the public website (easyneurology.com).
 *
 * Colours come from packages/shared/src/designTokens.ts: lightPalette and darkPalette, plus the
 * book's box colours (lightBoxes, darkBoxes), which are tested there for WCAG 2.1 AA contrast
 * (BOOK_STYLE_AUDIT.md). Type is Carlito, the book's typeface (SIL Open Font License 1.1; see
 * assets/fonts/LICENSE_FONT). Layout uses logical properties only, so it mirrors for the Arabic
 * version later (S-13). There are no inline styles: the Content-Security-Policy allows this file only.
 */

@font-face {
  font-family: Carlito;
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/Carlito_400Regular.ttf") format("truetype");
}

@font-face {
  font-family: Carlito;
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/Carlito_400Regular_Italic.ttf") format("truetype");
}

@font-face {
  font-family: Carlito;
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/assets/fonts/Carlito_700Bold.ttf") format("truetype");
}

/* lightPalette and lightBoxes */
:root {
  color-scheme: light dark;
  --background: #fcfbfe;
  --surface: #efeaf8;
  --border: #c6b3ea;
  --border-strong: #6a6482;
  --text: #2e2a3d;
  --text-strong: #241f36;
  --text-muted: #5f5a75;
  --heading: #5b3fa0;
  --primary: #3c2f72;
  --on-primary: #ffffff;
  --draft: #7a5a00;
  --draft-surface: #fff8e4;
  --draft-line: #e8b93c;
  --key-fill: #fff8e4;
  --key-line: #e8b93c;
  --key-label: #7a5a00;
  --trap-fill: #fdebf1;
  --trap-line: #e86a96;
  --trap-label: #8e1740;
  --nums-fill: #ebf7e8;
  --nums-line: #5faf5a;
  --nums-label: #3f733b;
  --emerg-fill: #fff0e4;
  --emerg-line: #f08a3c;
  --emerg-label: #975726;
  --note-fill: #edf4fc;
  --note-line: #4e8fd0;
  --note-label: #3b6b9c;
  --gulf-fill: #e3f5f4;
  --gulf-line: #2e9b96;
  --gulf-label: #22716e;
}

/* darkPalette and darkBoxes */
@media (prefers-color-scheme: dark) {
  :root {
    --background: #15131c;
    --surface: #1d1a26;
    --border: #3a3550;
    --border-strong: #8f8aa6;
    --text: #ecebf2;
    --text-strong: #ffffff;
    --text-muted: #aaa6bd;
    --heading: #bca9f2;
    --primary: #b9aef0;
    --on-primary: #15131c;
    --draft: #e8b93c;
    --draft-surface: #372e21;
    --draft-line: #e8b93c;
    --key-fill: #372e21;
    --key-line: #e8b93c;
    --key-label: #e8b93c;
    --trap-fill: #372130;
    --trap-line: #e86a96;
    --trap-label: #e96e99;
    --nums-fill: #212c26;
    --nums-line: #5faf5a;
    --nums-label: #5faf5a;
    --emerg-fill: #382621;
    --emerg-line: #f08a3c;
    --emerg-label: #f08a3c;
    --note-fill: #1e2739;
    --note-line: #4e8fd0;
    --note-label: #609ad5;
    --gulf-fill: #192930;
    --gulf-line: #2e9b96;
    --gulf-label: #41a49f;
  }
}

*,
*::before,
*::after {
  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;
  background: var(--background);
  color: var(--text);
  font-family: Carlito, Calibri, "Segoe UI", system-ui, sans-serif;
  font-size: 1.125rem;
  line-height: 1.55;
  overflow-wrap: break-word;
}

a {
  color: var(--primary);
  text-decoration-thickness: 0.07em;
  text-underline-offset: 0.18em;
}

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

:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}

/* The skip link waits above the page until it receives focus. */
.skip-link {
  position: absolute;
  inset-block-start: 0.5rem;
  inset-inline-start: 0.5rem;
  z-index: 1;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 700;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

#main:focus {
  outline: none;
}

/* One column on a phone; from tablet width, the column becomes a page of the book on its lavender frame. */
.sheet {
  max-inline-size: 44rem;
  margin-inline: auto;
  padding-inline: 1rem;
}

@media (min-width: 50em) {
  body {
    background: var(--surface);
  }

  .sheet {
    margin-block: 2.5rem;
    padding-inline: 3.5rem;
    border: 1px solid var(--border);
    border-radius: 1rem;
    background: var(--background);
  }
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem 1.5rem;
  padding-block: 0.5rem;
  border-block-end: 1px solid var(--border);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  min-block-size: 2.75rem;
  color: var(--primary);
  font-size: 1.25rem;
  font-weight: 700;
  text-decoration: none;
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  min-block-size: 2.75rem;
}

/* Type */
h1,
h2,
h3 {
  font-weight: 700;
}

h1 {
  margin-block: 0 1.25rem;
  color: var(--primary);
  font-size: clamp(2.25rem, 1.6rem + 2.6vw, 3.25rem);
  line-height: 1.08;
  text-wrap: balance;
}

h2 {
  margin-block: 0 1rem;
  color: var(--heading);
  font-size: 1.625rem;
  line-height: 1.2;
}

h3 {
  margin-block: 0 0.25rem;
  color: var(--text-strong);
  font-size: 1.1875rem;
  line-height: 1.3;
}

p,
ul,
ol,
dl {
  margin-block: 0 1rem;
}

p {
  max-inline-size: 36em;
}

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

.small {
  color: var(--text-muted);
  font-size: 1rem;
}

/* The book's spaced capitals: kickers and box labels */
.kicker,
.label,
.box-label,
.chip {
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.kicker {
  margin-block: 0 0.75rem;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

/* The landing page opens like a chapter of the book: kicker, title, lede with a navy rule. */
.hero {
  padding-block: 2.5rem 2.25rem;
}

.lede {
  margin-block: 0 1.25rem;
  padding-inline-start: 1rem;
  border-inline-start: 3px solid var(--primary);
  font-size: 1.25rem;
  line-height: 1.5;
}

.label {
  margin-inline-end: 0.5rem;
  color: var(--heading);
  font-size: 0.8125rem;
}

.status {
  margin-block: 1.5rem 0.75rem;
  padding: 0.875rem 1rem;
  border-radius: 0.5rem;
  background: var(--surface);
}

.edu {
  font-weight: 700;
}

.section {
  padding-block: 2.25rem;
  border-block-start: 1px solid var(--border);
}

.steps {
  display: grid;
  gap: 1.25rem;
  margin-block-end: 1.5rem;
  padding-inline-start: 2rem;
}

.steps li::marker {
  font-size: 1.1875rem;
  font-weight: 700;
}

.steps p {
  margin-block-end: 0;
}

.modes {
  display: grid;
  gap: 0.75rem;
}

.mode {
  padding: 1rem 1.125rem;
  border-radius: 0.75rem;
  background: var(--surface);
}

.mode dt {
  color: var(--text-strong);
  font-weight: 700;
}

.mode dd {
  margin-block: 0.25rem 0;
  margin-inline: 0;
}

.tag {
  display: inline-block;
  margin-inline-start: 0.375rem;
  padding-inline: 0.5rem;
  border: 1px solid var(--heading);
  border-radius: 1rem;
  color: var(--heading);
  font-size: 0.875rem;
  font-weight: 700;
}

.parts {
  display: grid;
  gap: 0.375rem;
  margin-block-end: 1.5rem;
  padding-inline-start: 1.25rem;
}

/* The book's teaching boxes (STYLE §4 and §8): fill, accent line, label colour */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-block-end: 1.5rem;
  padding: 0;
  list-style: none;
}

.chip {
  padding: 0.375rem 0.75rem;
  border-inline-start: 4px solid var(--line);
  border-radius: 0.375rem;
  background: var(--fill);
  color: var(--label);
  font-size: 0.8125rem;
}

.box {
  margin-block: 2rem;
  padding: 1rem 1.25rem;
  border-inline-start: 4px solid var(--line);
  border-radius: 0.75rem;
  background: var(--fill);
}

/* The closing box of the landing page follows a section, which already ends with space. */
.section + .box {
  margin-block: 0 2.5rem;
}

.box p:last-child,
.box ul:last-child {
  margin-block-end: 0;
}

.box-label {
  margin-block: 0 0.5rem;
  color: var(--label);
  font-size: 0.8125rem;
  line-height: 1.4;
}

.key {
  --fill: var(--key-fill);
  --line: var(--key-line);
  --label: var(--key-label);
}

.trap {
  --fill: var(--trap-fill);
  --line: var(--trap-line);
  --label: var(--trap-label);
}

.nums {
  --fill: var(--nums-fill);
  --line: var(--nums-line);
  --label: var(--nums-label);
}

.emerg {
  --fill: var(--emerg-fill);
  --line: var(--emerg-line);
  --label: var(--emerg-label);
}

.note {
  --fill: var(--note-fill);
  --line: var(--note-line);
  --label: var(--note-label);
}

.gulf {
  --fill: var(--gulf-fill);
  --line: var(--gulf-line);
  --label: var(--gulf-label);
}

.plans {
  display: grid;
  gap: 1rem;
  margin-block-end: 1.25rem;
}

.plan {
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
}

.plan ul {
  padding-inline-start: 1.25rem;
}

.plan p:last-child {
  margin-block-end: 0;
}

.price {
  margin-block-end: 0.75rem;
  color: var(--primary);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.25;
}

@media (min-width: 36em) {
  .modes,
  .plans {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Policy and help pages */
.doc {
  padding-block: 1.5rem 2.5rem;
}

.doc h1 {
  margin-block-start: 1.5rem;
  font-size: clamp(2rem, 1.7rem + 1.6vw, 2.75rem);
}

.doc h2 {
  margin-block-start: 2.25rem;
  font-size: 1.375rem;
}

.doc h3 {
  margin-block-start: 1.25rem;
}

.doc .box-label {
  margin-block: 0 0.5rem;
  font-size: 0.8125rem;
}

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

.draft-banner {
  padding: 0.875rem 1rem;
  border: 2px solid var(--draft-line);
  border-radius: 0.5rem;
  background: var(--draft-surface);
  color: var(--draft);
}

.draft-banner p {
  margin-block: 0;
}

.draft-banner strong {
  font-size: 1.1875rem;
}

.toc {
  margin-block: 1.5rem 0;
  padding: 1rem 1.25rem;
  border-radius: 0.75rem;
  background: var(--surface);
}

.toc p {
  margin-block-end: 0.25rem;
  color: var(--text-strong);
  font-weight: 700;
}

.toc ol {
  margin-block-end: 0;
  padding-inline-start: 1.5rem;
}

.toc a {
  display: inline-block;
  padding-block: 0.3rem;
}

.facts dt {
  margin-block-start: 1rem;
  color: var(--text-strong);
  font-weight: 700;
}

.facts dd {
  margin-block: 0.125rem 0;
  margin-inline: 0;
}

.todo {
  margin-block: 2.5rem 0;
  padding: 1rem 1.25rem;
  border: 2px dashed var(--border-strong);
  border-radius: 0.75rem;
}

.doc .todo h2 {
  margin-block-start: 0;
  color: var(--text-strong);
  font-size: 1.1875rem;
}

.todo ul {
  margin-block-end: 0;
  padding-inline-start: 1.25rem;
}

.site-footer {
  padding-block: 1.75rem 2.5rem;
  border-block-start: 1px solid var(--border);
  font-size: 1rem;
}

.site-footer ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.25rem;
  margin-block-end: 0.5rem;
  padding: 0;
  list-style: none;
}

.site-footer li a {
  display: inline-flex;
  align-items: center;
  min-block-size: 2.75rem;
}

.site-footer p {
  margin-block-end: 0.5rem;
}
