/* ============================================================
   Từ Điển (Dictionary) – Modern Interactive Search Page
   Matches visual quality of radicals.css + pinyin_chart.css
   ============================================================ */

/* ── HSK level colour palette ──────────────────────────────── */
:root {
  --hsk1-color:  #16a34a; --hsk1-bg: #f0fdf4; --hsk1-border: #86efac;
  --hsk2-color:  #2563eb; --hsk2-bg: #eff6ff; --hsk2-border: #93c5fd;
  --hsk3-color:  #7c3aed; --hsk3-bg: #f5f3ff; --hsk3-border: #c4b5fd;
  --hsk4-color:  #d97706; --hsk4-bg: #fffbeb; --hsk4-border: #fcd34d;
  --hsk5-color:  #dc2626; --hsk5-bg: #fef2f2; --hsk5-border: #fca5a5;
  --hsk6-color:  #1e293b; --hsk6-bg: #f1f5f9; --hsk6-border: #94a3b8;
}

/* ── Fade-in animation ─────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position:  600px 0; }
}
.fade-in-up { animation: fadeInUp .4s ease both; }


/* ── Hero ───────────────────────────────────────────────────── */
.dict-hero {
  background: linear-gradient(135deg, #0f4c75 0%, #0d6e6e 45%, #0a9396 100%);
  color: #fff;
  border-radius: 1.25rem;
  padding: 2.75rem 2rem 3rem;
  position: relative;
  /* z-index elevates this stacking context above content below so the
     pinyin candidates dropdown (absolute inside) paints over the tip card */
  z-index: 10;
  /* overflow must stay visible so the candidates dropdown is not clipped */
  overflow: visible;
}
/* Clip the large decorative radical without clipping positioned descendants */
.dict-hero-deco-clip {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  pointer-events: none;
}
.dict-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(ellipse at 75% 45%, rgba(10,147,150,.28) 0, transparent 60%),
              radial-gradient(ellipse at 20% 80%, rgba(15,76,117,.25) 0, transparent 50%);
  pointer-events: none;
}
.dict-hero-deco {
  position: absolute;
  right: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11rem;
  line-height: 1;
  font-weight: 900;
  font-family: 'Noto Serif CJK SC', 'STSong', serif;
  color: rgba(255,255,255,.055);
  pointer-events: none;
  user-select: none;
}
.dict-hero h1 { font-weight: 900; letter-spacing: -.5px; }

/* Stat badges in hero */
.dict-hero .stat-badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .35rem .75rem;
  background: rgba(255,255,255,.13);
  border: 1px solid rgba(255,255,255,.22);
  border-radius: .5rem;
  color: rgba(255,255,255,.9);
  font-size: .78rem;
  font-weight: 600;
}


/* ── Search bar ─────────────────────────────────────────────── */
.dict-search-wrap {
  position: relative;
  max-width: 680px;
  margin: 0 auto;
}
.dict-search-input {
  height: 3.4rem;
  border-radius: 1.7rem !important;
  padding-left: 3.2rem !important;
  padding-right: 7rem !important;
  font-size: 1.08rem;
  border: 2px solid rgba(255,255,255,.3) !important;
  background: rgba(255,255,255,.95) !important;
  box-shadow: 0 4px 24px rgba(0,0,0,.18) !important;
  transition: border-color .2s, box-shadow .2s;
  color: #1e293b !important;
}
.dict-search-input:focus {
  border-color: #0a9396 !important;
  box-shadow: 0 4px 28px rgba(10,147,150,.25), 0 0 0 3px rgba(10,147,150,.15) !important;
  outline: none;
}
.dict-search-input::placeholder { color: #94a3b8 !important; }
/* Pinyin input candidate dropdown */
.dict-pinyin-candidates {
  position: absolute;
  top: calc(100% + .5rem);
  left: 0;
  right: 0;
  z-index: 200;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .4rem;
  padding: .5rem;
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: .85rem;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .12);
}

