/* ASK v2.0.031.1 — Screen 2 reusable Topic Book template
   Scope: Screen 2 only. Home, shared shell, Screens 3-4, API, and navigation are unchanged. */

.screen[data-screen="category"] > .topic-book-screen {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  padding: 0 14px 6px;
  display: flex;
  flex-direction: column;
}

/* Hero is fully inside the content viewport so its rounded top edge and shadow cannot be clipped. */
.topic-book-hero {
  flex: 0 0 198px;
  min-height: 198px;
  margin: 0 -14px;
  padding: 0 18px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  background: linear-gradient(180deg, rgba(255,255,255,.06) 0%, rgba(255,255,255,.92) 100%);
}

.topic-book-image-tile {
  position: relative;
  z-index: 1;
  width: 112px;
  height: 112px;
  flex: 0 0 112px;
  margin: 0 0 5px;
  padding: 5px;
  border: 1px solid rgba(15,143,136,.12);
  border-radius: 17px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: rgba(255,255,255,.98);
  box-shadow: 0 7px 18px rgba(6,50,55,.075);
}

.topic-book-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 5px 8px rgba(6,50,55,.10));
}

.topic-book-hero h1 {
  margin: 0;
  font-size: 29px;
  line-height: 1.04;
  letter-spacing: -.025em;
  color: var(--text);
}

/* Screen 2 introductions use one fixed two-line text area on every topic. */
.topic-book-hero p {
  width: min(100%, 330px);
  height: calc(2 * 1.35em);
  margin: 7px auto 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  line-height: 1.35;
  color: var(--muted);
  overflow: hidden;
}

/* Shared Screen 2 instruction uses the practice theme color, not a topic-specific color. */
.topic-book-bridge {
  flex: 0 0 28px;
  width: 100%;
  margin: 2px 0 6px;
  display: grid;
  grid-template-columns: minmax(24px,1fr) auto minmax(24px,1fr);
  align-items: center;
  gap: 11px;
  color: var(--teal-dark);
  font-size: 15px;
  line-height: 1;
  font-weight: 800;
  text-align: center;
}

.topic-book-bridge::before,
.topic-book-bridge::after {
  content: "";
  height: 2px;
  border-radius: 999px;
  background: var(--teal);
  opacity: .9;
}

.topic-book-list {
  flex: 0 0 auto;
  display: grid;
  grid-template-rows: repeat(5, 66px);
  gap: 9px;
}

.topic-book-card,
.did-you-know-card {
  width: 100%;
  min-height: 66px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 7px 13px;
  display: grid;
  grid-template-columns: 44px minmax(0,1fr) 18px;
  align-items: center;
  gap: 10px;
  text-align: left;
  background: #fff;
  color: var(--text);
  box-shadow: 0 5px 14px rgba(6,50,55,.045);
}

.topic-book-icon,
.did-you-know-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: #fff4ed;
  font-size: 21px;
  line-height: 1;
}

.topic-book-copy,
.did-you-know-copy {
  min-width: 0;
}

.topic-book-copy strong {
  display: block;
  margin: 0 0 3px;
  color: var(--text);
  font-size: 15px;
  line-height: 1.08;
  letter-spacing: 0;
  font-weight: 800;
}

.topic-book-copy small {
  display: block;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.2;
  font-weight: 400;
  white-space: normal;
  overflow: visible;
}

.did-you-know-card {
  flex: 0 0 66px;
  margin-top: 8px;
  margin-bottom: 2px;
  grid-template-columns: 44px minmax(0,1fr);
  border-color: rgba(15,143,136,.28);
  background: linear-gradient(135deg,#fbfffe 0%,#e8f7f5 100%);
}

.did-you-know-icon {
  background: #dff3ef;
}

.did-you-know-copy strong {
  display: block;
  margin: 0 0 3px;
  color: var(--teal-dark);
  font-size: 11px;
  line-height: 1.08;
  letter-spacing: .10em;
  font-weight: 900;
}

.did-you-know-copy small {
  display: block;
  color: #27434d;
  font-size: 10.5px;
  line-height: 1.2;
  font-weight: 400;
  white-space: normal;
  overflow: visible;
}

.topic-book-screen .knowledge-answer[hidden] {
  display: none;
}

/* Typical installed-phone and tablet usable heights. Keep the complete template on one screen. */
@media (max-height: 820px) {
  .screen[data-screen="category"] > .topic-book-screen {
    padding: 0 12px 3px;
  }

  .topic-book-hero {
    flex-basis: 142px;
    min-height: 142px;
    margin: 0 -12px;
    padding: 0 15px 3px;
  }

  .topic-book-image-tile {
    width: 76px;
    height: 76px;
    flex-basis: 76px;
    margin-bottom: 2px;
    padding: 3px;
    border-radius: 14px;
  }

  .topic-book-hero h1 {
    font-size: 24px;
  }

  .topic-book-hero p {
    width: min(100%, 300px);
    height: calc(2 * 1.22em);
    margin-top: 3px;
    font-size: 12px;
    line-height: 1.22;
  }

  .topic-book-bridge {
    flex-basis: 24px;
    margin: 2px 0 4px;
    gap: 8px;
    font-size: 13px;
  }

  .topic-book-list {
    grid-template-rows: repeat(5, 50px);
    gap: 5px;
  }

  .topic-book-card,
  .did-you-know-card {
    min-height: 50px;
    border-radius: 14px;
    padding: 4px 10px;
    grid-template-columns: 36px minmax(0,1fr) 16px;
    gap: 8px;
  }

  .topic-book-icon,
  .did-you-know-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: 17px;
  }

  .topic-book-copy strong {
    margin-bottom: 1px;
    font-size: 13.3px;
  }

  .topic-book-copy small,
  .did-you-know-copy small {
    font-size: 9.1px;
    line-height: 1.15;
  }

  .did-you-know-card {
    flex-basis: 50px;
    margin-top: 4px;
    margin-bottom: 1px;
    grid-template-columns: 36px minmax(0,1fr);
  }

  .did-you-know-copy strong {
    margin-bottom: 1px;
    font-size: 9.8px;
  }
}

/* Extra-short usable heights, including Android tablet taskbars. */
@media (max-height: 700px) {
  .screen[data-screen="category"] > .topic-book-screen {
    padding-top: 2px;
    padding-bottom: 3px;
  }

  .topic-book-hero {
    flex-basis: 124px;
    min-height: 124px;
    padding-bottom: 2px;
  }

  .topic-book-image-tile {
    width: 68px;
    height: 68px;
    flex-basis: 68px;
    margin-bottom: 1px;
  }

  .topic-book-hero h1 {
    font-size: 22px;
  }

  .topic-book-hero p {
    width: min(100%, 290px);
    height: calc(2 * 1.18em);
    margin-top: 2px;
    font-size: 11.2px;
    line-height: 1.18;
  }

  .topic-book-bridge {
    flex-basis: 22px;
    margin-top: 2px;
    margin-bottom: 4px;
    font-size: 12.5px;
  }

  .topic-book-list {
    grid-template-rows: repeat(5, 47px);
    gap: 4px;
  }

  .topic-book-card,
  .did-you-know-card {
    min-height: 47px;
    padding-top: 3px;
    padding-bottom: 3px;
  }

  .topic-book-copy strong {
    font-size: 12.8px;
  }

  .topic-book-copy small,
  .did-you-know-copy small {
    font-size: 8.8px;
  }

  .did-you-know-card {
    flex-basis: 47px;
    margin-top: 4px;
    margin-bottom: 0;
  }
}
