/*
  style.css - the appearance of every page.

  HTML says WHAT is on the page; this file says how it LOOKS.
  The file is organised from general to specific:

    1. Font
    2. Design tokens (colours, spacing and other values we reuse)
    3. Base styles (applied to plain HTML elements)
    4. Layout helper and buttons
    5. Header and navigation
    6. Homepage: hero
    7. Homepage: feature cards
    8. Feature pages
    9. Disclaimer and footer
   10. Small screens
*/

/* ---------- 1. Font ----------
   Atkinson Hyperlegible Next was designed with the Braille Institute so that
   letters and numbers are hard to confuse, which suits medical values.
   The font files live in static/fonts, so the site makes no requests to
   outside servers and still looks right without an internet connection. */

@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("../fonts/atkinson-hyperlegible-next-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("../fonts/atkinson-hyperlegible-next-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

/* ---------- 2. Design tokens ----------
   These are CSS variables. We define each colour once and reuse it with
   var(--name), so changing a colour here changes it everywhere. */

:root {
  --navy: #14294d;        /* primary colour: headings, main buttons */
  --navy-deep: #0d1c38;   /* darker navy for hover states */
  --teal: #0b7a6f;        /* accent colour: icons, highlights, focus rings */
  --teal-tint: #e2f2ef;   /* very light teal for backgrounds */
  --page: #f4f6f9;        /* light gray page background */
  --surface: #ffffff;     /* white cards and header */
  --line: #d9e0ea;        /* borders */
  --text: #1c2a40;        /* body text */
  --muted: #52607a;       /* secondary text */
  --alert-bg: #fff3d9;    /* emergency notice background */
  --alert-text: #5c3a00;  /* emergency notice text */

  --radius-small: 8px;
  --radius-medium: 12px;
  --radius-large: 18px;

  --shadow-card: 0 1px 2px rgba(20, 41, 77, 0.05), 0 10px 28px rgba(20, 41, 77, 0.07);

  --font: "Atkinson Hyperlegible Next", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

/* ---------- 3. Base styles ---------- */

/* Make sure anything with the "hidden" attribute stays hidden, even when a
   class below gives it display: flex or inline-block. */
[hidden] {
  display: none !important;
}

/* Makes width and height include padding and borders, which is easier to reason about. */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: var(--font);
  font-size: 1.0625rem; /* 17px: slightly larger than default for readability */
  line-height: 1.6;

  /* Stack header, main content and footer in a column that is at least as
     tall as the screen, so the footer sits at the bottom on short pages. */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* The main content takes up any spare height. */
main {
  flex: 1;
}

h1,
h2,
h3 {
  margin: 0;
  color: var(--navy);
  line-height: 1.15;
}

h1 {
  font-size: clamp(2.25rem, 5vw, 3.4rem); /* grows with the screen, within limits */
  letter-spacing: -0.02em;
  line-height: 1.08;
}

h2 {
  font-size: 1.75rem;
  letter-spacing: -0.01em;
}

h3 {
  font-size: 1.25rem;
}

p {
  margin: 0;
}

a {
  color: var(--navy);
}

/* A clearly visible outline for people who navigate with the keyboard. */
:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 3px;
  border-radius: 4px;
}

/* Hidden until a keyboard user presses Tab, then it appears at the top. */
.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 10;
  padding: 0.6rem 1rem;
  background: var(--navy);
  color: #ffffff;
  border-radius: var(--radius-small);
}

.skip-link:focus {
  top: 1rem;
}

/* Smooth scrolling for the "Get started" button, unless the visitor has
   asked their device to reduce motion. */
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

/* ---------- 4. Layout helper and buttons ---------- */

/* Centres content and stops it from becoming too wide on large screens. */
.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.button {
  display: inline-block;
  padding: 0.8rem 1.4rem;
  border: 2px solid var(--navy);
  border-radius: var(--radius-medium);
  font-family: inherit; /* <button> elements don't use the page font unless told to */
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s, color 0.15s;
}

.button-primary {
  background: var(--navy);
  color: #ffffff;
}

.button-primary:hover {
  background: var(--navy-deep);
  border-color: var(--navy-deep);
}

.button-secondary {
  background: var(--surface);
  color: var(--navy);
}

