/* BioBuzz Scorer dashboard. One dark theme: black ground, white type, hairline cards.
   Colour is reserved for data. */

:root {
  --bg: #000000;
  --card: #0E0E10;
  --card-alt: #131315;
  --text: #FFFFFF;
  --text-2: #9A9AA0;
  --text-3: #6B6B72;
  --hairline: rgba(255, 255, 255, 0.09);
  --hairline-strong: rgba(255, 255, 255, 0.16);
  --fill: rgba(255, 255, 255, 0.06);
  --fill-strong: rgba(255, 255, 255, 0.12);
  --grid: rgba(255, 255, 255, 0.07);
  --map-empty: #1B1B1E;
  --map-has: #FFFFFF;
  --red: #FF453A;
  --blue: #0A84FF;
  --gold: #E0B341;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow: none;

  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; background: var(--bg); }

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Poppins", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Helvetica Neue",
    Helvetica, Arial, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 20px; }
h2 { font-size: 15px; }
h3 { font-size: 13px; font-weight: 500; color: var(--text); }

p { margin: 0; }

button, select, input {
  font-family: inherit;
  font-size: 14px;
  color: inherit;
}

button { cursor: pointer; }

a { color: var(--text); }

.hidden { display: none !important; }

/* Decorative hooks kept inert so old markup, if any, draws nothing. */
.honeycomb, .hex-dot, .hex-big, .mark { display: none; }

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

.wrap {
  width: min(1280px, 100% - 48px);
  margin: 0 auto;
}

.site-header {
  border-bottom: 1px solid var(--hairline);
  background: rgba(0, 0, 0, 0.8);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.site-header .wrap { padding: 14px 0; }

.header-top {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.title-block { min-width: 0; }
.title-block h1 { font-size: 16px; font-weight: 600; }
.title-block p { font-size: 12px; color: var(--text-2); margin-top: 1px; }

.header-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

footer.site-footer {
  width: min(1280px, 100% - 48px);
  margin: 40px auto 28px;
  padding-top: 16px;
  border-top: 1px solid var(--hairline);
  font-size: 12px;
  color: var(--text-3);
}

/* ---------- Controls ---------- */

.btn {
  appearance: none;
  border: 1px solid var(--hairline-strong);
  background: transparent;
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.btn:hover { background: var(--fill); }
.btn:active { background: var(--fill-strong); }
.btn:disabled { opacity: 0.45; cursor: default; }

.btn.primary {
  background: var(--text);
  color: #000000;
  border-color: var(--text);
}
.btn.primary:hover { background: #E6E6EA; border-color: #E6E6EA; }

.btn.quiet { border-color: transparent; color: var(--text-2); }
.btn.quiet:hover { color: var(--text); background: var(--fill); }

.picker {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--hairline-strong);
  background: transparent;
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 7px 30px 7px 12px;
  font-size: 13px;
  font-weight: 500;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5l3.5 3.5 3.5-3.5' fill='none' stroke='%239A9AA0' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
  max-width: 100%;
}
.segmented::-webkit-scrollbar { display: none; }

.segmented button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-2);
  border-radius: 6px;
  padding: 5px 11px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-selected="true"] {
  background: var(--fill-strong);
  color: var(--text);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 22px 0 18px;
}
.toolbar .spacer { flex: 1; }

.stamp { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }

.badge {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 3px 9px;
  border: 1px solid var(--hairline-strong);
  color: var(--text-2);
}
.badge.warn { border-color: rgba(224, 179, 65, 0.5); color: var(--gold); }

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

.card {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 16px;
  min-width: 0;
}

.card > header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.card .note { font-size: 12px; color: var(--text-3); white-space: nowrap; }

.section-title {
  display: flex;
  align-items: center;
  margin: 34px 0 12px;
}
.section-title h2 {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-2);
}

/* ---------- Stat cards ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}

.stat {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 14px 16px;
  min-width: 0;
}

.stat .label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
}

.stat .value {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-top: 6px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat .detail {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 5px;
}

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

.charts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.charts .wide { grid-column: span 3; }
.charts .two { grid-column: span 2; }

.chart-box { position: relative; height: 220px; }
.chart-box.tall { height: 340px; }
.chart-box canvas { width: 100% !important; height: 100% !important; }

/* ---------- Map ---------- */

