/* PKD Digest — visual redesign v3
   Broadsheet Rail: FT paper/ink/rules + liquid-glass sticky section bar.
   Bilingual EN/PT, responsive desktop/mobile, keep a11y + pathPrefix. */

:root {
  /* Surfaces — FT paper */
  --background: #fdf2e3;
  --foreground: #1a1a1a;
  --card: #fffef8;
  --card-foreground: #1a1a1a;
  --muted: #f4e9d2;
  --muted-foreground: #5c5546;
  --accent: #f4e9d2;
  --accent-foreground: #1a1a1a;
  --border: #d9cbae;
  --ring: #9e2b25;

  /* Dual framing — warm paper pair, oxblood clinical marker */
  --plain-bg: #faf8f3;
  --plain-border: #ddd4c4;
  --clinical-bg: #f6ead0;
  --clinical-border: #c9b183;
  --clinical-label: #9e2b25;

  /* Shape / elevation */
  --radius: 0.75rem;
  --radius-sm: calc(var(--radius) * 0.55);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) * 1.35);
  --shadow-card: 0 1px 2px rgb(18 24 32 / 6%), 0 8px 24px rgb(18 24 32 / 7%);
  --shadow-header: 0 1px 0 var(--border), 0 8px 20px rgb(18 24 32 / 5%);

  /* Spacing (4px grid) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --card-spacing: 1.25rem;

  /* Type */
  --font-display: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, 'Times New Roman', serif;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;

  /* Accent — FT oxblood */
  --primary: #9e2b25;
  --primary-foreground: #fffdf7;

  /* Legacy aliases */
  --bg: var(--background);
  --bg-muted: var(--muted);
  --surface: var(--card);
  --ink: var(--foreground);
  --ink-soft: var(--muted-foreground);
  --accent-soft: var(--clinical-bg);
  --draft: #8a5a00;
  --placeholder: #5b4a8a;
  --shadow: var(--shadow-card);
  --max: 46rem;

  color-scheme: light;
}

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

html {
  /* Keep authorial type scale on small screens: no mobile font boosting. */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Never let a wide descendant shift the page sideways on narrow
   viewports (Fold cover screens et al). `clip` preserves sticky. */
html,
body {
  overflow-x: hidden;
}

@supports (overflow: clip) {
  html,
  body {
    overflow-x: clip;
  }
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--foreground);
  background: var(--background);
  line-height: 1.6;
  min-height: 100vh;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
  transition:
    color 150ms ease,
    background-color 150ms ease,
    border-color 150ms ease;
}

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

a:focus-visible,
button:focus-visible,
.button:focus-visible,
.locale-option:focus-visible,
.nav a:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -3rem;
  background: var(--foreground);
  color: #fff;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  z-index: 10;
}

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

