/* afib.ucsd.edu — shared styles.
   Palette comes from the simulators' own colour map: resting tissue is deep
   indigo, an activation front is amber. Text is set in STIX Two, the typeface
   physics journals publish in, falling back to other system serifs.
   No web fonts, no third-party requests. */

:root {
  color-scheme: light dark;

  --bg: #ffffff;
  --surface: #f1f3fb;
  --text: #14163f;
  --text-muted: #4a4d75;
  --accent: #2a2fb5;
  --accent-contrast: #ffffff;
  --border: #767aa8;
  --rule: #d5d8ec;
  --focus: #b84d00;

  /* The indigo band keeps its colours in both themes. */
  --band-bg: #10134f;
  --band-text: #f2f3ff;
  --band-muted: #c9cdf0;
  --band-accent: #f7b55e;
  --band-focus: #ffd08a;

  --font-serif: "STIX Two Text", Charter, "Bitstream Charter", "Iowan Old Style",
    "Sitka Text", Cambria, Georgia, serif;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;

  --measure: 40rem;
  --page: 70rem;
  --gutter: clamp(1rem, 4vw, 2.5rem);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0e33;
    --surface: #151848;
    --text: #eceeff;
    --text-muted: #b4b8e0;
    --accent: #f7b55e;
    --accent-contrast: #10134f;
    --border: #8187c0;
    --rule: #2b2f66;
    --focus: #ffd08a;
  }
}

/* Colour pairs used below. tests/check_site.py verifies each one in both
   themes against WCAG 2.1 AA (4.5:1 for text, 3:1 for the pairs marked ui). */
/* contrast: --text on --bg */
/* contrast: --text on --surface */
/* contrast: --text-muted on --bg */
/* contrast: --text-muted on --surface */
/* contrast: --accent on --bg */
/* contrast: --accent on --surface */
/* contrast: --accent-contrast on --accent */
/* contrast(ui): --border on --bg */
/* contrast(ui): --border on --surface */
/* contrast(ui): --focus on --bg */
/* contrast(ui): --focus on --surface */
/* contrast: --band-text on --band-bg */
/* contrast: --band-muted on --band-bg */
/* contrast: --band-accent on --band-bg */
/* contrast: --band-bg on --band-accent */
/* contrast(ui): --band-focus on --band-bg */

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 1.125rem;
  line-height: 1.6;
}

img,
canvas,
svg {
  max-width: 100%;
  height: auto;
}

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

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

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

h1,
h2,
h3 {
  font-weight: 600;
  line-height: 1.15;
  margin: 0;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2.1rem, 1.3rem + 3.6vw, 3.6rem);
  letter-spacing: -0.012em;
}

h2 {
  font-size: clamp(1.55rem, 1.3rem + 1vw, 2rem);
  letter-spacing: -0.006em;
}

h3 {
  font-size: 1.3rem;
  line-height: 1.25;
}

p,
ul,
ol,
dl,
figure,
blockquote,
pre {
  margin: 0;
}