#map-card { padding-bottom: 12px; }

#map-holder { position: relative; width: 100%; }
#map-holder svg { display: block; width: 100%; height: auto; }
#map-holder path { transition: fill 120ms ease; }

.sphere { fill: var(--card); }
.graticule { fill: none; stroke: rgba(255, 255, 255, 0.04); stroke-width: 0.5; }

/* A stylesheet rule beats the fill attribute d3 sets, so the has-data fill must live
   here too or every country draws as empty. */
.country { fill: var(--map-empty); stroke: #000000; stroke-width: 0.4; }
.country.has-data { fill: var(--map-has); cursor: default; }
.country.hovered { stroke: var(--gold); stroke-width: 1.1; }
.country.has-data.hovered { fill: #E6E6EA; }

.map-tip {
  position: absolute;
  pointer-events: none;
  background: #1A1A1D;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.4;
  min-width: 140px;
  z-index: 5;
}
.map-tip .name { font-weight: 600; margin-bottom: 4px; }
.map-tip .row { display: flex; justify-content: space-between; gap: 14px; color: var(--text-2); }
.map-tip .row b { color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }

.legend {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.legend .ramp {
  display: inline-block;
  width: 160px;
  height: 8px;
  border-radius: 4px;
  border: 1px solid var(--hairline);
}
.legend .swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--map-empty);
  border: 1px solid var(--hairline-strong);
}
.legend .swatch.has { background: var(--map-has); border-color: var(--map-has); }
.legend .swatch + span { margin-right: 10px; }
.legend .legend-note { margin-left: auto; }

.map-tip .tip-bar {
  height: 4px;
  background: var(--fill);
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}
.map-tip .tip-bar i { display: block; height: 100%; border-radius: 2px; }

/* ---------- Heatmap ---------- */

.heat-grid {
  display: grid;
  grid-template-columns: 36px repeat(24, minmax(0, 1fr));
  gap: 3px;
  align-items: center;
}
.heat-corner { height: 14px; }
.heat-hour { font-size: 10px; color: var(--text-3); text-align: center; height: 14px; line-height: 14px; }
.heat-day { font-size: 11px; color: var(--text-2); }
.heat-cell {
  aspect-ratio: 1 / 1;
  border-radius: 3px;
  background: var(--map-has);
  opacity: var(--strength, 0.15);
  min-height: 10px;
}
.heat-cell.zero { background: var(--fill); opacity: 1; }

.stack { display: grid; gap: 10px; }

.table-scroll.raw { max-height: 420px; }
.table-scroll.raw table { font-size: 12px; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.table-scroll.raw th { font-family: "Poppins", -apple-system, system-ui, sans-serif; }

/* ---------- Table ---------- */

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -16px;
  padding: 0 16px;
  max-height: 560px;
  overflow-y: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
}

th, td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--hairline);
}

th {
  position: sticky;
  top: 0;
  background: var(--card);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  z-index: 1;
}
th:hover { color: var(--text); }
th .arrow { color: var(--text); font-size: 9px; margin-left: 4px; }

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--fill); }
td.red { color: var(--red); font-weight: 500; }
td.blue { color: var(--blue); font-weight: 500; }

.pill {
  display: inline-block;
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 12px;
  border: 1px solid var(--hairline-strong);
}
.pill.red { color: var(--red); }
.pill.blue { color: var(--blue); }

.table-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 12px;
}
.table-foot .stamp { margin-left: auto; }

/* ---------- Full screen panels: lock, setup, loading ---------- */

.screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

.panel {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 28px;
}

.panel h1 { font-size: 18px; margin-bottom: 6px; }
.panel p { color: var(--text-2); font-size: 13px; margin-bottom: 20px; }

/* The lock and token screens borrow the landing page treatment: a small pill, a
   headline that fades toward the bottom, one line of grey copy. One gradient, on the
   title only. */
.pill-row { text-align: center; margin-bottom: 18px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  font-size: 12px;
  color: var(--text-2);
}
.panel h1.display {
  text-align: center;
  font-size: 30px;
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1.12;
  margin-bottom: 10px;
  color: #FFFFFF;
}
.panel p.lead { text-align: center; font-size: 14px; margin-bottom: 24px; }

