/* ==========================================================================
   Hash — dashboard stylesheet
   Dark terminal aesthetic. IBM Plex Mono for data/hashes, IBM Plex Sans for
   labels/body. Bitcoin-orange accent, green for live/confirmed, red for stale.
   ========================================================================== */

:root[data-theme="dark"] {
  --bg:        #0b0e10;
  --panel:     #12161a;
  --panel-2:   #171c21;
  --border:    #232a30;
  --text:      #d7dee3;
  --text-dim:  #7c8791;
  --accent:    #f7931a;   /* bitcoin orange */
  --accent-dim: #a8621a;
  --live:      #3ddc84;
  --stale:     #e5484d;
}

:root[data-theme="light"] {
  --bg:        #f3f4f2;
  --panel:     #ffffff;
  --panel-2:   #eceeec;
  --border:    #d8dcd9;
  --text:      #14181b;
  --text-dim:  #5c666d;
  --accent:    #d97a06;
  --accent-dim: #b96703;
  --live:      #1f9d5c;
  --stale:     #c62a2f;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

code, .mono, .hash, .num {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Focus visibility (accessibility floor) */
a:focus-visible, button:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

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

.shell {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.brand .mark {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.5px;
  color: var(--text);
  text-decoration: none;
}
.brand .mark:hover { text-decoration: none; }
.brand .mark span { color: var(--accent); }

.brand .tagline {
  font-size: 12px;
  color: var(--text-dim);
}

.topbar-right { display: flex; align-items: center; gap: 18px; }

.price-pill {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.price-pill .chg-up { color: var(--live); }
.price-pill .chg-down { color: var(--stale); }

.theme-toggle {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
}
.theme-toggle:hover { border-color: var(--accent); }

/* ---------------------------------------------------------------------- */
/* Grid                                                                    */
/* ---------------------------------------------------------------------- */

.grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start; /* prevent the shorter column stretching to match the taller one and leaving dead space */
}

.col-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.col-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.big-stat-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
.big-stat-row .stat-box .value { font-size: 24px; color: var(--accent); }

#hashrateChart { width: 100%; height: 90px; }

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

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.panel-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  font-weight: 600;
}

.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--live);
  display: inline-block;
  margin-right: 6px;
}
.status-dot.stale { background: var(--stale); }

/* ---------------------------------------------------------------------- */
/* Mempool / fees panel                                                    */
/* ---------------------------------------------------------------------- */

.fee-tiers {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.fee-tier {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  text-align: center;
}
.fee-tier .label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.fee-tier .value { font-family: 'IBM Plex Mono', monospace; font-size: 20px; margin-top: 4px; color: var(--accent); }
.fee-tier .unit { font-size: 11px; color: var(--text-dim); }

.mempool-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.stat-box .label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-box .value { font-family: 'IBM Plex Mono', monospace; font-size: 18px; margin-top: 2px; }

#feeSparkline { width: 100%; height: 60px; margin-top: 14px; }

/* ---------------------------------------------------------------------- */
/* Explorer search panel                                                   */
/* ---------------------------------------------------------------------- */

.explorer-form {
  display: flex;
  gap: 10px;
}
.explorer-input {
  flex: 1;
  min-width: 0;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 13px;
}
.explorer-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.explorer-btn {
  background: var(--accent);
  border: none;
  border-radius: 6px;
  padding: 10px 18px;
  color: #14181b;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}
.explorer-btn:hover { background: var(--accent-dim); }

.explorer-result { margin-top: 14px; }
.explorer-result:empty { margin-top: 0; }

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}
.result-item {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  min-width: 0;
}
.result-item .label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.result-item .value { font-family: 'IBM Plex Mono', monospace; font-size: 14px; margin-top: 4px; word-break: break-all; }
.result-error { color: var(--stale); font-size: 13px; }
.result-type-tag {
  display: inline-block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
  margin-bottom: 8px;
}

/* ---------------------------------------------------------------------- */
/* Projected mempool blocks (fee queue)                                    */
/* ---------------------------------------------------------------------- */

.projected-blocks {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.projected-block {
  flex: 1;
  min-width: 90px;
  border-radius: 6px;
  padding: 10px 10px 12px;
  color: #14181b;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.projected-block .pb-eta { font-size: 11px; opacity: 0.85; font-weight: 600; }
.projected-block .pb-fee { font-family: 'IBM Plex Mono', monospace; font-size: 16px; font-weight: 700; }
.projected-block .pb-tx { font-size: 10px; opacity: 0.8; }

/* ---------------------------------------------------------------------- */
/* Price history chart                                                     */
/* ---------------------------------------------------------------------- */

#priceHistoryChart { width: 100%; height: 170px; }
.chart-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-dim);
}
.legend-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.legend-dot-halving { background: #5b8def; }

/* ---------------------------------------------------------------------- */
/* Blocks strip                                                            */
/* ---------------------------------------------------------------------- */

.blocks-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.block-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  min-width: 0;
}
.block-card .height {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 15px;
  color: var(--accent);
  font-weight: 600;
}
.block-card .hash {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 3px;
  word-break: break-all;
}
.block-card .pool {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
}
.block-card .meta {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-dim);
}

/* ---------------------------------------------------------------------- */
/* Miners donut + difficulty                                               */
/* ---------------------------------------------------------------------- */

#minersChart { width: 220px; height: 220px; max-width: 100%; display: block; margin: 0 auto; }

.legend { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; font-size: 12px; }
.legend-item { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.legend-swatch { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.legend-name { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; }
.legend-pct { font-family: 'IBM Plex Mono', monospace; color: var(--text-dim); }

.diff-bar-track {
  height: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin: 10px 0;
}
.diff-bar-fill {
  height: 100%;
  background: var(--accent);
}
.diff-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
  padding: 4px 0;
}
.diff-meta .num {
  color: var(--text);
  text-align: right;
  white-space: nowrap;
}

/* ---------------------------------------------------------------------- */
/* Ad slot                                                                  */
/* ---------------------------------------------------------------------- */

.ad-slot {
  width: 300px;
  max-width: 100%;
  height: 250px;
  margin: 0 auto;
  border: 1px dashed var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 12px;
  background: var(--panel-2);
}

/* ---------------------------------------------------------------------- */
/* Footer                                                                   */
/* ---------------------------------------------------------------------- */

.site-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.site-footer a { color: var(--text-dim); }
.site-footer a:hover { color: var(--accent); }

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

@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
  .fee-tiers { grid-template-columns: repeat(2, 1fr); }
  .mempool-stats { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; gap: 10px; }
}
