/* ==========================================================================
   Department modal enhancements — head, doctors, gallery
   All selectors scoped to .dept-* prefix (no global selectors)
   Uses CSS vars from styles.css for automatic theme/HC/font-scaling support
   ========================================================================== */

/* ---------- Head (department chief) ---------- */

.dept-head {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding-bottom: 1.75rem;
  margin-bottom: 1.75rem;
  border-bottom: 1px solid var(--color-border);
}

.dept-head__photo-wrap {
  flex-shrink: 0;
  width: 10rem;
  aspect-ratio: 4 / 5;
  border-radius: 12px;
  overflow: hidden;
  background: var(--color-surface);
}

.dept-head__photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dept-head__placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--color-accent) 15%, var(--color-surface));
  color: var(--color-accent);
  font-size: 2rem;
  font-weight: 700;
}

.dept-head__info {
  min-width: 0;
}

.dept-head__name {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text);
  margin: 0 0 0.25rem;
}

.dept-head__position {
  font-size: 1rem;
  color: var(--color-muted);
  margin: 0;
}

@media (max-width: 480px) {
  .dept-head {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  .dept-head__photo-wrap {
    width: 8rem;
  }
}

/* ---------- Doctors grid ---------- */

.dept-doctors {
  margin: 2rem 0;
}

.dept-doctors__title {
  font-size: 1.125rem;
  margin: 0 0 0.75rem;
  color: var(--color-text);
}

.dept-doctors__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
}

.dept-doctor-card {
  text-align: center;
  padding: 1rem 0.875rem;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--color-surface) 70%, transparent);
  box-shadow: var(--shadow);
}

.dept-doctor-card__photo-wrap {
  width: 9rem;
  aspect-ratio: 4 / 5;
  margin: 0 auto 0.75rem;
  border-radius: 10px;
  overflow: hidden;
  background: var(--color-surface);
}

.dept-doctor-card__photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dept-doctor-card__placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--color-accent) 10%, var(--color-surface));
  color: var(--color-accent);
  font-size: 1.5rem;
  font-weight: 700;
}

.dept-doctor-card__name {
  font-weight: 600;
  font-size: 0.9375rem;
  margin: 0 0 0.25rem;
  color: var(--color-text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: normal;
  overflow-wrap: break-word;
}

.dept-doctor-card__position {
  font-size: 0.8125rem;
  color: var(--color-muted);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: normal;
  overflow-wrap: break-word;
}

/* ---------- Gallery ---------- */

.dept-gallery {
  margin-top: 2rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--color-border);
}

.dept-gallery__title {
  font-size: 1.125rem;
  margin: 0 0 0.75rem;
  color: var(--color-text);
}

.dept-gallery__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

@media (min-width: 640px) {
  .dept-gallery__grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.dept-gallery__item {
  margin: 0;
}

.dept-gallery__link {
  display: block;
  text-decoration: none;
}

.dept-gallery__img-wrap {
  aspect-ratio: 3 / 2;
  border-radius: 10px;
  overflow: hidden;
  background: var(--color-surface);
}

.dept-gallery__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.dept-gallery__link:hover .dept-gallery__img {
  transform: scale(1.03);
}

.dept-gallery__link:focus-visible .dept-gallery__img-wrap {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

.dept-gallery__caption {
  font-size: 0.8125rem;
  color: var(--color-muted);
  margin-top: 0.375rem;
  text-align: center;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

/* ---------- Lightbox ---------- */

.dept-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10001;
}

.dept-lightbox.is-open {
  display: flex;
  align-items: center;
  justify-content: center;
}

.dept-lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
}

.dept-lightbox__container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 3rem 3.5rem;
}

.dept-lightbox__img-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 100%;
  overflow: hidden;
}

.dept-lightbox__img {
  max-width: 100%;
  max-height: calc(100vh - 8rem);
  max-height: calc(100dvh - 8rem);
  object-fit: contain;
  border-radius: 6px;
  user-select: none;
  -webkit-user-select: none;
}

/* Nav buttons */
.dept-lightbox__close,
.dept-lightbox__prev,
.dept-lightbox__next {
  position: absolute;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 0.75rem;
  border-radius: 50%;
  transition: background-color 0.2s ease;
  z-index: 1;
}

.dept-lightbox__close:hover,
.dept-lightbox__prev:hover,
.dept-lightbox__next:hover {
  background: rgba(255, 255, 255, 0.15);
}

.dept-lightbox__close:focus-visible,
.dept-lightbox__prev:focus-visible,
.dept-lightbox__next:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.dept-lightbox__close {
  position: fixed;
  top: 3rem;
  right: 3rem;
  z-index: 10002;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.dept-lightbox__prev {
  left: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
}

.dept-lightbox__next {
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
}

.dept-lightbox__close svg,
.dept-lightbox__prev svg,
.dept-lightbox__next svg {
  width: 1.75rem;
  height: 1.75rem;
}

/* Footer: counter + caption */
.dept-lightbox__footer {
  position: fixed;
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 10002;
  text-align: center;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.875rem;
  max-width: 80%;
  pointer-events: none;
}

.dept-lightbox__counter {
  display: block;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.dept-lightbox__caption {
  display: block;
  opacity: 0.8;
}

/* Scroll lock when lightbox is open */
.dept-lightbox-open {
  overflow: hidden;
}

/* Mobile: tighter padding */
@media (max-width: 640px) {
  .dept-lightbox__container {
    padding: 2.5rem 0.5rem;
  }
  .dept-lightbox__prev {
    left: 0.25rem;
  }
  .dept-lightbox__next {
    right: 0.25rem;
  }
  .dept-lightbox__prev svg,
  .dept-lightbox__next svg {
    width: 1.25rem;
    height: 1.25rem;
  }
  .dept-lightbox__close svg {
    width: 1.5rem;
    height: 1.5rem;
  }
}