.skip-link:focus {
  top: var(--space-4);
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

/* CSS motion is anchor scrolling and the button lift (colour fades are not
   motion); kidney3d.js reads the same preference for its spin. */
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

@media (prefers-reduced-motion: reduce) {
  .button:hover,
  .button:active {
    transform: none;
  }
}

/* Glass surfaces turn solid for readers who ask for less transparency. */
@media (prefers-reduced-transparency: reduce) {
  .topbar,
  .digest-rail {
    background: var(--background);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

/* ——— Token utilities ——— */

.surface {
  background: var(--card);
  color: var(--card-foreground);
}

.surface--muted {
  background: var(--muted);
}

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

.card {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--card-spacing);
}

.separator {
  display: block;
  height: 1px;
  width: 100%;
  border: 0;
  margin: 0;
  background: var(--border);
}

.separator--vertical {
  width: 1px;
  height: auto;
  align-self: stretch;
  background: var(--border);
}

/* ——— Masthead / section topbar / language ——— */

.site-footer,
.main {
  width: min(100% - 2rem, 64rem);
  margin-inline: auto;
}

.site-header {
  margin: 0;
}

.masthead {
  background: #1a1a1a;
  color: #fdf2e3;
  text-align: center;
  padding: 1.6rem 1rem 1.2rem;
  padding-top: max(1.6rem, env(safe-area-inset-top, 0px));
}

.wordmark {
  display: inline-flex;
  flex-direction: column;
  gap: 0.35rem;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}

.wordmark:hover {
  text-decoration: none;
  color: #fdf2e3;
}

.wordmark__name {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0.14em;
  font-size: clamp(1.4rem, 4vw, 2rem);
  color: #fdf2e3;
}

.wordmark__tagline {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  opacity: 0.75;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--background) 88%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(1.5);
  backdrop-filter: blur(16px) saturate(1.5);
  border-bottom: 1px solid var(--foreground);
}

.topbar__inner {
  width: min(100% - 2rem, 64rem);
  margin-inline: auto;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 0.45rem 0;
}

.nav {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.nav__list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  list-style: none;
  margin: 0;
  padding: 0;
  align-items: center;
}

.nav a {
  position: relative;
  color: var(--foreground);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.8125rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 0.35rem 0.6rem;
  white-space: nowrap;
}

.nav a:hover {
  color: var(--primary);
  text-decoration: none;
}

.nav a[aria-current='page'] {
  color: var(--primary);
}

.nav a[aria-current='page']::after {
  content: '';
  position: absolute;
  left: 0.6rem;
  right: 0.6rem;
  bottom: 0.1rem;
  height: 2px;
  background: var(--primary);
}

.locale-switcher {
  display: inline-flex;
  flex-shrink: 0;
  gap: 2px;
  padding: 2px;
  margin-left: auto;
  border: 1px solid var(--foreground);
  border-radius: 999px;
  background: transparent;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--foreground);
}

.locale-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.75rem;
  text-align: center;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  color: var(--foreground);
  text-decoration: none;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.08em;
}

.locale-option:hover {
  background: var(--muted);
  color: var(--foreground);
  text-decoration: none;
}

.locale-option.is-current {
  background: var(--foreground);
  color: var(--background);
}

/* ——— Browser surfaces: selection carries the palette ——— */
::selection {
  background: var(--ring);
  color: var(--background);
}

/* ——— Main / hero ——— */

.main {
  padding: var(--space-8) 0 3.5rem;
}

.hero,
.page-header,
.section {
  margin-bottom: var(--space-6);
}

.hero,
.page-header {
  max-width: var(--max);
}

.hero {
  padding-block: var(--space-2) var(--space-1);
}

.eyebrow,
.audiences,
.item-card__label {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.eyebrow {
  margin: 0 0 var(--space-3);
  color: var(--primary);
  font-weight: 700;
}

.audiences {
  margin: var(--space-3) 0 0;
  color: var(--muted-foreground);
  font-weight: 600;
}

h1,
h2,
h3,
h4 {
  line-height: 1.2;
  letter-spacing: -0.025em;
  text-wrap: balance;
  color: var(--foreground);
}

h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4.2vw, 2.85rem);
  margin: 0 0 var(--space-4);
  font-weight: 700;
  letter-spacing: -0.03em;
}

h2 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  margin: 0 0 var(--space-3);
  font-weight: 700;
}

.lede {
  font-size: 1.08rem;
  color: var(--muted-foreground);
  max-width: 40rem;
  margin: 0;
  text-wrap: pretty;
  line-height: 1.55;
}

.page-header h1 {
  margin-bottom: var(--space-6);
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-6);
}

.hero__link {
  align-self: center;
  font-weight: 600;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1.05rem;
  border-radius: 999px;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid transparent;
  transition:
    background-color 150ms ease,
    border-color 150ms ease,
    color 150ms ease,
    transform 180ms ease,
    box-shadow 180ms ease;
}

.button:hover {
  transform: translateY(-1px);
  box-shadow:
    0 1px 2px rgb(18 24 32 / 8%),
    0 6px 16px rgb(18 24 32 / 10%);
}

.button:active {
  transform: translateY(0) scale(0.98);
  box-shadow: none;
}

