/* Gooma — indigo night. Duun text: Charis SIL; French UI: Archivo. */

:root {
  --ink-950: #0d1526;
  --ink-900: #141e38;
  --ink-800: #1c2b4e;
  --ink-700: #29457c;
  --ink-line: #2e3d63;
  --gold: #d9a441;
  --gold-bright: #e8c168;
  --cream: #efe6d3;
  --cream-dim: #c9bfa9;
  --rust: #b4642d;
  --laterite: #9c3b22;
  --radius: 20px;
  --duun-size: 1.75rem;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html { height: 100%; }

body {
  min-height: 100%;
  background: linear-gradient(175deg, var(--ink-950) 0%, var(--ink-900) 38%, #101a30 100%);
  color: var(--cream);
  font-family: "Archivo", system-ui, sans-serif;
  padding-bottom: 64px;
}

[lang="dux-x-ortho"], [lang="dux"], [lang^="dux-"] {
  font-family: "Charis SIL", serif;
}

#motif {
  position: fixed;
  inset: 0 0 auto 0;
  width: 100%;
  height: 240px;
  color: var(--gold);
  opacity: 0.07;
  pointer-events: none;
  z-index: 0;
}

/* ---------- header ---------- */

#topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: max(14px, env(safe-area-inset-top)) 16px 0;
  background: linear-gradient(180deg, rgba(13, 21, 38, 0.97) 55%, rgba(13, 21, 38, 0.88) 85%, rgba(13, 21, 38, 0));
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.brand h1 {
  font-family: "Charis SIL", serif;
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--gold-bright);
  text-shadow: 0 0 28px rgba(217, 164, 65, 0.35);
  line-height: 1.05;
}

.tagline {
  color: var(--cream-dim);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  margin: 2px 0 12px;
}

.searchwrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-ico {
  position: absolute;
  left: 15px;
  width: 19px;
  height: 19px;
  color: var(--cream-dim);
  pointer-events: none;
}

#search {
  width: 100%;
  height: 50px;
  border-radius: 25px;
  border: 1.5px solid var(--ink-line);
  background: var(--ink-800);
  color: var(--cream);
  font: inherit;
  font-size: 1rem;
  padding: 0 44px;
  outline: none;
  transition: border-color 0.25s, box-shadow 0.25s;
}

#search::placeholder { color: #8d93a8; }

#search::-webkit-search-cancel-button,
#search::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

#search:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(217, 164, 65, 0.18);
}

#clear-search {
  position: absolute;
  right: 8px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: var(--ink-700);
  color: var(--cream);
  font-size: 1.2rem;
  line-height: 1;
}

#letter-rail {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 12px 2px 12px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

#letter-rail::-webkit-scrollbar { display: none; }

.letter-btn {
  flex: 0 0 auto;
  min-width: 42px;
  height: 40px;
  padding: 0 11px;
  border-radius: 13px;
  border: 1px solid var(--ink-line);
  background: transparent;
  color: var(--cream-dim);
  font-family: "Charis SIL", serif;
  font-size: 1.08rem;
  transition: transform 0.15s, background 0.2s, color 0.2s;
}

.letter-btn.active {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--ink-950);
  font-weight: 700;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(217, 164, 65, 0.35);
}

.letter-btn.home-btn { color: var(--gold-bright); }
.letter-btn.home-btn.active { color: var(--ink-950); }

/* ---------- content ---------- */

#content {
  position: relative;
  z-index: 5;
  padding: 8px 16px 24px;
  max-width: 640px;
  margin: 0 auto;
}

.section-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--gold);
  margin: 20px 2px 10px;
}

/* word of the day hero */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: 24px;
  border: 1px solid rgba(217, 164, 65, 0.35);
  background:
    radial-gradient(120% 140% at 85% -20%, rgba(217, 164, 65, 0.22), transparent 55%),
    linear-gradient(160deg, var(--ink-800), var(--ink-900) 70%);
  padding: 22px 20px 20px;
  animation: rise 0.5s ease both;
}

.hero .kicker {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--gold-bright);
}

