/* ============================================================
   Token system
   Brand tokens (indigo, saffron accent, paper, ink, type, scale)
   live in _tokens.css — shared with the main Speak Nigeria site.
   Below are the tokens specific to the dictionary itself.
   Signature: the "tone rule" — three marks (low / mid / high)
           standing in for Yorùbá's grave/unmarked/acute tones,
           used as a recurring divider motif instead of a plain <hr>.
   ============================================================ */

@import url("_tokens.css");

:root {
  --accent-grammar: #5f6f52; /* part-of-speech / grammatical tags */
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--background-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: inherit; }

/* ---------- Header ---------- */

.site-header {
  background: var(--brand-indigo);
  color: var(--surface);
  border-bottom: 3px solid var(--brand-accent);
}

.header-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.wordmark-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
}

.wordmark {
  text-decoration: none;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  row-gap: 2px;
  gap: 10px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.parent-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
  font-family: var(--font-body);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: rgba(255, 255, 255, 0.62);
}
.parent-link img { display: block; border-radius: 3px; }
.parent-link:hover { color: var(--brand-accent); }

.wordmark-yo {
  font-family: var(--font-yoruba);
  font-weight: 600;
  font-size: 1.5rem;
  color: var(--brand-accent);
  letter-spacing: 0.01em;
  text-rendering: optimizeLegibility;
}

.wordmark-en {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.82rem;
  color: rgba(255,255,255,0.72);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-left: 1px solid rgba(255,255,255,0.3);
  padding-left: 10px;
}

.header-search {
  flex: 1;
  position: relative;
}

#search-input {
  width: 100%;
  font-family: var(--font-yoruba); /* Changed from --font-body */
  font-size: 1rem;
  padding: 10px 16px;
  border-radius: 3px;
  border: none;
  background: var(--surface);
  color: var(--text-primary);
  outline: none;
  text-rendering: optimizeLegibility; /* Added */
}

#search-input:focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-accent) 55%, transparent);
}

.search-mode-toggle {
  display: flex;
  gap: 16px;
  margin-top: 10px;
  font-family: var(--font-body);
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.75);
}

.search-mode-toggle label {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s;
}

.search-mode-toggle label:hover,
.search-mode-toggle label:has(input:checked) {
  color: var(--surface);
}

.search-mode-toggle input[type="radio"] {
  accent-color: var(--brand-accent);
  margin: 0;
  cursor: pointer;
}

/* Signature motif: three tone marks, quietly reused as dividers */
.tone-rule {
  display: flex;
  gap: 3px;
  height: 4px;
  margin-top: 5px;
  padding: 0 2px;
}
.tone-rule span {
  flex: 1;
  height: 2px;
  background: rgba(255,255,255,0.28);
  border-radius: 1px;
}
.tone-rule span:nth-child(1) { transform: translateY(2px); }
.tone-rule span:nth-child(3) { transform: translateY(-2px); background: var(--brand-accent); }

.ghost-btn {
  display: inline-block;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.35);
  color: var(--surface);
  font-family: var(--font-body);
  font-size: 0.82rem;
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
}
.ghost-btn:hover { border-color: var(--brand-accent); color: var(--brand-accent); }

/* ---------- App shell ---------- */

.app-shell {
  flex: 1;
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 0;
  min-height: 0;
}

@media (max-width: 800px) {
  .app-shell { grid-template-columns: 1fr; }
}

.results-pane {
  border-right: 1px solid var(--border-subtle);
  overflow-y: auto;
  max-height: calc(100vh - 90px);
  padding: 8px 0;
}

@media (max-width: 800px) {
  .results-pane { max-height: 40vh; border-right: none; border-bottom: 1px solid var(--border-subtle); }
}

.result-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 20px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-left: 3px solid transparent;
  font-family: var(--font-body);
}

.result-item:hover, .result-item.active {
  background: var(--background-secondary);
  border-left-color: var(--brand-accent);
}

