/* ── RELATED / DISCOVERY RAIL ──
   Loaded by _doctor.html and _category.html (after their page CSS). Turns the
   single-column .detail into a two-column "content + aside" grid on desktop, and
   styles the cross-link rail (other specialties/cities, peer doctors). On mobile
   the grid collapses to one column and the rail stacks BELOW the content - there
   is no side space on a phone, which is the dominant device here. Uses the design
   tokens from css/style.css (no hardcoded colours). */

/* ── Breadcrumb ──
   Defined here (not just in category.css) so the doctor page's up-link crumb is
   styled too - _doctor.html loads style.css + doctor.css + related.css, and
   doctor.css has no .crumbs rule. Identical to category.css's; on the category
   page (which loads both) the duplicate is harmless. */
.crumbs {
  font-size: 12px;
  color: var(--ink-mute);
  margin-bottom: 12px;
}
.crumbs a {
  color: var(--ink-soft);
  text-decoration: none;
}
.crumbs a:hover {
  color: var(--red);
}

/* ── Two-column layout (desktop) ──
   .detail keeps its own max-width/padding from doctor.css / category.css; we only
   override the inner display to a grid when .detail-grid is present. The content
   column is fluid; the rail is a fixed, comfortable reading width. */
.detail-grid {
  /* Widen the centred column to fit content + rail without feeling cramped. */
  max-width: 1100px;
}

@media (min-width: 960px) {
  .detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    column-gap: 48px;
    align-items: start;
  }
  /* Explicit placement: content top-left, rail top-right, FAQ below content in
     the left column. (.faq-section lives outside .detail-main so it can sit above
     the rail on mobile - see the mobile rule below.) */
  .detail-grid > .detail-main {
    grid-column: 1;
    grid-row: 1;
  }
  .detail-grid > .rail {
    grid-column: 2;
    grid-row: 1 / span 2;
  }
  .detail-grid > .faq-section {
    grid-column: 1;
    grid-row: 2;
  }
  /* The rail sticks as you scroll the (usually taller) main column. */
  .detail-grid .rail {
    position: sticky;
    top: 88px; /* clears the sticky nav */
  }
}

/* Mobile: single column with the rail ABOVE the FAQ. .detail-grid becomes a flex
   column and we order its three direct children: content, then rail, then FAQ. */
@media (max-width: 959px) {
  .detail-grid {
    display: flex;
    flex-direction: column;
  }
  .detail-grid > .detail-main { order: 1; }
  .detail-grid > .rail { order: 2; }
  .detail-grid > .faq-section { order: 3; }
}

/* min-width:0 lets the main column shrink instead of overflowing the grid. */
.detail-main {
  min-width: 0;
}

/* ── Rail ── */
.rail {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* On mobile the rail sits below the content with a clear separation. */
@media (max-width: 959px) {
  .rail {
    margin-top: 40px;
    padding-top: 32px;
    border-top: 1px solid var(--border);
  }
}

.rail-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rail-heading {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}

/* ── Pill links (other specialties / other cities) ── */
.rail-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}
.rail-pill:hover {
  border-color: var(--red-mid);
  background: #fffafa;
}
.rail-pill-label {
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.3;
}
.rail-pill:hover .rail-pill-label {
  color: var(--ink);
}
/* The doctor count - a small signal the link leads to real content. */
.rail-pill-count {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--red-text);
  background: var(--red-light);
  border-radius: 999px;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ── Peer-doctor rows in the rail ──
   Reuses .doctor-row / .doctor-list from doctor.css / category.css; we only tune
   spacing for the narrower rail context. */
.rail-doctor-list {
  gap: 6px;
}
.rail-doctor-list .doctor-row {
  padding: 10px 12px;
  gap: 10px;
}
/* "+N more … in the app" - an underlined text link so its clickability reads
   without a hover (always-on underline, not hover-only). */
