/* structural-biology.com: the approved Bento tile system (Section 6.2).
   Reference: design/Bento.dc.html. Tokens first, then components. */

:root {
  --sb-navy: #1C244B;
  --sb-accent: #467FF7;
  --sb-action: #2F5FD0;
  --sb-ground: #FFFFFF;
  --sb-ground-alt: #F4F6FC;
  --sb-muted: #4A5478;
  --sb-border: #E3E7F2;
  --sb-viewer: #0F1533;
  --sb-light: #9DB8F5;
  --sb-warn: #F2B544;
  --radius: 10px;
  --radius-lg: 16px;
  --font: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --sb-bento-ground: #EDF0F7;
  --sb-tile: #FFFFFF;
  --sb-tile-inner: #F4F6FC;
  --sb-chip: #EEF2FD;
  --sb-ok-text: #276A4D;   /* 5.7:1 on --sb-ok-bg */
  --sb-ok-bg: #E4F5EC;
  --sb-note: #8A5A00;
  --sb-hero-text: #C9D1EE;
  --sb-rule: #C9D1E6;

  --r-tile: 22px;
  --r-bar: 18px;
  --r-kpi: 20px;
  --r-inner: 16px;
  --r-pill: 999px;
  --gap: 16px;
  --page-max: 1320px;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--sb-navy);
  background: var(--sb-bento-ground);
}

a { color: var(--sb-action); }
a:hover { color: var(--sb-navy); }
:focus-visible {
  outline: 3px solid var(--sb-accent);
  outline-offset: 2px;
  border-radius: 4px;
}

img { max-width: 100%; height: auto; }

