:root {
  --teacher-card-bg: rgba(255, 255, 255, 0.55);
}

.teachers-section {
  padding: var(--space-2xl) 0;
  background: linear-gradient(180deg, rgba(247,239,227,0.16) 0%, rgba(255,255,255,0) 100%);
  overflow-x: hidden;
}

.teachers-container {
  display: flex;
  flex-direction: column;
}

.teachers-heading {
  text-align: center;
  margin-bottom: var(--space-lg);
}

/* Explicit section-tag styling for teachers section */
.teachers .section-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0 0 0.8rem;
  padding: 0.38rem 0.8rem;
  border: 1px solid rgba(216, 192, 154, 0.7);
  border-radius: var(--radius-full);
  background: rgba(233, 217, 184, 0.14);
  color: var(--color-accent-dark);
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.45);
}

.teachers-toolbar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
  margin-bottom: var(--space-lg);
}

.teacher-search {
  position: relative;
  width: 100%;
  max-width: 380px;
}

.teacher-search input {
  width: 100%;
  padding: 0.85rem 1rem 0.85rem 2.75rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: rgba(255,255,255,0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-family: inherit;
  transition: border-color var(--t-fast);
  color: var(--color-text);
}

.teacher-search input:focus {
  border-color: var(--color-accent-dark);
  outline: none;
}

.teacher-search i {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-dim);
  pointer-events: none;
}

.teachers-filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.filter-chip {
  position: relative;
  padding: 0.5rem 1.2rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: rgba(255,255,255,0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: var(--fs-sm);
  transition: color var(--t-fast), transform var(--t-fast);
  color: var(--color-text-muted);
  overflow: hidden;
}

.filter-chip::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--gradient-accent);
  opacity: 0;
  transition: opacity var(--t-fast);
  z-index: 0;
}

.filter-chip > * {
  position: relative;
  z-index: 1;
  display: inline-flex;
}

.filter-chip.active,
.filter-chip:hover,
.filter-chip:focus-visible {
  color: #3d342b;
  transform: translateY(-1px);
}

.filter-chip span {
  color: inherit;
}

.filter-chip.active::after,
.filter-chip:hover::after,
.filter-chip:focus-visible::after {
  opacity: 1;
}

.filter-chip.active {
  border-color: transparent;
}

.teachers-carousel-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding: 0.5rem 0 1.5rem;
  margin: 0 -20px;
  padding-inline: 20px;
  scrollbar-width: none;
}

.teachers-carousel-wrap::-webkit-scrollbar {
  display: none;
}

.teachers-carousel {
  display: flex;
  gap: 1rem;
  align-items: stretch;
  width: max-content;
  min-height: 350px;
}

.teacher-card {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  width: clamp(140px, 38vw, 200px);
  height: auto;
  min-height: 0;
  scroll-snap-align: start;
  background: rgba(255,255,255,0.55);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border: 1px solid rgba(255,255,255,0.6);
  border-radius: 28px;
  overflow: hidden;
  cursor: pointer;
  transition: opacity 0.35s var(--ease), transform 0.35s var(--ease);
  will-change: transform, opacity;
}

@media (max-width: 434px) {
  .teacher-card {
    width: clamp(155px, 42vw, 180px);
    flex-shrink: 0;
  }
}

.teacher-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transition: opacity var(--t-fast);
  pointer-events: none;
}

.teacher-card:hover::after,
.teacher-card:focus-visible::after,
.teacher-card:active::after {
  opacity: 1;
}

.teacher-card:hover,
.teacher-card:focus-visible,
.teacher-card:active {
  transform: translateY(-4px) scale(1.02);
}

.teacher-card.is-hidden {
  opacity: 0;
  visibility: hidden;
  transform: scale(0.92);
  pointer-events: none;
}

.teacher-card-media {
  position: relative;
  aspect-ratio: 3 / 3.4;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 24px 24px 0 0;
  background: var(--color-surface-2);
}

@media (min-width: 470px) and (max-width: 768px) {
  .teacher-card-media {
    aspect-ratio: 3 / 3.6;
  }
}

@media (max-width: 434px) {
  .teacher-card-media {
    aspect-ratio: 3 / 3.2;
  }
}

.teacher-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 15%;
  display: block;
}

.teacher-founder-badge {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: var(--gradient-accent);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.65rem;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
  color: #3d342b;
}

.teacher-card-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 0.85rem 0.9rem;
  gap: 0.3rem;
}

@media (max-width: 600px) {
  .teacher-card-body {
    padding: 0.8rem 0.85rem;
  }
}

.teacher-card-body h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
  min-height: calc(1.3 * 0.95rem * 2);
}

@media (max-width: 480px) {
  .teacher-card-body h3 {
    font-size: 0.9rem;
    line-height: 1.25;
    min-height: calc(1.25 * 0.9rem * 2);
  }
}

