/* ── Variables ────────────────────────────────────────────────────────────── */
:root {
  --navy:      #1B3A5C;
  --navy-deep: #122740;
  --teal:      #00838F;
  --teal-light:#e0f4f5;
  --teal-dark: #006670;
  --accent:    #e8962e;
  --bg:        #f7f9fc;
  --hero-bg:   #eceff3;
  --card-bg:   #ffffff;
  --border:    #e2e8f0;
  --text:      #1e293b;
  --muted:     #64748b;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius:    10px;
  --shadow:    0 2px 12px rgba(27,58,92,.08);
  --shadow-md: 0 4px 24px rgba(27,58,92,.14);
}

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

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.ap-main { flex: 1; }

/* ── Navbar ───────────────────────────────────────────────────────────────── */
.ap-navbar {
  background: var(--navy);
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
  min-height: 60px;
}

.brand-helix {
  font-size: 1.5rem;
  color: var(--teal);
  line-height: 1;
}
.brand-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.5px;
}
.brand-db {
  color: var(--teal);
}

/* Navbar search */
.nav-search-wrap { width: min(480px, 100%); }
.nav-search-group .nav-search-icon {
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.2);
  color: #ccc;
  border-right: none;
}
.nav-search-input {
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.2);
  color: #fff;
  border-radius: 0 6px 6px 0 !important;
}
.nav-search-input::placeholder { color: rgba(255,255,255,.5); }
.nav-search-input:focus {
  background: rgba(255,255,255,.15);
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(0,131,143,.3);
  color: #fff;
}