.button-secondary:hover {
  background: var(--navy);
  color: #ffffff;
}

/* ---------- 5. Header and navigation ---------- */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding-top: 0.9rem;
  padding-bottom: 0.9rem;
}

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

.brand-mark {
  width: 2rem;
  height: 2rem;
}

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

.site-nav a {
  padding: 0.5rem 0.8rem;
  border-radius: var(--radius-small);
  color: var(--muted);
  text-decoration: none;
}

.site-nav a:hover {
  background: var(--page);
  color: var(--navy);
}

/* The link for the page you are currently on. */
.site-nav a[aria-current="page"] {
  background: var(--teal-tint);
  color: var(--navy);
}

/* The Menu button is hidden on wide screens (see section 10). */
.nav-toggle {
  display: none;
  padding: 0.5rem 0.9rem;
  border: 2px solid var(--navy);
  border-radius: var(--radius-small);
  background: var(--surface);
  color: var(--navy);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

/* ---------- 6. Homepage: hero ---------- */

.hero {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

/* CSS grid places the text and the example side by side. */
.hero-inner {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  align-items: center;
  gap: 4rem;
  padding-top: 5rem;
  padding-bottom: 5rem;
}

.hero-lead {
  max-width: 34rem;
  margin: 1.5rem 0 2rem;
  color: var(--muted);
  font-size: 1.2rem;
}

/* The example: a report line and its plain-language explanation. */
.sample {
  margin: 0;
}

.sample-report,
.sample-explanation {
  border: 1px solid var(--line);
  border-radius: var(--radius-large);
  padding: 1.25rem;
}

.sample-report {
  background: var(--page);
}

.sample-heading {
  margin-bottom: 0.6rem;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
}

.sample-rows {
  margin: 0;
}

.sample-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 0.8rem;
  border-radius: var(--radius-small);
}

.sample-row dd {
  margin: 0;
  font-variant-numeric: tabular-nums; /* digits line up in columns */
  white-space: nowrap;
}

/* The row being explained. */
.sample-row.is-highlighted {
  background: var(--surface);
  box-shadow: inset 4px 0 0 var(--teal), 0 0 0 1px var(--line);
  color: var(--navy);
  font-weight: 700;
}

/* The explanation sits lower and to the right, joined by a short line. */
.sample-explanation {
  position: relative;
  margin: 1rem 0 0 2.5rem;
  background: var(--teal-tint);
  border-color: #b9ddd7;
}

.sample-explanation::before {
  content: "";
  position: absolute;
  left: 2rem;
  top: -1rem;
  width: 2px;
  height: 1rem;
  background: var(--teal);
}

.sample-explanation .sample-heading {
  color: var(--teal);
}

.sample figcaption {
  margin: 0.75rem 0 0 2.5rem;
  color: var(--muted);
  font-size: 0.95rem;
}

/* ---------- 7. Homepage: feature cards ---------- */

.tools {
  padding: 4.5rem 0 5rem;
}

/* Three equal columns. */
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin-top: 2rem;
}

/* Each card is a column, so the button can sit at the bottom. */
.card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 1.75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-large);
  box-shadow: var(--shadow-card);
}

.card-icon {
  width: 3rem;
  height: 3rem;
  padding: 0.7rem;
  margin-bottom: 1.25rem;
  background: var(--teal-tint);
  border-radius: var(--radius-medium);
  fill: none;
  stroke: var(--teal);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.card p {
  margin: 0.6rem 0 1.5rem;
  color: var(--muted);
}

/* margin-top: auto pushes the button to the bottom of the card. */
.card .button {
  margin-top: auto;
}

/* ---------- 8. Feature pages ---------- */

.page {
  padding: 4rem 0 5rem;
}

.page h1 {
  font-size: clamp(2rem, 4vw, 2.75rem);
}

.page-lead {
  max-width: 38rem;
  margin-top: 1rem;
  color: var(--muted);
  font-size: 1.15rem;
}

/* ---------- 8b. Symptom Assistant chat ---------- */

/* The chat column is narrower than the page so messages stay easy to read. */
.chat-page {
  max-width: 46rem;
}

/* Emergency reminder above the chat. */
.urgent-note {
  margin-top: 1.5rem;
  padding: 0.9rem 1.1rem;
  background: var(--alert-bg);
  border-radius: var(--radius-medium);
  color: var(--alert-text);
}

.chat {
  margin-top: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-large);
  box-shadow: var(--shadow-card);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--line);
}

