/* ==========================================================================
   Medical team
   Header (RTL): [heading] | [intro], then a horizontal carousel of
   doctor cards (photo → name → specialty → booking CTA); the hovered card
   comes forward with its photo as the background and a glass info panel.
   The track is a native scroll-snap row (swipe on touch); the round arrows
   step one card at a time (js/team.js). Edges align with the navbar
   (--nav-edge-left/right). Light aqua surface, full-bleed.
   ========================================================================== */

.team {
  --team-gutter: var(--space-4);
  --cards-visible: 4;
  --card-gap: var(--space-3);       /* 24px */
  --nav-size: var(--space-7);       /* 56px arrows */

  padding-block: var(--space-8);
  background: color-mix(in srgb, var(--color-primary-100) 18%, #ffffff);
  scroll-margin-top: var(--header-height, 0px);
}

.team__inner {
  margin-left: var(--nav-edge-left, var(--team-gutter));
  margin-right: var(--nav-edge-right, var(--team-gutter));
}

/* ---- Header ---- */
.team__header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: end;
  gap: var(--space-6);
  margin-bottom: var(--space-6);
}

.team__title {
  margin: 0;
  color: var(--color-primary-700);
  font-size: var(--font-size-h4);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-h4);
  text-wrap: balance;
}

.team__title-accent {
  color: var(--color-primary);
}

.team__intro {
  max-width: 36em;
  margin: 0;
  justify-self: end; /* RTL: hugs the left edge */
  color: var(--color-neutral-900);
  font-size: var(--font-size-b1);
  line-height: var(--line-height-b1);
  text-wrap: pretty;
}

/* ---- Carousel ---- */
.team-carousel {
  position: relative;
}

.team-carousel .team-carousel__track { /* beats the global ul[role="list"] reset; shared by team + reviews */
  display: flex;
  gap: var(--card-gap);
  margin: calc(var(--space-3) * -1) calc(var(--space-2) * -1); /* room for card shadows */
  padding: var(--space-3) var(--space-2);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: var(--space-2);
  scroll-behavior: smooth;
  scrollbar-width: none;
}

.team-carousel__track::-webkit-scrollbar {
  display: none;
}

.team-carousel__track:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: -2px;
  border-radius: var(--radius-panel);
}

/* Arrows sit on the carousel's sides, centred on the photos */
.team-carousel__nav {
  position: absolute;
  z-index: 2;
  top: var(--media-center, 40%);
  transform: translateY(-50%);
}

.team-carousel__nav:active {
  transform: translateY(-50%) scale(0.94);
}

.team-carousel__nav--prev { right: calc(var(--nav-size) / -2); }
.team-carousel__nav--next { left: calc(var(--nav-size) / -2); }

.team-carousel__nav:disabled {
  opacity: 0;
  pointer-events: none;
}

/* ---- Doctor card ----
   Rest: framed photo on top, name / specialty / CTA on white below.
   Hover or keyboard focus (the "active" card): the card steps forward while
   the others recede; the framed photo grows to fill the whole card and the
   text block becomes a glass panel over it. The photo frame is absolutely
   positioned so it can grow; a 4:5 spacer keeps its place in the flow. */
.doctor-card {
  --card-pad: var(--space-2);       /* 16px */
  --card-radius: var(--radius-panel); /* 32px */
  --morph: 450ms var(--ease-smooth);

  position: relative;
  isolation: isolate;
  container-type: inline-size;      /* 100cqi = the photo frame's width */
  display: flex;
  flex: 0 0 calc((100% - var(--card-gap) * (var(--cards-visible) - 1)) / var(--cards-visible));
  flex-direction: column;
  padding: var(--card-pad);
  border-radius: var(--card-radius);
  background: var(--color-neutral-100);
  box-shadow: 0 2px 4px rgb(19 61 63 / 0.04), 0 12px 32px rgb(19 61 63 / 0.08);
  overflow: hidden;                 /* clips the grown photo to the card's corners */
  scroll-snap-align: start;
  transition:
    transform var(--morph),
    box-shadow var(--morph),
    opacity var(--morph),
    filter var(--morph);
}

/* Reserves the photo frame's resting space (frame width × 5/4) */
.doctor-card::before {
  content: "";
  display: block;
  flex: none;
  aspect-ratio: 4 / 5;
}

.doctor-card__media {
  position: absolute;
  z-index: 0;
  top: var(--card-pad);
  right: var(--card-pad);
  left: var(--card-pad);
  height: calc(100cqi * 5 / 4);
  border-radius: var(--space-3); /* 24px, nested in the 32px card */
  /* Supplied frame: light aqua → pale green, behind the cut-out portraits */
  background: linear-gradient(180deg, #c7f6f8 0%, #e5f5cd 100%);
  overflow: hidden;
  transition:
    top var(--morph),
    right var(--morph),
    left var(--morph),
    height var(--morph),
    border-radius var(--morph);
}

.doctor-card__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 0%;       /* head stays at the top as the frame grows */
}