.button:hover {
  text-decoration: none;
}

.button--primary {
  background: var(--primary);
  color: var(--primary-foreground);
}

.button--primary:hover {
  background: color-mix(in srgb, var(--primary) 88%, #000);
}

.button--secondary {
  background: var(--card);
  color: var(--foreground);
  border-color: var(--border);
}

.button--secondary:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}

.section {
  padding: var(--space-6) var(--card-spacing);
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.section--muted {
  background: var(--muted);
}

.section > p {
  max-width: 68ch;
  text-wrap: pretty;
}

/* Home latest issue: balance the short river against the tall rail. */
.section--latest .digest-shell {
  align-items: center;
}

.section--latest .digest-river h3 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  line-height: 1.25;
  margin: var(--space-2) 0;
}

.section--latest .digest-river p {
  max-width: 68ch;
}

/* Inside the issue card the rail is a ruled index, not a second card. */
.section--latest .digest-rail {
  position: static;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

/* Bare variant: groups framed cards/lists without adding another frame. */
.section--bare {
  padding: var(--space-6) 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.feature-list {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--muted-foreground);
  max-width: 72ch;
}

.feature-list li + li {
  margin-top: var(--space-2);
}

/* ——— Cards / dual framing ——— */

.card-stack,
.timeline-list {
  display: grid;
  gap: var(--space-6);
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Timeline anchors sit below the sticky section bar on jump. */
.timeline-list > li[id] {
  scroll-margin-top: 5rem;
}

.item-card {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--card-spacing);
  box-shadow: var(--shadow-card);
  border-top: 3px solid color-mix(in srgb, var(--primary) 55%, var(--border));
}

.item-card--placeholder {
  border-style: dashed;
  background: color-mix(in srgb, var(--card) 92%, var(--muted));
}

.item-card__header {
  margin-bottom: var(--space-1);
}

.item-card__title {
  margin: 0 0 var(--space-2);
  font-family: var(--font-display);
  font-size: 1.22rem;
  line-height: 1.28;
  font-weight: 700;
  overflow-wrap: anywhere;
  word-break: break-word;
  hyphens: auto;
  text-wrap: pretty;
  color: var(--foreground);
}

.item-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  color: var(--muted-foreground);
  margin: 0 0 var(--space-4);
  font-size: 0.875rem;
}

.item-card__meta time {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.digest-link {
  color: inherit;
  text-decoration: none;
}

.digest-link:hover {
  color: var(--primary);
  text-decoration: underline;
}

.card-back {
  margin: 0 0 var(--space-4);
  font-size: 0.875rem;
}

.card-back a {
  text-decoration: none;
}

.item-card--standalone {
  margin-bottom: var(--space-6);
}

.item-card--standalone .item-card__title {
  font-size: clamp(1.5rem, 1.1rem + 2vw, 2.1rem);
  line-height: 1.15;
}

/* Dual framing: plain → clinical stack on narrow viewports */
.item-card__body {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
  max-width: 72ch;
}

@media (min-width: 720px) {
  .item-card__body {
    grid-template-columns: 1fr 1fr;
    max-width: none;
  }
}

.item-card__block {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid var(--plain-border);
  background: var(--plain-bg);
  border-left-width: 4px;
}

.item-card__block--plain {
  background: var(--plain-bg);
  border-color: var(--plain-border);
  border-left-color: var(--plain-border);
}

.item-card__block--clinical {
  background: var(--plain-bg);
  border-color: var(--plain-border);
  border-left-color: var(--plain-border);
}

.item-card__label {
  display: block;
  margin-bottom: var(--space-2);
  color: var(--muted-foreground);
  font-weight: 600;
}

.item-card__block p,
.item-card__footer p {
  margin: 0;
}

.item-card__block p {
  max-width: 65ch;
}

.item-card__footer {
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
  color: var(--muted-foreground);
  font-size: 0.9rem;
}

/* ——— Badges ——— */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted-foreground);
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  line-height: 1.4;
  font-weight: 600;
}

