/* ═══════════════════════════════════════════════════════════════
   SPECIALITIES INDEX  (/specialities/)
   Standalone stylesheet for the specialities listing. Component
   classes mirror the conditions-and-procedures listing; this file
   is independent so the two pages can evolve separately.
   ═══════════════════════════════════════════════════════════════ */

/* ── Astra container reset ───────────────────────────────────── */
.specialities-index-page .ast-container {
  padding-left: 0;
  padding-right: 0;
  max-width: none;
}

/* ═══════════════════════════════════════════════════════════════
   LISTING PAGE  (conditions.html)
   ═══════════════════════════════════════════════════════════════ */

/* ── Page intro ─────────────────────────────────────────────── */
.page-intro {
  background: hsl(var(--card));
  padding: 40px 200px 8px;
}

.page-intro__inner {
  max-width: none;
}

.breadcrumb {
  font-size: 13px;
  color: hsl(var(--muted-foreground));
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.breadcrumb a {
  color: hsl(var(--muted-foreground));
}

.breadcrumb a:hover {
  color: hsl(var(--primary));
}

.breadcrumb__sep {
  opacity: 0.4;
  font-size: 9px;
}

.breadcrumb__current {
  color: hsl(var(--accent));
  font-weight: 500;
}

.page-intro__eyebrow {
  font: 600 12px/1 var(--font-sans);
  color: hsl(var(--accent));
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

/* Heading is ~69 chars, so its size is derived from the container width
   ((100vw − gutters) / divisor) to hold ONE line on PC and tablet; the
   divisor ≈ line length in em for Inter 600 plus a safety margin. */
.page-intro h1 {
  margin: 20px 0px;
  font: 600 min(2.75rem, calc((100vw - 400px) / 30)) / 1.12 var(--font-sans);
  color: hsl(var(--primary));
  letter-spacing: -0.025em;
  white-space: nowrap;
}

/* Gutters drop to 40px/side at 1200px — same one-line rule, new container.
   Divisor 30 measured against the live heading (validated at 1440px viewport):
   capacity is a constant 30em at any width, so the fit carries over exactly. */
@media (max-width: 1200px) {
  .page-intro h1 {
    font-size: min(2.75rem, calc((100vw - 80px) / 30));
  }
}

/* Mobile: wrap into two balanced lines — half the one-line divisor (15)
   plus word-wrap slack, so two lines always hold the full 30em heading */
@media (max-width: 640px) {
  .page-intro h1 {
    white-space: normal;
    text-wrap: balance;
    font-size: clamp(0.95rem, calc((100vw - 80px) / 16), 1.6rem);
    line-height: 1.25;
  }
}

.page-intro h1 span {
  color: hsl(var(--accent));
}

.page-intro p {
  margin: 0;
  /* max-width: 720px; */
  color: hsl(var(--muted-foreground));
  font-size: 17px;
  line-height: 1.6;
  text-wrap: pretty;
}

.page-intro p+p {
  margin-top: 12px;
}

/* ── Alphabet + Search ──────────────────────────────────────── */
.index-tools {
  background: hsl(var(--card));
  padding: 40px 200px 24px;
}

.index-tools__inner {
  max-width: none;
}

/* ── Vertical rhythm (8pt scale, grouped by proximity) ─────────
   search ─24─ filters ─32─ A–Z index ─12─ "Filtered by"
   ─20─ results meta ─48─ first letter section                    */
#library-alpha {
  margin-top: 32px;
}

.alpha {
  display: grid;
  grid-template-columns: repeat(14, 1fr);
  gap: 10px;
}

.alpha__letter {
  aspect-ratio: 1;
  border-radius: 9999px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  color: hsl(var(--primary));
  font: 600 14px/1 var(--font-sans);
  display: grid;
  place-items: center;
  transition:
    background 0.2s,
    color 0.2s,
    border-color 0.2s,
    transform 0.15s;
  text-decoration: none;
}

.alpha__letter:hover {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-color: hsl(var(--primary));
  transform: translateY(-2px);
}

.alpha__letter[aria-disabled="true"] {
  color: hsl(var(--muted-foreground));
  background: hsl(var(--muted));
  cursor: default;
  opacity: 0.5;
  pointer-events: none;
}

.alpha__letter.is-active {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
  border-color: hsl(var(--accent));
}

.alpha-active-filter {
  margin-top: 12px;
  font-size: 13px;
  color: hsl(var(--muted-foreground));
  display: flex;
  align-items: center;
  gap: 8px;
}

.alpha-active-filter strong {
  color: hsl(var(--primary));
}

.alpha-active-filter a {
  color: hsl(var(--accent));
  font-weight: 600;
}

@media (max-width: 880px) {
  .alpha {
    grid-template-columns: repeat(9, 1fr);
  }
}

@media (max-width: 480px) {
  .alpha {
    grid-template-columns: repeat(7, 1fr);
  }
}

.search {
  display: flex;
  align-items: center;
  gap: 12px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 9999px;
  padding: 0 24px;
  height: 56px;
  box-shadow: var(--shadow-sm);
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
  outline: none !important;
}

.search:focus-within {
  border-color: hsl(var(--primary) / 0.35);
  box-shadow: var(--shadow-md);
}

.search .fa {
  color: hsl(var(--muted-foreground));
  font-size: 15px;
}

.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  outline: none;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
  font: 400 15px/1 var(--font-sans);
  color: hsl(var(--foreground));
}