.panel label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 6px;
}

.panel input[type="text"], .panel input[type="password"] {
  width: 100%;
  appearance: none;
  border: 1px solid var(--hairline-strong);
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.02em;
  outline: none;
  transition: border-color 120ms ease;
}
.panel input:focus { border-color: rgba(255, 255, 255, 0.5); }
.panel input::placeholder { color: var(--text-3); font-family: inherit; }

.panel .picker { width: 100%; padding-top: 10px; padding-bottom: 10px; background-color: var(--bg); }

.field { margin-bottom: 16px; }

.hint {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
.hint.bad { color: var(--gold); }

.panel .actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.panel .actions .btn { padding: 9px 14px; }
.panel .actions .btn.primary { flex: 1; min-width: 120px; }

.steps {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--hairline);
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.5;
}
.steps b { color: var(--text-2); font-weight: 500; }

.alert {
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.45;
  margin-bottom: 16px;
  background: rgba(255, 69, 58, 0.1);
  border: 1px solid rgba(255, 69, 58, 0.35);
  color: #FF7B72;
}
.alert.warn {
  background: rgba(224, 179, 65, 0.08);
  border-color: rgba(224, 179, 65, 0.4);
  color: var(--gold);
}

/* The lock: three words on three underlines. Each line starts at a fixed width and
   only grows once the word outruns it, so the line gives no hint of length. */

.words {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 8px 0 4px;
}

.panel .words input.word {
  width: 96px;
  min-width: 96px;
  border: 0;
  border-bottom: 2px solid var(--hairline-strong);
  border-radius: 0;
  background: transparent;
  padding: 6px 2px;
  text-align: center;
  font-size: 18px;
  letter-spacing: 0.12em;
  font-family: "Poppins", -apple-system, system-ui, sans-serif;
  transition: border-color 120ms ease, width 80ms ease-out;
}
.panel .words input.word:focus { border-bottom-color: #FFFFFF; }
.panel .words input.word::placeholder { color: transparent; }

/* Off screen twin used to measure how wide a typed word is. */
.word-measure {
  position: absolute;
  left: -9999px;
  top: 0;
  white-space: pre;
  font-size: 18px;
  letter-spacing: 0.12em;
  font-family: "Poppins", -apple-system, system-ui, sans-serif;
}

.eye {
  width: 34px;
  height: 34px;
  margin-bottom: 2px;
  border: 0;
  background: transparent;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
}
.eye:hover { color: var(--text); background: var(--fill); }
.eye svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Loading */

#loading-screen .panel { max-width: 360px; text-align: center; }

.counter {
  font-size: 40px;
  font-weight: 600;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

#loading-screen p { margin-top: 4px; }

.bar {
  position: relative;
  height: 3px;
  background: var(--fill);
  border-radius: 2px;
  overflow: hidden;
  margin: 20px 0 18px;
}
.bar > i {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 35%;
  background: var(--text);
  border-radius: 2px;
  animation: crawl 1.4s ease-in-out infinite;
}
@keyframes crawl {
  0% { left: -35%; }
  100% { left: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .bar > i { animation: none; width: 100%; left: 0; opacity: 0.5; }
}

/* Empty state */

.empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-2);
}
.empty h2 { font-size: 15px; color: var(--text); margin-bottom: 6px; }
.empty p { font-size: 13px; }

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

@media (max-width: 960px) {
  .charts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .charts .wide, .charts .two { grid-column: span 2; }
}

@media (max-width: 640px) {
  .wrap, footer.site-footer { width: calc(100% - 32px); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stat .value { font-size: 22px; }
  .charts { grid-template-columns: 1fr; gap: 8px; }
  .charts .wide, .charts .two { grid-column: auto; }
  .chart-box { height: 200px; }
  .chart-box.tall { height: 300px; }
  .header-actions { margin-left: 0; width: 100%; }
  .toolbar { gap: 8px; }
  .segmented button { padding: 5px 9px; font-size: 12px; }
  .panel { padding: 22px; }
}
