/* Pali Etymological Dictionary -- static styles.
   No framework, no CDN, no web font: a local serif stack chosen because these
   families ship the full Latin Extended Additional range (a-macron, t/d/n/m/l
   with dot below, n with dot above, s with acute) that Pali transliteration
   needs.  Falling all the way back to `serif` is still legible. */

:root {
  --ink: #1b1a17;
  --ink-soft: #4a463f;
  --ink-faint: #6f695f;
  --paper: #fbfaf7;
  --paper-raised: #ffffff;
  --rule: #ddd8ce;
  --accent: #6b3f13;
  --accent-soft: #f2ead9;
  --focus: #0b5bd3;
  --measure: 46rem;
}

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

html { font-size: 100%; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Gentium Plus", "Gentium Book Plus", "Charis SIL", "Doulos SIL",
               "Brill", "Cardo", "Noto Serif", "Times New Roman", Georgia, serif;
  font-size: 1.0625rem;
  line-height: 1.65;
}

.wrap {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 1.25rem;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

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

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: -9999px;
  background: var(--paper-raised); padding: .5rem .75rem; z-index: 10;
}
.skip-link:focus { left: 1rem; top: 1rem; }

/* ---------------------------------------------------------------- header */
.site-header {
  border-bottom: 1px solid var(--rule);
  background: var(--paper-raised);
  padding: 1.1rem 0 .9rem;
}
.site-title {
  margin: 0 0 .45rem;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: .01em;
}
.site-title a { color: var(--ink); text-decoration: none; }
.site-title a:hover { text-decoration: underline; }

.notice {
  margin: 0;
  padding: .55rem .8rem;
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  border-radius: 2px;
  color: var(--ink-soft);
  font-size: .95rem;
  line-height: 1.5;
}

/* ---------------------------------------------------------------- search */
.search {
  margin: 1.5rem 0 1.25rem;
  padding: 0;
  border: 0;
}
.search-label {
  display: block;
  font-size: .95rem;
  font-weight: 600;
  margin-bottom: .35rem;
}
.search-row { display: flex; gap: .5rem; flex-wrap: wrap; }

.search input[type="search"] {
  flex: 1 1 18rem;
  min-width: 0;
  font: inherit;
  padding: .55rem .7rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--paper-raised);
  color: inherit;
}

button, .btn {
  font: inherit;
  padding: .55rem 1rem;
  border: 1px solid var(--accent);
  border-radius: 3px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button:hover, .btn:hover { background: #56320f; }

.modes {
  margin: .6rem 0 0;
  padding: 0;
  border: 0;
  display: flex;
  gap: 1.1rem;
  flex-wrap: wrap;
}
.modes label {
  font-size: .95rem;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  cursor: pointer;
}

.search-hint { margin: .5rem 0 0; font-size: .9rem; color: var(--ink-faint); }

/* ---------------------------------------------------------------- states */
.loading, .empty {
  margin: 1.5rem 0;
  padding: 1rem 1.1rem;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: 3px;
}
.empty h2 { margin: 0 0 .5rem; font-size: 1.1rem; }
.error {
  margin: 1.5rem 0; padding: 1rem 1.1rem;
  border: 1px solid #a4361f; border-left-width: 4px;
  background: #fdf2ef; border-radius: 3px;
}

/* --------------------------------------------------------------- results */
.result-count { margin: 0 0 .6rem; font-size: .92rem; color: var(--ink-faint); }

.results { list-style: none; margin: 0; padding: 0; }
.result { border-bottom: 1px solid var(--rule); }
.result-link {
  display: block;
  padding: .7rem .2rem;
  text-decoration: none;
  color: inherit;
}
.result-link:hover, .result-link:focus-visible { background: var(--accent-soft); }
.result-headword {
  display: block;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--accent);
}
.result-snippet {
  display: block;
  font-size: .95rem;
  color: var(--ink-soft);
  margin-top: .15rem;
}
.result-snippet mark {
  background: #fff1b8;
  color: inherit;
  padding: 0 .1em;
}

/* ------------------------------------------------------------------ home */
.home h1 { font-size: 1.55rem; margin: .2rem 0 .6rem; line-height: 1.25; }
.lede { font-size: 1.05rem; color: var(--ink-soft); }
.count-line { font-size: .95rem; color: var(--ink-faint); }

.contact {
  margin: 1.25rem 0 0;
  padding: .85rem 1rem;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-left: 4px solid var(--accent);
  border-radius: 3px;
  font-size: .97rem;
}

/* ----------------------------------------------------------------- entry */
.breadcrumb { margin: .25rem 0 .9rem; font-size: .93rem; }

.headword {
  font-size: 2rem;
  line-height: 1.2;
  margin: 0 0 .7rem;
  font-style: italic;
  font-weight: 600;
  word-break: break-word;
}

.downloads { display: flex; gap: .5rem; flex-wrap: wrap; margin: 0 0 1.4rem; }
.downloads .btn { font-size: .95rem; padding: .45rem .85rem; }

.section { margin: 0 0 1.35rem; }
.section-label {
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ink-faint);
  margin: 0 0 .25rem;
  font-weight: 700;
}
.section-body { margin: 0; }
.section-body p { margin: 0 0 .5rem; }
.section-body p:last-child { margin-bottom: 0; }

