/* Base & accessibility */
:root {
  --font-scale: 1;
  --base-font: 1rem;
  --color-bg: #f8f9fb;
  --color-surface: #ffffff;
  --color-text: #1a1d26;
  --color-muted: #5c6370;
  --color-accent: #2563eb;
  --color-accent-hover: #1d4ed8;
  --color-border: #e2e6ee;
  --color-placeholder: #d8dde8;
  --shadow-sm: 0 1px 3px rgb(26 29 38 / 8%);
  --shadow-md: 0 4px 16px rgb(26 29 38 / 10%);
  --radius: 12px;
  --max-width: 1100px;
}

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

html {
  font-size: calc(var(--base-font) * var(--font-scale));
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

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

a:hover {
  color: var(--color-accent-hover);
}

code {
  font-size: 0.9em;
  background: var(--color-border);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 200;
  padding: 0.5rem 1rem;
  background: var(--color-accent);
  color: #fff;
  text-decoration: none;
  border-radius: 0 0 var(--radius) var(--radius);
}

.skip-link:focus {
  top: 0;
}

.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;
}

.container {
  width: min(100% - 2rem, var(--max-width));
  margin-inline: auto;
}

/* Accessibility toolbar — fixed size, independent of page zoom */
.a11y-toolbar {
  position: fixed;
  z-index: 150;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 16px;
}

.a11y-toolbar.is-dragging {
  cursor: grabbing;
}

.a11y-toolbar.is-snapping {
  transition: left 0.2s ease, top 0.2s ease, right 0.2s ease, bottom 0.2s ease;
}

.a11y-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  box-shadow: var(--shadow-md);
  max-width: min(calc(100vw - 32px), 384px);
  flex-wrap: nowrap;
}

.a11y-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-text);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  line-height: 1;
  box-shadow: var(--shadow-md);
  touch-action: manipulation;
}

.a11y-toolbar.is-collapsed .a11y-controls {
  display: none;
}

.a11y-toolbar:not(.is-collapsed) .a11y-toggle {
  display: none;
}

.a11y-toolbar.is-collapsed .a11y-toggle {
  cursor: grab;
  touch-action: none;
}

.a11y-toolbar.is-dragging .a11y-toggle {
  cursor: grabbing;
}

.a11y-close {
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

.a11y-btn-compact {
  display: none;
}

.a11y-mobile-only {
  display: none;
}

.a11y-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-muted);
  margin-right: 4px;
  white-space: nowrap;
}

.a11y-scale {
  min-width: 48px;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--color-text);
  text-align: center;
  margin-left: 4px;
}

.a11y-toolbar button {
  min-width: 36px;
  min-height: 36px;
  padding: 4px 8px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-bg);
  color: var(--color-text);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  line-height: 1;
}

.a11y-toolbar button:hover,
.a11y-toggle:hover {
  background: var(--color-border);
}

.a11y-toolbar button:focus-visible,
.a11y-toggle:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Main content */
main {
  padding-block: 2rem 3rem;
}

h1 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  line-height: 1.2;
  margin: 0 0 1rem;
}

h2 {
  font-size: clamp(1.25rem, 2.5vw, 1.5rem);
  margin: 0 0 0.75rem;
}

p {
  margin: 0 0 1rem;
  color: var(--color-muted);
}

p:last-child {
  margin-bottom: 0;
}

/* Image placeholders */
.image-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-placeholder);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  color: var(--color-muted);
  font-weight: 600;
  font-size: 0.9375rem;
}

/* Hero */
.hero {
  display: grid;
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

.hero .image-placeholder {
  min-height: 220px;
}

@media (min-width: 768px) {
  .hero {
    grid-template-columns: 1fr 1fr;
    align-items: center;
    gap: 2rem;
  }

  .hero .image-placeholder {
    min-height: 280px;
  }
}

/* Card grid */
.content-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1fr;
}

@media (min-width: 600px) {
  .content-grid {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  }
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.card-image {
  min-height: 140px;
  margin-bottom: 1rem;
}

/* Mobile: compact controls when expanded */
@media (max-width: 767px) {
  .a11y-desktop-only,
  .a11y-btn-full {
    display: none;
  }

  .a11y-mobile-only,
  .a11y-btn-compact {
    display: inline;
  }

  .a11y-controls {
    padding: 6px;
  }

  .a11y-toolbar button {
    min-width: 44px;
    min-height: 44px;
  }

  main {
    padding-top: 3.5rem;
  }
}
