/* ============================================================
   Lunarian Database — standalone styles.
   Deliberately self-contained: this site is served from /lunarian/
   via hostname routing, so it shares no CSS with the comic site.
   ============================================================ */

:root {
  --bg:          #14101f;
  --bg-soft:     #1e1830;
  --bg-card:     #241d3a;
  --ink:         #ece8f6;
  --ink-soft:    #a396c4;
  --purple:      #4b2e83;
  --purple-deep: #2e1a52;
  --moon:        #cfd8ff;
  --moon-bright: #eef2ff;
  --amber:       #ffb43c;
  --line:        #362c55;
  --radius:      16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Trebuchet MS", system-ui, sans-serif;
  scroll-behavior: smooth;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* ---- Header ---- */
.site-header {
  position: relative;
  overflow: hidden;
  text-align: center;
  padding: 54px 24px 40px;
  background:
    radial-gradient(circle at 50% -20%, rgba(207, 216, 255, 0.22), transparent 60%),
    linear-gradient(160deg, var(--purple) 0%, var(--purple-deep) 55%, var(--bg) 100%);
  border-bottom: 1px solid var(--line);
}

/* Faint moon disc behind the title */
.site-header::after {
  content: "";
  position: absolute;
  top: -120px;
  left: 50%;
  transform: translateX(-50%);
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(238, 242, 255, 0.16), transparent 68%);
  pointer-events: none;
}

/* "Back to the Comic" pill — sits over the header, above the moon glow */
.back-link {
  position: absolute;
  top: 18px;
  left: 20px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px 9px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(36, 29, 58, 0.82);
  color: var(--moon);
  font-size: 0.85rem;
  font-weight: 600;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
}

.back-link:hover {
  background: var(--purple);
  border-color: var(--moon);
  color: var(--moon-bright);
  transform: translateX(-2px);
}

.back-link svg { flex-shrink: 0; }

/* Admin entry point — mirrors the back button on the opposite corner */
.admin-link {
  position: absolute;
  top: 18px;
  right: 20px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 17px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(36, 29, 58, 0.82);
  color: var(--moon);
  font-size: 0.85rem;
  font-weight: 600;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
}

.admin-link:hover {
  background: var(--purple);
  border-color: var(--moon);
  color: var(--moon-bright);
  transform: translateX(2px);
}

.admin-link svg { flex-shrink: 0; }

.site-title {
  position: relative;
  margin: 0;
  font-size: clamp(2.1rem, 6vw, 3.4rem);
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: linear-gradient(90deg, var(--moon-bright), var(--moon));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.site-tagline {
  position: relative;
  margin: 10px 0 0;
  color: var(--ink-soft);
  font-size: 1rem;
}

/* ---- Search ---- */
.search-wrap {
  position: relative;
  max-width: 520px;
  margin: 26px auto 0;
}

.search-wrap input {
  width: 100%;
  padding: 13px 18px 13px 44px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(20, 16, 31, 0.75);
  color: var(--ink);
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-wrap input::placeholder { color: var(--ink-soft); }

.search-wrap input:focus {
  outline: none;
  border-color: var(--moon);
  box-shadow: 0 0 0 3px rgba(207, 216, 255, 0.14);
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-soft);
  pointer-events: none;
  line-height: 0;
}

/* ---- Layout ---- */
main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 44px 24px 90px;
}

.category { margin-bottom: 46px; }

.category-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 18px;
}

.category-heading h2 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--moon-bright);
  letter-spacing: 0.03em;
}

.category-heading .rule {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--line), transparent);
}

.category-heading .count {
  font-size: 0.8rem;
  color: var(--ink-soft);
  font-weight: 600;
}

/* ---- Link cards ---- */
.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}