/* `hidden` must win over any display rule below (grid, flex, block). */
[hidden] {
  display: none !important;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------------------------------------ skeleton */

.skip-link {
  position: absolute;
  left: 0.75rem;
  top: -4rem;
  z-index: 10;
  padding: 0.6rem 1rem;
  background: var(--band-bg);
  color: var(--band-text);
  font-family: var(--font-ui);
  font-size: 1rem;
  font-weight: 600;
}

.skip-link:focus {
  top: 0.75rem;
  outline-color: var(--band-focus);
}

.wrap {
  width: 100%;
  max-width: var(--page);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.site-header {
  border-bottom: 1px solid var(--rule);
  font-family: var(--font-ui);
}

.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem 2rem;
  padding-block: 0.6rem;
}

.site-name {
  display: inline-block;
  padding-block: 0.6rem;
  color: var(--text);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  text-decoration: none;
}

.site-name:hover {
  text-decoration: underline;
}

.site-header ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.6rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-header nav a {
  display: inline-block;
  padding-block: 0.6rem;
  color: var(--text);
  font-size: 1rem;
  text-decoration: none;
  border-bottom: 3px solid transparent;
}

.site-header nav a:hover {
  border-bottom-color: var(--border);
}

.site-header nav a[aria-current="page"] {
  font-weight: 700;
  border-bottom-color: var(--accent);
}

main {
  display: block;
}

.section {
  padding-block: clamp(2.5rem, 6vw, 4.5rem);
}

.section + .section {
  border-top: 1px solid var(--rule);
}

.section > .wrap > h2 {
  margin-bottom: 1.5rem;
}

.prose {
  max-width: var(--measure);
}

.prose > * + * {
  margin-top: 1.1em;
}

.prose > h2 {
  margin-top: 2.4em;
}

.prose > h3 {
  margin-top: 1.9em;
}

.prose ul,
.prose ol {
  padding-left: 1.3em;
}

.prose li + li {
  margin-top: 0.45em;
}

.lede {
  font-size: 1.25rem;
  line-height: 1.5;
}

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

/* -------------------------------------------------------- indigo band */

.band {
  background: var(--band-bg);
  color: var(--band-text);
}

.band a {
  color: var(--band-accent);
}

.band :focus-visible {
  outline-color: var(--band-focus);
}

.hero {
  display: grid;
  gap: clamp(2rem, 5vw, 4rem);
  align-items: center;
  padding-block: clamp(2.5rem, 7vw, 5.5rem);
}

@media (min-width: 56rem) {
  .hero {
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  }
}

.hero p {
  max-width: 34rem;
  margin-top: 1.4rem;
  color: var(--band-muted);
  font-size: 1.2rem;
  line-height: 1.55;
}

.hero figure img {
  display: block;
  width: 100%;
  border: 1px solid var(--band-muted);
}

.hero figcaption {
  margin-top: 0.7rem;
  color: var(--band-muted);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  line-height: 1.45;
}

.page-head {
  padding-block: clamp(2.5rem, 6vw, 4rem) clamp(1.5rem, 4vw, 2.5rem);
}

.page-head p {
  max-width: var(--measure);
  margin-top: 1.2rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin-top: 2rem;
}

.btn {
  display: inline-block;
  padding: 0.7rem 1.25rem;
  border: 2px solid var(--accent);
  border-radius: 3px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-family: var(--font-ui);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover {
  text-decoration: underline;
}

.btn--quiet {
  background: transparent;
  color: var(--accent);
}

.band .btn {
  border-color: var(--band-accent);
  background: var(--band-accent);
  color: var(--band-bg);
}

.band .btn--quiet {
  background: transparent;
  color: var(--band-accent);
}

.split {
  display: grid;
  gap: 2rem 3.5rem;
  align-items: center;
}

@media (min-width: 52rem) {
  .split {
    grid-template-columns: minmax(0, var(--measure)) minmax(0, 17rem);
  }
}

.figure img {
  display: block;
  width: 100%;
  border: 1px solid var(--border);
}

.figure figcaption {
  margin-top: 0.6rem;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  line-height: 1.45;
}

/* ------------------------------------------------------------- papers */

.papers {
  display: grid;
  gap: 2.5rem;
  padding: 0;
  list-style: none;
}

.paper {
  display: grid;
  gap: 0.3rem 2rem;
}

@media (min-width: 44rem) {
  .paper {
    grid-template-columns: 5rem minmax(0, var(--measure));
  }
}

.paper__year {
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 1.05rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding-top: 0.2rem;
}

.paper h3 a {
  color: inherit;
}

.paper__meta {
  margin-top: 0.45rem;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.95rem;
}

.paper p + p {
  margin-top: 0.6rem;
}

.paper-full {
  padding-block: clamp(2.5rem, 6vw, 4rem);
  border-top: 1px solid var(--rule);
}

.cite {
  padding: 1rem 1.2rem;
  border-left: 4px solid var(--accent);
  background: var(--surface);
  font-size: 1.02rem;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.6rem;
  padding: 0 !important;
  list-style: none;
  font-family: var(--font-ui);
  font-size: 1rem;
}

.links li + li {
  margin-top: 0;
}

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

blockquote {
  padding-left: 1.2rem;
  border-left: 4px solid var(--rule);
}

blockquote footer {
  margin-top: 0.5rem;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.95rem;
}

details {
  font-family: var(--font-ui);
  font-size: 1rem;
}

summary {
  display: inline-block;
  padding: 0.35rem 0;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

details pre {
  margin-top: 0.6rem;
  padding: 1rem;
  background: var(--surface);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* --------------------------------------------------------- simulators */

.sims {
  display: grid;
  gap: 3rem;
}

.sim {
  display: grid;
  gap: 1.2rem 2.5rem;
  align-items: start;
}

@media (min-width: 44rem) {
  .sim {
    grid-template-columns: minmax(0, 16rem) minmax(0, var(--measure));
  }
}

.sim img {
  display: block;
  width: 100%;
  max-width: 20rem;
  border: 1px solid var(--border);
}

.sim > div > * + * {
  margin-top: 0.8rem;
}

.note {
  padding: 1rem 1.2rem;
  border: 1px solid var(--border);
  border-left-width: 6px;
  background: var(--surface);
}

.note > * + * {
  margin-top: 0.5rem;
}

.note strong:first-child {
  font-family: var(--font-ui);
}

.refs li {
  padding-left: 0.2em;
}

/* --------------------------------------------- particle illustration */

.demo {
  margin-top: 2rem;
  border: 1px solid var(--border);
  background: var(--surface);
}

.demo__stage {
  display: grid;
  gap: 0;
}

@media (min-width: 52rem) {
  .demo__stage {
    grid-template-columns: minmax(0, 6fr) minmax(0, 5fr);
    align-items: start;
  }
}

.demo canvas {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  background: var(--band-bg);
}

.demo__panel {
  padding: 1.25rem 1.4rem 1.4rem;
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.45;
}

.demo__panel > * + * {
  margin-top: 1rem;
}

.demo__buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.demo button {
  min-width: 6.5rem;
  padding: 0.55rem 1rem;
  border: 2px solid var(--accent);
  border-radius: 3px;
  background: var(--accent);
  color: var(--accent-contrast);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.demo button.is-quiet {
  background: transparent;
  color: var(--accent);
}

.demo label {
  display: block;
  font-weight: 600;
}

.demo select,
.demo input[type="range"] {
  display: block;
  width: 100%;
  max-width: 22rem;
  margin-top: 0.3rem;
  font: inherit;
  accent-color: var(--accent);
}

.demo select {
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--bg);
  color: var(--text);
}

.demo input[type="range"] {
  min-height: 1.75rem;
}

.demo__readout {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 1rem;
  font-variant-numeric: tabular-nums;
}

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

.demo__readout dd {
  margin: 0;
  font-weight: 600;
}

.demo__status {
  min-height: 1.5em;
  color: var(--text);
}

.demo__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.4rem;
  padding: 0.7rem 1.4rem;
  border-top: 1px solid var(--rule);
  list-style: none;
  font-family: var(--font-ui);
  font-size: 0.92rem;
}

.demo__legend span[aria-hidden] {
  display: inline-block;
  width: 1.1em;
  text-align: center;
  font-weight: 700;
}

.demo__caption {
  padding: 0.9rem 1.4rem 1.1rem;
  border-top: 1px solid var(--rule);
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.92rem;
  line-height: 1.5;
}

/* ------------------------------------------------------------- footer */

.site-footer {
  padding-block: 2.5rem;
  border-top: 1px solid var(--rule);
  background: var(--surface);
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.95rem;
  line-height: 1.55;
}

.site-footer .wrap > * + * {
  margin-top: 1rem;
}

.site-footer p {
  max-width: 46rem;
}

.site-footer ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.6rem;
  padding: 0;
  list-style: none;
}

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

/* ----------------------------------------------------- redirect stubs */

.moved {
  max-width: var(--measure);
  margin: 4rem auto;
  padding-inline: var(--gutter);
}

@media print {
  .site-header nav,
  .skip-link,
  .actions,
  .demo {
    display: none;
  }
}
