/* ═══════════════════════════════════════════════════════════════════
   Dictionary Page Styles — Page-Specific Only
   ═══════════════════════════════════════════════════════════════════
   Colors, spacing, typography, and shared components come from
   tokens.css and components.css. This file only contains styles
   unique to dictionary entry pages.
   ═══════════════════════════════════════════════════════════════════ */

/* ---- Page Layout ---- */
.entry {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--space-lg) var(--space-md) 80px;
}

/* ---- Entry Header ----
   Layout: word | IPA | audio | CEFR   ...space...   [Add to List]
   Left side = identity (what is this word)
   Right side = action (what can I do with it) */
.entry-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 2px solid var(--primary);
}
.entry-header h1 {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0;
  flex-shrink: 0;
}
/* Info group: IPA + audio + CEFR, pushed right of the word */
.entry-header .header-info {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex: 1;
  min-width: 0;
}
/* Action group: Add to List button, pushed to far right */
.entry-header .header-action {
  flex-shrink: 0;
  margin-left: auto;
}

.phonetic {
  font-size: 1.1rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Start Learning / Add to List button */
.start-learning-btn {
  background: var(--primary);
  color: #ffffff;
  border: none;
  padding: 8px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-pill);
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s, transform 0.1s;
}
.start-learning-btn:hover {
  opacity: 0.9;
}
.start-learning-btn:active {
  transform: scale(0.97);
}
.start-learning-btn.added {
  background: var(--correct);
  opacity: 1;
}

@media (max-width: 600px) {
  .entry-header h1 { font-size: 1.6rem; }
  .entry-header .header-info { flex-wrap: wrap; }
  .entry-header .header-action { width: 100%; margin-top: 8px; }
  .start-learning-btn { width: 100%; padding: 10px; }
}

/* Start Learning button — old inline styles removed, now uses .header-action wrapper */

/* ---- Bridge Tabs ---- */
.bridge-tabs {
  display: flex;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
  border-bottom: 2px solid var(--border);
}
.bridge-tab {
  padding: var(--space-sm) var(--space-md);
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--text-muted);
  transition: all 0.15s;
  font-weight: 500;
  margin-bottom: -2px;
}
.bridge-tab:hover { color: var(--primary); }
.bridge-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}
.bridge-tab:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- Bridge Gist (headword-level overview) ---- */
.bridge-gist {
  padding: var(--space-md);
  margin-bottom: var(--space-md);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  line-height: 1.7;
  display: none;
}
.bridge-gist.active { display: block; }
.bridge-gist[data-lang="zh"] { background: var(--bridge-zh-bg); }
.bridge-gist[data-lang="es"] { background: var(--bridge-es-bg); }
.bridge-gist[data-lang="en"] { background: var(--bg-light); }
.bridge-gist[data-lang="fr"] { background: var(--bridge-fr-bg); }
.bridge-gist[data-lang="de"] { background: var(--bridge-de-bg); }
.bridge-gist[data-lang="ja"] { background: var(--bridge-ja-bg); }
.bridge-gist[data-lang="pt"] { background: var(--bridge-pt-bg); }
.bridge-gist .gist { font-size: 1rem; }
.bridge-gist .gist strong { color: var(--primary-dark); }
.bridge-gist .usage-note {
  margin-top: var(--space-sm);
  font-size: 0.9rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ---- Origin Story ---- */
.origin-story {
  margin-bottom: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-light);
  border-radius: var(--radius);
  border-left: 4px solid var(--primary-light);
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--text-muted);
}
.origin-story .label {
  font-weight: 600;
  color: var(--primary);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
  display: block;
}

