:root {
  --home-text: #263341;
  --home-muted: #64748b;
  --home-container: 1720px;
}

.home-hero {
  position: relative;
  overflow: hidden;
  width: 100%;
  height: clamp(300px, calc(100vw * 500 / 1920), 560px);
  min-height: 280px;
  background: #c7f0fb;
}

.home-banner-track {
  position: absolute;
  inset: 0;
}

.home-banner-slide {
  position: absolute;
  inset: 0;
  display: block;
  opacity: 0;
  background-position: center center;
  background-size: cover;
  background-repeat: no-repeat;
  pointer-events: none;
  transition: opacity 900ms ease;
  will-change: opacity;
}

.home-banner-slide.is-active {
  opacity: 1;
  pointer-events: auto;
}

.home-section {
  position: relative;
  overflow: hidden;
  min-height: clamp(560px, calc(100vw * 585 / 1920), 650px);
  padding: 96px 24px 40px;
  background-position: center top;
  background-size: 100% 100%;
  background-repeat: no-repeat;
}

.home-section.is-blue {
  background-image: url("../img/teacher-home/section-blue.png");
}

.home-section.is-gray {
  background-image: url("../img/teacher-home/section-gray.png");
}

.home-inner {
  max-width: var(--home-container);
  margin: 0 auto;
}

.section-head {
  display: flex;
  width: min(100%, 1160px);
  align-items: center;
  justify-content: space-between;
  margin: 0 auto 24px;
}

.section-title {
  margin: 0;
  color: #2e3b48;
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
}

.section-title-group,
.section-head-actions {
  display: flex;
  align-items: center;
}

.section-title-group {
  min-width: 0;
  gap: 12px;
}

.section-head-actions {
  gap: 16px;
}

.section-count {
  display: inline-flex;
  min-height: 28px;
  flex: 0 0 auto;
  align-items: center;
  gap: 3px;
  padding: 4px 10px;
  border: 1px solid rgba(16, 153, 189, 0.2);
  border-radius: 999px;
  color: #168eac;
  background: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  line-height: 1;
  box-shadow: 0 4px 12px rgba(23, 91, 111, 0.07);
}

