/* ═══ Kyrgyz Dictionary — Manuscript aesthetic ═══ */

:root {
  --bg: #f5f0e8;
  --bg-warm: #ede7d9;
  --fg: #1a1612;
  --fg-dim: #6b5e4f;
  --fg-muted: #9a8b78;
  --accent: #8b2500;
  --accent-light: #c4572a;
  --turkic: #1a6b3c;
  --persian: #6b3fa0;
  --arabic: #2a6b8b;
  --russian: #8b1a1a;
  --mongol: #8b6b1a;
  --chinese: #b84300;
  --intl: #4a4a6b;
  --serif: 'Noto Serif', 'Georgia', serif;
  --mono: 'JetBrains Mono', monospace;
  --radius: 2px;
  --shadow: 0 1px 3px rgba(26,22,18,.08);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--serif);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.grain {
  position: fixed; inset: 0; z-index: 9999; pointer-events: none; opacity: .03;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ═══ Header ═══ */

header {
  border-bottom: 1px solid rgba(26,22,18,.1);
  background: var(--bg-warm);
  position: sticky; top: 0; z-index: 100;
}

.header-inner {
  max-width: 960px; margin: 0 auto;
  padding: .75rem 1.5rem;
  display: flex; align-items: center; justify-content: space-between;
}

.logo { display: flex; align-items: center; gap: .75rem; }
.logo-tamga { font-size: 2rem; color: var(--accent); line-height: 1; }
.logo h1 { font-size: 1.25rem; font-weight: 700; letter-spacing: -.02em; }
.logo .subtitle { font-size: .7rem; color: var(--fg-dim); font-style: italic; }

nav { display: flex; gap: 1.5rem; }
nav a {
  color: var(--fg-dim); text-decoration: none; font-size: .8rem;
  padding: .25rem 0; border-bottom: 2px solid transparent;
  transition: all .15s;
}
nav a:hover, nav a.active { color: var(--fg); border-bottom-color: var(--accent); }

/* ═══ Views ═══ */

main { max-width: 960px; margin: 0 auto; padding: 0 1.5rem; }
.view { display: none; }
.view.active { display: block; }

/* ═══ Search ═══ */

.search-hero { padding: 3rem 0 2rem; text-align: center; }

.proverb-banner {
  font-style: italic; color: var(--fg-dim); font-size: .85rem;
  margin-bottom: 2rem; min-height: 1.5em;
  opacity: 0; transition: opacity .5s;
}
.proverb-banner.loaded { opacity: 1; }

.search-box { position: relative; max-width: 560px; margin: 0 auto; }

#search-input {
  width: 100%; padding: .9rem 1.25rem;
  font-family: var(--serif); font-size: 1.15rem;
  background: #fff; border: 1px solid rgba(26,22,18,.15);
  border-radius: var(--radius); outline: none;
  box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s;
}
#search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139,37,0,.08);
}
#search-input::placeholder { color: var(--fg-muted); }

.search-hint {
  font-size: .7rem; color: var(--fg-muted); margin-top: .5rem;
  font-family: var(--mono); letter-spacing: .02em;
}

.search-results {
  max-width: 560px; margin: .25rem auto 0;
  background: #fff; border: 1px solid rgba(26,22,18,.1);
  border-radius: var(--radius); box-shadow: 0 8px 24px rgba(26,22,18,.1);
  display: none; text-align: left;
}
.search-results.open { display: block; }

.search-results .result {
  padding: .5rem 1.25rem; cursor: pointer;
  border-bottom: 1px solid rgba(26,22,18,.05);
  font-size: .95rem; transition: background .1s;
}
.search-results .result:hover { background: var(--bg-warm); }
.search-results .result:last-child { border-bottom: none; }

/* ═══ Word Detail ═══ */

.word-detail { padding: 0 0 3rem; }
.word-detail.hidden { display: none; }

.word-header {
  padding: 2rem 0 1.5rem;
  border-bottom: 2px solid var(--fg);
  margin-bottom: 2rem;
}

.word-header h2 {
  font-size: 2.5rem; font-weight: 700;
  letter-spacing: -.03em; line-height: 1.1;
}

.word-meta {
  display: flex; gap: 1rem; margin-top: .75rem;
  flex-wrap: wrap; align-items: center;
}

.tag {
  font-family: var(--mono); font-size: .65rem; font-weight: 600;
  padding: .15rem .5rem; border-radius: var(--radius);
  text-transform: uppercase; letter-spacing: .06em;
}
.tag-pos { background: rgba(26,22,18,.08); color: var(--fg-dim); }
.tag-turkic { background: rgba(26,107,60,.1); color: var(--turkic); }
.tag-persian { background: rgba(107,63,160,.1); color: var(--persian); }
.tag-arabic { background: rgba(42,107,139,.1); color: var(--arabic); }
.tag-russian { background: rgba(139,26,26,.1); color: var(--russian); }
.tag-mongol { background: rgba(139,107,26,.1); color: var(--mongol); }
.tag-chinese { background: rgba(184,67,0,.1); color: var(--chinese); }
.tag-intl { background: rgba(74,74,107,.1); color: var(--intl); }

.word-ipa {
  font-family: var(--mono); font-size: .8rem; color: var(--fg-dim);
}