.badge--secondary {
  background: var(--muted);
  border-color: transparent;
  color: var(--foreground);
}

.badge--outline {
  background: transparent;
  border-color: var(--border);
  color: var(--muted-foreground);
}

.badge--muted {
  background: var(--muted);
  border-color: transparent;
  color: var(--muted-foreground);
}

.badge--placeholder {
  color: var(--placeholder);
  background: color-mix(in srgb, var(--placeholder) 10%, var(--card));
  border-color: color-mix(in srgb, var(--placeholder) 28%, var(--border));
}

.badge--draft {
  color: var(--draft);
  background: color-mix(in srgb, var(--draft) 10%, var(--card));
  border-color: color-mix(in srgb, var(--draft) 28%, var(--border));
}

.empty {
  color: var(--muted-foreground);
}

/* ——— Footer ——— */

.site-footer {
  padding-bottom: var(--space-8);
}

.site-footer__inner {
  padding: var(--space-6) var(--space-1) 0;
  border-top: 1px solid var(--border);
  color: var(--muted-foreground);
  font-size: 0.9rem;
}

.site-footer__tagline {
  color: var(--foreground);
  font-weight: 600;
}

.site-footer p {
  margin: 0 0 var(--space-2);
}

.issue-label {
  margin: var(--space-3) 0 0;
  font-size: 0.95rem;
  color: var(--muted-foreground);
}

/* ——— Digest broadsheet rail ——— */

.digest-dateline {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  flex-wrap: wrap;
  border-top: 3px solid var(--foreground);
  border-bottom: 1px solid var(--foreground);
  padding: 0.4rem 0;
  margin: 0 0 var(--space-6);
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}

.digest-dateline strong {
  color: var(--foreground);
}

.digest-shell {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  gap: 2.25rem;
  align-items: start;
}

.digest-shell > *,
.digest-item > * {
  min-width: 0;
}

.digest-rail {
  position: sticky;
  top: 4.5rem;
  background: color-mix(in srgb, var(--card) 72%, transparent);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  backdrop-filter: blur(20px) saturate(1.6);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
}

.digest-rail h2 {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  margin: 0;
  color: var(--primary);
  font-weight: 700;
}

.digest-rail ol {
  list-style: none;
  margin: 0.8rem 0 0;
  padding: 0.8rem 0 0;
  border-top: 2px solid var(--foreground);
  font-size: 0.9rem;
}

.digest-rail li {
  padding: 0.4rem 0;
  border-bottom: 1px dotted var(--border);
}

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

.digest-rail a {
  /* Full title stays in the DOM for screen readers and search; show 3 lines. */
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  color: var(--foreground);
  text-decoration: none;
}

.digest-rail a:hover {
  text-decoration: underline;
}

.digest-rail b {
  font-family: system-ui, sans-serif;
  color: var(--primary);
}

.digest-lead {
  border-bottom: 3px solid var(--foreground);
  padding-bottom: 1.5rem;
  margin-bottom: 0.5rem;
  scroll-margin-top: 5rem;
}

.digest-kicker {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--primary);
  margin: 0;
}

.digest-kicker time {
  font-variant-numeric: tabular-nums;
}

.digest-lead h2 {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  line-height: 1.1;
  margin: 0.5rem 0;
}

.digest-standfirst {
  font-family: var(--font-display);
  font-size: 1.125rem;
  color: var(--foreground);
  max-width: 68ch;
  margin: 0.5rem 0;
  line-height: 1.55;
}

.digest-meta {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted-foreground);
  margin: 0.75rem 0 0;
}

.digest-meta a {
  color: var(--foreground);
}

.digest-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  margin: 0.5rem 0 0;
}

.digest-item {
  display: grid;
  grid-template-columns: 3rem minmax(0, 1fr);
  gap: 1.1rem;
  padding: 1.4rem 0;
  border-bottom: 1px solid var(--foreground);
  scroll-margin-top: 5rem;
}

