/* Topic viewer — Travel-style layout, VocabKit green/pink theme. */

.topic-view {
  flex: 1;
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 0;
}

/* ── Sidebar ──────────────────────────────────────── */
.topic-sidebar {
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  padding: var(--s-4) var(--s-3) var(--s-6);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
.sidebar-head {
  padding: var(--s-2) var(--s-3) var(--s-3);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--s-2);
}
.sidebar-head .badge { align-self: flex-start; }
.sidebar-title { font-size: var(--fs-xl); }

.ch-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
}
.ch-btn {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3);
  border-radius: var(--r-md);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  text-decoration: none;
  transition: background .15s, border-color .15s;
}
.ch-btn:hover {
  background: var(--surface);
  border-color: var(--border);
  text-decoration: none;
}
.ch-btn.active {
  background: var(--surface);
  border-color: var(--ch);
  box-shadow: var(--shadow-1);
}
.ch-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--ch);
  flex-shrink: 0;
}
.ch-info { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.ch-name {
  font-weight: 700;
  font-size: var(--fs-base);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ch-count {
  font-size: var(--fs-xs);
  color: var(--text-mute);
}

/* ── Right panel ──────────────────────────────────── */
.topic-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg);
}

.topic-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-4) var(--s-6);
  background: var(--surface);
  border-bottom: 3px solid var(--ch);
}
.panel-title { font-size: var(--fs-2xl); margin: 0; }
.panel-count {
  color: var(--text-mute);
  font-size: var(--fs-sm);
  font-weight: 700;
}

/* ── Body: image (left) + word column (right) ─────── */
.topic-panel-body {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  min-height: 0;
}

/* ── Image hero ───────────────────────────────────── */
.image-zone {
  position: relative;
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-4);
  min-height: 0;
  overflow: hidden;
}
.image-zone img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
}
.img-placeholder {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: var(--s-2);
  width: 100%; height: 100%;
  background:
    repeating-linear-gradient(135deg,
      var(--primary-bg) 0 24px,
      var(--accent-bg) 24px 48px);
  color: var(--text);
  border-radius: var(--r-md);
}
.ph-icon { font-size: 4rem; opacity: .45; }
.ph-label {
  font-size: var(--fs-2xl); font-weight: 800;
  letter-spacing: .04em;
  opacity: .55;
  text-align: center; padding: 0 var(--s-4);
}
.ph-hint { font-size: var(--fs-sm); color: var(--text-mute); }

/* ── Word column (right side of body) ─────────────── */
.word-column {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg);
}

/* ── Search row ───────────────────────────────────── */
.word-search-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.word-search {
  flex: 1;
  display: flex;
  align-items: center;
}
#wordSearch {
  width: 100%;
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text);
  font-size: var(--fs-base);
}
#wordSearch:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
}
.match-count { font-size: var(--fs-sm); }

/* ── Word grid (vertical list inside the right column) ─ */
.word-grid {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  overflow-y: auto;
  align-content: start;
}
.word-card {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-3) var(--s-4);
  text-align: left;
  color: var(--text);
  cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .15s;
}
.word-card:hover {
  border-color: var(--ch);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
.word-card.expanded {
  border-color: var(--ch);
  background: color-mix(in srgb, var(--ch) 6%, var(--surface));
}
.word-card.flash {
  animation: flash-pulse .6s ease-out;
}
@keyframes flash-pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ch) 60%, transparent); }
  100% { box-shadow: 0 0 0 14px transparent; }
}
.word-card.hidden { display: none; }

.wi-top {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}
.wi-word {
  font-size: var(--fs-lg);
  font-weight: 800;
  color: var(--ch);
}
.wi-type {
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-mute);
  background: var(--surface-2);
  padding: 2px 8px;
  border-radius: var(--r-full);
}
.wi-toggle {
  margin-left: auto;
  font-size: var(--fs-xs);
  color: var(--text-mute);
  transition: transform .2s;
}
.word-card.expanded .wi-toggle { transform: rotate(90deg); color: var(--ch); }

.wi-ex {
  display: block;
  font-size: var(--fs-sm);
  line-height: var(--lh-normal);
  color: var(--text);
  max-height: 0;
  overflow: hidden;
  margin-top: 0;
  transition: max-height .22s ease, margin-top .22s ease;
}
.word-card.expanded .wi-ex { max-height: 120px; margin-top: var(--s-2); }

.wi-ex b, .wi-ex mark, .wi-ex strong {
  background: transparent;
  color: var(--ch);
  font-weight: 800;
}

/* ── Bottom pill strip ────────────────────────────── */
.word-strip {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-6);
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-wrap: wrap;
}
.strip-label {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--text-mute);
  flex-shrink: 0;
}
.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}
.pill {
  padding: 2px 10px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: var(--fs-sm);
  color: var(--text);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.pill:hover {
  border-color: var(--ch);
  color: var(--ch);
}

/* ── Empty state ──────────────────────────────────── */
.empty-state {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: var(--s-3);
  color: var(--text-mute);
  padding: var(--s-12);
}
.es-icon { font-size: 4rem; opacity: .35; }

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 1100px) {
  /* Stack image above word list once the right column gets too narrow. */
  .topic-panel-body {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(220px, 40vh) 1fr;
  }
  .image-zone {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
}

@media (max-width: 900px) {
  .topic-view { grid-template-columns: 1fr; }
  .topic-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    max-height: 240px;
  }
  .topic-panel-header { padding: var(--s-3) var(--s-4); }
  .word-strip { padding: var(--s-3) var(--s-4); }
}

@media (max-width: 480px) {
  .panel-title { font-size: var(--fs-xl); }
  .wi-word { font-size: var(--fs-base); }
}