/* In-text annotations.  All three are double-click targets, so the cursor
   stays a text caret -- a pointer would promise a single-click action. */
.citation, .abbr, .lemma-link {
  cursor: help;
  border-radius: 2px;
}
.citation { color: var(--accent); border-bottom: 1px dotted currentColor; }
.abbr { border-bottom: 1px dotted var(--ink-faint); }
.lemma-link { color: var(--focus); text-decoration: underline; cursor: pointer; }
.citation:hover, .abbr:hover, .lemma-link:hover { background: var(--accent-soft); }

.entry-tools { display: flex; gap: .5rem; flex-wrap: wrap; margin: -0.8rem 0 1rem; }
.btn-quiet {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--rule);
  font-size: .9rem;
  padding: .35rem .8rem;
}
.btn-quiet:hover { background: var(--accent-soft); color: var(--accent); }

.annotation-hint {
  margin: 0 0 1.5rem;
  font-size: .88rem;
  color: var(--ink-faint);
}

.linkback {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--rule);
  font-size: .9rem;
  padding: .3rem .7rem;
  margin-left: .6rem;
}
.linkback:hover { background: var(--accent-soft); color: var(--accent); }
.linkback[hidden] { display: none; }

.entry-contact { margin-top: 2rem; }

/* ----------------------------------------------------------------- popups */
.popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 15, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  z-index: 100;
}
.popup {
  background: var(--paper-raised);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 4px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .3);
  width: min(38rem, 100%);
  max-height: min(80vh, 44rem);
  display: flex;
  flex-direction: column;
}
.popup-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: .85rem 1rem .6rem;
  border-bottom: 1px solid var(--rule);
}
.popup-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: .01em;
}
.popup-close {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink-soft);
  font-size: 1.1rem;
  line-height: 1;
  padding: .15rem .5rem;
  border-radius: 3px;
}
.popup-close:hover { background: var(--accent-soft); color: var(--accent); }

/* Long works-cited lists must scroll inside the popup, not the page. */
.popup-body {
  padding: .75rem 1rem 1rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.popup-count { margin: 0 0 .6rem; font-size: .85rem; color: var(--ink-faint); }
.popup-row { padding: .55rem 0; border-bottom: 1px solid var(--rule); }
.popup-row:last-child { border-bottom: 0; }
.popup-term {
  margin: 0 0 .2rem;
  font-weight: 700;
  word-break: break-word;
}
.popup-detail {
  margin: 0 0 .25rem;
  font-size: .95rem;
  color: var(--ink-soft);
}
.popup-detail:last-child { margin-bottom: 0; }

/* ---------------------------------------------------------------- footer */
.site-footer {
  margin-top: 3rem;
  padding: 1.5rem 0 2.5rem;
  border-top: 1px solid var(--rule);
  background: var(--paper-raised);
  font-size: .95rem;
}
.site-footer .contact { border-left-color: var(--accent); }
.wip-footer { margin: .9rem 0 0; color: var(--ink-faint); font-size: .9rem; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 34rem) {
  body { font-size: 1rem; }
  .wrap { padding: 0 .9rem; }
  .headword { font-size: 1.6rem; }
  .site-title { font-size: 1.15rem; }
  .search-row { flex-direction: column; align-items: stretch; }
  .search input[type="search"] { flex: 1 1 auto; }
  button, .btn { width: 100%; text-align: center; }
  .downloads { flex-direction: column; }
  /* The full-width rule above is for page controls; a popup's close button
     must stay a small square or it fills the dialog header. */
  .popup-close { width: auto; flex: 0 0 auto; }
  .popup-title { flex: 1 1 auto; min-width: 0; }
  .popup { max-height: 85vh; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #ece8e1;
    --ink-soft: #c9c3b8;
    --ink-faint: #a29a8d;
    --paper: #171614;
    --paper-raised: #1f1e1b;
    --rule: #39362f;
    --accent: #e0a86a;
    --accent-soft: #2c2519;
    --focus: #7db3ff;
  }
  button, .btn { color: #171614; }
  button:hover, .btn:hover { background: #efc48a; }
  .result-snippet mark { background: #6b5a1c; color: #fff; }
  .error { background: #2a1c19; border-color: #c2573c; }
}

/* -------------------------------------------------------------- printing */
@media print {
  :root { --paper: #fff; --paper-raised: #fff; }
  body { font-size: 11pt; color: #000; background: #fff; }
  .skip-link, .search, .downloads, .breadcrumb, .entry-tools,
  .annotation-hint, .popup-overlay, .site-footer .wip-footer { display: none; }
  .citation, .abbr, .lemma-link { color: #000; border-bottom: 0; text-decoration: none; }
  .site-header { border-bottom: 1pt solid #999; }
  .notice { background: none; border-left: 2pt solid #666; }
  .wrap { max-width: none; padding: 0; }
  .headword { font-size: 20pt; }
  .section { page-break-inside: avoid; }
  .section-label { color: #000; }
  a { color: #000; text-decoration: none; }
  .contact { border: 1pt solid #999; background: none; }
}