/* ── Search dropdown ─────────────────────────────────────────────────────── */
.search-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 1060;
  overflow: hidden;
  max-height: 360px;
  overflow-y: auto;
}
.search-dropdown .sd-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  text-decoration: none;
  color: var(--text);
  transition: background .12s;
}
.search-dropdown .sd-item:last-child { border-bottom: none; }
.search-dropdown .sd-item:hover { background: var(--teal-light); }
.search-dropdown .sd-pdb { font-family: var(--font-mono); font-weight: 600; font-size: .78rem; color: var(--navy); }
.search-dropdown .sd-title { font-size: .82rem; color: var(--muted); text-overflow: ellipsis; overflow: hidden; white-space: nowrap; max-width: 260px; }
.search-dropdown .sd-org { font-size: .75rem; color: #94a3b8; margin-left: auto; flex-shrink: 0; }
.search-dropdown .sd-empty { padding: 1rem; text-align: center; color: var(--muted); font-size: .85rem; }

/* ── Footer ───────────────────────────────────────────────────────────────── */
.ap-footer {
  background: var(--navy-deep);
  border-top: 3px solid var(--teal);
}
.footer-link { color: var(--teal); text-decoration: none; }
.footer-link:hover { color: #fff; }

/* ── Hero section ─────────────────────────────────────────────────────────── */
/* A light grey band, not a dark gradient: the page below it is light, and the
   search box is the thing to look at — it reads as white-on-grey, unaided. */
.hero-section {
  background: var(--hero-bg);
  color: var(--text);
  padding: 4rem 1.5rem 3.25rem;
  position: relative;
  border-bottom: 1px solid var(--border);
}
.hero-badge {
  display: inline-flex;
  align-items: center;
  background: var(--teal-light);
  border: 1px solid rgba(0,131,143,.25);
  color: var(--teal-dark);
  padding: .35rem .9rem;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 500;
}
.hero-title {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1.15;
  color: var(--navy);
}
.text-teal { color: var(--teal) !important; }
.hero-subtitle {
  font-size: 1.05rem;
  color: var(--muted);
  margin-bottom: 2rem;
}
.hero-search-wrap {
  max-width: 680px;
  position: relative;
}
.hero-search-group {
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.hero-search-icon {
  background: #fff;
  border: none;
  color: var(--muted);
  padding: 0 1rem;
  font-size: 1.1rem;
}
.hero-search-input {
  border: none;
  padding: .85rem 1rem;
  font-size: 1rem;
  height: auto;
}
.hero-search-input:focus {
  box-shadow: none;
  border-color: transparent;
}
.hero-search-btn {
  background: var(--teal);
  color: #fff;
  border: none;
  padding: 0 1.75rem;
  font-weight: 600;
  border-radius: 0 !important;
  transition: background .15s;
}
.hero-search-btn:hover { background: var(--teal-dark); color: #fff; }
.hero-dropdown { top: calc(100% + 4px); }
.hero-examples .hero-example-link {
  color: var(--teal-dark);
  text-decoration: none;
  border-bottom: 1px dotted rgba(0,102,112,.45);
}
.hero-example-link:hover { color: var(--navy); }

/* ── Stats strip ──────────────────────────────────────────────────────────── */
.stats-strip { background: var(--navy); }
.stat-card {
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.stat-num {
  font-size: 2rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.1;
}
.stat-label {
  font-size: .78rem;
  color: rgba(255,255,255,.5);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-top: .3rem;
}

/* ── Featured section ─────────────────────────────────────────────────────── */
.featured-section { background: var(--bg); }
.section-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--navy);
}

/* Entry cards */
.entry-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: box-shadow .18s, transform .18s;
  color: var(--text);
}
.entry-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.entry-card-img-wrap {
  position: relative;
  height: 160px;
  /* Skeleton shimmer shows while the RCSB render is in flight, so the tile is
     never a blank box. */
  background: linear-gradient(100deg, #eef2f7 30%, #f7fafc 50%, #eef2f7 70%);
  background-size: 220% 100%;
  animation: img-skeleton 1.4s ease-in-out infinite;
  overflow: hidden;
}
@keyframes img-skeleton {
  from { background-position: 180% 0; }
  to   { background-position: -80% 0; }
}
.entry-card-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
  opacity: 0;
  transition: opacity .25s ease;
}
/* Stop the shimmer once the render has actually arrived. */
.entry-card-img.loaded { opacity: 1; }
.entry-card-img-wrap:has(.entry-card-img.loaded) { animation: none; background: #fff; }

/* No render available on the CDN — draw a local placeholder rather than
   chasing a second remote image that can also 404. */
.entry-card-img-wrap.img-missing {
  animation: none;
  background: #f0f4f8;
  display: flex;
  align-items: center;
  justify-content: center;
}
.entry-card-img-wrap.img-missing::after {
  content: "⬡  no render available";
  font-size: .75rem;
  color: #93a5b8;
  letter-spacing: .02em;
}
.badge-res {
  position: absolute;
  top: .5rem; right: .5rem;
  background: rgba(27,58,92,.85);
  color: #fff;
  font-size: .7rem;
  font-weight: 600;
  padding: .2rem .5rem;
  border-radius: 6px;
  backdrop-filter: blur(4px);
}
.entry-title {
  font-size: .85rem;
  font-weight: 500;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.entry-org, .entry-uni {
  font-size: .75rem;
  color: var(--muted);
}

/* ── How-to section ───────────────────────────────────────────────────────── */
.howto-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  height: 100%;
}
.howto-icon {
  width: 52px; height: 52px;
  background: var(--teal-light);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: var(--teal);
}

/* ── Badges ───────────────────────────────────────────────────────────────── */
.pdb-badge {
  font-family: var(--font-mono);
  font-size: .78rem;
  font-weight: 700;
  background: var(--navy);
  color: #fff;
  padding: .2rem .55rem;
  border-radius: 6px;
  letter-spacing: .5px;
  display: inline-block;
}
.pdb-badge-sm { font-size: .72rem; padding: .15rem .45rem; }
.pdb-badge-lg { font-size: .95rem; padding: .3rem .75rem; border-radius: 8px; }
.pdb-badge-xs { font-size: .65rem; padding: .1rem .35rem; border-radius: 4px; }

.oligo-badge {
  font-size: .72rem;
  background: #eef2ff;
  color: #3730a3;
  border: 1px solid #c7d2fe;
  padding: .18rem .5rem;
  border-radius: 6px;
  font-weight: 600;
}
.oligo-badge-sm { font-size: .68rem; padding: .12rem .4rem; }

.res-badge {
  font-family: var(--font-mono);
  font-size: .72rem;
  font-weight: 700;
  padding: .18rem .5rem;
  border-radius: 6px;
}
.res-badge-lg { font-size: .85rem; padding: .25rem .65rem; border-radius: 8px; }
.res-hi { background: #dcfce7; color: #15803d; }
.res-mid { background: #fef9c3; color: #854d0e; }
.res-lo { background: #fee2e2; color: #b91c1c; }

/* ── Browse page ──────────────────────────────────────────────────────────── */
.page-title { font-size: 1.6rem; font-weight: 700; color: var(--navy); }

.filter-panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  position: sticky;
  top: 1rem;
  box-shadow: var(--shadow);
}
.filter-panel-header {
  background: var(--navy);
  color: #fff;
  padding: .75rem 1rem;
  font-size: .85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
}
.filter-group {
  padding: .75rem 1rem .5rem;
  border-bottom: 1px solid var(--border);
}
.filter-group:last-of-type { border-bottom: none; }
.filter-label {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  margin-bottom: .35rem;
  display: block;
}
.filter-panel form { padding-bottom: .75rem; }

.browse-table-wrap {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.browse-table thead th {
  background: var(--navy);
  color: rgba(255,255,255,.85);
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  padding: .75rem 1rem;
  white-space: nowrap;
  border: none;
}
.browse-table tbody td {
  padding: .65rem 1rem;
  vertical-align: middle;
  font-size: .85rem;
  border-bottom: 1px solid #f1f5f9;
}
.browse-row { cursor: pointer; transition: background .1s; }
.browse-row:hover { background: var(--teal-light) !important; }
.title-cell { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.org-cell { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-style: italic; }

.sort-link { color: rgba(255,255,255,.85); text-decoration: none; display: inline-flex; align-items: center; gap: .25rem; }
.sort-link:hover { color: #fff; }
.active-sort { color: #fff !important; }

.uni-link { color: var(--teal); font-family: var(--font-mono); font-size: .78rem; }
.uni-link:hover { color: var(--teal-dark); }

/* ── Entry detail page ────────────────────────────────────────────────────── */
.entry-header {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.entry-page-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.3;
}

.section-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.section-card-header {
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  padding: .75rem 1.1rem;
  font-size: .82rem;
  font-weight: 600;
  color: var(--navy);
  display: flex;
  align-items: center;
  gap: .35rem;
}
.section-card-body { padding: 1rem 1.1rem; }

/* Viewer controls */
.viewer-controls { gap: .25rem; }
.btn-xs { padding: .2rem .45rem; font-size: .7rem; border-radius: 5px; }
.viewer-legend { background: #0f0f1e; color: #6b7280; border-top: 1px solid #2d2d3e; }
.dot-blue { display: inline-block; width: 10px; height: 10px; background: #6699ff; border-radius: 50%; margin-right: 4px; }

/* Info table */
.info-table th {
  font-size: .75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .3px;
  white-space: nowrap;
  width: 140px;
  background: transparent;
}
.info-table td { font-size: .85rem; }
.info-table td code { font-family: var(--font-mono); font-size: .85rem; }

/* Siblings */
.siblings-list { margin: 0; }
.sibling-item { padding: .55rem 1rem; }
.sibling-title { font-size: .8rem; color: var(--muted); }

/* Enriched data panels */
.enriched-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem 1rem; }
.enriched-item { }
.enriched-label { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); margin-bottom: .2rem; }
.enriched-value { font-size: .87rem; color: var(--text); }

.kw-badge {
  display: inline-flex;
  background: #f0f4ff;
  color: #3730a3;
  border: 1px solid #c7d2fe;
  border-radius: 5px;
  font-size: .72rem;
  padding: .15rem .45rem;
  margin: .1rem;
}
.go-term {
  font-size: .78rem;
  padding: .2rem 0;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  gap: .5rem;
  align-items: baseline;
}
.go-term:last-child { border-bottom: none; }
.go-id { font-family: var(--font-mono); font-size: .7rem; color: var(--muted); flex-shrink: 0; }
.go-label { color: var(--text); }

.disease-item {
  background: #fff5f5;
  border-left: 3px solid #f87171;
  padding: .4rem .75rem;
  border-radius: 0 6px 6px 0;
  font-size: .82rem;
  margin-bottom: .3rem;
}

.ligand-item {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: .5rem .75rem;
  font-size: .8rem;
}
.ligand-id { font-family: var(--font-mono); font-weight: 700; color: var(--accent); }

/* Author list */
.author-list { font-size: .82rem; color: var(--muted); }

/* Chain chips */
.chain-chip {
  display: inline-block;
  background: var(--navy);
  color: #fff;
  border-radius: 6px;
  padding: .2rem .6rem;
  font-size: .75rem;
  margin: .1rem;
}

/* Sequence block */
.seq-block {
  font-family: var(--font-mono);
  font-size: .72rem;
  word-break: break-all;
  background: #0f172a;
  color: #7dd3fc;
  padding: .75rem;
  border-radius: 8px;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.6;
}

/* Lineage breadcrumb */
.lineage-pill {
  display: inline-block;
  background: #f1f5f9;
  color: var(--muted);
  font-size: .7rem;
  padding: .15rem .5rem;
  border-radius: 999px;
  margin: .1rem;
}

/* Pagination */
.page-link { font-size: .8rem; }
.page-item.active .page-link { background: var(--navy); border-color: var(--navy); }
.page-link:focus { box-shadow: 0 0 0 2px rgba(0,131,143,.25); }

/* Utility */
.fw-600 { font-weight: 600; }

/* ── Download section (home page) ─────────────────────────────────────────── */
.download-section { background: #fff; }
.download-banner {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(135deg, #f6fdfc 0%, #ffffff 55%);
  padding: 2rem 2.25rem;
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(15,23,42,.06));
}
.download-facts { list-style: none; padding: 0; margin: 0; }
.download-facts li {
  font-size: .82rem;
  color: var(--muted, #64748b);
  padding: .55rem 0;
  border-bottom: 1px dashed var(--border);
}
.download-facts li:last-child { border-bottom: 0; }
.download-facts strong { color: var(--text, #0f172a); }

@media (max-width: 575.98px) {
  .download-banner { padding: 1.25rem; }
}