/* Pinyin Candidate Items (shared look across site) */
.candidate-item {
  cursor: pointer;
  transition: transform 0.18s cubic-bezier(0.2, 1, 0.22, 1), box-shadow 0.18s ease, background-color 0.12s ease;
  border: 1px solid rgba(2, 6, 23, 0.04) !important;
  border-radius: 0.75rem !important;
  padding: 0.55rem 0.75rem !important;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: linear-gradient(180deg, #ffffff, #fbfffb);
  box-shadow: 0 6px 18px rgba(2, 6, 23, 0.04), inset 0 -6px 18px rgba(79, 70, 229, 0.02);
  min-height: 56px;
}
.candidate-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 18px 40px rgba(2, 6, 23, 0.1);
  background: linear-gradient(180deg, #ffffff, #f8fff8);
  border-color: rgba(25, 135, 84, 0.12) !important;
}
.candidate-item .fs-2 {
  font-weight: 400;
  color: #0f172a;
  line-height: 1;
  font-size: 1.8rem !important; /* Ensure character is prominent */
}
.candidate-key {
  font-size: 0.75rem;
  background: rgba(79, 70, 229, 0.06);
  color: #4f46e5;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid rgba(79, 70, 229, 0.08);
  min-width: 22px;
  text-align: center;
  font-weight: 600;
}


.dict-search-icon {
  position: absolute;
  left: 1.1rem;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  font-size: 1.15rem;
  pointer-events: none;
  z-index: 5;
}
.dict-search-btn {
  position: absolute;
  right: .45rem;
  top: 50%;
  transform: translateY(-50%);
  border-radius: 1.4rem !important;
  height: 2.6rem;
  padding: 0 1.2rem;
  font-weight: 700;
  background: linear-gradient(135deg, #0f4c75, #0a9396) !important;
  border: none !important;
  box-shadow: 0 2px 8px rgba(10,147,150,.3) !important;
  z-index: 5;
}
.dict-search-btn:hover {
  box-shadow: 0 4px 14px rgba(10,147,150,.4) !important;
}


/* ── Level filter bar ───────────────────────────────────────── */
.dict-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  padding: .9rem 0;
  position: sticky;
  top: 60px;
  z-index: 20;
  background: rgba(203,213,225,.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: .75rem;
  padding: .6rem .75rem;
  margin-bottom: .5rem;
}
.dict-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .35rem .9rem;
  border-radius: 2rem;
  border: 1.5px solid #cbd5e1;
  background: #fff;
  color: #475569;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .18s ease;
  white-space: nowrap;
}
.dict-filter-btn:hover {
  border-color: #0a9396;
  color: #0a9396;
  background: #f0fdfa;
}
.dict-filter-btn.active {
  background: #0a9396;
  border-color: #0a9396;
  color: #fff;
  box-shadow: 0 2px 8px rgba(10,147,150,.3);
}
.dict-filter-btn .level-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}


/* ── Results area ───────────────────────────────────────────── */
#dict-results-area { min-height: 300px; }

/* Skeleton loading cards */
.dict-skeleton {
  background: #f1f5f9;
  border-radius: 1rem;
  height: 88px;
  overflow: hidden;
  position: relative;
}
.dict-skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,.65) 50%, transparent 100%);
  background-size: 600px 100%;
  animation: shimmer 1.4s infinite linear;
}


/* ── Result cards ───────────────────────────────────────────── */
.dict-result-card {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
  background: #fff;
  border-radius: 1rem;
  border: 1.5px solid #e2e8f0;
  padding: .85rem 1.1rem;
  cursor: pointer;
  transition: border-color .18s, box-shadow .18s, transform .18s;
  position: relative;
  animation: fadeInUp .3s ease both;
}
.dict-result-card:hover {
  border-color: #0a9396;
  box-shadow: 0 4px 18px rgba(10,147,150,.12);
  transform: translateY(-1px);
}
.dict-result-card:active { transform: translateY(0); }

/* Left: character block */
.dict-card-char-wrap {
  flex-shrink: 0;
  min-width: 3.4rem;
  width: auto;
  height: 3.8rem;
  border-radius: .75rem;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 0 .55rem;
}
.dict-card-char {
  font-family: 'Noto Serif CJK SC', 'STSong', 'SimSun', serif;
  font-size: 2rem;
  line-height: 1;
  font-weight: 700;
  color: #1e293b;
  white-space: nowrap;
}
/* HSK level corner badge */
.dict-level-badge {
  position: absolute;
  top: -.45rem;
  right: -.45rem;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .62rem;
  font-weight: 800;
  color: #fff;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.18);
}
.dict-level-badge.lv-1 { background: var(--hsk1-color); }
.dict-level-badge.lv-2 { background: var(--hsk2-color); }
.dict-level-badge.lv-3 { background: var(--hsk3-color); }
.dict-level-badge.lv-4 { background: var(--hsk4-color); }
.dict-level-badge.lv-5 { background: var(--hsk5-color); }
.dict-level-badge.lv-6 { background: var(--hsk6-color); }