.hero .headword {
  font-size: 2.9rem;
  line-height: 1.15;
  margin: 8px 0 2px;
  color: var(--cream);
}

.hero .gram { color: var(--cream-dim); font-style: italic; font-size: 0.9rem; }

.hero .gloss {
  margin-top: 10px;
  font-size: 1.02rem;
  line-height: 1.5;
  color: var(--cream);
}

.hero-row { display: flex; align-items: center; gap: 14px; margin-top: 16px; }

.hero .open-entry {
  margin-left: auto;
  border: 1px solid var(--ink-line);
  background: transparent;
  color: var(--cream-dim);
  border-radius: 12px;
  padding: 9px 14px;
  font: inherit;
  font-size: 0.88rem;
}

/* letter tiles on home */
.letters-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
}

.letter-tile {
  border: 1px solid var(--ink-line);
  border-radius: 16px;
  background: linear-gradient(150deg, var(--ink-800), rgba(28, 43, 78, 0.4));
  color: var(--cream);
  padding: 12px 4px 9px;
  text-align: center;
  transition: transform 0.15s, border-color 0.2s;
}

.letter-tile:active { transform: scale(0.94); }

.letter-tile .u {
  display: block;
  font-family: "Charis SIL", serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gold-bright);
}

.letter-tile .n { font-size: 0.68rem; color: var(--cream-dim); }

/* entry cards */
.entry-card {
  border: 1px solid var(--ink-line);
  border-radius: var(--radius);
  background: rgba(28, 43, 78, 0.35);
  padding: 15px 16px 13px;
  margin-bottom: 10px;
  animation: rise 0.4s ease both;
}

.entry-card:nth-child(-n+12) { animation-delay: calc(var(--i, 0) * 28ms); }

.entry-head { display: flex; align-items: center; gap: 11px; }

.entry-head .headword {
  font-size: var(--duun-size);
  font-weight: 700;
  color: var(--cream);
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.homograph { color: var(--gold); font-size: 0.85rem; vertical-align: super; }

.gram { font-style: italic; color: var(--cream-dim); font-size: 0.85rem; }

.entry-glosses { margin-top: 7px; font-size: 0.95rem; line-height: 1.5; }

.lang-badge {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-950);
  background: var(--cream-dim);
  border-radius: 5px;
  padding: 1.5px 5px;
  margin: 0 6px 2px 0;
  vertical-align: 0.14em;
}

.lang-badge.b-fr { background: var(--gold); }
.lang-badge.b-bm { background: var(--rust); color: var(--cream); }
.lang-badge.b-en { background: var(--ink-700); color: var(--cream); }

.lang-text { margin-right: 10px; }

/* play buttons */
.play-btn {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1.6px solid var(--gold);
  background: rgba(217, 164, 65, 0.1);
  color: var(--gold-bright);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 0.12s, background 0.2s;
}

.play-btn:active { transform: scale(0.9); }

.play-btn svg { width: 18px; height: 18px; }

.play-btn.small { width: 38px; height: 38px; }
.play-btn.small svg { width: 15px; height: 15px; }

.play-btn.big { width: 64px; height: 64px; border-width: 2px; }
.play-btn.big svg { width: 26px; height: 26px; }

.play-btn.playing {
  background: var(--gold);
  color: var(--ink-950);
}

.play-btn.playing::before,
.play-btn.playing::after {
  content: "";
  position: absolute;
  inset: -1.6px;
  border-radius: 50%;
  border: 1.6px solid var(--gold);
  animation: ripple 1.5s ease-out infinite;
}

.play-btn.playing::after { animation-delay: 0.75s; }