/* Text + CTA: plain at rest, glass when active. Padding never changes → no layout shift. */
.doctor-card__panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-1);
  padding: var(--space-2);
  border: 1px solid transparent;
  border-radius: var(--space-3); /* 24px */
  transition:
    background-color var(--morph),
    border-color var(--morph),
    box-shadow var(--morph),
    -webkit-backdrop-filter var(--morph),
    backdrop-filter var(--morph);
}

.doctor-card__body {
  flex: 1 1 auto;
}

.doctor-card__name {
  margin: 0;
  color: var(--color-primary-700);
  font-size: var(--font-size-h7);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-h7);
}

.doctor-card__specialty {
  margin: var(--space-0-5) 0 0;
  color: var(--color-neutral-900);
  font-size: var(--font-size-b3);
  line-height: var(--line-height-b3);
  text-wrap: pretty;
}

.doctor-card__cta {
  --pill-height: var(--space-6);   /* 48px */
  --cta-icon-size: var(--space-5); /* 40px */
  --cta-gap: var(--space-1);

  font-size: var(--font-size-b2);
  line-height: var(--line-height-b2);
}

/* ---- Active card: hover (mouse) or keyboard focus inside it ---- */
@media (hover: hover) {
  .doctor-card:hover {
    z-index: 2;
    transform: translateY(calc(var(--space-1) * -1)) scale(1.03);
    box-shadow: 0 4px 8px rgb(19 61 63 / 0.06), 0 24px 48px rgb(19 61 63 / 0.18);
  }

  .doctor-card:hover .doctor-card__media {
    top: 0;
    right: 0;
    left: 0;
    height: 100%;
    border-radius: var(--card-radius);
  }

  .doctor-card:hover .doctor-card__panel {
    border-color: rgb(255 255 255 / 0.7);
    background-color: rgb(255 255 255 / 0.66);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    backdrop-filter: blur(16px) saturate(140%);
    box-shadow: 0 8px 24px rgb(19 61 63 / 0.12), inset 0 1px 0 rgb(255 255 255 / 0.6);
  }

  /* The rest step back */
  .team-carousel__track:has(.doctor-card:hover) .doctor-card:not(:hover) {
    opacity: 0.72;
    filter: saturate(0.85);
    transform: scale(0.96);
  }
}

.doctor-card:has(:focus-visible) {
  z-index: 2;
  transform: translateY(calc(var(--space-1) * -1)) scale(1.03);
  box-shadow: 0 4px 8px rgb(19 61 63 / 0.06), 0 24px 48px rgb(19 61 63 / 0.18);
}

.doctor-card:has(:focus-visible) .doctor-card__media {
  top: 0;
  right: 0;
  left: 0;
  height: 100%;
  border-radius: var(--card-radius);
}

.doctor-card:has(:focus-visible) .doctor-card__panel {
  border-color: rgb(255 255 255 / 0.7);
  background-color: rgb(255 255 255 / 0.66);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .doctor-card:is(:hover, :has(:focus-visible)) .doctor-card__panel {
    background-color: rgb(255 255 255 / 0.92);
  }
}

@media (prefers-reduced-motion: reduce) {
  .team-carousel .team-carousel__track {
    scroll-behavior: auto;
  }

  .doctor-card,
  .doctor-card__media,
  .doctor-card__panel {
    transition: none;
  }
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1599.98px) {
  .team {
    --team-gutter: var(--space-3);
  }
}

@media (max-width: 1439.98px) {
  .team__title {
    font-size: var(--font-size-h5);
    line-height: var(--line-height-h5);
  }

  .team__intro {
    font-size: var(--font-size-b2);
    line-height: var(--line-height-b2);
  }

  .doctor-card__name {
    font-size: var(--font-size-b1);
    line-height: var(--line-height-b1);
  }
}

@media (max-width: 1279.98px) {
  .team {
    --cards-visible: 3;
  }
}

/* Tablet: two cards, header stacks */
@media (max-width: 1023.98px) {
  .team {
    --cards-visible: 2;
    --card-gap: var(--space-2);
  }

  .team__header {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-2);
    margin-bottom: var(--space-4);
  }

  .team__intro {
    justify-self: start;
  }
}

/* Mobile: one card with the next one peeking; arrows move under the track */
@media (max-width: 767.98px) {
  .team {
    --team-gutter: var(--space-2);
    --cards-visible: 1.2;
    --nav-size: var(--space-6); /* 48px */

    padding-block: var(--space-6);
  }

  .team__title {
    font-size: var(--font-size-h6);
    line-height: var(--line-height-h6);
  }

  .team-carousel {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr)); /* track always gets the full width */
    grid-template-areas:
      "track track"
      "prev  next";
    gap: var(--space-2) var(--space-2);
  }

  .team-carousel .team-carousel__track {
    grid-area: track;
  }

  .team-carousel__nav {
    position: static;
    width: var(--nav-size);
    height: var(--nav-size);
    transform: none;
  }

  .team-carousel__nav:active {
    transform: scale(0.94);
  }

  /* RTL: column 1 is on the right → both arrows hug the centre line */
  .team-carousel__nav--prev { grid-area: prev; justify-self: end; }
  .team-carousel__nav--next { grid-area: next; justify-self: start; }

  .team-carousel__nav:disabled {
    opacity: 0.4;
  }
}