.link-card {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.link-card:hover {
  transform: translateY(-3px);
  border-color: var(--moon);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}

.link-card .name {
  font-weight: 700;
  color: var(--moon-bright);
  margin-bottom: 5px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.link-card .desc {
  font-size: 0.87rem;
  color: var(--ink-soft);
  line-height: 1.5;
}

.link-card.external .name::after {
  content: "↗";
  font-size: 0.8rem;
  opacity: 0.65;
}

/* Shown when a search matches nothing */
.no-results {
  display: none;
  text-align: center;
  padding: 50px 20px;
  color: var(--ink-soft);
}

/* ---- Footer ---- */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 30px 24px 44px;
  text-align: left;
  color: var(--ink-soft);
  font-size: 0.87rem;
  max-width: 1080px;
  margin: 0 auto;
}

.footer-links {
  display: flex;
  justify-content: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.footer-links a {
  padding: 9px 20px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.88rem;
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
}

.footer-links a:hover {
  background: var(--purple);
  border-color: var(--moon);
  transform: translateY(-2px);
}

/* ============================================================
   Sections: Characters / World & Locations / Info
   ============================================================ */
.section-nav {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 24px;
  position: relative;
  z-index: 1;
}

.section-nav a {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(36, 29, 58, 0.7);
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 600;
  transition: background 0.2s, border-color 0.2s;
}

.section-nav a:hover { background: var(--purple); border-color: var(--moon); }

.section { margin-bottom: 58px; scroll-margin-top: 20px; }

.section-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 14px;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.3rem;
  color: var(--moon-bright);
  letter-spacing: 0.03em;
}

.section-heading .rule {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--line), transparent);
}

.section-heading .count {
  font-size: 0.8rem;
  color: var(--ink-soft);
  font-weight: 600;
  white-space: nowrap;
}

.section-desc {
  color: var(--ink-soft);
  line-height: 1.6;
  margin: 0 0 18px;
  max-width: 70ch;
}

.section .search-wrap { margin: 0 0 18px; max-width: 100%; }

/* ---- Result cards ---- */
.results-panel {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(30, 24, 48, 0.55);
  min-height: 90px;
}

.entry-card {
  display: flex;
  gap: 13px;
  align-items: center;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-card);
  cursor: pointer;
  transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s;
}

.entry-card:hover,
.entry-card:focus-visible {
  transform: translateY(-2px);
  border-color: var(--moon);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.4);
  outline: none;
}

.card-thumb {
  width: 62px;
  height: 62px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--purple-deep);
}

.card-thumb.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.5rem;
  color: var(--moon);
  background: linear-gradient(135deg, var(--purple-deep), var(--purple));
}

.card-body { min-width: 0; }

.card-name {
  font-weight: 700;
  color: var(--moon-bright);
  margin-bottom: 3px;
}

.card-summary {
  font-size: 0.84rem;
  color: var(--ink-soft);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-more {
  margin-top: 6px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--moon);
  opacity: 0;
  transition: opacity 0.18s;
}

.entry-card:hover .card-more,
.entry-card:focus-visible .card-more { opacity: 1; }

.empty-note {
  grid-column: 1 / -1;
  text-align: center;
  padding: 26px 12px;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.muted { color: var(--ink-soft); }

/* ---- Map ---- */
.map-block { margin-top: 26px; }
.map-block[hidden] { display: none; }

.map-caption {
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin-bottom: 10px;
}

.map-wrap {
  position: relative;
  display: inline-block;
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  line-height: 0;
}

.map-wrap img { width: 100%; height: auto; display: block; }

.map-node {
  position: absolute;
  transform: translate(-50%, -50%);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  line-height: 0;
  z-index: 2;
}

.map-dot {
  display: block;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--amber);
  border: 2.5px solid #fff;
  box-shadow: 0 0 0 4px rgba(255, 180, 60, 0.32);
  transition: transform 0.18s, box-shadow 0.18s;
}

.map-node:hover .map-dot,
.map-node:focus-visible .map-dot {
  transform: scale(1.25);
  box-shadow: 0 0 0 7px rgba(255, 180, 60, 0.42);
}

/* Hover summary bubble */
.map-tip {
  position: absolute;
  bottom: 150%;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 240px;
  padding: 10px 13px;
  border-radius: 10px;
  background: rgba(20, 16, 31, 0.97);
  border: 1px solid var(--line);
  color: var(--ink);
  text-align: left;
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s;
  z-index: 3;
}

.map-node:hover .map-tip,
.map-node:focus-visible .map-tip { opacity: 1; }

.map-tip-name {
  display: block;
  font-weight: 700;
  font-size: 0.86rem;
  color: var(--moon-bright);
  margin-bottom: 3px;
}