.section-count-value {
  min-width: 1.3ch;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.section-count.is-counting {
  animation: shelf-count-in 560ms ease-out;
}

.shelf-progress {
  min-width: 74px;
  color: #74818d;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

@keyframes shelf-count-in {
  0% { opacity: 0.45; transform: translateY(4px); }
  100% { opacity: 1; transform: translateY(0); }
}

.view-all {
  color: #52606d;
  font-size: 14px;
  text-decoration: none;
}

.view-all:hover,
.view-all:focus-visible {
  color: #1099bd;
  outline: none;
}

.shelf-stage {
  position: relative;
  --cover-width: clamp(265px, 14.7vw, 300px);
  --cover-height: calc(var(--cover-width) * 422 / 340);
  --shelf-overlap: 26px;
  --title-offset: 58px;
  width: min(100%, 1360px);
  margin: 0 auto;
  padding: 0 52px 58px;
}

.book-grid {
  position: relative;
  z-index: 2;
  display: flex;
  gap: 24px;
  overflow-x: auto;
  overflow-y: hidden;
  align-items: flex-end;
  transform: translateY(14px);
  scroll-behavior: smooth;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  cursor: grab;
  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
}

.book-grid::-webkit-scrollbar {
  display: none;
}

.book-grid.is-dragging {
  scroll-behavior: auto;
  scroll-snap-type: none;
  cursor: grabbing;
  user-select: none;
}

.book-item {
  display: flex;
  min-width: 0;
  flex: 0 0 calc((100% - 72px) / 4);
  flex-direction: column;
  align-items: center;
  scroll-snap-align: start;
}

.book-link {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.book-cover {
  width: min(100%, var(--cover-width));
  max-width: var(--cover-width);
  aspect-ratio: 340 / 422;
  object-fit: contain;
  filter: drop-shadow(0 18px 16px rgba(24, 37, 57, 0.16));
  transform: translateY(0);
  transition: transform 180ms ease, filter 180ms ease;
}

.book-item:hover .book-cover {
  transform: translateY(-8px);
  filter: drop-shadow(0 24px 22px rgba(24, 37, 57, 0.2));
}

.book-title {
  margin-top: var(--title-offset);
  color: #5b6470;
  font-size: 15px;
  line-height: 1.4;
  text-align: center;
  white-space: nowrap;
}

.shelf-image {
  position: absolute;
  z-index: 1;
  top: calc(var(--cover-height) - var(--shelf-overlap));
  left: 50%;
  width: min(100%, 1370px);
  max-width: none;
  transform: translateX(-50%);
  pointer-events: none;
  user-select: none;
}

.shelf-nav {
  position: absolute;
  z-index: 4;
  top: 195px;
  display: inline-flex;
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  padding: 0 0 3px;
  border: 1px solid rgba(16, 153, 189, 0.2);
  border-radius: 50%;
  color: #168eac;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 8px 24px rgba(23, 91, 111, 0.18);
  font-family: Arial, sans-serif;
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
  transform: translateY(-50%);
  transition: color 160ms ease, background-color 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.shelf-nav:hover:not(:disabled),
.shelf-nav:focus-visible {
  color: #fff;
  background: #1099bd;
  box-shadow: 0 10px 26px rgba(16, 153, 189, 0.28);
  outline: none;
}

.shelf-nav:disabled {
  opacity: 0.32;
  cursor: default;
  box-shadow: none;
}

.shelf-nav[hidden] {
  display: none;
}

.shelf-nav.is-prev {
  left: 2px;
}

.shelf-nav.is-next {
  right: 2px;
}

@media (max-width: 1100px) {
  .home-section {
    min-height: 520px;
    padding: 78px 20px 44px;
  }

  .section-head {
    width: min(100%, 820px);
    margin-bottom: 28px;
  }

  .shelf-stage {
    --cover-width: clamp(185px, 20vw, 224px);
    --shelf-overlap: 22px;
    --title-offset: 58px;
    padding-right: 44px;
    padding-bottom: 60px;
    padding-left: 44px;
  }

  .book-grid {
    gap: 16px;
  }

  .book-item {
    flex-basis: calc((100% - 48px) / 4);
  }

  .shelf-nav {
    top: 145px;
    width: 38px;
    height: 38px;
    font-size: 28px;
  }
}

@media (max-width: 760px) {
  .home-hero {
    height: clamp(210px, calc(100vw * 500 / 1920), 260px);
    min-height: 210px;
  }

  .home-section {
    padding: 46px 16px 38px;
  }

  .section-head {
    margin-bottom: 28px;
  }

  .section-title {
    font-size: 25px;
  }

  .section-title-group {
    gap: 8px;
  }

  .section-head-actions {
    gap: 10px;
  }

  .section-count {
    min-height: 25px;
    padding: 3px 8px;
    font-size: 12px;
  }

  .shelf-progress {
    min-width: 62px;
    font-size: 12px;
  }

  .shelf-stage {
    padding: 0 36px 40px;
  }

  .book-grid {
    gap: 16px;
  }

  .book-item {
    flex-basis: calc((100% - 16px) / 2);
  }

  .shelf-image {
    display: none;
  }

  .book-cover {
    max-width: 170px;
  }

  .book-title {
    margin-top: 14px;
    font-size: 14px;
    white-space: normal;
  }

  .shelf-nav {
    top: 104px;
    width: 32px;
    height: 32px;
    font-size: 24px;
  }

  .shelf-nav.is-prev {
    left: 0;
  }

  .shelf-nav.is-next {
    right: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .book-grid {
    scroll-behavior: auto;
  }

  .book-cover,
  .shelf-nav {
    transition: none;
  }

  .section-count.is-counting {
    animation: none;
  }
}
