/* WEB-5: responsive layout and accessibility polish. Loaded last on every page. */

/* Tablet landscape and below */
@media (max-width: 1024px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section { padding: var(--space-7) 0; }
}

/* Tablet portrait and below */
@media (max-width: 768px) {
  h2 { font-size: var(--text-2xl); }
  .section-head p { font-size: var(--text-lg); }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }

  /* Header: brand on one row, nav wraps below it; no JS menu needed. */
  .site-header { position: static; }
  .site-header .container { flex-wrap: wrap; justify-content: center; padding-top: var(--space-2); padding-bottom: var(--space-2); }
  .site-nav { width: 100%; }
  .site-nav ul { justify-content: center; }
  .site-footer nav ul { gap: var(--space-2) var(--space-4); }
  .site-footer nav a { display: inline-flex; align-items: center; min-height: 44px; }
}

/* Phones */
@media (max-width: 480px) {
  .container { padding: 0 var(--space-4); }
  .section { padding: var(--space-6) 0; }
  .site-nav a { padding: 0 var(--space-2); }
  .btn-row { flex-direction: column; align-items: stretch; }
  .btn-row .btn { width: 100%; }
  th, td { padding: var(--space-2) var(--space-3); }
}

/* Very narrow screens (320px): never scroll sideways. */
@media (max-width: 360px) {
  .brand .badge { display: none; }
}
html, body { overflow-x: clip; }
main, .container { min-width: 0; }
p, li, td, th { overflow-wrap: break-word; }

/* Users who ask for less motion get no glow animation or transitions. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Windows high-contrast / forced colours: keep edges and buttons visible. */
@media (forced-colors: active) {
  .btn, .card, .badge, .site-header, .site-footer, figure, table { border: 1px solid CanvasText; }
  :focus-visible { outline: 2px solid Highlight; }
}

/* Print: plain text on white, no navigation. */
@media print {
  body { background: #fff; color: #000; }
  .site-header, .skip-link, .btn-row { display: none; }
  .site-footer { background: none; color: #000; }
  a { color: #000; }
}