.digest-num {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--primary);
  line-height: 1.2;
}

.digest-item h3 {
  font-family: var(--font-display);
  margin: 0.3rem 0 0.4rem;
  font-size: 1.2rem;
  line-height: 1.28;
  overflow-wrap: break-word;
}

.digest-lede {
  font-size: 1.0625rem;
  margin: 0 0 0.5rem;
  line-height: 1.6;
  max-width: 68ch;
}

/* Clinical panel mirrors the plain-language text styling. */
.digest-lead .digest-clinical {
  font-family: var(--font-display);
  font-size: 1.125rem;
  color: var(--foreground);
  max-width: 68ch;
  margin: 0.5rem 0;
  line-height: 1.55;
}

.digest-item .digest-clinical {
  font-size: 1.0625rem;
  margin: 0 0 0.5rem;
  line-height: 1.6;
  max-width: 68ch;
}

.digest-lead .digest-clinical p,
.digest-item .digest-clinical p {
  margin: 0;
}

/* ——— Dual framing toggle ——— */
.dual__switch {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  row-gap: 2px;
  padding: 2px;
  margin-bottom: var(--space-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: color-mix(in srgb, var(--card) 60%, transparent);
}

.dual__btn {
  appearance: none;
  cursor: pointer;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted-foreground);
  font-size: 0.875rem;
  font-weight: 700;
  padding: 0.3rem 0.8rem;
  min-width: 0;
  max-width: 100%;
}

.dual__btn:hover {
  color: var(--foreground);
}

.dual__btn.is-active {
  background: var(--foreground);
  color: var(--background);
}

.item-card__body > .dual__switch {
  grid-column: 1 / -1;
  justify-self: start;
  max-width: 100%;
}

.item-card__body.is-dual > section {
  grid-column: 1 / -1;
}

/* Touch screens: controls get a 40px target (WCAG 2.5.8 asks for 24px);
   the desktop look is unchanged. 40 rather than 44 keeps the sticky bar
   and filter rows from eating a phone viewport. */
@media (pointer: coarse) {
  .nav a {
    display: inline-flex;
    align-items: center;
  }

  .nav a,
  .locale-option,
  .dual__btn,
  .chip,
  .filters__reset,
  .disclosure__summary,
  .kidney3d__table th button {
    min-height: 2.5rem;
  }
}

/* ——— Related cards ——— */
.card-related {
  margin: var(--space-6) 0 0;
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
  max-width: 72ch;
}

.card-related h2 {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-foreground);
  margin: 0 0 var(--space-2);
}

.card-related ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-1);
}

.card-related a {
  font-weight: 700;
}

.digest-foot {
  margin-top: 1.5rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}

@media (max-width: 760px) {
  .digest-shell {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.25rem;
  }

  .digest-rail {
    position: static;
    padding: 1rem;
  }

  .digest-item {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.2rem;
  }

  .digest-num {
    font-size: 1rem;
  }
}

.item-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.tag {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-family: var(--mono);
  letter-spacing: 0.02em;
  background: var(--muted);
  color: var(--muted-foreground);
  border: 1px solid var(--border);
}

/* ——— Card filters ——— */
[hidden] {
  display: none !important;
}

/* Filters and the issue rail: open on desktop, closed on phones (filters.js). */
.disclosure__summary {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: fit-content;
  cursor: pointer;
  list-style: none;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--primary);
}

.disclosure__summary::-webkit-details-marker {
  display: none;
}

.disclosure__summary::after {
  content: '';
  width: 0.45em;
  height: 0.45em;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-0.15em) rotate(45deg);
}

.disclosure[open] > .disclosure__summary::after {
  transform: translateY(0.1em) rotate(-135deg);
}

@media (prefers-reduced-motion: no-preference) {
  .disclosure__summary::after {
    transition: transform 0.2s ease-out;
  }
}

