/* Diɲa — night sky over the Sahel. Duun: Gentium Plus; UI: Space Grotesk. */

:root {
  --night: #0b1026;
  --night-deep: #060a1a;
  --star: #e8c168;
  --star-white: #f2ead6;
  --thread: #3a4b7c;
  --ink-card: rgba(13, 19, 43, 0.92);
  --line: #27335c;
  --dim: #8d96b8;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  background: var(--night);
  color: var(--star-white);
  font-family: "Space Grotesk", system-ui, sans-serif;
  overflow: hidden;
  touch-action: none;
}

[lang^="dux"] { font-family: "Gentium Plus", serif; }

#cosmos {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

/* ---------- HUD ---------- */

#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: max(14px, env(safe-area-inset-top)) 18px 0;
  pointer-events: none;
  z-index: 10;
}

#hud h1 {
  font-size: 1.75rem;
  font-weight: 400;
  color: var(--star);
  text-shadow: 0 0 30px rgba(232, 193, 104, 0.5);
}

#hud h1 .sub {
  display: block;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--dim);
}

#hud-right { display: flex; align-items: center; gap: 10px; pointer-events: auto; }

#guide-link { color: var(--star); text-decoration: none; font-size: 0.85rem; font-weight: 700; }

#net-badge {
  border: 1px solid var(--thread);
  color: var(--star);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.7rem;
  font-weight: 700;
}

/* ---------- search ---------- */

#searchbar {
  position: fixed;
  top: calc(max(14px, env(safe-area-inset-top)) + 58px);
  left: 18px;
  right: 18px;
  display: flex;
  gap: 8px;
  z-index: 10;
}

#search {
  flex: 1;
  height: 44px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(13, 19, 43, 0.8);
  color: var(--star-white);
  font: inherit;
  font-size: 0.95rem;
  padding: 0 18px;
  outline: none;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

#search::placeholder { color: var(--dim); }
#search:focus { border-color: var(--star); }

#search::-webkit-search-cancel-button,
#search::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }

#voyage {
  height: 44px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(13, 19, 43, 0.8);
  color: var(--star);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0 16px;
  cursor: pointer;
  transition: transform 0.15s;
}

#voyage:active { transform: scale(0.93); }

#search-results {
  position: fixed;
  top: calc(max(14px, env(safe-area-inset-top)) + 108px);
  left: 18px;
  right: 18px;
  z-index: 11;
  background: var(--ink-card);
  border: 1px solid var(--line);
  border-radius: 16px;
  max-height: 40vh;
  overflow-y: auto;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.result-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--star-white);
  padding: 12px 16px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  border-bottom: 1px solid rgba(39, 51, 92, 0.5);
}

.result-row:last-child { border-bottom: 0; }
.result-row .w { font-family: "Gentium Plus", serif; font-size: 1.15rem; color: var(--star); }
.result-row .g { font-size: 0.82rem; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- hint ---------- */

#hint {
  position: fixed;
  bottom: calc(18px + env(safe-area-inset-bottom));
  left: 20px;
  right: 20px;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--dim);
  line-height: 1.6;
  z-index: 9;
  pointer-events: none;
  transition: opacity 1s;
}

#hint.faded { opacity: 0; }

/* ---------- star card ---------- */

#star-card {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 20;
  background: var(--ink-card);
  border: 1px solid rgba(232, 193, 104, 0.5);
  border-radius: 22px;
  padding: 20px 20px 18px;
  box-shadow: 0 14px 50px rgba(0, 0, 0, 0.6), 0 0 40px rgba(232, 193, 104, 0.08);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  animation: card-up 0.3s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}

@keyframes card-up { from { opacity: 0; transform: translateY(26px); } }

#card-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--star-white);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
}

#card-word {
  font-size: 2.3rem;
  line-height: 1.15;
  color: var(--star);
  text-shadow: 0 0 24px rgba(232, 193, 104, 0.35);
  padding-right: 40px;
  overflow-wrap: anywhere;
}

#card-meta {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
  margin: 2px 0 8px;
}

#card-gloss { font-size: 0.98rem; line-height: 1.5; color: var(--star-white); }

#card-links-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
  margin: 14px 0 7px;
}

#card-links { display: flex; flex-wrap: wrap; gap: 7px; padding-right: 62px; }

.link-chip {
  border: 1px solid var(--line);
  background: rgba(39, 51, 92, 0.35);
  color: var(--star-white);
  border-radius: 999px;
  padding: 7px 14px;
  font-family: "Gentium Plus", serif;
  font-size: 0.98rem;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
}

.link-chip:active { transform: scale(0.93); }
.link-chip .rel { font-family: "Space Grotesk", sans-serif; font-size: 0.68rem; color: var(--dim); margin-right: 5px; text-transform: uppercase; }

#card-play {
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #f2dfae, var(--star) 65%);
  color: var(--night-deep);
  display: grid;
  place-items: center;
  box-shadow: 0 0 26px rgba(232, 193, 104, 0.45);
  cursor: pointer;
  transition: transform 0.15s;
}

#card-play:active { transform: scale(0.9); }
#card-play svg { width: 22px; height: 22px; }

#card-play.playing { animation: throb 0.9s ease infinite; }

@keyframes throb { 50% { transform: scale(1.1); } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