/* ---- Senses ---- */
.senses { margin-bottom: var(--space-lg); }
.sense {
  background: var(--sense-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px var(--space-md);
  margin-bottom: 12px;
}
.sense .definition {
  font-size: 1.05rem;
  font-weight: 500;
  margin-bottom: var(--space-xs);
}
.sense .example {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: var(--space-xs);
  padding-left: 12px;
  border-left: 3px solid var(--primary-light);
}

/* ---- Inline Translations ---- */
.sense-translation {
  font-size: 0.92rem;
  padding: var(--space-xs) 0 var(--space-xs) 12px;
  border-left: 3px solid transparent;
  display: none;
}
.sense-translation.active { display: block; }

.sense-translation[data-lang="zh"] {
  color: #8B5E3C;
  border-left-color: #D4A76A;
  background: rgba(255, 247, 237, 0.5);
  border-radius: 0 4px 4px 0;
  margin-bottom: 2px;
}
.sense-translation[data-lang="es"] {
  color: #9B2335;
  border-left-color: #D4726A;
  background: rgba(254, 243, 242, 0.5);
  border-radius: 0 4px 4px 0;
  margin-bottom: 2px;
}
.sense-translation[data-lang="fr"] {
  color: #1B4332;
  border-left-color: #2D6A4F;
  background: rgba(240, 248, 244, 0.5);
  border-radius: 0 4px 4px 0;
  margin-bottom: 2px;
}
.sense-translation[data-lang="de"] {
  color: #B8860B;
  border-left-color: #DAA520;
  background: rgba(250, 245, 230, 0.5);
  border-radius: 0 4px 4px 0;
  margin-bottom: 2px;
}
.sense-translation[data-lang="ja"] {
  color: #4A5568;
  border-left-color: #718096;
  background: rgba(240, 240, 245, 0.5);
  border-radius: 0 4px 4px 0;
  margin-bottom: 2px;
}
.sense-translation[data-lang="pt"] {
  color: #6B2D5C;
  border-left-color: #9B59B6;
  background: rgba(248, 240, 248, 0.5);
  border-radius: 0 4px 4px 0;
  margin-bottom: 2px;
}

.pos-translation {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: 6px;
}
.trans-synonyms {
  font-weight: 500;
  margin-bottom: 2px;
}
.trans-synonyms .trans-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-right: var(--space-xs);
}