/* Until filters.js closes them, phones paint the disclosures as closed so nothing shifts. */
@media (max-width: 760px) and (scripting: enabled) {
  :root:not(.disclosures-ready) .disclosure[data-collapse-narrow] > :not(summary) {
    display: none;
  }

  :root:not(.disclosures-ready) .disclosure[data-collapse-narrow] > .disclosure__summary::after {
    transform: translateY(-0.15em) rotate(45deg);
  }
}

.disclosure:has(> .filters) {
  margin-bottom: var(--space-6);
}

.disclosure > .filters {
  margin: var(--space-2) 0 0;
}

.filters {
  display: grid;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--card) 60%, transparent);
}

.filters__group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1);
}

.filters__label {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-foreground);
  margin-right: var(--space-1);
}

.chip {
  appearance: none;
  cursor: pointer;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted-foreground);
}

.chip:hover {
  border-color: var(--primary);
  color: var(--foreground);
}

.chip.is-active {
  background: var(--foreground);
  border-color: var(--foreground);
  color: var(--background);
}

.filters__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2) var(--space-4);
}

.filters__reset {
  appearance: none;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font-size: 0.875rem;
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

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

/* ——— Search page ——— */
.search__label {
  display: block;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-foreground);
  margin-bottom: var(--space-1);
}

.search__input {
  width: 100%;
  max-width: 36rem;
  padding: 0.6rem 0.9rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
  color: var(--foreground);
}

.search__input:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.search__status {
  font-size: 0.85rem;
  color: var(--muted-foreground);
}

.search__results {
  list-style: none;
  margin: var(--space-3) 0 0;
  padding: 0;
  display: grid;
  gap: var(--space-2);
  max-width: 72ch;
}

.search__results a {
  font-weight: 700;
}

/* ——— Issue archive ——— */
.archive-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-6);
}

.archive-issue h2 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin: 0 0 var(--space-1);
}

.archive-count {
  margin: 0 0 var(--space-2);
  font-size: 0.85rem;
  color: var(--muted-foreground);
}

.archive-issue ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-1);
  max-width: 72ch;
}

.archive-issue li li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.75rem;
}

.archive-issue time {
  font-size: 0.8rem;
  color: var(--muted-foreground);
  font-variant-numeric: tabular-nums;
}

/* ——— Print: take the issue to the appointment ——— */
@media print {
  .topbar,
  .site-footer,
  .filters,
  .digest-rail,
  .dual__switch,
  .card-related,
  .card-back,
  .kidney3d__canvas,
  .kidney3d__controls,
  .kidney3d__status,
  .kidney3d__hint,
  .skip-link {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
  }

  .digest-shell,
  .digest-item {
    display: block;
  }

  [data-dual-panel][hidden] {
    display: block !important;
  }

  .kidney3d__fallback[hidden] {
    display: block !important;
  }

  .digest-lead,
  .digest-item,
  .item-card {
    break-inside: avoid;
  }

  a {
    color: inherit;
  }

  .digest-meta a[href^='http']::after,
  .item-card__footer a[href^='http']::after {
    content: ' (' attr(href) ')';
    font-size: 0.8em;
    overflow-wrap: anywhere;
  }
}

/* ——— Mobile layout (<640 / <480) ———
   Compact header: wordmark + locale on one row; nav as a dense
   horizontal row. Gutters stay 1rem so text never meets the screen edge.
   Desktop (≥640) layout above is unchanged. */