.result-headword {
  font-family: var(--font-yoruba);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--brand-indigo);
  text-rendering: optimizeLegibility;
}

.result-meta {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.result-gloss {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.results-empty, .results-hint {
  padding: 24px 20px;
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.5;
}

/* ---------- Entry pane ---------- */

.entry-pane {
  overflow-y: auto;
  max-height: calc(100vh - 90px);
  padding: 36px 40px 80px;
}

@media (max-width: 800px) {
  .entry-pane { max-height: none; padding: 24px 20px 60px; }
}

.entry-welcome {
  max-width: 46ch;
  color: var(--text-secondary);
  line-height: 1.65;
}

.entry-welcome h1 {
  font-family: var(--font-yoruba);
  font-size: 2rem;
  color: var(--brand-indigo);
  margin-bottom: 8px;
  text-rendering: optimizeLegibility;
}

.entry-header {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
}

.entry-headword {
  font-family: var(--font-yoruba);
  font-size: 2.6rem;
  font-weight: 600;
  color: var(--brand-indigo);
  line-height: 1.1;
  text-rendering: optimizeLegibility;
}

.entry-pos {
  font-family: var(--font-body);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--surface);
  background: var(--accent-grammar);
  padding: 3px 9px;
  border-radius: 3px;
}

.entry-ipa {
  font-family: var(--font-mono);
  color: var(--brand-accent-deep);
  font-size: 1rem;
}

.entry-inferred-badge {
  font-size: 0.72rem;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  padding: 2px 8px;
  border-radius: 12px;
  cursor: help;
}

.tone-rule.divider {
  max-width: 220px;
  margin: 22px 0;
  height: 4px;
}
.tone-rule.divider span { background: var(--border-subtle); }
.tone-rule.divider span:nth-child(3) { background: var(--brand-accent); }

.entry-section { margin-bottom: 30px; }

.entry-section-title {
  font-family: var(--font-body);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--brand-accent-deep);
  margin-bottom: 10px;
  font-weight: 600;
}

.sense-list { list-style: none; margin: 0; padding: 0; counter-reset: sense; }
.sense-item {
  counter-increment: sense;
  margin-bottom: 16px;
  padding-left: 30px;
  position: relative;
}
.sense-item::before {
  content: counter(sense);
  position: absolute;
  left: 0;
  top: 1px;
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--brand-accent);
  font-size: 0.95rem;
}
.sense-gloss { font-size: 1.05rem; line-height: 1.5; }
.sense-tags {
  display: inline-flex;
  gap: 6px;
  margin-left: 8px;
  vertical-align: middle;
}
.sense-tag {
  font-size: 0.68rem;
  color: var(--accent-grammar);
  border: 1px solid var(--accent-grammar);
  padding: 1px 6px;
  border-radius: 10px;
  text-transform: lowercase;
}
.sense-example {
  margin-top: 6px;
  padding-left: 14px;
  border-left: 2px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.5;
}
.sense-example .yo-text { 
  font-style: italic; 
  color: var(--text-primary); 
  display: block; 
  font-family: var(--font-yoruba);
  text-rendering: optimizeLegibility;
}
.sense-example .en-text { display: block; }

.etymology-text { 
  line-height: 1.6; 
  color: var(--text-primary);
  font-family: var(--font-yoruba); /* Added */
  text-rendering: optimizeLegibility; /* Added */
}

.relation-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.relation-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 16px;
  border: 1px solid var(--brand-indigo);
  background: var(--surface);
  color: var(--brand-indigo);
  text-decoration: none;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: var(--font-yoruba); /* Added */
  text-rendering: optimizeLegibility; /* Added */
}
.relation-pill:hover { background: var(--brand-indigo-deep); color: var(--surface); }
.relation-pill .pos-hint {
  font-size: 0.7rem;
  opacity: 0.7;
}
.relation-pill.unresolved {
  border-style: dashed;
  border-color: var(--border-subtle);
  color: var(--text-secondary);
  cursor: default;
}
.relation-pill.synthesized::after {
  content: '↺';
  font-size: 0.75rem;
  opacity: 0.6;
}