.map-tip-sum {
  display: block;
  font-size: 0.78rem;
  color: var(--ink-soft);
}

/* ---- Info topics ---- */
.topic-list {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-bottom: 18px;
}

.topic-chip {
  padding: 9px 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, color 0.18s;
}

.topic-chip:hover { border-color: var(--moon); }

.topic-chip.active {
  background: var(--moon);
  border-color: var(--moon);
  color: #14101f;
}

.topic-detail {
  display: none;
  padding: 22px 24px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(30, 24, 48, 0.55);
  line-height: 1.65;
}

.topic-detail.open { display: block; }
.topic-detail h3 { margin: 0 0 6px; color: var(--moon-bright); font-size: 1.1rem; }
.topic-detail p  { margin: 0 0 12px; color: var(--ink); }
.topic-summary   { color: var(--ink-soft) !important; font-style: italic; }

.topic-link {
  display: inline-block;
  margin-top: 6px;
  color: var(--moon);
  font-weight: 600;
  font-size: 0.88rem;
}

.topic-link:hover { text-decoration: underline; }

/* ---- Testing area (Figma embed) ---- */
.figma-open {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--moon);
  white-space: nowrap;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-card);
  transition: background 0.2s, border-color 0.2s;
}

.figma-open:hover { background: var(--purple); border-color: var(--moon); }
.figma-open[hidden] { display: none; }

.figma-frame {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: #1b1626;
  /* Tall enough to actually work in, without swallowing the whole page */
  height: min(72vh, 760px);
}

.figma-frame[hidden] { display: none; }

.figma-frame iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.figma-empty {
  padding: 46px 20px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.9rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(30, 24, 48, 0.4);
}

.figma-empty[hidden] { display: none; }

.figma-note {
  margin: 12px 0 0;
  font-size: 0.8rem;
  color: var(--ink-soft);
  line-height: 1.5;
}

.figma-note[hidden] { display: none; }

/* ---- Full-entry modal ---- */
.entry-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(10, 7, 18, 0.86);
}

.entry-modal.open { display: flex; }

.entry-modal-box {
  position: relative;
  width: 100%;
  max-width: 620px;
  max-height: 86vh;
  overflow-y: auto;
  padding: 28px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.6);
}

.entry-modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  color: var(--ink-soft);
  font-size: 1.9rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s;
}

.entry-modal-close:hover { color: var(--moon-bright); }

.entry-modal-head {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 18px;
  padding-right: 34px;
}

.entry-modal-head img {
  width: 104px;
  height: 104px;
  border-radius: 12px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--purple-deep);
}

.entry-modal-head h3 {
  margin: 0 0 5px;
  font-size: 1.4rem;
  color: var(--moon-bright);
}

.entry-modal-head p {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.5;
}

.entry-modal-body { line-height: 1.7; }
.entry-modal-body p { margin: 0 0 13px; }

.entry-modal-present {
  margin-top: 14px;
  padding: 13px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(75, 46, 131, 0.28);
  font-size: 0.9rem;
  line-height: 1.55;
}

.entry-modal-present[hidden] { display: none; }

.entry-modal-link {
  display: inline-block;
  margin-top: 18px;
  padding: 11px 24px;
  border-radius: 999px;
  background: var(--moon);
  color: #14101f;
  font-weight: 700;
  font-size: 0.9rem;
  transition: background 0.2s;
}

.entry-modal-link:hover { background: var(--moon-bright); }
.entry-modal-link[hidden] { display: none; }

/* ---- Mobile ---- */
@media only screen and (max-width: 768px) {
  .site-header { padding: 20px 16px 30px; }

  /* Let both buttons sit in the flow so they can't overlap the title */
  .back-link, .admin-link {
    position: static;
    display: inline-flex;
    margin: 0 5px 18px;
  }
  main { padding: 32px 16px 70px; }
  .link-grid { grid-template-columns: 1fr; }
  .section { margin-bottom: 40px; }
  .results-panel { grid-template-columns: 1fr; padding: 12px; }
  .entry-modal-box { padding: 22px 18px; }
  .entry-modal-head { flex-direction: column; }
  .entry-modal-head img { width: 100%; height: 190px; }
  /* Tooltips would be cut off at the screen edge on a phone */
  .map-tip { max-width: 190px; }
}
