/* ==========================================================================
   Kibigia design system
   --------------------------------------------------------------------------
   Oat UI provides the semantic component foundation (see `static/vendor/oat/`
   and `compat.css`). This file layers a small, theme-aware token set on top
   of it so light/dark mode, spacing, elevation and brand colour stay
   consistent across every app in the project.

   Tokens switch on `data-bs-theme` (set by an inline script in _base.html
   before first paint). Native browser UI follows the <meta name="color-scheme">
   element, mapped to the `color-scheme` property below.
   ========================================================================== */

/* Participates in Oat's `@layer theme, base, components, animations,
   utilities` order. Tokens live in `theme` so any layer can read them;
   everything below lives in `components`, loaded after Oat so we win ties
   instead of needing `!important`. */
@layer theme {

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */
:root {
  /* MANDATORY: keep the root default as "light dark"; the <meta> below maps
     the user's stored override back onto this property. */
  color-scheme: light dark;

  /* Brand palette (shared with the town landing pages) */
  --kb-brand-900: #1b4332;
  --kb-brand-700: #2d6a4f;
  --kb-brand-500: #40916c;
  --kb-brand-300: #52b788;
  --kb-brand-100: #d8f3e3;

  /* Surfaces. Every token below is a single `light-dark()` definition keyed
     off `color-scheme`, which the `:has()` mappings at the bottom of this
     layer pin to the user's stored choice. Adding a token means editing one
     line — do not reintroduce `html[data-bs-theme="dark"]` token blocks. */
  --kb-surface: light-dark(#ffffff, #151a18);
  --kb-surface-2: light-dark(#f4f7f5, #0f1412);
  --kb-surface-3: light-dark(#e9efec, #222a26);
  --kb-border: light-dark(#dbe4e0, #2b3531);
  --kb-border-strong: light-dark(#c3d0ca, #3a4641);
  /* Boundaries that delimit a control (inputs, secondary buttons) need
     >=3:1 against the surface — WCAG 1.4.11 Non-text Contrast. Use
     --kb-border for decorative dividers only. */
  --kb-border-control: light-dark(#7d918a, #5c6b64);
  --kb-text: light-dark(#1c2321, #e7eeea);
  --kb-text-muted: light-dark(#5b6763, #a3b1ab);

  /* Elevation. `light-dark()` is a <color> function, so shadow *geometry*
     cannot live inside it — each layer takes its colour from a pair instead.
     Dark mode keeps the light geometry (2px blur difference) so the token
     stays a single declaration. */
  --kb-shadow-sm:
    0 1px 2px light-dark(rgb(16 24 20 / 0.06), rgb(0 0 0 / 0.4)),
    0 1px 3px light-dark(rgb(16 24 20 / 0.05), transparent);
  --kb-shadow:
    0 1px 2px light-dark(rgb(16 24 20 / 0.06), rgb(0 0 0 / 0.4)),
    0 10px 28px -10px light-dark(rgb(16 24 20 / 0.2), rgb(0 0 0 / 0.6));
  --kb-shadow-lg:
    0 2px 4px light-dark(rgb(16 24 20 / 0.06), rgb(0 0 0 / 0.45)),
    0 28px 56px -20px light-dark(rgb(16 24 20 / 0.3), rgb(0 0 0 / 0.7));
  --kb-ring: light-dark(
    color-mix(in oklab, var(--kb-brand-500) 55%, transparent),
    color-mix(in oklab, var(--kb-brand-300) 65%, transparent)
  );

  /* Geometry + motion */
  --kb-radius-sm: 0.5rem;
  --kb-radius: 0.75rem;
  --kb-radius-lg: 1rem;
  --kb-duration: 180ms;
  --kb-ease: cubic-bezier(0.2, 0.7, 0.2, 1);

  /* Browser UI — the thumb must stay >=3:1 against the track. */
  --kb-scrollbar-thumb: light-dark(#7d918a, #5c6b64);
  --kb-scrollbar-track: transparent;

  /* Layout */
  --header-height: 4rem;

  accent-color: var(--kb-brand-500);
}

/* Reflect the <meta name="color-scheme"> override in CSS. Without this the
   meta would be a no-op, because author CSS wins over the presentational hint. */
:root:has(> head > meta[name="color-scheme"][content="dark"]) {
  color-scheme: dark;
}

:root:has(> head > meta[name="color-scheme"][content="light"]) {
  color-scheme: light;
}

} /* @layer theme */

@layer components {


/* --------------------------------------------------------------------------
   2. Base
   -------------------------------------------------------------------------- */
html {
  height: 100%;
  scroll-padding-top: calc(var(--header-height) + 1rem);
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  background-color: var(--kb-surface-2);
  color: var(--kb-text);
  /* Keep copy-paste, translation and AT gestures intact; do not disable. */
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background-color: var(--kb-brand-300);
  color: #0b1f16;
}

/* Scrollbars: thumb must stay >=3:1 against the track. Legacy WebKit
   fallback only runs where the standard property is unsupported. */
:root {
  scrollbar-color: var(--kb-scrollbar-thumb) var(--kb-scrollbar-track);
}

@supports not (scrollbar-color: auto) {
  html::-webkit-scrollbar {
    width: 12px;
    height: 12px;
  }

  html::-webkit-scrollbar-thumb {
    background: var(--kb-scrollbar-thumb);
    border-radius: 999px;
  }

  html::-webkit-scrollbar-track {
    background: var(--kb-scrollbar-track);
  }
}

/* Skip link */
.skip-link {
  position: absolute;
  left: 1rem;
  top: 0;
  z-index: 2000;
  padding: 0.6rem 1rem;
  border-radius: 0 0 var(--kb-radius-sm) var(--kb-radius-sm);
  background: var(--kb-brand-900);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  translate: 0 -120%;
}

.skip-link:focus-visible {
  translate: 0 0;
  outline: 2px solid var(--kb-brand-300);
  outline-offset: 2px;
}

/* The skip link targets <main>; suppress the ring on the whole page region. */
#main-content:focus {
  outline: none;
}

/* Visually hidden but still in the accessibility tree (live regions,
   icon-button labels). Kept focusable-safe via :not(:focus-within). */
.kb-visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Focus visibility: one consistent ring instead of per-component overrides. */
:where(a, button, summary, [tabindex], input, select, textarea):focus-visible {
  outline: 2px solid var(--kb-ring);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   3. Layout
   -------------------------------------------------------------------------- */
.container {
  flex: 1 0 auto;
  width: 100%;
  max-width: 72rem;
  margin-inline: auto;
  padding: 1.5rem 1.25rem;
}

/* Pages frequently nest a .container inside the base layout's .container.
   Collapse the inner one so content isn't double-padded or narrowed. */
.container .container {
  max-width: none;
  padding-inline: 0;
}

@media (max-width: 576px) {
  .container {
    padding: 1rem;
  }
}

.page-header {
  min-width: 0;
}

.page-kicker {
  margin-bottom: 0.25rem;
  color: light-dark(var(--kb-brand-700), var(--kb-brand-300));
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}


.page-title {
  font-size: clamp(1.75rem, 1.25rem + 2.4vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.page-lead {
  max-width: 60ch;
  color: var(--kb-text-muted);
}

/* Sticky side panels must clear the sticky app bar (pair with .sticky-top). */
.sticky-below-header {
  top: calc(var(--header-height) + 1rem);
}

/* Opt-in pointer cursor for clickable non-controls (inline-edit titles,
   label cards). Native controls already get it. */
.cursor-pointer {
  cursor: pointer;
}

/* --------------------------------------------------------------------------
   4. Typography
   -------------------------------------------------------------------------- */
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
  /* Balanced line breaks for short blocks; the browser caps this at ~6 lines. */
  text-wrap: balance;
}

p, li, blockquote, dd {
  /* Avoid orphaned words in body copy. */
  text-wrap: pretty;
}

/* --------------------------------------------------------------------------
   5. Components
   -------------------------------------------------------------------------- */

/* Cards */
.card {
  box-shadow: var(--kb-shadow-sm);
}

.card-header,
.card-footer {
  border-color: var(--kb-border);
}

.card-header {
  padding: 0.9rem 1.15rem;
  font-weight: 600;
}

.card-title {
  font-weight: 600;
}

@media (prefers-reduced-motion: no-preference) {
  .card,
  .kb-lift {
    transition:
      box-shadow var(--kb-duration) var(--kb-ease),
      border-color var(--kb-duration) var(--kb-ease),
      translate var(--kb-duration) var(--kb-ease);
  }

  .kb-lift:hover {
    translate: 0 -3px;
    box-shadow: var(--kb-shadow);
  }
}

.kb-lift:hover {
  border-color: var(--kb-border-strong);
}

/* Buttons */
.btn {
  border-radius: var(--kb-radius-sm);
}

.btn:not(.btn-link) {
  box-shadow: var(--kb-shadow-sm);
}

@media (prefers-reduced-motion: no-preference) {
  .btn:not(.btn-link) {
    transition:
      background-color var(--kb-duration) var(--kb-ease),
      border-color var(--kb-duration) var(--kb-ease),
      color var(--kb-duration) var(--kb-ease),
      box-shadow var(--kb-duration) var(--kb-ease),
      translate var(--kb-duration) var(--kb-ease);
  }

  .btn:not(.btn-link):hover {
    translate: 0 -1px;
    box-shadow: var(--kb-shadow);
  }
}

/* Badges */
.badge {
  padding: 0.42em 0.72em;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* Status pills: theme-aware foreground + tinted background. */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  padding: 0.4em 0.75em;
  border-radius: 999px;
  background-color: var(--status-bg, var(--kb-surface-3));
  color: var(--status-fg, var(--kb-text));
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.2;
  text-transform: uppercase;
  white-space: nowrap;
}

.status-open {
  --status-bg: light-dark(#d1e7dd, #12351f);
  --status-fg: light-dark(#0f5132, #8fe0b4);
}

.status-progress {
  --status-bg: light-dark(#fff3cd, #3a2f0b);
  --status-fg: light-dark(#664d03, #ffd968);
}

.status-closed {
  --status-bg: light-dark(#e2e3e5, #2b3531);
  --status-fg: light-dark(#41464b, #c3d0ca);
}

.status-duplicate {
  --status-bg: light-dark(#f8d7da, #3d1a1d);
  --status-fg: light-dark(#842029, #f4a6ad);
}

.status-completed {
  --status-bg: light-dark(#cfe2ff, #12283f);
  --status-fg: light-dark(#084298, #9ec5fe);
}

.status-cancelled {
  --status-bg: #e2e3e5;
  --status-fg: #41464b;
}

/* Area-of-interest pills: tinted, theme-aware, and readable in both schemes. */
.area-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.35em 0.7em;
  border-radius: 999px;
  background-color: var(--area-bg, var(--kb-surface-3));
  color: var(--area-fg, var(--kb-text));
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

.area-spirituality {
  --area-bg: light-dark(#ede9fe, #2a1e4a);
  --area-fg: light-dark(#5b21b6, #c4b5fd);
}

.area-environment {
  --area-bg: light-dark(#d1e7dd, #12351f);
  --area-fg: light-dark(#0f5132, #8fe0b4);
}

.area-social_progress {
  --area-bg: light-dark(#cfe2ff, #12283f);
  --area-fg: light-dark(#084298, #9ec5fe);
}

.area-science {
  --area-bg: light-dark(#cff4fc, #0d2f36);
  --area-fg: light-dark(#055160, #86e7f5);
}

.area-peace {
  --area-bg: light-dark(#fff3cd, #3a2f0b);
  --area-fg: light-dark(#664d03, #ffd968);
}

.area-unassigned {
  --area-bg: var(--kb-surface-3);
  --area-fg: var(--kb-text-muted);
}

/* List groups */
.list-group {
  border-radius: var(--kb-radius);
}

.list-group-item {
  padding: 0.9rem 1.1rem;
}

/* Alerts */
.alert {
  border-radius: var(--kb-radius);
  border-color: var(--kb-border);
}

/* Django messages wrapper (alerts carry their own spacing) */
.messages {
  display: grid;
  gap: 0.5rem;
}

/* Avatars: size via custom property, crop via .rounded-circle */
.kb-avatar {
  inline-size: var(--kb-avatar-size, 3rem);
  block-size: var(--kb-avatar-size, 3rem);
  object-fit: cover;
}

.kb-avatar-md {
  --kb-avatar-size: 5rem;
}

.kb-avatar-lg {
  --kb-avatar-size: 7.5rem;
}

/* Debug-only panel (rendered when DEBUG is on). Themed so it stays
   readable in dark mode — a hardcoded light background does not. */
.debug-panel {
  padding: 0.75rem 1rem;
  margin-block-end: 1rem;
  border: 1px dashed var(--kb-border-strong);
  border-radius: var(--kb-radius-sm);
  background-color: var(--kb-surface-3);
  color: var(--kb-text-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
}

/* Platform glyph on video cards */
.video-platform-icon {
  color: var(--kb-text-muted);
}

/* Video card thumbnail: fixed-height brand panel behind the platform glyph */
.video-thumb {
  block-size: 150px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.video-thumb-glyph {
  inline-size: 4rem;
  block-size: 4rem;
  opacity: 0.75;
  color: #ffffff;
}

/* Clamp body copy to n lines without breaking the text for AT (the full
   text stays in the DOM and in copy/paste). */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   6. Page furniture
   -------------------------------------------------------------------------- */
.footer {
  flex-shrink: 0;
  width: 100%;
  margin-top: auto;
  padding-block: 1.25rem;
  border-top: 1px solid var(--kb-border);
  background-color: var(--kb-surface);
  color: var(--kb-text-muted);
}

.footer-text {
  color: inherit;
}

.footer a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Auth provider buttons (allauth social sign-in) */
.auth-provider-logo {
  display: inline-block;
  width: auto;
  height: 2.5rem;
  max-width: 100%;
  vertical-align: middle;
}

/* Home hero */
.kb-hero {
  position: relative;
  overflow: hidden;
  margin: -1.5rem -1.25rem 2rem;
  padding: clamp(2.5rem, 8cqi, 5rem) 1.5rem;
  border-radius: 0 0 1.75rem 1.75rem;
  background:
    radial-gradient(
      ellipse 70% 60% at 15% 90%,
      light-dark(rgb(255 255 255 / 0.1), rgb(255 255 255 / 0.06)),
      transparent 60%
    ),
    linear-gradient(
      135deg,
      light-dark(#1b4332, #0b1511) 0%,
      light-dark(#2d6a4f, #17392b) 45%,
      light-dark(#40916c, #235c43) 100%
    );
  color: #fff;
  text-align: center;
  container-type: inline-size;
}


.kb-hero__logo {
  width: clamp(5rem, 18cqi, 8rem);
  height: clamp(5rem, 18cqi, 8rem);
  margin-bottom: 1.25rem;
  border: 3px solid rgb(255 255 255 / 0.35);
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.3);
}

.kb-hero__eyebrow {
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.8;
}

.kb-hero__title {
  margin-bottom: 0.5rem;
  font-size: clamp(2rem, 9cqi, 3.5rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.kb-hero__lead {
  max-width: 46ch;
  margin-inline: auto;
  margin-bottom: 1.75rem;
  font-size: clamp(1rem, 2.5cqi, 1.2rem);
  line-height: 1.6;
  opacity: 0.92;
}

.kb-hero .btn-light {
  color: #1b4332;
}

@media (prefers-reduced-motion: no-preference) {
  .kb-hero__logo,
  .kb-hero__title,
  .kb-hero__lead {
    animation: kb-fade-up 500ms var(--kb-ease) both;
  }

  .kb-hero__title { animation-delay: 60ms; }
  .kb-hero__lead { animation-delay: 120ms; }
}

@keyframes kb-fade-up {
  from {
    opacity: 0;
    translate: 0 12px;
  }
  to {
    opacity: 1;
    translate: 0 0;
  }
}

/* Empty states */
.kb-empty {
  padding: 2.5rem 1rem;
  color: var(--kb-text-muted);
  text-align: center;
}

.kb-empty i {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 2rem;
  opacity: 0.45;
}

/* Oversized decorative icon for placeholder states */
.kb-placeholder-icon {
  font-size: var(--kb-icon-size, 3rem);
  opacity: 0.5;
}

.kb-placeholder-icon--lg {
  --kb-icon-size: 4rem;
}

.kb-placeholder-icon--sm {
  --kb-icon-size: 2rem;
}

/* Loading */
.kb-loading {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.kb-spinner {
  display: inline-block;
  width: 1em;
  height: 1em;
  border: 2px solid color-mix(in oklab, currentColor 28%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  vertical-align: -0.125em;
}

@media (prefers-reduced-motion: no-preference) {
  .kb-spinner {
    animation: kb-spin 700ms linear infinite;
  }
}

@keyframes kb-spin {
  to {
    rotate: 360deg;
  }
}

/* Status cards (town health) */
.status-card {
  border: 1px solid var(--kb-border);
  border-left: 4px solid var(--status-color, var(--kb-border));
  border-radius: var(--kb-radius);
  background-color: var(--kb-surface);
}

.status-indicator {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  background-color: var(--status-color, var(--kb-border));
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--status-color, var(--kb-border)) 18%, transparent);
}

/* The dot encodes health; the label spells it out (never colour alone). */
.status-label {
  color: var(--kb-text-muted);
  font-size: 0.9rem;
  font-weight: 600;
}

@media (prefers-reduced-motion: no-preference) {
  .status-card {
    transition:
      box-shadow var(--kb-duration) var(--kb-ease),
      translate var(--kb-duration) var(--kb-ease);
  }

  .status-card:hover {
    translate: 0 -2px;
    box-shadow: var(--kb-shadow);
  }
}

.status-level-0 { --status-color: #6c757d; }
.status-level-1 { --status-color: #6c757d; }
.status-level-2 { --status-color: #8b0000; }
.status-level-3 { --status-color: #a0522d; }
.status-level-4 { --status-color: #ff6347; }
.status-level-5 { --status-color: #ffa500; }
.status-level-6 { --status-color: #ffd700; }

/* --------------------------------------------------------------------------
   7. HTMX behaviours
   -------------------------------------------------------------------------- */
.htmx-indicator {
  display: none;
  opacity: 0;
  transition: opacity 200ms ease-in;
}

.htmx-request .htmx-indicator {
  display: inline-flex;
  opacity: 1;
}

.htmx-request.htmx-indicator {
  display: inline-flex;
  opacity: 1;
}

/* Top-of-page HTMX progress bar. JS only toggles display and the bar width;
   the 3px height lives here. */
#page-progress {
  block-size: 3px;
}

/* Horizontal vote histogram (gradients process): fixed label/value gutters
   so the bars line up. */
.vote-histogram-label {
  inline-size: 140px;
}

.vote-histogram-count {
  inline-size: 30px;
}

/* Photos attached to issues, bounded so they cannot swallow the detail view */
.issue-photo {
  max-block-size: 300px;
  inline-size: auto;
}

.issue-photo--sm {
  max-block-size: 200px;
}

/* Standalone map view (templates/issues/map.html) */
.map-embedded {
  block-size: 400px;
}

.clickable-item {
  cursor: pointer;
  border-radius: var(--kb-radius-sm);
  transition:
    background-color var(--kb-duration) var(--kb-ease),
    color var(--kb-duration) var(--kb-ease);
}

.clickable-item:hover {
  background-color: light-dark(
    color-mix(in oklab, var(--kb-brand-500) 9%, transparent),
    color-mix(in oklab, var(--kb-brand-300) 13%, transparent)
  );
}


@media (prefers-reduced-motion: no-preference) {
  .clickable-item {
    transition:
      background-color var(--kb-duration) var(--kb-ease),
      color var(--kb-duration) var(--kb-ease),
      translate var(--kb-duration) var(--kb-ease);
  }

  .clickable-item:hover {
    translate: 3px 0;
  }
}

.arrow-icon {
  display: inline-block;
  font-size: 0.9em;
  color: var(--kb-text-muted);
}

.arrow-icon,
.expanded .arrow-icon {
  rotate: 0deg;
}

.expanded .arrow-icon {
  rotate: 90deg;
  color: var(--kb-brand-500);
}

@media (prefers-reduced-motion: no-preference) {
  .arrow-icon {
    transition:
      rotate var(--kb-duration) var(--kb-ease),
      color var(--kb-duration) var(--kb-ease);
  }
}

.content-panel {
  border-radius: var(--kb-radius-sm);
}

/* --------------------------------------------------------------------------
   8. Markdown rendered content
   -------------------------------------------------------------------------- */
.card-text h1,
.card-text h2,
.card-text h3,
.card-text h4,
.card-text h5,
.card-text h6 {
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}

.card-text h1 { font-size: 1.75rem; }
.card-text h2 { font-size: 1.5rem; }
.card-text h3 { font-size: 1.25rem; }

.card-text p {
  margin-bottom: 0.75rem;
}

.card-text ul,
.card-text ol {
  margin-bottom: 0.75rem;
  padding-left: 2rem;
}

.card-text li {
  margin-bottom: 0.25rem;
}

.card-text code {
  padding: 0.2rem 0.4rem;
  border-radius: 0.25rem;
  background-color: var(--kb-surface-3);
  font-size: 0.875em;
  color: light-dark(#b02a5b, #ff9ecb);
}

.card-text pre {
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--kb-border);
  border-radius: var(--kb-radius-sm);
  background-color: var(--kb-surface-3);
  overflow-x: auto;
}

.card-text blockquote {
  padding: 0.5rem 1rem;
  margin: 0.75rem 0;
  border-left: 0.25rem solid var(--kb-brand-500);
  border-radius: var(--kb-radius-sm);
  background-color: var(--kb-surface-2);
}


/* --------------------------------------------------------------------------
   9. Overtype editor
   -------------------------------------------------------------------------- */
.overtype-container {
  border-radius: var(--kb-radius-sm);
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   10. Responsive / accessibility adjustments
   -------------------------------------------------------------------------- */

/* Touch targets: key off the input device, not the viewport — a touch
   laptop or a landscape phone is still a coarse pointer (WCAG 2.5.8).
   Size with min-block-size so labels can grow the control, never shrink it. */
@media (pointer: coarse) {
  .btn,
  .nav-link,
  .dropdown-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-block-size: 44px;
    padding-block: 0.5rem;
  }

  .btn-sm {
    min-block-size: 38px;
    padding: 0.375rem 0.75rem;
  }

  /* Increase spacing between interactive elements */
  .btn + .btn {
    margin-inline-start: 8px;
  }

  /* Ensure clickable list items have adequate height */
  .list-group-item.clickable-item,
  .expandable-toggle {
    min-block-size: 44px;
    padding: 12px 16px;
  }

  /* Better touch targets for badges that are clickable */
  a.badge {
    padding: 0.5em 0.75em;
  }
}

/* Forced Colors Mode (Windows High Contrast): author colours, gradients and
   box-shadows are stripped, so boundaries must come from borders/outlines
   painted in system colours. */
@media (forced-colors: active) {
  :where(.card, .modal-content, .dropdown-menu, .list-group-item, .alert,
    .badge, .form-control, .form-select, .btn, .progress, .skip-link,
    .debug-panel) {
    border: 1px solid CanvasText;
  }

  /* Status/hover colours are backgrounds only; keep the edge visible. */
  .status-indicator {
    border: 1px solid CanvasText;
  }

  .progress-bar {
    border-inline-end: 1px solid CanvasText;
  }

  /* The form focus ring is a box-shadow, which forced colours drops; the
     outline below is the only remaining indicator. */
  .form-control:focus-visible,
  .form-select:focus-visible,
  .btn:focus-visible,
  a:focus-visible {
    outline: 2px solid Highlight;
    outline-offset: 2px;
  }
}

/* Honour reduced-motion globally for view transitions and any animation that
   slipped through the component-level opt-ins above. Non-motion transitions
   (colour changes) stay enabled. */
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }
}

} /* @layer components */