@media (max-width: 639.98px) {
  .site-footer,
  .main {
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
  }

  .masthead {
    padding: 1.1rem 0.9rem 0.9rem;
    padding-top: max(1.1rem, env(safe-area-inset-top, 0px));
  }

  .topbar__inner {
    flex-wrap: wrap;
    gap: var(--space-2);
    row-gap: 0;
    padding: 0.15rem 0;
  }

  .locale-switcher {
    order: 2;
  }

  .wordmark__name {
    font-size: 1.15rem;
  }

  .wordmark__tagline {
    letter-spacing: 0.2em;
  }

  .nav {
    min-width: 0;
    flex-wrap: wrap;
    row-gap: 0.15rem;
  }

  /* Links and pill share a row; on the narrowest screens the links wrap inside the list. */
  .nav__list {
    flex: 1 1 0;
    order: 1;
    flex-wrap: wrap;
    width: auto;
    gap: 0.15rem;
    row-gap: 0.1rem;
  }

  .nav a {
    white-space: nowrap;
    font-size: 0.84rem;
    padding: 0.28rem 0.55rem;
  }

  .locale-option {
    padding: 0.18rem 0.45rem;
  }

  .main {
    padding-top: var(--space-4);
    padding-bottom: max(2.5rem, env(safe-area-inset-bottom, 0px) + 1.5rem);
  }

  .item-card {
    padding: var(--card-spacing);
  }

  .card-stack,
  .timeline-list {
    gap: var(--space-4);
  }

  .item-card__title {
    font-size: 1.02rem;
    line-height: 1.35;
  }

  .item-card__body {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }

  .item-card__block {
    padding: var(--space-3);
  }

  .site-footer {
    padding-bottom: max(var(--space-6), env(safe-area-inset-bottom, 0px) + var(--space-4));
  }

  .site-footer__inner {
    padding: var(--space-4) var(--space-1) 0;
  }
}

@media (max-width: 479.98px) {
  .wordmark__name {
    font-size: 1.05rem;
  }

  .nav a {
    font-size: 0.8rem;
    padding: 0.25rem 0.45rem;
  }

  /* Narrow fold (~344px): stack filter labels above their chips so the
     rows read cleanly, and keep chips/switches compact and on-screen. */
  .filters {
    padding: var(--space-2);
  }

  .filters__label {
    flex: 1 1 100%;
  }

  .chip {
    font-size: 0.8125rem;
    padding: 0.28rem 0.6rem;
  }

  .dual__switch {
    max-width: 100%;
  }

  .dual__btn {
    font-size: 0.8125rem;
    padding: 0.3rem 0.6rem;
  }

  .item-card__title {
    font-size: 0.98rem;
    line-height: 1.4;
  }

  h1 {
    font-size: clamp(1.55rem, 7vw, 1.85rem);
  }

  .hero__actions {
    gap: var(--space-2);
  }

  .button {
    padding: 0.55rem 0.9rem;
  }
}

.legal-page h2 {
  margin-top: 1.75rem;
  font-size: 1.1rem;
}
.legal-page p {
  max-width: 42rem;
}
.site-footer__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  align-items: center;
  margin: 0.75rem 0;
}
.site-footer__links a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Patient dictionary — begin (definitions always visible; no motion or hover dependency) */
.patient-glossary {
  max-width: 44rem;
  margin: var(--space-6) 0 0;
}

.patient-glossary__entry {
  border-top: 1px solid var(--border);
  padding: var(--space-4) 0;
  overflow-wrap: anywhere;
}

.patient-glossary dt {
  font-weight: 700;
}

.patient-glossary dfn {
  font-style: normal;
}

.patient-glossary dd {
  margin: var(--space-2) 0 0;
}
/* Patient dictionary — end */

/* Kidney 3D island (home) — begin */
.kidney3d {
  display: grid;
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.kidney3d__stage {
  position: relative;
  background: var(--plain-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  aspect-ratio: 4 / 3;
  max-height: 26rem;
  overflow: hidden;
}

.kidney3d__canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: pan-y;
}

.kidney3d__hint {
  position: absolute;
  left: var(--space-3);
  bottom: var(--space-3);
  margin: 0;
  padding: var(--space-1) var(--space-2);
  max-width: calc(100% - 2 * var(--space-3));
  font-family: var(--mono);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-foreground);
  background: rgb(250 248 243 / 88%);
  border-radius: var(--radius-sm);
  pointer-events: none;
}

.kidney3d__hint[hidden] {
  display: none;
}

@media (max-width: 639.98px) {
  .kidney3d__hint-more {
    display: none;
  }
}