/* ---- Synonyms / Antonyms ---- */
.syn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: var(--space-sm);
}
.syn-group .label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  line-height: 1.8;
}
.syn-chip {
  display: inline-block;
  background: var(--bg-light);
  border: 1px solid var(--border);
  padding: 1px var(--space-sm);
  border-radius: var(--radius-pill);
  font-size: 0.82rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.15s;
}
.syn-chip:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.syn-chip.antonym { border-color: var(--warm-accent); color: var(--warm-accent); }
.syn-chip.antonym:hover { background: var(--warm-accent); color: #fff; }

/* ---- Morphemes ---- */
.morphemes {
  background: var(--bg-light);
  border-radius: var(--radius);
  padding: 12px var(--space-md);
  margin-bottom: var(--space-md);
  font-size: 0.95rem;
}
.morphemes .label { font-weight: 600; color: var(--text-muted); margin-right: var(--space-sm); }
.morph-prefix { color: var(--morph-prefix); font-weight: 600; }
.morph-root { color: var(--morph-root); font-weight: 600; }
.morph-suffix { color: var(--morph-suffix); font-weight: 600; }
.morph-plus { color: var(--text-muted); margin: 0 2px; }

/* ---- Collocations ---- */
.collocations { margin-bottom: var(--space-md); }
.collocations h3 {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
}
.coll-list { display: flex; flex-wrap: wrap; gap: 6px; }
.coll-item {
  background: var(--bg-light);
  border: 1px solid var(--border);
  padding: var(--space-xs) 10px;
  border-radius: var(--radius);
  font-size: 0.88rem;
}
.coll-item .pos { color: var(--text-muted); font-size: 0.78rem; margin-left: var(--space-xs); }

/* ---- Etymology Family (Related Words) ---- */
.etymology-family { margin-bottom: var(--space-md); }
.etymology-family h3 {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
}
.etym-grid { display: flex; flex-wrap: wrap; gap: var(--space-sm); }
.etym-item {
  background: var(--bg-light);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  text-decoration: none;
  color: var(--text);
  transition: all 0.15s;
}
.etym-item:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.etym-item .word { font-weight: 500; }
.etym-item .relation { font-size: 0.75rem; color: var(--text-muted); margin-left: var(--space-xs); }
.etym-item:hover .relation { color: rgba(255, 255, 255, 0.8); }

/* ---- Dictionary CTA ---- */
.cta {
  margin-top: var(--space-2xl);
  padding: var(--space-xl);
  background: var(--bg-light);
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  text-align: center;
}
.cta p { font-size: 1rem; color: var(--text-muted); margin-bottom: 12px; }
.cta-btn {
  display: inline-block;
  background: var(--cta-bg);
  color: #fff;
  padding: 12px 28px;
  border-radius: var(--radius);
  text-decoration: none;
  font-size: 1.05rem;
  font-weight: 600;
  transition: background 0.15s;
}
.cta-btn:hover { background: var(--cta-hover); }
.cta-features {
  display: flex;
  justify-content: center;
  gap: var(--space-lg);
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ---- Entry Footer ---- */
.entry-footer {
  margin-top: 40px;
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

/* ---- Dictionary Mobile ---- */
@media (max-width: 600px) {
  .entry { padding: var(--space-md) 12px 60px; }
  .entry-header h1 { font-size: 1.6rem; }
  .bridge-tabs { overflow-x: auto; }
  .sense { padding: 10px 12px; }
  .cta-features { flex-direction: column; gap: var(--space-xs); }
}

/* ═══ Dictionary page search bar ═══
   Full-size search bar injected at the top of individual word pages.
   Sits below the nav bar, above the word entry. */

.dict-page-search {
  background: var(--bg-light);
  border-bottom: 1px solid var(--border);
  padding: 12px var(--space-md);
  margin-top: 56px; /* below fixed nav */
}

.dict-search-wrap {
  position: relative;
  max-width: 700px;
  margin: 0 auto;
}

.dict-search-form {
  display: flex;
  gap: 0;
  border: 2px solid var(--primary);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.dict-search-form:focus-within {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(98, 184, 94, 0.15);
}

.dict-search-input {
  flex: 1;
  border: none;
  padding: 10px var(--space-md);
  font-size: 1rem;
  outline: none;
  color: var(--text);
  background: var(--bg-card);
}
.dict-search-input::placeholder {
  color: var(--text-muted);
}

.dict-search-btn {
  border: none;
  background: var(--primary);
  color: #fff;
  padding: 10px 18px;
  font-size: 1rem;
  cursor: pointer;
  white-space: nowrap;
}
.dict-search-btn:hover { opacity: 0.9; }

/* Autocomplete dropdown for page search */
.dict-search-autocomplete {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 12px 12px;
  max-height: 360px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.dict-ac-item {
  padding: var(--space-sm) var(--space-md);
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  font-size: 0.9rem;
  transition: background 0.1s;
}
.dict-ac-item:last-child { border-bottom: none; }
.dict-ac-item:hover {
  background: var(--pale-green);
}

.dict-ac-word {
  font-weight: 600;
  color: var(--primary);
}
.dict-ac-def {
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Responsive */
@media (max-width: 600px) {
  .dict-search-input {
    padding: var(--space-sm) 12px;
    font-size: 0.95rem;
  }
  .dict-search-btn {
    padding: var(--space-sm) 14px;
  }
}
/* POS badge — legacy class still used by pre-v2 word pages and the v2 generator.
   Rule lost during the Oct 18 unified-theme rewrite; restored 2026-10-22 from
   handoff/dictionary.css (Oct 16), color tokens verified against current tokens.css. */
.pos-badge {
  display: inline-block;
  background: var(--primary-light, #88CF85);
  color: white;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-left: 8px;
  vertical-align: middle;
}