.chat-header h2 {
  font-size: 1.05rem;
}

/* A button that looks like a link, for less important actions. */
.button-text {
  padding: 0.35rem 0.5rem;
  border: 0;
  border-radius: var(--radius-small);
  background: none;
  color: var(--navy);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

.button-text:hover {
  background: var(--page);
}

.button-text:disabled {
  color: var(--muted);
  text-decoration: none;
  cursor: default;
  opacity: 0.6;
}

/* The scrolling area that holds the messages. */
.chat-log {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  height: min(55vh, 520px);
  min-height: 260px;
  padding: 1.25rem;
  overflow-y: auto;
}

.chat-empty {
  margin: auto;
  max-width: 24rem;
  color: var(--muted);
  text-align: center;
}

/* One message bubble. */
.message {
  max-width: 85%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-large);
}

/* white-space: pre-wrap keeps the line breaks people type. */
.message p {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* The user's messages sit on the right in navy. */
.message-user {
  align-self: flex-end;
  background: var(--navy);
  border-bottom-right-radius: 6px;
  color: #ffffff;
}

/* The assistant's replies sit on the left in light teal. */
.message-assistant {
  align-self: flex-start;
  background: var(--teal-tint);
  border-bottom-left-radius: 6px;
  color: var(--text);
}

/* Fixed emergency guidance: amber with a strong left edge so it stands out. */
.message-urgent {
  max-width: 100%;
  background: var(--alert-bg);
  border-left: 5px solid #b25e00;
  color: var(--alert-text);
  font-weight: 700;
}

/* The three dots shown while waiting. */
.message-loading {
  display: flex;
  gap: 0.35rem;
  padding: 1rem 1.1rem;
}

.dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--teal);
  opacity: 0.4;
}

@media (prefers-reduced-motion: no-preference) {
  .dot {
    animation: dot-pulse 1.2s infinite ease-in-out;
  }

  .dot:nth-child(3) {
    animation-delay: 0.15s;
  }

  .dot:nth-child(4) {
    animation-delay: 0.3s;
  }
}

@keyframes dot-pulse {
  0%, 80%, 100% { opacity: 0.4; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

.chat-error {
  margin: 0 1.25rem 0.75rem;
}

/* The typing area at the bottom. */
.chat-form {
  padding: 1rem 1.25rem 1.25rem;
  border-top: 1px solid var(--line);
}

.chat-form textarea {
  display: block;
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-medium);
  background: var(--page);
  color: var(--text);
  font: inherit;
  line-height: 1.5;
  resize: vertical;
}

.chat-form textarea:focus {
  background: var(--surface);
  border-color: var(--teal);
}

.chat-form-footer {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.75rem;
}

.chat-hint {
  color: var(--muted);
  font-size: 0.9rem;
}

/* margin-left: auto pushes the counter and the Send button to the right. */
.chat-count {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.chat-count.is-near-limit {
  color: #8a1c1c;
  font-weight: 700;
}

.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Hides content visually but keeps it readable by screen readers. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- 8c. Document Explainer ---------- */

/* Same reading width as the chat page. */
.narrow-page {
  max-width: 46rem;
}

/* A neutral note (the urgent note above the chat uses amber instead). */
.info-note {
  margin-top: 1.5rem;
  padding: 0.9rem 1.1rem;
  background: var(--teal-tint);
  border-radius: var(--radius-medium);
}

.info-note a {
  font-weight: 700;
}

/* A white box that groups one step of the page. */
.panel {
  margin-top: 1.5rem;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-large);
  box-shadow: var(--shadow-card);
}

.panel h2 {
  font-size: 1.25rem;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

/* Headings that receive focus from JavaScript don't need a visible ring. */
.panel h2[tabindex="-1"]:focus {
  outline: none;
}

/* The "Upload a PDF" / "Paste text" switch: two buttons joined together. */
.mode-switch {
  display: inline-flex;
  margin-top: 1rem;
  padding: 0.25rem;
  border-radius: var(--radius-medium);
  background: var(--page);
}

.mode-button {
  padding: 0.5rem 1rem;
  border: 0;
  border-radius: var(--radius-small);
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

/* The selected option looks raised, like a tab. */
.mode-button[aria-pressed="true"] {
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(20, 41, 77, 0.15);
  color: var(--navy);
}

.paste-label {
  display: block;
  margin-top: 1rem;
  color: var(--navy);
  font-weight: 700;
}

#paste-input {
  display: block;
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-medium);
  background: var(--page);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  resize: vertical;
}

#paste-input:focus {
  background: var(--surface);
  border-color: var(--teal);
}