/* Middle: pronunciation + meaning */
.dict-card-body { flex: 1; min-width: 0; }
.dict-card-pinyin {
  font-size: .92rem;
  color: #475569;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dict-card-vipron {
  color: #94a3b8;
  font-size: .82rem;
  margin-left: .4rem;
  font-style: italic;
}
.dict-card-def {
  font-size: .88rem;
  color: #334155;
  margin-top: .15rem;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.4;
}
/* Example sentence row – full width below char/body/actions */
.dict-card-example {
  width: 100%;
  margin-top: -.25rem;
  padding-top: .6rem;
  border-top: 1px solid #f1f5f9;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .25rem .6rem;
  font-size: .82rem;
  color: #475569;
}
.dict-card-example-label {
  font-size: .7rem;
  font-weight: 700;
  color: #0a9396;
  text-transform: uppercase;
  letter-spacing: .04em;
  flex-shrink: 0;
}
.dict-card-example-zh {
  font-size: .95rem;
  color: #1e293b;
  font-family: 'Noto Serif CJK SC', 'STSong', serif;
}
.dict-card-example-pinyin {
  font-size: .78rem;
  color: #94a3b8;
  font-style: italic;
  flex-basis: 100%;
}
.dict-card-example-vn {
  font-size: .8rem;
  color: #64748b;
  flex-basis: 100%;
}
.dict-card-pos {
  display: inline-block;
  font-size: .68rem;
  font-weight: 700;
  padding: .1rem .45rem;
  border-radius: .35rem;
  background: #f1f5f9;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-right: .35rem;
  vertical-align: middle;
}

/* Right: actions */
.dict-card-actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.dict-card-audio-btn {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 1.5px solid #e2e8f0;
  background: #f8fafc;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .85rem;
  cursor: pointer;
  transition: all .15s;
  flex-shrink: 0;
}
.dict-card-audio-btn:hover {
  background: #0a9396;
  border-color: #0a9396;
  color: #fff;
}
.dict-card-chevron { color: #cbd5e1; font-size: .85rem; }
.dict-result-card:hover .dict-card-chevron { color: #0a9396; }


/* ── HSK level inline badge (result list header) ────────────── */
.hsk-inline-badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  font-size: .7rem;
  font-weight: 700;
  padding: .1rem .5rem;
  border-radius: .4rem;
  border: 1.5px solid;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.hsk-inline-badge.lv-1 { color: var(--hsk1-color); border-color: var(--hsk1-border); background: var(--hsk1-bg); }
.hsk-inline-badge.lv-2 { color: var(--hsk2-color); border-color: var(--hsk2-border); background: var(--hsk2-bg); }
.hsk-inline-badge.lv-3 { color: var(--hsk3-color); border-color: var(--hsk3-border); background: var(--hsk3-bg); }
.hsk-inline-badge.lv-4 { color: var(--hsk4-color); border-color: var(--hsk4-border); background: var(--hsk4-bg); }
.hsk-inline-badge.lv-5 { color: var(--hsk5-color); border-color: var(--hsk5-border); background: var(--hsk5-bg); }
.hsk-inline-badge.lv-6 { color: var(--hsk6-color); border-color: var(--hsk6-border); background: var(--hsk6-bg); }


/* ── Empty / suggested state ────────────────────────────────── */
.dict-suggested-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: .75rem 1.1rem;
  border-radius: .85rem;
  border: 1.5px solid #e2e8f0;
  background: #fff;
  cursor: pointer;
  transition: all .18s;
  text-align: center;
  gap: .15rem;
  min-width: 100px;
}
.dict-suggested-btn:hover {
  border-color: #0a9396;
  background: #f0fdfa;
  box-shadow: 0 2px 10px rgba(10,147,150,.1);
  transform: translateY(-2px);
}
.dict-suggested-char {
  font-family: 'Noto Serif CJK SC','STSong',serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.1;
}
.dict-suggested-hint {
  font-size: .7rem;
  color: #94a3b8;
  white-space: nowrap;
}

/* No-results state */
.dict-no-results {
  text-align: center;
  padding: 3rem 1rem;
  color: #64748b;
}
.dict-no-results .no-results-icon {
  font-size: 3.5rem;
  opacity: .25;
  display: block;
  margin-bottom: 1rem;
}


/* ── Result count badge ─────────────────────────────────────── */
.dict-result-count {
  font-size: .8rem;
  color: #64748b;
  background: #f1f5f9;
  padding: .2rem .65rem;
  border-radius: .5rem;
  font-weight: 600;
}


/* ── Callout card ───────────────────────────────────────────── */
.dict-tip-card {
  background: linear-gradient(135deg, #f0fdfa, #f0f9ff);
  border: 0;
  border-left: 4px solid #0a9396 !important;
  border-radius: .85rem;
  padding: 1rem 1.25rem;
}


/* ── Responsive tweaks ──────────────────────────────────────── */
@media (max-width: 575px) {
  .dict-hero { padding: 2rem 1.25rem 2.25rem; }
  .dict-hero h1 { font-size: 1.5rem; }
  .dict-hero-deco { font-size: 7rem; }
  .dict-card-char { font-size: 1.65rem; }
  .dict-card-char-wrap { width: 3.2rem; height: 3.2rem; }
  .dict-card-vipron { display: none; }
  .dict-search-input { font-size: .95rem; }
}