@keyframes ripple {
  from { transform: scale(1); opacity: 0.85; }
  to { transform: scale(1.75); opacity: 0; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* search results */
.tier-heading {
  font-size: 0.85rem;
  color: var(--gold-bright);
  margin: 18px 2px 8px;
  font-weight: 500;
}

.result-count { color: var(--cream-dim); font-size: 0.9rem; margin: 10px 2px; }

.empty-state {
  text-align: center;
  color: var(--cream-dim);
  padding: 60px 20px;
  line-height: 1.6;
}

.empty-state .big { font-size: 2.6rem; display: block; margin-bottom: 10px; }

/* ---------- entry sheet ---------- */

#sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 9, 18, 0.62);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  z-index: 40;
  animation: fade 0.25s ease both;
}

@keyframes fade { from { opacity: 0; } }

#sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 93%;
  min-height: 42%;
  z-index: 50;
  background: linear-gradient(180deg, var(--ink-800), var(--ink-900) 30%);
  border-radius: 28px 28px 0 0;
  border-top: 1px solid rgba(217, 164, 65, 0.4);
  box-shadow: 0 -18px 60px rgba(0, 0, 0, 0.55);
  overflow-y: auto;
  overscroll-behavior: contain;
  animation: slideup 0.32s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}

@keyframes slideup { from { transform: translateY(60px); opacity: 0.4; } }

#sheet.closing { transition: transform 0.22s ease-in, opacity 0.22s; transform: translateY(70vh); opacity: 0; }

#sheet-grip {
  position: sticky;
  top: 10px;
  width: 44px;
  height: 5px;
  margin: 10px auto 0;
  border-radius: 3px;
  background: var(--ink-line);
}

#sheet-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--ink-line);
  background: rgba(13, 21, 38, 0.6);
  color: var(--cream);
  font-size: 1.35rem;
  line-height: 1;
  z-index: 2;
}

#sheet-body { padding: 26px 22px 48px; }

.sheet-headword {
  font-size: clamp(2.4rem, 11vw, 3.4rem);
  font-weight: 700;
  line-height: 1.12;
  color: var(--cream);
  overflow-wrap: anywhere;
}

.sheet-topline { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 4px; }
.sheet-topline .play-btn { margin-top: 10px; }

.sheet-gram { font-style: italic; color: var(--gold-bright); margin: 2px 0 14px; }

.sense {
  border-left: 2px solid rgba(217, 164, 65, 0.4);
  padding: 2px 0 4px 14px;
  margin: 16px 0;
}

.sense-number {
  display: inline-block;
  font-weight: 700;
  color: var(--ink-950);
  background: var(--gold);
  width: 22px;
  height: 22px;
  text-align: center;
  line-height: 22px;
  border-radius: 7px;
  font-size: 0.8rem;
  margin-bottom: 6px;
}

.sense .definitions { font-size: 1.02rem; line-height: 1.55; display: block; }

.example {
  background: rgba(13, 21, 38, 0.55);
  border-radius: 14px;
  padding: 12px 14px;
  margin: 10px 0;
}

.example-duun {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
  line-height: 1.4;
}

.example-duun .lang-text { color: var(--gold-bright); }

.example-trans { display: block; margin-top: 6px; font-size: 0.9rem; color: var(--cream-dim); line-height: 1.5; }

.xrefs { margin-top: 18px; }

.xref-chip {
  display: inline-block;
  border: 1px solid var(--ink-line);
  border-radius: 999px;
  padding: 7px 14px;
  margin: 0 6px 8px 0;
  color: var(--cream);
  background: rgba(28, 43, 78, 0.5);
  font-family: "Charis SIL", serif;
  font-size: 1rem;
  text-decoration: none;
}

.xref-rel { font-size: 0.72rem; color: var(--cream-dim); text-transform: uppercase; letter-spacing: 0.1em; display: block; margin: 10px 0 5px; }

.sheet-picture { width: 100%; border-radius: 16px; margin: 14px 0 4px; }

.picture-caption { font-size: 0.85rem; color: var(--cream-dim); }

/* ---------- footer ---------- */

#foot {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px calc(10px + env(safe-area-inset-bottom));
  background: rgba(13, 21, 38, 0.92);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--ink-line);
  font-size: 0.75rem;
  color: var(--cream-dim);
}

#net-badge {
  border: 1px solid var(--rust);
  color: var(--gold-bright);
  border-radius: 999px;
  padding: 2px 10px;
}

#guide-link { margin-left: auto; color: var(--gold); text-decoration: none; }

button { cursor: pointer; font-family: inherit; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
