/* Shared word-card, badge, and check-button styles */

.word-card {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 0.5rem;
  min-height: 180px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  padding: 0.75rem;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, opacity 0.25s;
}

.word-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 0;
  background: var(--muted);
  border-radius: 3px 0 0 3px;
  transition: height 0.08s ease-out;
}

.word-card.learned {
  opacity: 0.45;
}

.word-card.learned::after {
  height: 100%;
}

.card-top {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.card-top .check-btn {
  margin-left: auto;
}

.card-top .ghost-btn {
  margin-left: auto;
}

.card-top .ghost-btn ~ .check-btn {
  margin-left: 0;
}

.check-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: none;
  color: var(--line);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s, box-shadow 0.15s;
}

.check-btn:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--accent);
}

.check-btn.checked {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.card-body {
  display: grid;
  align-content: start;
  gap: 0.4rem;
}

.card-sentence {
  margin: 0;
  font-size: 0.85rem;
  color: var(--sentence);
  line-height: 1.4;
}
.card-sentence-translated {
  font-style: italic;
  font-size: 0.8rem;
  margin-top: 0.2rem;
  opacity: 0.75;
}

.sentence-word:not(.sentence-word-hidden) {
  color: var(--accent, #475569);
  font-weight: 600;
}

.sentence-word.sentence-word-hidden {
  color: transparent !important;
  border-bottom: 2px solid var(--accent, #475569);
  font-weight: 700;
  transition: color 0.15s ease;
}

.card-study-label {
  display: block;
  margin-top: auto;
  text-align: center;
  font-size: 0.5625rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: transparent;
  transition: color 0.2s;
}

.card-word {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.15;
}

/* The word is a real link for crawlers / a11y / open-in-new-tab, but should
   look identical to the surrounding card text. Whole-card click still works
   via the article's @click handler. */
.card-word a,
.list-item-word a {
  color: inherit;
  text-decoration: none;
}

.card-word a:hover,
.list-item-word a:hover {
  text-decoration: underline;
}

.card-transliteration {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
  font-style: italic;
}

/* Word images */
.card-image {
  max-width: 100%;
  max-height: 200px;
  object-fit: contain;
  border-radius: 6px;
  margin: 0.5rem 0;
}
.card-image.recall-hidden { opacity: 0; transition: opacity 0.15s; }
.card-image.redacted { filter: blur(12px); transition: filter 0.2s; }

.card-memory-hook {
  margin: 0.15rem 0 0.35rem;
  font-size: 0.8125rem;
  font-style: italic;
  color: var(--muted);
  text-align: center;
  line-height: 1.4;
}
.card-memory-hook.recall-hidden { opacity: 0; transition: opacity 0.15s; }

.card-thumb {
  width: 80px;
  height: 80px;
  object-fit: contain;
  border-radius: 4px;
  margin: 0.25rem auto;
}

.list-thumb {
  width: 28px;
  height: 28px;
  object-fit: cover;
  border-radius: 3px;
  vertical-align: middle;
  margin-right: 0.25rem;
}

.card-definition {
  margin: 0;
  font-size: var(--def-size, 0.85rem);
  color: var(--muted);
  line-height: 1.4;
}

.card-definition.recall-hidden {
  opacity: 0;
  transition: opacity 0.15s;
}

.def-pos {
  font-style: italic;
  font-size: 0.85em;
  opacity: 0.7;
}

.def-num {
  font-weight: 600;
  opacity: 0.5;
}

.def-sentence {
  display: block;
  font-style: italic;
  font-size: 0.8em;
  opacity: 0.7;
  margin: 0.1em 0 0.35em 1.2em;
  line-height: 1.4;
}

.check-btn-sm {
  width: 24px;
  height: 24px;
}

.check-btn-sm svg {
  width: 10px;
  height: 10px;
}

.set-badge,
.note-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.45rem;
  font-size: 0.6875rem;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--surface);
  color: var(--muted);
}

/* ---- Hover effects (desktop only) ---- */
/* Mobile browsers apply :hover on touch and keep it "sticky" until the user
   taps elsewhere. This breaks hold-to-reveal in study modes: after releasing
   a tap-hold, hover-based reveal rules (accent border, recall definitions,
   cloze sentence words) stay active, making hidden content visible even though
   the JS state has correctly reset. Wrapping in @media (hover: hover) restricts
   these rules to devices with a real pointer (mouse/trackpad), where :hover
   naturally clears on mouseout. */

@media (hover: hover) {
  .word-card:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(71, 85, 105, 0.08);
    z-index: 1;
  }

  .word-card.learned:hover {
    opacity: 1;
  }

  .check-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
  }

  .word-card:hover .card-study-label {
    color: var(--accent);
  }

  .word-card:hover .card-definition.recall-hidden {
    opacity: 1;
  }

  .card-sentence:hover .sentence-word.sentence-word-hidden,
  *:hover > .sentence-word.sentence-word-hidden {
    color: var(--accent, #475569) !important;
  }

  .word-list-item:hover {
    background: var(--surface);
  }

  .word-list-item.learned:hover {
    opacity: 1;
  }

  .word-list-item:hover .list-item-def.recall-hidden {
    opacity: 1;
  }
}

/* ---- Grid layout ---- */

/* ---- Section headers ---- */

.section-group + .section-group {
  margin-top: 1.25rem;
}

.section-header {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--line);
}

.section-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.section-count {
  font-size: 0.7rem;
  color: var(--muted);
  opacity: 0.7;
}

/* ---- Section filter chips ---- */

.section-filter-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-top: 0.35rem;
}

.section-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  font: inherit;
  font-size: 0.75rem;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.section-chip:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.section-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.section-chip-count {
  font-size: 0.65rem;
  opacity: 0.7;
}

.section-chip.active .section-chip-count {
  opacity: 0.85;
}

.word-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.5rem;
}

/* ---- List view ---- */

.word-list {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.word-list-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem 0.55rem 0.85rem;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.15s, opacity 0.25s;
}

.word-list-item:first-child {
  border-radius: 6px 6px 0 0;
}

.word-list-item:last-child {
  border-bottom: none;
  border-radius: 0 0 6px 6px;
}

.word-list-item:only-child {
  border-radius: 6px;
}

.word-list-item.learned {
  opacity: 0.45;
}

.list-item-content {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.list-item-top {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  min-width: 0;
}

.list-item-word {
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.2;
  flex-shrink: 0;
}

.list-item-transliteration {
  font-size: 0.75rem;
  color: var(--muted);
  font-style: italic;
  flex-shrink: 0;
}

.list-item-def {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.list-item-def.recall-hidden {
  opacity: 0;
  transition: opacity 0.15s;
}

.list-item-sentence {
  margin: 0;
  font-size: 0.8rem;
  color: var(--sentence, var(--muted));
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-item-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

/* ---- Empty state ---- */

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 6px;
  padding: 2rem;
  background: var(--panel);
  text-align: center;
}

.empty-state h2 {
  margin: 0 0 0.25rem;
  font-size: 1rem;
}

.empty-state p {
  margin: 0 0 0.75rem;
  color: var(--muted);
}

@media (max-width: 640px) {
  .list-item-def,
  .list-item-sentence {
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
  }
}
