/* ── Shared buttons & links ─────────────────────────────────────────────── */
.scan-link,
.scan-viewer-button,
.scan-modal__button,
.scan-modal__close,
.scan-card__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 0;
  border-radius: 999px;
  padding: 0.72rem 1rem;
  color: #253044;
  background: #fff;
  box-shadow: 0 8px 18px rgba(37, 48, 68, 0.12);
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.scan-viewer-button,
.scan-card__button {
  color: #fff;
  background: linear-gradient(135deg, #1d74b7, #227a58);
}

.scan-link:hover,
.scan-viewer-button:hover,
.scan-modal__button:hover,
.scan-modal__close:hover,
.scan-card__button:hover,
.scan-link:focus-visible,
.scan-viewer-button:focus-visible,
.scan-modal__button:focus-visible,
.scan-modal__close:focus-visible,
.scan-card__button:focus-visible {
  outline: 3px solid rgba(29, 116, 183, 0.25);
  transform: translateY(-1px);
}

/* ── Sticky chapter nav ─────────────────────────────────────────────────── */
.scan-nav {
  position: sticky;
  top: 0;
  z-index: 25;
  border-bottom: 1px solid rgba(37, 48, 68, 0.1);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
}

.scan-nav__inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 10px 22px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
}

.scan-nav__links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ── Scan modal ─────────────────────────────────────────────────────────── */
.scan-modal[hidden] {
  display: none;
}

.scan-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  grid-template-rows: auto 1fr auto;
  color: #fff;
  background: rgba(13, 18, 28, 0.94);
}

.scan-modal__header,
.scan-modal__footer {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 14px clamp(14px, 3vw, 28px);
  background: rgba(0, 0, 0, 0.28);
}

.scan-modal__title {
  margin: 0;
  font-size: clamp(1rem, 3vw, 1.35rem);
}

.scan-modal__meta {
  color: rgba(255, 255, 255, 0.75);
  font-weight: 700;
}

.scan-modal__controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.scan-modal__button,
.scan-modal__close {
  min-width: 44px;
  min-height: 44px;
  padding: 0.6rem 0.85rem;
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  box-shadow: none;
}

.scan-modal__button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.scan-modal__stage {
  min-height: 0;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: clamp(12px, 3vw, 28px);
}

.scan-modal__image {
  display: block;
  max-width: min(100%, 1100px);
  max-height: 100%;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  transform-origin: center center;
  transition: transform 160ms ease;
}

.scan-modal__filmstrip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px clamp(14px, 3vw, 28px);
  background: rgba(0, 0, 0, 0.2);
}

.scan-modal__thumb {
  flex: 0 0 auto;
  width: 54px;
  height: 70px;
  border: 2px solid transparent;
  border-radius: 8px;
  padding: 0;
  overflow: hidden;
  background: #fff;
  cursor: pointer;
}

.scan-modal__thumb[aria-current="true"] {
  border-color: #f7941d;
}

.scan-modal__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ── Landing pages (book index + chapter grid) ──────────────────────────── */
.scan-landing {
  margin: 0;
  color: #253044;
  background:
    radial-gradient(circle at top left, rgba(247, 148, 29, 0.25), transparent 32rem),
    linear-gradient(135deg, #fff6e8 0%, #eef6fb 58%, #f8f1f5 100%);
  font-family: "Segoe UI", Arial, sans-serif;
  line-height: 1.56;
}

.scan-landing__hero,
.scan-landing__main {
  max-width: 1160px;
  margin: 0 auto;
  padding: 44px 22px 16px;
}

.scan-landing__hero h1 {
  margin: 0 0 12px;
  font-size: clamp(2.4rem, 8vw, 5rem);
  line-height: 0.95;
  letter-spacing: -0.06em;
  text-transform: uppercase;
}

.scan-landing__hero p {
  max-width: 760px;
  color: #667085;
  font-size: 1.15rem;
}

.scan-landing__hero .scan-link {
  font-size: 0.95rem;
}

/* ── Card grid ──────────────────────────────────────────────────────────── */
.scan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 22px;
  padding-bottom: 64px;
}

.scan-card {
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 18px 45px rgba(37, 48, 68, 0.12);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.scan-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 26px 60px rgba(37, 48, 68, 0.17);
}

.scan-card__preview {
  position: relative;
  height: 210px;
  background: #e8f4fc;
  overflow: hidden;
}

.scan-card__preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.scan-card__badge {
  position: absolute;
  top: 12px;
  left: 12px;
  border-radius: 999px;
  padding: 0.38rem 0.7rem;
  color: #fff;
  background: rgba(37, 48, 68, 0.84);
  font-size: 0.84rem;
  font-weight: 900;
}

.scan-card__body {
  display: grid;
  gap: 12px;
  padding: 20px;
}

.scan-card__body h2 {
  margin: 0;
  font-size: 1.45rem;
}

.scan-card__body p {
  margin: 0;
  color: #667085;
}

.scan-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

/* ── Library section headings ───────────────────────────────────────────── */
.book-section {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 22px 64px;
}

.book-section + .book-section {
  padding-top: 8px;
}

.book-section__heading {
  margin: 0 0 8px;
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 900;
  letter-spacing: -0.04em;
  text-transform: uppercase;
  color: #1d74b7;
  line-height: 1;
}

.book-section__title {
  margin: 0 0 24px;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #667085;
}

/* ── Root library (book covers) ─────────────────────────────────────────── */
.book-library {
  min-height: 100vh;
  margin: 0;
  color: #253044;
  background:
    radial-gradient(circle at top right, rgba(29, 116, 183, 0.18), transparent 36rem),
    linear-gradient(160deg, #f0f7ff 0%, #fff8f0 55%, #f5f0fa 100%);
  font-family: "Segoe UI", Arial, sans-serif;
  line-height: 1.56;
}

.book-library__hero {
  max-width: 1160px;
  margin: 0 auto;
  padding: 56px 22px 24px;
}

.book-library__hero h1 {
  margin: 0 0 12px;
  font-size: clamp(2.8rem, 9vw, 6rem);
  line-height: 0.92;
  letter-spacing: -0.06em;
  text-transform: uppercase;
}

.book-library__hero p {
  max-width: 660px;
  color: #667085;
  font-size: 1.15rem;
  margin: 0;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 28px;
}

.book-card {
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 14px 40px rgba(37, 48, 68, 0.11);
  text-decoration: none;
  color: inherit;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.book-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 24px 56px rgba(37, 48, 68, 0.18);
}

.book-card__cover {
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: #dde8f0;
}

.book-card__cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.book-card__body {
  padding: 16px 18px 20px;
}

.book-card__body h2 {
  margin: 0 0 2px;
  font-size: 1.05rem;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.book-card__body p {
  margin: 0;
  color: #667085;
  font-size: 0.88rem;
  font-weight: 600;
}

/* ── Placeholder chapter page ───────────────────────────────────────────── */
.placeholder-page {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 64px);
  padding: 40px 22px;
  text-align: center;
}

.placeholder-page h1 {
  margin: 0 0 16px;
  font-size: clamp(2rem, 6vw, 3.5rem);
  letter-spacing: -0.04em;
  text-transform: uppercase;
}

.placeholder-page p {
  max-width: 520px;
  color: #667085;
  font-size: 1.1rem;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .scan-modal__footer {
    align-items: stretch;
  }

  .scan-modal__controls,
  .scan-modal__button {
    flex: 1 1 auto;
  }

  .scan-modal__filmstrip {
    display: none;
  }
}

@media print {
  .scan-nav,
  .scan-modal {
    display: none !important;
  }
}
