/* 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: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;
}

.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:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.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;
}

.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-sentence:hover .sentence-word.sentence-word-hidden,
*:hover > .sentence-word.sentence-word-hidden {
  color: var(--accent, #475569) !important;
}

.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;
}

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

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

.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;
}

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

.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);
}

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

.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:hover {
  background: var(--surface);
}

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

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

.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-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;
}

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

.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;
  }
}