#paste-input[readonly] {
  color: var(--muted);
}

.paste-footer {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.paste-footer .dropzone-hint {
  margin-top: 0.5rem;
}

.paste-footer .chat-count {
  margin-top: 0.5rem;
  white-space: nowrap;
}

/* The dashed area files can be dropped onto. */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 1rem;
  padding: 2rem 1.25rem;
  border: 2px dashed #b4c0d1;
  border-radius: var(--radius-large);
  background: var(--page);
  text-align: center;
}

/* Highlight while a file is dragged over it. */
.dropzone.is-dragging {
  border-color: var(--teal);
  background: var(--teal-tint);
}

/* The hidden file input sits inside the drop area, so show a focus ring on
   the "Choose a PDF" button when keyboard users reach the input. */
.dropzone:focus-within label {
  outline: 3px solid var(--teal);
  outline-offset: 3px;
}

.dropzone-icon,
.file-card-icon {
  fill: none;
  stroke: var(--teal);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dropzone-icon {
  width: 2.75rem;
  height: 2.75rem;
  margin-bottom: 0.5rem;
}

.dropzone-title {
  margin-bottom: 0.75rem;
  color: var(--navy);
  font-weight: 700;
}

.dropzone-hint {
  margin-top: 0.9rem;
  color: var(--muted);
  font-size: 0.95rem;
}

/* The chosen file. */
.file-card {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-medium);
}

.file-card-icon {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
}

/* min-width: 0 lets long file names shrink and wrap instead of overflowing. */
.file-card-text {
  flex: 1;
  min-width: 0;
}

.file-name {
  color: var(--navy);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.file-size {
  color: var(--muted);
  font-size: 0.95rem;
}

/* Upload progress bar. */
.progress {
  margin-top: 1rem;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.4rem;
  color: var(--muted);
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

.progress-track {
  height: 0.6rem;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: var(--teal);
}

/* Once uploaded, the bar gently pulses while the server reads the file. */
@media (prefers-reduced-motion: no-preference) {
  .progress.is-processing .progress-bar {
    animation: processing-pulse 1.4s infinite ease-in-out;
  }
}

@keyframes processing-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* Error messages on forms (shared style with the chat). */
.form-error,
.chat-error {
  padding: 0.75rem 1rem;
  background: #fde8e8;
  border-radius: var(--radius-medium);
  color: #8a1c1c;
}

.form-error {
  margin-top: 1rem;
}

.panel > .button {
  margin-top: 1.25rem;
}

/* The explanation text. */
.explanation {
  margin-top: 1rem;
  white-space: pre-wrap;
}

.result-note {
  margin-top: 0.75rem;
  padding: 0.6rem 0.9rem;
  border-left: 3px solid var(--teal);
  background: var(--page);
  color: var(--muted);
  font-size: 0.95rem;
}

/* The collapsible "text read from your document" box. */
.extracted {
  margin-top: 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-medium);
}

.extracted summary {
  padding: 0.7rem 1rem;
  color: var(--navy);
  font-weight: 700;
  cursor: pointer;
}

/* pre keeps the line breaks and spacing exactly as read. */
.extracted-text {
  max-height: 18rem;
  margin: 0;
  padding: 0 1rem 1rem;
  overflow: auto;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.85rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* An answer that is emergency guidance. */
.qa-answer.is-urgent {
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-small);
  background: var(--alert-bg);
  color: var(--alert-text);
  font-weight: 700;
}

.questions-title {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  font-size: 1.1rem;
}

.qa-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}

.qa-list:empty {
  display: none;
}

