/* ========================================= */
/* CHAPTER SELECTION PAGES */
/* ========================================= */

.chapters-wrap {
  min-height: 100vh;              /* Fill full screen height */
  background: var(--accent);
  display: grid;
  grid-template-columns: 120px 1fr 120px;
  align-items: stretch;           /* Stretch center area vertically */
}

.chapters-center {
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  gap: 150px;
  flex-direction: column;
  height: 100%;                   /* Fill available height */
  padding: 100px 0px;
}


/* Top-left Home button */
.chapters-topbar {
  width: 100%;
  display: flex;
  justify-content: flex-start;
}

.home-btn {
  display: inline-flex;
  align-items: left;
  gap: 0.5rem;
  padding: 10px 14px;
  border-radius: 12px;
  text-decoration: none;
  color: #fff;
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.35);
  backdrop-filter: blur(2px);
  box-shadow: var(--shadow);
  transition: transform .06s ease, background .15s ease, border-color .15s ease;
  font-weight: 700;
}
.home-btn:hover {
  transform: translateY(-1px);
  background: rgba(255,255,255,.26);
  border-color: rgba(255,255,255,.55);
}

/* Title */
.chapters-title {
  text-align: center;
  font-size: clamp(32px, 5vw, 68px);
  line-height: 1.05;
  color: #fff;
  text-shadow: 0 3px 20px rgba(0,0,0,.25);
  letter-spacing: .5px;
  font-weight: 800;
  margin: 0;
}

/* Cards */
.chapters-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  align-items: stretch;
  place-self: center;
}

.chapter-card {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  text-decoration: none;
  color: #111;
  transition: transform .08s ease, box-shadow .15s ease, background .15s ease;
  border: 1px solid rgba(0,0,0,.05);
}
.chapter-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 26px rgba(0,0,0,.25);
  background: #cecece;
}

.card-head {
  padding: 12px 14px;
  font-weight: 900;
  font-size: clamp(16px, 2vw, 22px);
  background: #e8e8e8;
  border-bottom: 1px solid rgba(0,0,0,.08);
  text-align: center;
}

.card-media {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #ddd;
  overflow: hidden;
}
.card-media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-body {
  padding: 12px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 auto;
}
.card-title {
  font-weight: 800;
  font-size: clamp(16px, 1.8vw, 20px);
  color: #222;
  margin: 0;
  text-align: center;
}
.card-desc {
  color: #333;
  line-height: 1.45;
  margin: 0;
  text-align: center;
}

/* Arrows */
.chapters-arrow {
  display: grid;
  place-items: center;
  height: 100%;
}
.arrow-btn {
  --size: 68px;
  width: var(--size);
  height: var(--size);
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(255,255,255,.25), rgba(255,255,255,.12));
  border: 1px solid rgba(255,255,255,.35);
  color: #fff;
  display: grid;
  place-items: center;
  text-decoration: none;
  backdrop-filter: blur(3px);
  box-shadow: 0 12px 30px rgba(0,0,0,.28);
  transition: transform .08s ease, box-shadow .15s ease, border-color .15s ease, background .15s ease;
}
.arrow-btn:hover {
  transform: translateY(-2px) scale(1.03);
  background: linear-gradient(145deg, rgba(255,255,255,.32), rgba(255,255,255,.18));
  border-color: rgba(255,255,255,.6);
  box-shadow: 0 14px 36px rgba(0,0,0,.32);
}
.arrow-icon {
  width: 28px;
  height: 28px;
  display: block;
}

/* Responsive */
@media (max-width: 1100px) {
  .chapters-wrap {
    grid-template-columns: 88px 1fr 88px;
  }
}
@media (max-width: 1000px) {
  .chapters-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 560px) {
  .chapters-wrap {
    grid-template-columns: 64px 1fr 64px;
  }
  .chapters-grid {
    grid-template-columns: 1fr;
  }
  .arrow-btn {
    --size: 56px;
  }
}

/* ========================================= */
/* POSITION HOME BUTTON ANYWHERE */
/* ========================================= */

.chapters-topbar {
  position: absolute;     /* Take out of normal layout */
  top: 40px;              /* Distance from top edge */
  left: 30px;             /* Distance from left edge */
  z-index: 10;            /* Keep it above everything else */
}

.home-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
