/* Baseline mobile-friendly enhancements */

html, body {
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  text-size-adjust: 100%;
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
}

/* Ensure content and in-page anchors are visible below fixed header */
:root {
  /* Default; updated dynamically by /header-offset.js to match real header height */
  --header-offset: 4.5rem;
  /* Keep sticky/anchor elements aligned to header height */
  --anchor-offset: var(--header-offset);
  /* Native scroll offset for anchor navigation */
  scroll-padding-top: var(--header-offset);
}

/* Push page content below the fixed header globally */
body {
  padding-top: var(--header-offset);
}
main > section[id], main [id] {
  scroll-margin-top: var(--header-offset);
}

/* Momentum scrolling for iOS */
* {
  -webkit-overflow-scrolling: touch;
}

/* Media scales to container */
img, video, canvas, svg, iframe, embed, object {
  max-width: 100%;
  height: auto;
}

/* Make tables scrollable on small screens */
.table-responsive,
table {
  display: block;
  width: 100%;
  overflow-x: auto;
}

/* Prevent layout breaks from long content on mobile */
@media (max-width: 640px) {
  pre, code, kbd, samp {
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
  }
  .container,
  main,
  section,
  article {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}

/* Utility: auto-fit grid for cards/galleries */
.grid-auto-fit {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

/* Utility: ensure tap targets are comfortable */
button, .btn, a.button, input[type="button"], input[type="submit"] {
  min-height: 44px; /* WCAG touch target */
}

/* Utility: clamp long words in headings and links */
h1, h2, h3, h4, h5, h6, a, p {
  overflow-wrap: anywhere;
}

/* Make iframes responsive with aspect ratio if wrapped */
.ratio {
  position: relative;
  width: 100%;
}
.ratio > iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.ratio-16x9 { aspect-ratio: 16 / 9; }
.ratio-4x3 { aspect-ratio: 4 / 3; }
.ratio-1x1 { aspect-ratio: 1 / 1; }

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* Improve focus visibility for accessibility */
:focus-visible {
  outline: 2px solid #19bfb7;
  outline-offset: 2px;
}

/* Skip link styling */
.skip-link {
  position: absolute;
  left: 0.5rem;
  top: -100%;
  background: #19bfb7;
  color: #000;
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  z-index: 1000;
  transition: top 0.2s ease;
}
.skip-link:focus {
  top: 0.5rem;
}

/* Star rows: prevent overflow on small screens */
.stars-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem; /* 4px */
  max-width: 100%;
}
.stars-row svg {
  flex: 0 0 auto; /* prevent shrinking */
}
@media (min-width: 640px) {
  .stars-row {
    gap: 0.375rem; /* 6px on sm+ */
  }
}