.qa-item {
  padding-left: 1rem;
  border-left: 3px solid var(--teal);
}

.qa-question {
  color: var(--navy);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.qa-answer {
  margin-top: 0.25rem;
  white-space: pre-wrap;
}

.qa-answer.is-loading {
  color: var(--muted);
}

/* A text box with a button beside it (searches and questions). */
.inline-form {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

.inline-form input {
  flex: 1;
  min-width: 0;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-medium);
  background: var(--page);
  color: var(--text);
  font: inherit;
}

.inline-form input:focus {
  background: var(--surface);
  border-color: var(--teal);
}

/* ---------- 8d. Medication Assistant ---------- */

/* The search form has no gap above it, unlike the question form. */
.panel > .inline-form:first-child {
  margin-top: 0;
}

/* Remove the browser's own "x" and search styling so it matches our inputs. */
.inline-form input[type="search"] {
  -webkit-appearance: none;
  appearance: none;
}

.examples {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-top: 1rem;
}

.examples-label {
  color: var(--muted);
  font-size: 0.95rem;
}

.examples-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Small rounded buttons for the example names. */
.example {
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--page);
  color: var(--navy);
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
}

.example:hover {
  border-color: var(--teal);
  background: var(--teal-tint);
}

.example:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.search-status {
  margin-top: 1rem;
  color: var(--muted);
}

/* The medication's name. */
.result-title {
  font-size: 1.6rem;
  text-transform: capitalize;
}

.result-title:focus {
  outline: none;
}

/* "Based on: ..." line under the medication's name. */
.label-info {
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.95rem;
}

/* "Not covered by this label." */
.med-section li.not-listed {
  color: var(--muted);
  font-style: italic;
  list-style: none;
  margin-left: -1.25rem;
}

.result-summary {
  margin-top: 1rem;
}

/* Each section: uses, side effects, precautions, sources. */
.med-section {
  margin-top: 1.5rem;
}

.med-section h3 {
  font-size: 1.05rem;
}

.med-section ul {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
}

.med-section li + li {
  margin-top: 0.35rem;
}

.source-list a {
  font-weight: 700;
  overflow-wrap: anywhere;
}

/* ---------- 9. Disclaimer and footer ---------- */

.disclaimer {
  background: var(--navy);
  color: #e6ebf3;
}

.disclaimer-inner {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  align-items: center;
  gap: 3rem;
  padding-top: 3rem;
  padding-bottom: 3rem;
}

.disclaimer h2 {
  margin-bottom: 0.75rem;
  color: #ffffff;
  font-size: 1.5rem;
}

.disclaimer p {
  max-width: 36rem;
}

.disclaimer .emergency {
  padding: 1.25rem 1.4rem;
  background: var(--alert-bg);
  border-radius: var(--radius-medium);
  color: var(--alert-text);
}

.site-footer {
  padding: 1.5rem 0;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.95rem;
}

/* ---------- 10. Small screens ----------
   A media query applies its rules only when the condition is true.
   These rules rearrange the page for tablets and phones. */

@media (max-width: 900px) {
  /* Stack the hero and disclaimer into one column. */
  .hero-inner,
  .disclaimer-inner {
    grid-template-columns: 1fr;
    gap: 2.5rem;
  }

  .hero-inner {
    padding-top: 3rem;
    padding-bottom: 3.5rem;
  }

  /* One card per row. */
  .card-grid {
    grid-template-columns: 1fr;
  }

  /* Show the Menu button and hide the links until it is clicked.
     The "js" class is added by main.js, so the links stay visible if
     JavaScript is not running. */
  .js .nav-toggle {
    display: block;
  }

  .js .site-nav {
    display: none;
    flex-basis: 100%;
    flex-direction: column;
  }

  .js .site-nav.is-open {
    display: flex;
  }
}

@media (max-width: 600px) {
  /* Phones have no Shift key shortcut worth explaining. */
  .chat-hint {
    display: none;
  }

  .chat-log {
    padding: 1rem;
  }

  .message {
    max-width: 92%;
  }
}

@media (max-width: 480px) {
  .sample-explanation,
  .sample figcaption {
    margin-left: 1rem;
  }

  .sample-explanation::before {
    left: 1.5rem;
  }
}