.rail-more {
  margin-top: 10px;
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  color: var(--red-text);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.rail-more:hover {
  color: var(--red);
}
/* Phones and tablets (the rail stacks under the content): "+N more" is the way
   on to the full list, so it becomes a full-width, 44px-tall button. */
@media (max-width: 959px) {
  .rail-more {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    margin-top: 12px;
    padding: 10px 16px;
    border: 1px solid var(--red-mid);
    border-radius: 12px;
    background: var(--red-light);
    font-size: 14px;
    text-align: center;
    text-decoration: none;
  }
  .rail-more:hover {
    background: var(--red-mid);
    color: var(--red-text);
  }
}

/* On mobile, render the two specialty/city pill groups side by side if they fit,
   so the related block doesn't push the footer too far down. Peer-doctor rows
   stay full-width (they're taller). */
@media (max-width: 959px) {
  .rail {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 28px 24px;
    align-items: start;
  }
  /* A peer-doctor group spans the full width even in the mobile grid. */
  .rail-group:has(.rail-doctor-list) {
    grid-column: 1 / -1;
  }
}

/* ── Small screens ──
   ~95% of visitors are on phones, many on 320-360px screens. Lives here because
   related.css loads after doctor.css / category.css on every programmatic page,
   so these override both copies of the row styles. */
@media (max-width: 540px) {
  /* Doctor and clinic rows: the fee moves under the text instead of taking its
     own column, so the name and clinic get the width. Avatar spans both rows. */
  .doctor-row {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 16px;
    grid-template-areas:
      "avatar info chev"
      "avatar fee  chev";
    column-gap: 12px;
    row-gap: 4px;
    align-items: center;
    padding: 12px;
  }
  .doctor-row-avatar {
    grid-area: avatar;
    width: 44px;
    align-self: start;
  }
  .doctor-row-info { grid-area: info; }
  .doctor-row-fee {
    grid-area: fee;
    justify-self: start;
  }
  .doctor-row-chev { grid-area: chev; }
  /* No fee (rail rows, clinic rows): one row, avatar centred with the text. */
  .doctor-row:not(:has(.doctor-row-fee)) {
    grid-template-areas: "avatar info chev";
  }
  .doctor-row:not(:has(.doctor-row-fee)) .doctor-row-avatar {
    align-self: center;
  }
  .rail-doctor-list .doctor-row {
    padding: 10px 12px;
  }
}
@media (max-width: 420px) {
  /* Narrow phones: 16px side margins (from 24px) - 16px more for every line. */
  .detail {
    padding-left: 16px;
    padding-right: 16px;
  }
}

/* ── List pager ──
   js/paginate.js shows a long list (category and clinic doctor lists, the town
   page's clinics) a page at a time and draws this pager after it. Without JS
   every row shows and there is no pager. Lives here because related.css is
   common to the category, town and clinic pages. */
/* Rows are display:flex, which beats the UA [hidden] rule: restate it. */
[data-paginate] > [hidden] {
  display: none !important;
}
.pager {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
}
.pager-status {
  font-size: 13px;
  color: var(--ink-mute);
}
.pager-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
}
.pager-btn {
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.pager-btn:hover:not(:disabled):not([aria-current]) {
  border-color: var(--red-mid);
  background: var(--red-light);
  color: var(--red-text);
}
.pager-btn[aria-current="page"] {
  border-color: var(--red);
  background: var(--red);
  color: #fff;
  cursor: default;
}
.pager-btn:disabled {
  color: var(--ink-mute);
  opacity: 0.5;
  cursor: default;
}
.pager-btn:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}
.pager-gap {
  min-width: 20px;
  text-align: center;
  color: var(--ink-mute);
}
.pager-step {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.pager-step svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
/* Phones (95% of visitors): one row that fits a 320px screen. paginate.js drops
   the page numbers next to the current one at the same breakpoint, so the row is
   at most 7 items: < 1 ... 4 ... 9 > or < 1 2 3 4 5 >. */
@media (max-width: 540px) {
  .pager-controls {
    flex-wrap: nowrap;
    gap: 4px;
  }
  .pager-btn {
    min-width: 38px;
    height: 40px;
    padding: 0 8px;
  }
  .pager-step {
    justify-content: center;
    padding: 0;
    width: 40px;
  }
  .pager-step-label {
    display: none;
  }
  .pager-gap {
    min-width: 14px;
  }
}

/* ── FAQ ──
   Loaded here (related.css is the one stylesheet common to doctor, clinic and
   category pages) so the long-tail FAQ section is styled on all three. */
.faq-section {
  margin-top: 44px;
}
.faq-section > h2 {
  font-size: 19px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 18px;
}
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.faq-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
}
.faq-q {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
}
.faq-a {
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.6;
}
.faq-a a {
  color: var(--red-text);
  font-weight: 500;
  text-decoration: underline;
}
.faq-a a:hover {
  color: var(--red);
}
