/* Wɔ — a paper encyclopedia. Cream stock, laterite ink, editorial serif. */

:root {
  --paper: #efe6d3;
  --paper-deep: #e3d6bc;
  --ink: #2c2013;
  --ink-soft: #6b5540;
  --laterite: #9c3b22;
  --gold: #b98a2e;
  --indigo: #29457c;
  --line: #cbbc9d;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

[hidden] { display: none !important; }

body {
  min-height: 100dvh;
  background:
    repeating-linear-gradient(0deg, transparent 0 3px, rgba(44, 32, 19, 0.012) 3px 4px),
    var(--paper);
  color: var(--ink);
  font-family: "Archivo", system-ui, sans-serif;
  padding-bottom: 60px;
}

[lang^="dux"] { font-family: "Charis SIL", serif; }

#top {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: max(18px, env(safe-area-inset-top)) 20px 10px;
  border-bottom: 3px double var(--line);
  margin-bottom: 6px;
}

#top h1 {
  font-family: "Charis SIL", serif;
  font-size: 2.3rem;
  font-weight: 700;
  color: var(--laterite);
  line-height: 1;
}

.tag { font-size: 0.78rem; color: var(--ink-soft); letter-spacing: 0.12em; text-transform: uppercase; margin-top: 3px; }

#back-btn {
  width: 42px;
  height: 42px;
  border: 1.5px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  font-size: 1.25rem;
  cursor: pointer;
}

#net-badge {
  margin-left: auto;
  border: 1.5px solid var(--laterite);
  color: var(--laterite);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.7rem;
  font-weight: 700;
}

#view { padding: 14px 18px 30px; max-width: 620px; margin: 0 auto; }

/* ---------- chapter covers ---------- */

.chapters { display: flex; flex-direction: column; gap: 13px; }

.chapter-card {
  position: relative;
  border: 1.5px solid var(--line);
  border-radius: 6px;
  background: #f7f0e0;
  padding: 18px 18px 16px 22px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  transition: transform 0.15s;
  overflow: hidden;
  animation: settle 0.4s ease both;
  animation-delay: calc(var(--i) * 50ms);
}

@keyframes settle { from { opacity: 0; transform: translateY(12px); } }

.chapter-card:active { transform: scale(0.98); }

.chapter-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 7px;
  background: var(--band, var(--laterite));
}

.chapter-card .roman {
  font-family: "Charis SIL", serif;
  font-size: 0.9rem;
  color: var(--gold);
  letter-spacing: 0.2em;
}

.chapter-card h2 {
  font-family: "Charis SIL", serif;
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--ink);
  margin: 1px 0 2px;
}

.chapter-card .duun-name { color: var(--laterite); font-weight: 400; }

.chapter-card .sub { font-size: 0.85rem; color: var(--ink-soft); }
.chapter-card .count { position: absolute; right: 14px; top: 14px; font-size: 0.75rem; font-weight: 700; color: var(--gold); }

/* ---------- chapter view ---------- */

.chapter-head { margin: 8px 0 18px; text-align: center; }

.chapter-head .roman { font-family: "Charis SIL", serif; letter-spacing: 0.3em; color: var(--gold); font-size: 0.95rem; }

.chapter-head h2 {
  font-family: "Charis SIL", serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--laterite);
  line-height: 1.2;
}

.chapter-head .sub { font-style: italic; font-family: "Charis SIL", serif; color: var(--ink-soft); margin-top: 4px; }

.chapter-head::after {
  content: "";
  display: block;
  width: 90px;
  height: 3px;
  margin: 14px auto 0;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.figure {
  margin: 16px 0;
  border: 1.5px solid var(--line);
  border-radius: 6px;
  background: #f7f0e0;
  padding: 10px;
}

.figure img { width: 100%; border-radius: 3px; display: block; }

.figure figcaption {
  padding: 9px 4px 2px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.figure .w { font-family: "Charis SIL", serif; font-size: 1.25rem; font-weight: 700; color: var(--ink); }

.entry-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 11px 2px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.entry-row .w {
  font-family: "Charis SIL", serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--ink);
  flex-shrink: 0;
}

.entry-row .g { font-size: 0.9rem; color: var(--ink-soft); line-height: 1.45; }

.entry-row.open .g { color: var(--ink); }

.spk {
  flex-shrink: 0;
  align-self: center;
  width: 36px;
  height: 36px;
  border: 1.5px solid var(--laterite);
  border-radius: 50%;
  background: transparent;
  color: var(--laterite);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.15s;
}

.spk:active { transform: scale(0.88); }
.spk svg { width: 14px; height: 14px; }
.spk.playing { background: var(--laterite); color: var(--paper); animation: throb 0.9s infinite; }

@keyframes throb { 50% { transform: scale(1.1); } }

#foot {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  padding: 9px 18px calc(9px + env(safe-area-inset-bottom));
  background: rgba(239, 230, 211, 0.96);
  border-top: 3px double var(--line);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-soft);
}

#foot a { color: var(--laterite); text-decoration: none; font-weight: 700; }

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