.mono { font-family: var(--mono); }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--sb-navy); color: #fff; padding: 12px 18px;
  border-radius: 0 0 var(--r-inner) 0; text-decoration: none; font-weight: 600;
}
.skip-link:focus { left: 0; color: #fff; }

/* --------------------------------------------------------------------- */
/* Layout                                                                 */
/* --------------------------------------------------------------------- */

.page {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 20px 24px 48px;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
}

.tile {
  background: var(--sb-tile);
  border-radius: var(--r-tile);
  padding: 24px;
  min-width: 0;
}
.tile--pad-lg { padding: 32px; }
.tile--7 { flex: 7 1 520px; }
.tile--5 { flex: 5 1 380px; }
.tile--full { flex: 1 1 100%; }
.tile--navy { background: var(--sb-navy); color: #fff; }
.tile--navy a { color: #fff; }
/* A chip keeps its own fill and navy text inside a navy or accent tile, or the
   white link colour leaves it unreadable on the pale pill. */
.tile--navy .chip, .tile--accent .chip { color: var(--sb-navy); background: var(--sb-chip); }
.tile--navy .chip:hover, .tile--accent .chip:hover { background: var(--sb-light); }
.tile--navy .badge, .tile--accent .badge { color: var(--sb-action); }
.tile--navy .badge--role, .tile--accent .badge--role { color: var(--sb-ok-text); }
.tile--navy .badge--ref, .tile--accent .badge--ref { color: var(--sb-note); }
.tile--accent { background: var(--sb-action); color: #fff; }
.tile--accent a { color: #fff; }
.tile--column { display: flex; flex-direction: column; gap: 14px; }

.panel {
  background: var(--sb-tile-inner);
  border-radius: var(--r-inner);
  padding: 16px 18px;
}

.tile-head {
  display: flex; flex-wrap: wrap; justify-content: space-between;
  align-items: baseline; gap: 10px; margin-bottom: 14px;
}
.tile-head h2, .tile-head h3 { margin: 0; }
.tile h2 { font-size: 22px; font-weight: 700; margin: 0 0 10px; }
.tile h3 { font-size: 18px; font-weight: 600; margin: 0 0 8px; }
.tile-note { font-size: 12px; color: var(--sb-muted); }
.tile--navy .tile-note { color: var(--sb-hero-text); }
/* #C9D1EE on the action blue is only 3.77:1, so the accent tile uses a paler note. */
.tile--accent .tile-note { color: #EDF2FE; }
.tile--accent .kpi-l { color: #EDF2FE; }

/* --------------------------------------------------------------------- */
/* Header and footer bars                                                 */
/* --------------------------------------------------------------------- */

.bar {
  background: var(--sb-tile);
  border-radius: var(--r-bar);
  padding: 10px 14px 10px 20px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--sb-navy); margin-right: auto;
  font-weight: 600; font-size: 16px;
}
.brand svg { flex: 0 0 auto; }

.nav { display: flex; flex-wrap: wrap; gap: 4px; font-size: 14px; font-weight: 500; }
.nav a {
  padding: 12px 14px; border-radius: var(--r-pill);
  text-decoration: none; color: var(--sb-navy); background: var(--sb-bento-ground);
  min-height: 44px; display: inline-flex; align-items: center;
}
.nav a:hover { background: var(--sb-chip); }
.nav a[aria-current="page"] { background: var(--sb-navy); color: #fff; }

.footbar {
  background: var(--sb-tile); border-radius: var(--r-bar);
  padding: 18px 22px; display: flex; flex-wrap: wrap;
  justify-content: space-between; gap: 14px;
  font-size: 14px; color: var(--sb-muted);
}
.footbar-links { display: flex; flex-wrap: wrap; gap: 18px; }

/* --------------------------------------------------------------------- */
/* Hero                                                                   */
/* --------------------------------------------------------------------- */

.hero {
  display: flex; flex-direction: column; gap: 18px; justify-content: space-between;
}
.eyebrow {
  font-size: 12px; font-weight: 600; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--sb-light);
}
.hero h1 { margin: 0; font-size: 44px; line-height: 1.08; font-weight: 700; }
.hero p { margin: 0; font-size: 16px; line-height: 1.6; color: var(--sb-hero-text); }
.hero-stack { display: flex; flex-direction: column; gap: 14px; }

.searchform {
  display: flex; align-items: center; gap: 10px;
  background: #fff; border-radius: 14px; padding: 0 14px; height: 54px;
}
.searchform svg { flex: 0 0 auto; }
.searchform input {
  border: 0; outline: none; flex: 1; min-width: 0;
  font-family: var(--font); font-size: 15px; color: var(--sb-navy); background: transparent;
}
.searchform button {
  border: 0; background: var(--sb-action); color: #fff; font-family: var(--font);
  font-weight: 600; font-size: 14px; border-radius: var(--radius);
  height: 40px; padding: 0 16px; cursor: pointer; flex: 0 0 auto;
}
.searchform button:hover { background: var(--sb-navy); }

/* --------------------------------------------------------------------- */
/* KPI tiles                                                              */
/* --------------------------------------------------------------------- */

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(146px, 1fr));
  gap: 12px;
}
.kpi {
  background: var(--sb-tile); border: 0; border-radius: var(--r-kpi);
  padding: 18px; text-align: left; font-family: var(--font); color: var(--sb-navy);
  cursor: pointer; display: block; width: 100%; min-height: 44px;
}
.kpi-cell:first-child .kpi { background: var(--sb-action); color: #fff; }
.kpi-cell:first-child .kpi-src { color: #E3EAFB; }
.kpi-v { display: block; font-size: 30px; font-weight: 700; line-height: 1.1; }
.kpi-l { display: block; font-size: 13px; font-weight: 600; margin-top: 6px; }
.kpi-sub { display: block; font-size: 12px; margin-top: 2px; color: var(--sb-muted); }
.kpi-cell:first-child .kpi-sub { color: #E3EAFB; }
.kpi-src { display: block; font-size: 11px; margin-top: 8px; color: var(--sb-muted); }
/* A bare [hidden] loses to an explicit display, so say it again for the tile internals. */
.kpi-src[hidden], .kpi-link[hidden], .ask-q[hidden], .ask-note[hidden] { display: none; }
.kpi[hidden] { display: none; }
.kpi--stale { background: var(--sb-tile-inner); color: var(--sb-muted); }
.kpi--stale .kpi-v { color: var(--sb-muted); }
.kpi-cell { display: flex; flex-direction: column; }
.kpi-link { display: block; font-size: 11px; margin: 6px 0 0 18px; }
.kpi-cell > .kpi { flex: 1 1 auto; }

/* --------------------------------------------------------------------- */
/* Chips and pills                                                        */
/* --------------------------------------------------------------------- */

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font-family: var(--font); font-size: 13px; color: var(--sb-navy);
  background: var(--sb-chip); border: 0; border-radius: var(--r-pill);
  padding: 0 16px; min-height: 44px; display: inline-flex; align-items: center;
  cursor: pointer; text-decoration: none; gap: 6px;
}
.chip:hover { background: var(--sb-light); color: var(--sb-navy); }
.chip[aria-pressed="true"], .chip[aria-current="true"], .chip--on {
  background: var(--sb-navy); color: #fff;
}
.chip--mono { font-family: var(--mono); font-size: 12px; }
/* A DOI or a long accession in a chip must wrap rather than push the page wide. */
.chip, .chip--mono { max-width: 100%; overflow-wrap: anywhere; }
.mono { overflow-wrap: anywhere; }
.chip-count { font-size: 12px; opacity: 0.8; }

.badge {
  display: inline-block; font-size: 11px; font-weight: 600; padding: 3px 9px;
  border-radius: var(--r-pill); background: var(--sb-chip); color: var(--sb-action);
}
.badge--role { background: var(--sb-ok-bg); color: var(--sb-ok-text); }
.badge--ref { background: #FDF1D8; color: var(--sb-note); }

.pill-ok {
  font-size: 12px; color: var(--sb-ok-text); background: var(--sb-ok-bg);
  padding: 6px 10px; border-radius: var(--r-pill); white-space: nowrap;
}
.pill-warn { font-size: 12px; color: var(--sb-note); background: #FDF1D8;
  padding: 6px 10px; border-radius: var(--r-pill); }
.pill-off { font-size: 12px; color: var(--sb-muted); background: var(--sb-ground-alt);
  padding: 6px 10px; border-radius: var(--r-pill); }

/* --------------------------------------------------------------------- */
/* Cards                                                                  */
/* --------------------------------------------------------------------- */

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--sb-tile-inner); border-radius: var(--r-inner);
  padding: 16px 18px; text-decoration: none; color: var(--sb-navy);
}
.card:hover { background: var(--sb-chip); color: var(--sb-navy); }
.card-meta { font-size: 12px; color: var(--sb-action); font-weight: 600; }
.card-title { font-weight: 600; font-size: 15px; line-height: 1.35; }
.card-excerpt { font-size: 13px; color: var(--sb-muted); line-height: 1.55; }

.section-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.section-tile {
  text-decoration: none; color: var(--sb-navy); background: var(--sb-tile);
  border-radius: var(--r-tile); padding: 20px;
  display: flex; flex-direction: column; gap: 6px;
}
.section-tile:hover { background: var(--sb-chip); color: var(--sb-navy); }
.section-tile .n { font-size: 30px; font-weight: 700; color: var(--sb-action); }
.section-tile .name { font-weight: 600; }
.section-tile .line { font-size: 13px; color: var(--sb-muted); }

.latest-list { display: flex; flex-direction: column; gap: 10px; }
.latest-item {
  text-decoration: none; color: var(--sb-navy); background: var(--sb-tile-inner);
  border-radius: 14px; padding: 12px 14px; display: block;
}
.latest-item:hover { background: var(--sb-chip); color: var(--sb-navy); }
.latest-item .kicker { font-size: 12px; color: var(--sb-action); font-weight: 600; }
.latest-item .t { display: block; font-weight: 600; font-size: 14px; margin-top: 2px; }

/* --------------------------------------------------------------------- */
/* Viewer                                                                 */
/* --------------------------------------------------------------------- */

.sb-viewer { display: flex; flex-direction: column; gap: 10px; }
.sb-viewer-frame {
  position: relative; background: var(--sb-tile-inner);
  border-radius: var(--r-inner); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.sb-viewer-frame--live { background: var(--sb-viewer); }
.sb-viewer-poster {
  max-height: 100%; max-width: 100%; object-fit: contain; display: block;
}
.sb-viewer-fallback {
  display: flex; align-items: center; justify-content: center; text-align: center;
  color: var(--sb-muted); font-size: 14px; padding: 24px; width: 100%; height: 100%;
}
.sb-viewer-load {
  position: absolute; bottom: 12px; left: 12px;
  background: var(--sb-action); color: #fff; border: 0; border-radius: var(--radius);
  font-family: var(--font); font-size: 13px; font-weight: 600;
  min-height: 44px; padding: 0 18px; cursor: pointer;
}
.sb-viewer-load:hover { background: var(--sb-navy); }
.sb-viewer-controls { display: flex; flex-wrap: wrap; gap: 6px; }
.sb-viewer-controls button {
  font-family: var(--font); font-size: 13px; color: var(--sb-navy);
  background: var(--sb-chip); border: 0; border-radius: var(--r-pill);
  min-height: 44px; padding: 0 14px; cursor: pointer;
}
.sb-viewer-controls button:hover { background: var(--sb-light); }
.sb-viewer-controls button[aria-pressed="true"] { background: var(--sb-navy); color: #fff; }
.sb-viewer-status { font-size: 12px; color: var(--sb-muted); min-height: 18px; }
.sb-viewer-host { position: absolute; inset: 0; }

figure.structure-tile { margin: 0; display: flex; flex-direction: column; gap: 12px; }
figure.structure-tile figcaption { font-size: 14px; color: var(--sb-muted); }

/* --------------------------------------------------------------------- */
/* Ask about Marc                                                         */
/* --------------------------------------------------------------------- */

.ask { display: flex; flex-direction: column; gap: 14px; }
.ask-out {
  background: var(--sb-tile-inner); border-radius: var(--r-inner);
  padding: 16px 18px; min-height: 150px;
  display: flex; flex-direction: column; gap: 10px;
}
.ask-q { font-size: 13px; font-weight: 600; color: var(--sb-action); }
.ask-a { font-size: 15px; line-height: 1.7; color: var(--sb-navy); }
.ask-a p { margin: 0 0 10px; }
.ask-a p:last-child { margin-bottom: 0; }
.ask-a ul, .ask-a ol { margin: 0 0 10px; padding-left: 22px; }
.ask-note { margin: 0; font-size: 13px; color: var(--sb-note); }
.ask-form { display: flex; gap: 10px; flex-wrap: wrap; }
.ask-form input {
  flex: 1 1 240px; min-width: 0; height: 46px; padding: 0 14px;
  border-radius: 12px; border: 1px solid #D5DBEB;
  font-family: var(--font); font-size: 14px; color: var(--sb-navy);
}
.ask-form button {
  height: 46px; padding: 0 20px; border: 0; border-radius: 12px;
  background: var(--sb-action); color: #fff; font-family: var(--font);
  font-weight: 600; font-size: 14px; cursor: pointer;
}
.ask-form button:hover { background: var(--sb-navy); }
.ask-form button[disabled] { background: var(--sb-light); cursor: not-allowed; }
.ask-foot { margin: 0; font-size: 12px; color: var(--sb-muted); }
.ask-caret { color: var(--sb-action); }

/* --------------------------------------------------------------------- */
/* Charts                                                                 */
/* --------------------------------------------------------------------- */

.chart { width: 100%; min-height: 240px; }
.chart-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chart-foot { font-size: 12px; color: var(--sb-muted); margin: 8px 0 0; }

/* --------------------------------------------------------------------- */
/* Lenses                                                                 */
/* --------------------------------------------------------------------- */

.lens-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.lens-panel[hidden] { display: none; }
.deflist { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 16px;
  font-size: 14px; }
.deflist dt { color: var(--sb-muted); }
.deflist dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.deflist dd.mono { font-family: var(--mono); }

/* A wide table scrolls inside its tile rather than widening the page. max-width is
   needed as well as overflow-x: a grid or flex child sizes to its content first. */
.table-wrap { overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }
table.data { border-collapse: collapse; width: 100%; font-size: 14px; }
table.data th, table.data td {
  text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--sb-border);
  vertical-align: top;
}
table.data th { font-weight: 600; color: var(--sb-muted); font-size: 13px; }
table.data tbody tr:hover { background: var(--sb-tile-inner); }

/* --------------------------------------------------------------------- */
/* Reading column                                                         */
/* --------------------------------------------------------------------- */

.prose { max-width: 720px; font-size: 17px; line-height: 1.75; }
.prose h2 { font-size: 26px; margin: 32px 0 12px; }
.prose h3 { font-size: 21px; margin: 26px 0 10px; }
.prose h4 { font-size: 18px; margin: 22px 0 8px; }
.prose p { margin: 0 0 18px; }
.prose ul, .prose ol { margin: 0 0 18px; padding-left: 24px; }
.prose li { margin-bottom: 8px; }
.prose img { border-radius: var(--r-inner); }
.prose figure { margin: 24px 0; }
.prose figcaption { font-size: 14px; color: var(--sb-muted); margin-top: 8px; }
.prose blockquote {
  margin: 24px 0; padding: 14px 20px; background: var(--sb-tile-inner);
  border-left: 3px solid var(--sb-accent); border-radius: 0 var(--radius) var(--radius) 0;
}
.prose { overflow-wrap: break-word; }
/* Reused post HTML can carry a table wider than a phone; it scrolls in place. */
.prose table { display: block; overflow-x: auto; max-width: 100%; }
.prose iframe, .prose video, .prose embed { max-width: 100%; }
.prose pre {
  background: var(--sb-navy); color: #E8ECF9; padding: 16px 18px;
  border-radius: var(--r-inner); overflow-x: auto; font-family: var(--mono);
  font-size: 13.5px; line-height: 1.6;
}
.prose code { font-family: var(--mono); font-size: 0.92em; }
.prose p code, .prose li code {
  background: var(--sb-chip); padding: 2px 6px; border-radius: 5px;
}
.prose table { border-collapse: collapse; width: 100%; font-size: 15px; margin: 0 0 18px; }
.prose th, .prose td { text-align: left; padding: 9px 11px; border-bottom: 1px solid var(--sb-border); }

.canonical-note {
  font-size: 14px; color: var(--sb-muted); background: var(--sb-tile-inner);
  border-radius: var(--r-inner); padding: 12px 16px; margin: 0 0 24px;
}

.breadcrumb { font-size: 13px; color: var(--sb-muted); margin: 0 0 10px; }
.breadcrumb a { color: var(--sb-muted); }
.breadcrumb a:hover { color: var(--sb-action); }

.postmeta { font-size: 13px; color: var(--sb-muted); margin: 0 0 20px;
  font-family: var(--mono); }

.empty { color: var(--sb-muted); font-size: 15px; margin: 0; }

.bars { display: flex; align-items: flex-end; gap: 6px; height: 160px;
  border-bottom: 1px solid var(--sb-rule); }
.bars > div { flex: 1 1 0; background: var(--sb-action); border-radius: 4px 4px 0 0;
  min-height: 2px; }
.bars-axis { display: flex; justify-content: space-between; font-size: 12px;
  color: var(--sb-muted); margin-top: 6px; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 14px; }
/* A select sizes itself to its widest option, so a long journal or organism name
   makes the whole page scroll sideways on a phone. Cap the label and let the
   select fill it; the chosen value truncates rather than widening the page. */
.filters label { font-size: 13px; color: var(--sb-muted); display: flex;
  flex-direction: column; gap: 4px; flex: 0 1 auto; min-width: 0; max-width: 100%; }
.filters select {
  font-family: var(--font); font-size: 14px; color: var(--sb-navy);
  background: var(--sb-chip); border: 0; border-radius: var(--radius);
  min-height: 44px; padding: 0 12px;
  width: 100%; max-width: 100%; min-width: 0;
  text-overflow: ellipsis;
}
@media (min-width: 641px) {
  .filters label { max-width: 260px; }
}

/* --------------------------------------------------------------------- */
/* Responsive                                                             */
/* --------------------------------------------------------------------- */

@media (max-width: 900px) {
  .tile--7, .tile--5 { flex: 1 1 100%; }
  .hero h1 { font-size: 32px; }
  .tile { padding: 20px; }
  .tile--pad-lg { padding: 22px; }
}

@media (max-width: 640px) {
  .page { padding: 16px 16px 36px; }
  .section-grid { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .cards { grid-template-columns: 1fr; }
  .prose { font-size: 16px; }
  .footbar { flex-direction: column; gap: 10px; }
}

@media print {
  body { background: #fff; }
  .bar, .footbar, .sb-viewer-controls, .ask { display: none; }
}