.alt-forms { 
  color: var(--text-secondary); 
  font-size: 0.92rem; 
  font-family: var(--font-yoruba); /* Added */
  text-rendering: optimizeLegibility; /* Added */
}
.alt-forms .form-tag { font-size: 0.72rem; color: var(--accent-grammar); }

.entry-provenance-note {
  margin-top: 40px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ---------- About page ---------- */

.about-content { max-width: 62ch; }

.about-content h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--brand-indigo);
  margin-bottom: 14px;
}

.about-lede {
  font-size: 1.05rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.about-content h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--brand-indigo);
  margin-top: 34px;
  margin-bottom: 6px;
}

.about-content p { line-height: 1.65; margin-top: 10px; }
.about-content a { color: var(--brand-indigo); text-decoration: underline; text-underline-offset: 2px; }
.about-content a:hover { color: var(--brand-accent-deep); }

.about-content ul { margin-top: 10px; padding-left: 20px; }
.about-content li { margin-top: 10px; line-height: 1.6; }

.about-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 30px; }
.about-content a.about-btn {
  display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none; font-weight: 600; font-size: 0.92rem;
  padding: 10px 18px; border-radius: 6px;
}
.about-content a.about-btn.primary { background: var(--brand-indigo); color: var(--surface); }
.about-content a.about-btn.primary:hover { background: var(--brand-indigo-deep); color: var(--surface); }
.about-content a.about-btn.ghost { border: 1px solid var(--border-subtle); color: var(--brand-indigo); }
.about-content a.about-btn.ghost:hover { border-color: var(--brand-indigo); }

/* ---------- Data quality panel ---------- */

.quality-panel {
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, var(--brand-indigo-deep) 55%, transparent);
  z-index: 50;
  display: flex;
  justify-content: flex-end;
}
.quality-panel.hidden { display: none; }
.quality-panel-inner {
  width: min(480px, 92vw);
  height: 100%;
  background: var(--surface);
  padding: 28px 30px;
  overflow-y: auto;
}
.quality-panel-inner h2 {
  font-family: var(--font-display);
  color: var(--brand-indigo);
  margin-top: 14px;
}
.quality-stat {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.92rem;
}
.quality-stat strong { color: var(--brand-indigo); font-family: var(--font-mono); }
.quality-note {
  margin-top: 18px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
  background: var(--background-primary);
  padding: 14px;
  border-radius: 4px;
}
.quality-download {
  display: block;
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--brand-indigo);
  text-decoration: none;
  line-height: 1.5;
}
.quality-download:hover { border-color: var(--brand-indigo); color: var(--brand-accent-deep); }

/* ---------- Footer ---------- */

.site-footer {
  text-align: center;
  padding: 22px 14px;
  font-size: 0.76rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-subtle);
}

.footer-inner {
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.parent-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--brand-indigo);
}
.parent-brand img { display: block; border-radius: 5px; }
.parent-brand:hover { color: var(--brand-accent-deep); }

.footer-inner p { line-height: 1.6; }
.footer-inner a { color: var(--brand-indigo); text-decoration: underline; text-underline-offset: 2px; }
.footer-inner a:hover { color: var(--brand-accent-deep); }

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 18px;
  margin-top: 4px;
}
.footer-links a { font-weight: 600; text-decoration: none; }
.footer-links a:hover { color: var(--brand-accent-deep); }

/* ---------- Focus visibility (accessibility floor) ---------- */

:focus-visible {
  outline: 2px solid var(--brand-accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- Header: narrow viewports ---------- */

@media (max-width: 700px) {
  .header-inner {
    flex-wrap: wrap;
    row-gap: 10px;
    padding-block: 12px;
  }
  .wordmark-group { flex: 1 0 100%; order: 1; }
  .header-actions { order: 2; }
  .header-search { flex: 1 0 100%; order: 3; }
}
