/* Prevent text overflow inside category cards and sidebar nav */
.glass-card,
.glass-card * {
  min-width: 0;
}
.glass-card .line-clamp-3,
.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-width: 0;
}
.font-headline-sm,
.font-headline-md,
.font-body-md,
.font-label-sm {
  overflow-wrap: break-word;
  word-break: break-word;
}
aside a,
footer a {
  overflow-wrap: break-word;
  word-break: break-word;
}
/* Home/category grid cards: stack title and description instead of squeezing them */
a.glass-card .min-w-0 > .flex.items-center.justify-between.gap-2 {
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-start !important;
  justify-content: flex-start !important;
  gap: 0.25rem !important;
}
a.glass-card .min-w-0 > .flex.items-center.justify-between.gap-2 .font-label-sm {
  display: block !important;
  flex: none !important;
  min-width: 0 !important;
  overflow-wrap: break-word !important;
  white-space: normal !important;
  word-break: break-word !important;
}

/* ---------- Mobile ---------- */
@media (max-width: 768px) {
  html, body {
    overflow-x: hidden;
  }
  body.menu-open {
    overflow: hidden;
  }

  /* Larger touch targets */
  header a,
  header button,
  aside a,
  aside button,
  footer a,
  button {
    min-height: 44px;
    min-width: 44px;
  }
  header a,
  header button,
  aside a,
  aside button,
  footer a {
    display: inline-flex;
    align-items: center;
  }

  /* Sidebar becomes a full-width slide-over panel */
  aside {
    width: 100vw !important;
    max-width: none !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  aside a,
  aside button {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
  }

  /* Prevent iOS zoom on form inputs */
  input,
  textarea,
  select {
    font-size: 16px !important;
  }

  /* Search input larger */
  input[type="search"],
  input[type="text"] {
    min-height: 44px;
  }

  /* Calculator result boxes stack on mobile */
  section.glass-card .grid-cols-3,
  .grid-cols-3 {
    grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
  }

  /* Range inputs get a bigger touch target */
  input[type="range"] {
    min-height: 28px;
  }

  /* Large display headings reduce */
  .font-display-lg {
    font-size: 1.75rem;
    line-height: 1.2;
  }
  .font-headline-md {
    font-size: 1.25rem;
    line-height: 1.25;
  }

  /* Tables become horizontally scrollable on small screens via mobile-menu.js .table-wrap */
  .table-wrap {
    margin-bottom: 1rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  table {
    font-size: 14px;
  }
  table td,
  table th {
    white-space: normal;
    word-break: break-word;
    padding: 0.5rem 0.375rem;
  }

  /* Breadcrumbs wrap and avoid glued-together text */
  .flex.items-center.gap-2.font-label-sm,
  .flex.items-center.gap-2:has(> a[href="/"]) {
    flex-wrap: wrap;
    row-gap: 0.25rem;
  }
  .flex.items-center.gap-2 .truncate,
  .flex.items-center.gap-2 [class*="truncate"] {
    white-space: normal;
    word-break: break-all;
    overflow-wrap: anywhere;
  }

  /* Tags/pills wrap */
  .rounded-full.px-3.py-1,
  .rounded-full.px-2.py-1,
  .text-\[10px\].uppercase {
    white-space: normal;
    word-break: break-word;
    text-wrap: wrap;
  }

  /* Article content fluid images */
  article img {
    max-width: 100%;
    height: auto;
  }
  article p {
    overflow-wrap: break-word;
  }

  /* Protocol cards less padding on narrow screens */
  a.glass-card.rounded-xl.p-6 {
    padding: 1rem;
  }
}