/* Astra's dynamic CSS paints a thin dotted border/outline on focused
   inputs (input[type=search]:focus) — neutralise it on both states. */
.search input:focus,
.search input:focus-visible {
  outline: none !important;
  border: none !important;
  box-shadow: none !important;
}

.search input::placeholder {
  color: hsl(var(--muted-foreground));
}

.results-meta {
  margin: 20px 0 0;
  font-size: 14px;
  color: hsl(var(--muted-foreground));
}

/* ── Pagination ─────────────────────────────────────────────── */
.pager {
  margin-top: 56px;
  padding-top: 32px;
  border-top: 1px solid hsl(var(--border));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.pager__meta {
  font-size: 13.5px;
  color: hsl(var(--muted-foreground));
}

.pager__nav {
  display: inline-flex;
  gap: 6px;
}

.pager__nav a,
.pager__nav span {
  min-width: 38px;
  height: 38px;
  padding: 0 12px;
  border-radius: 9999px;
  border: 1px solid hsl(var(--border));
  display: inline-grid;
  place-items: center;
  font: 600 13px/1 var(--font-sans);
  color: hsl(var(--primary));
  background: hsl(var(--card));
  transition:
    background 0.15s,
    color 0.15s,
    border-color 0.15s;
}

.pager__nav a:hover {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-color: hsl(var(--primary));
}

.pager__nav .is-current {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
  border-color: hsl(var(--accent));
}

.pager__nav .is-gap {
  border: 0;
  background: transparent;
  color: hsl(var(--muted-foreground));
}

/* ── Letter sections ────────────────────────────────────────── */
.listing {
  background: hsl(var(--card));
  padding: 24px 200px 40px;
}

.listing__inner {
  max-width: none;
}

.letter-section {
  margin-top: 56px;
  scroll-margin-top: 24px;
}

/* The section paddings above (24 + 24) already provide the 48px break
   after the results meta — no extra margin on the first section. */
.letter-section:first-of-type {
  margin-top: 0;
}

.letter-section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid hsl(var(--border));
  margin-bottom: 28px;
}

.letter-section__letter {
  font: 600 28px/1 var(--font-sans);
  color: hsl(var(--primary));
  letter-spacing: -0.02em;
}

.letter-section__meta {
  display: inline-flex;
  align-items: center;
  gap: 18px;
  font: 600 12px/1 var(--font-sans);
  letter-spacing: 0.04em;
}