.kidney3d__fallback {
  padding: var(--space-4);
  text-align: center;
  color: var(--muted-foreground);
}

.kidney3d__svg {
  width: min(100%, 22rem);
  height: auto;
}

.kidney3d__controls {
  display: grid;
  grid-template-columns: auto minmax(13rem, 18rem);
  gap: var(--space-4) var(--space-8);
  align-items: start;
  justify-content: start;
}

.kidney3d__group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  align-items: start;
  margin: 0;
}

.kidney3d__group .dual__switch {
  margin-bottom: 0;
}

.kidney3d__group-label {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--primary);
}

label.kidney3d__group-label {
  cursor: pointer;
}

.kidney3d__sublabel {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted-foreground);
  cursor: pointer;
  margin-top: var(--space-2);
}

.kidney3d__slider-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 2.25rem;
}

.kidney3d__group input[type='range'] {
  flex: 1;
  min-width: 8rem;
  accent-color: var(--primary);
}

.kidney3d__slider-row output {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  min-width: 1.5rem;
  text-align: center;
}

.kidney3d__group.is-disabled .kidney3d__sublabel,
.kidney3d__group.is-disabled .kidney3d__slider-row {
  opacity: 0.45;
}

.kidney3d__group.is-disabled input[type='range'] {
  cursor: not-allowed;
}

@media (max-width: 639.98px) {
  .kidney3d__controls {
    grid-template-columns: 1fr;
  }
}

/* Wide screens: controls sit beside the model instead of leaving the right half empty. */
@media (min-width: 960px) {
  .kidney3d {
    grid-template-columns: minmax(0, 36rem) minmax(15rem, 1fr);
    column-gap: var(--space-8);
  }

  .kidney3d__stage {
    grid-row: span 2;
  }

  .kidney3d__controls {
    grid-template-columns: 1fr;
    align-content: start;
    padding-top: var(--space-2);
  }

  .kidney3d__status {
    align-self: end;
  }

  .kidney3d__alt {
    grid-column: 1 / -1;
  }
}

.kidney3d__status {
  margin: 0;
  min-height: 1.5em;
  color: var(--muted-foreground);
}

.kidney3d__alt {
  border-top: 1px solid var(--border);
  padding-top: var(--space-3);
}

.kidney3d__alt h3 {
  font-size: 1rem;
  margin: 0 0 var(--space-2);
}

.kidney3d__table {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--space-2);
}

.kidney3d__table th,
.kidney3d__table td {
  text-align: left;
  vertical-align: top;
  padding: var(--space-2) var(--space-3) var(--space-2) 0;
  border-top: 1px solid var(--border);
}

.kidney3d__part {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}

.kidney3d__swatch {
  flex: none;
  display: inline-block;
  width: 0.8rem;
  height: 0.8rem;
  transform: translateY(0.1rem);
  border-radius: 50%;
  border: 1px solid rgb(26 26 26 / 18%);
  background: var(--swatch, var(--muted));
}

.kidney3d__swatch--cortex {
  --swatch: #b85a45;
}

.kidney3d__swatch--medulla {
  --swatch: #8f2e25;
}

.kidney3d__swatch--calyx,
.kidney3d__swatch--pelvis {
  --swatch: #f6ecd9;

  border-color: #cfae86;
}

.kidney3d__swatch--ureter {
  --swatch: #e0b58a;
}

.kidney3d__swatch--vessels {
  --swatch: linear-gradient(90deg, #b3262a 50%, #3e5c9e 50%);
}

.kidney3d__swatch--cyst {
  --swatch: radial-gradient(circle at 38% 35%, #fffaf0 0 18%, #f6e8b8 45%);

  border: 2px solid #c9a75a;
}

.kidney3d__swatch--fat {
  --swatch: #e6bb55;
}

.kidney3d__table th button {
  text-align: left;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-weight: 700;
  color: var(--clinical-label);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.kidney3d__table th button:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}
/* Kidney 3D island (home) — end */