.word-section { margin-bottom: 2rem; }
.word-section h3 {
  font-size: .75rem; font-family: var(--mono); font-weight: 600;
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--fg-muted); margin-bottom: .75rem;
  padding-bottom: .35rem;
  border-bottom: 1px solid rgba(26,22,18,.08);
}

.etymology-text {
  font-style: italic; color: var(--fg-dim);
  line-height: 1.7; font-size: .95rem;
}

.proto-turkic {
  font-family: var(--mono); font-size: .9rem;
  color: var(--turkic); font-weight: 600;
}

.morphology-display {
  font-family: var(--mono); font-size: 1.1rem;
}
.morphology-display .root-part { color: var(--accent); font-weight: 600; }
.morphology-display .suffix-part { color: var(--fg-dim); }
.morphology-display .separator { color: var(--fg-muted); }

.def-list { list-style: none; }
.def-item {
  padding: .6rem 0;
  border-bottom: 1px solid rgba(26,22,18,.04);
  display: grid; grid-template-columns: auto 1fr; gap: .75rem;
  font-size: .9rem;
}
.def-item:last-child { border-bottom: none; }
.def-dict {
  font-family: var(--mono); font-size: .6rem;
  color: var(--fg-muted); text-align: right;
  padding-top: .15rem; min-width: 100px;
}
.def-text { line-height: 1.5; }

.cognate-row {
  display: grid; grid-template-columns: 80px 1fr; gap: .5rem;
  padding: .35rem 0; font-size: .85rem;
  border-bottom: 1px solid rgba(26,22,18,.04);
}
.cognate-lang {
  font-family: var(--mono); font-size: .65rem;
  color: var(--fg-muted); text-transform: uppercase;
  padding-top: .1rem;
}

.proverb-item {
  padding: .5rem 0; font-style: italic;
  color: var(--fg-dim); font-size: .9rem;
  border-bottom: 1px solid rgba(26,22,18,.04);
}

.unimorph-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .25rem;
}
.unimorph-item {
  font-size: .8rem; padding: .25rem .5rem;
  background: rgba(26,22,18,.02); border-radius: var(--radius);
}
.unimorph-form { font-weight: 600; }
.unimorph-feat { font-family: var(--mono); font-size: .6rem; color: var(--fg-muted); }

/* ═══ Explore ═══ */

.explore-grid {
  padding: 2rem 0 3rem;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem;
}

.stat-card {
  background: #fff; padding: 1.5rem; border-radius: var(--radius);
  border: 1px solid rgba(26,22,18,.08); box-shadow: var(--shadow);
}
.stat-card.big { grid-column: span 1; }
.stat-number {
  font-size: 2rem; font-weight: 700;
  letter-spacing: -.03em; line-height: 1;
  color: var(--accent);
}
.stat-label {
  font-size: .7rem; color: var(--fg-dim);
  font-family: var(--mono); text-transform: uppercase;
  letter-spacing: .06em; margin-top: .35rem;
}

.explore-section {
  grid-column: span 4; background: #fff;
  padding: 2rem; border-radius: var(--radius);
  border: 1px solid rgba(26,22,18,.08); box-shadow: var(--shadow);
}
.explore-section h2 {
  font-size: 1.1rem; margin-bottom: .25rem;
}
.section-desc {
  font-size: .75rem; color: var(--fg-muted);
  font-family: var(--mono); margin-bottom: 1.5rem;
}

.loan-chart { display: flex; gap: .5rem; flex-wrap: wrap; }
.loan-bar {
  display: flex; align-items: center; gap: .5rem;
  padding: .4rem .75rem; border-radius: var(--radius);
  font-size: .8rem; font-family: var(--mono);
}
.loan-bar .count { font-weight: 600; }

.cognate-table { overflow-x: auto; }
.cognate-table table {
  width: 100%; border-collapse: collapse; font-size: .8rem;
}
.cognate-table th {
  font-family: var(--mono); font-size: .65rem;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--fg-muted); text-align: left;
  padding: .5rem; border-bottom: 2px solid rgba(26,22,18,.1);
}
.cognate-table td {
  padding: .4rem .5rem;
  border-bottom: 1px solid rgba(26,22,18,.04);
}

/* ═══ About ═══ */

.about-content { padding: 2rem 0 3rem; max-width: 640px; }
.about-content h2 { font-size: 1.5rem; margin-bottom: 1rem; }
.about-content p { margin-bottom: 1.5rem; color: var(--fg-dim); }

.sources-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: .5rem; margin-bottom: 2rem;
}
.source-card {
  padding: .75rem 1rem; background: #fff;
  border: 1px solid rgba(26,22,18,.08);
  border-radius: var(--radius); font-size: .8rem;
}
.source-card strong { display: block; margin-bottom: .15rem; }
.source-card span { font-size: .7rem; color: var(--fg-dim); font-family: var(--mono); }

.about-footer { font-size: .8rem; border-top: 1px solid rgba(26,22,18,.1); padding-top: 1.5rem; }
.about-footer a { color: var(--accent); }

/* ═══ Responsive ═══ */

@media (max-width: 640px) {
  .header-inner { flex-direction: column; gap: .5rem; }
  .explore-grid { grid-template-columns: repeat(2, 1fr); }
  .explore-section { grid-column: span 2; }
  .word-header h2 { font-size: 1.8rem; }
  .def-item { grid-template-columns: 1fr; }
  .def-dict { text-align: left; }
}