.letter-section__count {
  color: hsl(var(--muted-foreground));
}

.letter-section__top {
  color: hsl(var(--muted-foreground));
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s;
  text-decoration: none;
}

.letter-section__top:hover {
  color: hsl(var(--accent));
}

.letter-section__more {
  margin-top: 24px;
  display: flex;
  justify-content: center;
}

.letter-section__more button,
.letter-section__more a {
  height: 40px;
  padding: 0 22px;
  border-radius: 9999px;
  background: transparent;
  border: 1px solid hsl(var(--border));
  color: hsl(var(--primary));
  font: 600 13px/1 var(--font-sans);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.letter-section__more button:hover,
.letter-section__more a:hover {
  background: hsl(var(--surface));
  border-color: hsl(var(--accent) / 0.5);
  color: hsl(var(--accent));
}

/* Collapsed letter sections hide cards beyond the first 4 until the
   "See all" trigger adds .is-expanded (conditions.js) */
.letter-section:not(.is-expanded) .cond-card--extra {
  display: none;
}

.cond-grid {
  display: grid;
  align-items: stretch;
  grid-template-columns: 1fr 1fr;
  gap: 12px 32px;
}

.cond-card {
  background: hsl(var(--surface));
  border: 1px solid hsl(var(--border));
  border-radius: 10px;
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

.cond-card:hover {
  border-color: hsl(var(--border));
  box-shadow: var(--shadow-sm);
}

.cond-card__title {
  margin: 0;
  font: 600 17px/1.3 var(--font-sans);
  color: hsl(var(--primary));
  letter-spacing: -0.01em;
}

.cond-card__desc {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.55;
  color: hsl(var(--muted-foreground));
}

.cond-card__links {
  margin-top: auto;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.cond-link {
  font: 600 13px/1 var(--font-sans);
  color: hsl(var(--accent));
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
  transition:
    border-color 0.15s,
    color 0.15s;
}

.cond-link:hover {
  border-bottom-color: hsl(var(--accent));
}

.cond-link--muted {
  color: hsl(var(--muted-foreground));
}

.cond-link--muted:hover {
  border-bottom-color: hsl(var(--muted-foreground));
  color: hsl(var(--primary));
}

@media (max-width: 720px) {
  .cond-grid {
    grid-template-columns: 1fr;
  }
}

/* ═══════════════════════════════════════════════════════════════
   LIBRARY CONTROLS — search row, sort, type toggle
   ═══════════════════════════════════════════════════════════════ */

/* PC: search on its own line; type-toggle, sort, and speciality
   share the second line at their natural widths. */
.library-controls {
  display: flex;
  align-items: center;
  gap: 24px 16px;
  flex-wrap: wrap;
}

.library-controls .search {
  flex: 1 1 100%;
}

/* Second row fills the full width in a 2:1:1 ratio
   (type-toggle : sort : speciality) */
.library-sort {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 0;
  min-width: 0;
}

.library-sort select {
  flex: 1;
  width: 100%;
  min-width: 0;
}

/* Long speciality names shouldn't stretch the row */
.library-spec select {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Height matches the type-toggle (13.5px text + 2×9px btn padding
   + 2×4px wrapper padding + 2×1px border ≈ 42px) */
.library-sort select {
  height: 42px;
  padding: 0 36px 0 16px;
  border-radius: 9999px;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card)) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2364748b' d='M6 8 0 2l1.4-1.4L6 5.2 10.6.6 12 2z'/%3E%3C/svg%3E") no-repeat right 16px center;
  font: 600 14px/1 var(--font-sans);
  color: hsl(var(--primary));
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.library-sort select:focus {
  outline: none;
  border-color: hsl(var(--primary) / 0.35);
  box-shadow: var(--shadow-md);
}

/* No-JS fallback only; conditions.js hides this on init. */
.library-sort__apply {
  height: 42px;
  padding: 0 20px;
  border-radius: 9999px;
  border: 0;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  font: 600 13.5px/1 var(--font-sans);
  cursor: pointer;
}

/* Type filter — segmented control; takes the 2-share of the 2:1:1 row */
.type-toggle {
  display: flex;
  flex: 2 1 0;
  min-width: 0;
  padding: 4px;
  gap: 4px;
  background: hsl(var(--muted));
  border: 1px solid hsl(var(--border));
  border-radius: 9999px;
}

.type-toggle__btn {
  appearance: none;
  border: 0;
  background: transparent;
  border-radius: 9999px;
  padding: 9px 10px;
  flex: 1;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  font: 600 13.5px/1 var(--font-sans);
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  text-decoration: none;
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
}

/* Astra paints a thin dotted outline on focused links (a:focus-visible
   { outline-style: dotted }) — replace it with the design's own focus
   treatment on the library's link-based controls. Mouse clicks show
   nothing; keyboard focus gets a soft accent ring. */
.type-toggle__btn:focus,
.alpha__letter:focus,
.letter-section__top:focus,
.letter-section__more a:focus {
  outline: none;
}

.type-toggle__btn:focus-visible,
.alpha__letter:focus-visible,
.letter-section__top:focus-visible,
.letter-section__more a:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px hsl(var(--accent) / 0.35);
}

/* In-flight feedback: spinner inside the clicked tab (set by conditions.js) */
.type-toggle__btn[data-loading]::after {
  content: "";
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  animation: lib-spin 0.6s linear infinite;
}

@keyframes lib-spin {
  to {
    transform: rotate(360deg);
  }
}

.type-toggle__btn:hover {
  color: hsl(var(--primary));
}

.type-toggle__btn.is-active {
  background: hsl(var(--card));
  color: hsl(var(--primary));
  box-shadow: var(--shadow-sm);
}

/* ── Per-card type badge ─────────────────────────────────────────── */
.cond-badge {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 9999px;
  font: 700 10.5px/1.3 var(--font-sans);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.cond-badge--condition {
  background: hsl(var(--accent) / 0.12);
  color: hsl(var(--accent));
}

.cond-badge--procedure {
  background: hsl(var(--info) / 0.14);
  color: hsl(199 88% 36%);
}

/* ── AJAX loading state ──────────────────────────────────────────── */
#library-list {
  transition: opacity 0.18s ease;
}

#library-list.is-loading {
  opacity: 0.45;
  pointer-events: none;
}

/* Tablet: search on its own line, type-toggle on its own line,
   then sort + speciality side by side on the third line. */
@media (max-width: 880px) {
  .library-controls {
    gap: 16px;
  }

  #library-alpha {
    margin-top: 24px;
  }

  .library-controls .type-toggle {
    flex: 1 1 100%;
  }

  .type-toggle__btn {
    padding: 9px 12px;
  }

  .library-controls .library-sort {
    flex: 1 1 calc(50% - 8px);
  }

  .cond-grid {
    grid-template-columns: 1fr;
  }
}

/* Mobile: every control on its own line */
@media (max-width: 640px) {
  .library-controls .library-sort,
  .library-controls .library-spec {
    flex: 1 1 100%;
  }
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — tighten horizontal gutters
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 1200px) {

  .page-intro,
  .index-tools,
  .listing,
  .detail {
    padding-left: 40px;
    padding-right: 40px;
  }
}
/* ── Speciality type badges (Medical / Surgical / Critical Care) ── */
.cond-card__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cond-badge--medical {
  background: hsl(var(--accent) / 0.12);
  color: hsl(var(--accent));
}

.cond-badge--surgical {
  background: hsl(var(--info) / 0.14);
  color: hsl(199 88% 36%);
}

.cond-badge--critical-care {
  background: hsl(var(--destructive) / 0.1);
  color: hsl(var(--destructive));
}

.conditions-no-results {
  margin: 24px 0 0;
  font-size: 15px;
  color: hsl(var(--muted-foreground));
}
