/* "All topics" browser for IELTS Writing.
   Own file — style.css is at its ceiling (see the file-size guard). */

/* The way in.

   This began as an outline pill the same weight as Reset and was, fairly, not
   noticed — it looked like another small control in a row of small controls, and
   nothing about it suggested a list of 107 topics sat behind it. Solid fill, the
   accent colour, an icon and the count. `margin-left: auto` matters as much as the
   colour: .writing2-topichead is space-between, so a third child lands stranded in
   the middle of the row; this pushes it over to sit beside Reset as a pair. */
.wtb-open-btn {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 0;
  border-radius: 10px;
  padding: 9px 14px;
  background: #4f46e5;
  color: #fff;
  font: inherit;
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.16);
}

.wtb-open-btn:hover {
  background: #4338ca;
}

.wtb-open-btn:active {
  transform: translateY(1px);
}

.wtb-open-ico {
  flex: none;
  fill: currentColor;
  opacity: 0.9;
}

/* Reads "Browse all topics" until the count lands, then "Browse 107 topics" —
   never a flash of "Browse 0 topics" if the banks are slow or missing. */
.wtb-open-n {
  font-variant-numeric: tabular-nums;
}

@media (max-width: 560px) {
  .wtb-open-btn {
    padding: 8px 11px;
    font-size: 13.5px;
  }
}

.wtb-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px;
  background: rgba(15, 23, 42, 0.55);
  overflow-y: auto;
}

body.wtb-open {
  overflow: hidden;
}

.wtb-card {
  width: min(920px, 100%);
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
  overflow: hidden;
}

.wtb-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid #e2e8f0;
}

.wtb-tabs {
  display: flex;
  gap: 8px;
}

.wtb-tab {
  border: 0;
  border-radius: 10px;
  padding: 9px 14px;
  background: #eff6ff;
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  color: #0f172a;
  cursor: pointer;
}

.wtb-tab.is-on {
  background: #93c5fd;
  box-shadow: inset 0 0 0 2px #1d4ed8;
}

.wtb-close {
  border: 0;
  background: transparent;
  font-size: 26px;
  line-height: 1;
  padding: 2px 8px;
  color: #475569;
  cursor: pointer;
}

.wtb-close:hover {
  color: #0f172a;
}

.wtb-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px 6px;
}

.wtb-search {
  flex: 1 1 auto;
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font: inherit;
  font-size: 15px;
}

.wtb-count {
  flex: none;
  font-size: 13px;
  font-weight: 700;
  color: #475569;
}

.wtb-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 16px 12px;
  border-bottom: 1px solid #e2e8f0;
}

.wtb-chip {
  border: 0;
  border-radius: 999px;
  padding: 6px 12px;
  background: #f1f5f9;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: #0f172a;
  cursor: pointer;
}

.wtb-chip.is-on {
  background: #1d4ed8;
  color: #fff;
}

.wtb-n {
  opacity: 0.65;
  font-weight: 700;
  margin-left: 4px;
}

.wtb-list {
  list-style: none;
  margin: 0;
  padding: 8px;
  overflow-y: auto;
  flex: 1 1 auto;
}

.wtb-item + .wtb-item {
  margin-top: 6px;
}

.wtb-pick {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 12px;
  background: #f8fafc;
  font: inherit;
  cursor: pointer;
}

.wtb-pick:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
}

/* Task 1 topics are pictures first — the chart is the question. */
.wtb-thumb {
  flex: none;
  width: 92px;
  height: 62px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  background: #fff;
}

.wtb-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.wtb-type {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #1d4ed8;
}

.wtb-text {
  font-size: 14.5px;
  line-height: 1.45;
  color: #0f172a;
}

.wtb-empty {
  padding: 24px 16px;
  text-align: center;
  color: #475569;
}

@media (max-width: 640px) {
  .wtb-overlay {
    padding: 0;
  }

  .wtb-card {
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
  }

  .wtb-thumb {
    width: 68px;
    height: 48px;
  }

  .wtb-text {
    font-size: 14px;
  }
}