.teacher-specialty {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
  font-size: 0.75rem;
  color: var(--color-accent-dark);
  line-height: 1.5;
  min-height: calc(1.5 * 0.75rem * 2);
  word-break: break-word;
}

@media (max-width: 480px) {
  .teacher-specialty {
    font-size: 0.72rem;
    line-height: 1.4;
    -webkit-line-clamp: 1;
    min-height: calc(1.4 * 0.72rem * 1);
  }
}

.scroll-hint {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 0.5rem;
}

.scroll-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-border);
  transition: opacity 0.3s ease, background 0.3s ease;
}

.scroll-dot.active {
  background: var(--gradient-accent);
}

.teachers-empty {
  text-align: center;
  color: var(--color-text-dim);
  padding: 2rem 0;
}

.teacher-panel {
  position: fixed;
  inset: 0;
  z-index: 2000;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-normal), visibility var(--t-normal);
  overflow: hidden;
}

.teacher-panel.active {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.panel-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(31, 27, 23, 0.5);
  backdrop-filter: blur(4px);
}

.teacher-panel-content {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--color-bg);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  max-height: 88vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.5rem;
  transform: translateY(100%);
  transition: transform var(--t-normal) var(--ease);
  box-shadow: 0 -10px 32px rgba(31, 27, 23, 0.14);
}

.teacher-panel.active .teacher-panel-content {
  transform: translateY(0);
}

.panel-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 253, 250, 0.98);
  color: var(--color-text);
  font-size: 1.35rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(31, 27, 23, 0.1);
  border: none;
  cursor: pointer;
}

.panel-close i {
  font-size: 1.2rem;
  line-height: 1;
}

.teacher-panel-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

#teacherPanelBody {
  display: block;
}

.panel-teacher-media {
  width: 100%;
  aspect-ratio: 4 / 5;
  max-height: 45vh;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--color-surface-2);
  flex: 0 0 auto;
  margin: 0;
}

.panel-teacher-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
}

.panel-teacher-info {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}

.panel-badge {
  display: inline-flex;
  align-items: flex-start;
  width: fit-content;
  max-width: 100%;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-md);
  background: var(--gradient-accent);
  color: #3d342b;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.5;
  white-space: normal !important;
  word-break: break-word;
  overflow-wrap: break-word;
  box-shadow: var(--shadow-sm);
}

.panel-teacher-info h3 {
  margin: 0;
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.2;
}

.panel-specialty {
  margin: 0;
  color: var(--color-accent-dark);
  font-size: var(--fs-base);
  font-weight: 600;
  line-height: 1.5;
  overflow-wrap: break-word;
}

.panel-bio-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.panel-bio-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid rgba(31, 27, 23, 0.06);
  color: var(--color-text-muted);
  font-size: 0.95rem;
  line-height: 1.7;
}

.panel-bio-list li::before {
  content: "✓";
  color: var(--color-accent-dark);
  font-weight: 700;
  flex: 0 0 auto;
  margin-top: 0.05rem;
}

@media (min-width: 768px) and (max-width: 1023px) {
  .teacher-panel-content {
    position: fixed;
    top: 50%;
    left: 50%;
    right: auto;
    bottom: auto;
    transform: translate(-50%, -50%) scale(0.92);
    width: min(90vw, 600px);
    max-height: 85vh;
    border-radius: var(--radius-lg);
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 0;
    padding: 0;
    overflow: hidden;
  }

  .teacher-panel.active .teacher-panel-content {
    transform: translate(-50%, -50%) scale(1);
  }

  #teacherPanelBody,
  .teacher-panel-body {
    display: contents;
  }

  .panel-teacher-media {
    height: 100%;
    max-height: none;
    aspect-ratio: auto;
    border-radius: 0;
  }

  .panel-teacher-info {
    padding: 2rem;
    overflow-y: auto;
    max-height: 85vh;
  }
}

@media (min-width: 1024px) {
  .teacher-panel-content {
    position: fixed;
    top: 50%;
    left: 50%;
    right: auto;
    bottom: auto;
    transform: translate(-50%, -50%) scale(0.92);
    width: min(1100px, 90vw);
    max-height: 85vh;
    border-radius: var(--radius-lg);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    padding: 0;
    overflow: hidden;
  }

  .teacher-panel.active .teacher-panel-content {
    transform: translate(-50%, -50%) scale(1);
  }

  #teacherPanelBody,
  .teacher-panel-body {
    display: contents;
  }

  .panel-teacher-media {
    height: 100%;
    max-height: none;
    aspect-ratio: auto;
    border-radius: 0;
  }

  .panel-teacher-info {
    padding: 2rem;
    overflow-y: auto;
    max-height: 85vh;
  }
}
