/* Archmage Intrinsics Browser — Dark theme (ayu-inspired) */

:root {
  --bg: #0b0e14;
  --bg-alt: #11151c;
  --bg-hover: #1a1f2e;
  --bg-selected: #1d2433;
  --border: #2d3548;
  --text: #bfbdb6;
  --text-bright: #e6e1cf;
  --text-dim: #6c7380;
  --accent: #e6b450;
  --green: #7fd962;
  --red: #f07171;
  --blue: #59c2ff;
  --amber: #ffb454;
  --purple: #d2a6ff;
  --mono: 'Cascadia Code', 'JetBrains Mono', 'Fira Code', 'SF Mono', 'Consolas', monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --row-height: 2.25rem;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 125%; /* 20px base — scale all rem values up from the too-compact 16px default */
}

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

/* ── Compact Toolbar ── */
.toolbar {
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  padding: 0.375rem 0.75rem;
}

.toolbar-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

h1 {
  font-family: var(--mono);
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 1px;
  white-space: nowrap;
}

.book-link {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.6875rem;
  font-family: var(--mono);
  margin-left: auto;
}
.book-link:hover { color: var(--blue); }

#searchInput {
  flex: 1 1 11.25rem;
  min-width: 7.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.25rem 0.5rem;
  color: var(--text-bright);
  font-family: var(--mono);
  font-size: 0.8125rem;
  outline: none;
}
#searchInput:focus { border-color: var(--accent); }
#searchInput::placeholder { color: var(--text-dim); }

.result-count {
  color: var(--text-dim);
  font-size: 0.6875rem;
  font-family: var(--mono);
  white-space: nowrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.1875rem;
}

.filter-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-dim);
  font-size: 0.6875rem;
  font-family: var(--mono);
  padding: 0.125rem 0.4375rem;
  cursor: pointer;
  transition: all 0.12s;
}
.filter-btn.active {
  background: var(--bg-selected);
  color: var(--text-bright);
  border-color: var(--accent);
}
.filter-btn:hover { background: var(--bg-hover); }

/* ── Token Row ── */
.token-row {
  display: flex;
  align-items: center;
  gap: 0.1875rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
  padding-top: 0.25rem;
  border-top: 1px solid rgba(45, 53, 72, 0.5);
}

.token-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-dim);
  font-size: 0.6875rem;
  font-family: var(--mono);
  padding: 0.125rem 0.375rem;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}
.token-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.token-btn.active {
  background: var(--bg-selected);
  color: var(--text-bright);
  border-color: var(--accent);
}
.token-btn.token-all {
  font-weight: 600;
}

.token-sep {
  color: var(--text-dim);
  font-size: 0.625rem;
  opacity: 0.4;
}

/* ── Table ── */
.table-container {
  flex: 1 1 0;
  min-height: 7.5rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.table-header {
  display: flex;
  background: var(--bg-alt);
  border-bottom: 2px solid var(--border);
  padding: 0.375rem 1.25rem;
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.col-name { flex: 0 0 17.5rem; }
.col-token { flex: 0 0 7.5rem; }
.col-desc { flex: 1; min-width: 12.5rem; }
.col-badges { flex: 0 0 8.75rem; text-align: right; }

.virtual-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.scroll-content { position: relative; }

.vrow {
  display: flex;
  align-items: center;
  height: var(--row-height);
  padding: 0 1.25rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(45, 53, 72, 0.4);
  position: absolute;
  left: 0;
  right: 0;
}
.vrow:hover { background: var(--bg-hover); }
.vrow.selected { background: var(--bg-selected); }

.vrow .col-name {
  font-family: var(--mono);
  font-size: 0.8125rem;
  color: var(--text-bright);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vrow .col-token {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vrow .col-desc {
  font-size: 0.75rem;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 0.5rem;
}
.vrow .col-badges {
  display: flex;
  gap: 0.25rem;
  justify-content: flex-end;
}

.badge {
  font-size: 0.6875rem;
  font-family: var(--mono);
  font-weight: 600;
  padding: 0.0625rem 0.375rem;
  border-radius: 3px;
  white-space: nowrap;
}
.badge-stable { background: rgba(127, 217, 98, 0.15); color: var(--green); }
.badge-unstable { background: rgba(255, 180, 84, 0.15); color: var(--amber); }
.badge-safe { background: rgba(89, 194, 255, 0.12); color: var(--blue); }
.badge-safe-wrapped { background: rgba(127, 217, 98, 0.12); color: var(--green); cursor: help; }
.badge-unsafe { background: rgba(240, 113, 113, 0.15); color: var(--red); }

/* ── Detail Panel ── */
.detail-panel {
  background: var(--bg-alt);
  border-top: 2px solid var(--accent);
  padding: 1rem 1.25rem 1.25rem;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 65vh;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.5);
}

.detail-close {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 1.125rem;
  line-height: 1;
  padding: 0.25rem;
}
.detail-close:hover { color: var(--text-bright); }

.detail-content h2 {
  font-family: var(--mono);
  font-size: 1.125rem;
  color: var(--accent);
  margin-bottom: 0.75rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12.5rem, 1fr));
  gap: 0.5rem 1.5rem;
  margin-bottom: 1rem;
}

.detail-field {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}
.detail-label {
  font-size: 0.625rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.detail-value {
  font-family: var(--mono);
  font-size: 0.8125rem;
  color: var(--text-bright);
}

.detail-timing {
  display: flex;
  gap: 1rem;
  margin: 0.75rem 0;
  padding: 0.625rem 0.875rem;
  background: var(--bg);
  border-radius: 4px;
  border: 1px solid var(--border);
}
.timing-col { text-align: center; }
.timing-col .timing-header {
  font-size: 0.625rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}
.timing-col .timing-value {
  font-family: var(--mono);
  font-size: 0.875rem;
  color: var(--text-bright);
}

.detail-code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.75rem 1rem;
  margin-top: 0.75rem;
  overflow-x: auto;
}
.detail-code pre {
  font-family: var(--mono);
  font-size: 0.8125rem;
  color: var(--text);
  line-height: 1.5;
  margin: 0;
}
.detail-code .code-label {
  font-size: 0.625rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 0.375rem;
}

.safe-variant-note {
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: rgba(89, 194, 255, 0.06);
  border: 1px solid rgba(89, 194, 255, 0.2);
  border-radius: 4px;
  font-size: 0.75rem;
  color: var(--blue);
}
.safe-variant-sig {
  font-family: var(--mono);
  font-size: 0.6875rem;
  color: var(--text-dim);
  margin-top: 0.25rem;
  display: inline-block;
}

.unsafe-note {
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: rgba(240, 113, 113, 0.06);
  border: 1px solid rgba(240, 113, 113, 0.2);
  border-radius: 4px;
  font-size: 0.75rem;
  color: var(--red);
}

.doc-link {
  color: var(--blue);
  text-decoration: none;
  font-size: 0.75rem;
}
.doc-link:hover { text-decoration: underline; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .col-token { display: none; }
  .col-badges { flex: 0 0 6.25rem; }
  .col-name { flex: 0 0 12.5rem; }
  .toolbar-row { gap: 0.25rem; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
}

/* ── Scrollbar ── */
.virtual-scroll::-webkit-scrollbar { width: 8px; }
.virtual-scroll::-webkit-scrollbar-track { background: var(--bg); }
.virtual-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.virtual-scroll::-webkit-scrollbar-thumb:hover { background: #3d4760; }
.detail-panel::-webkit-scrollbar { width: 6px; }
.detail-panel::-webkit-scrollbar-track { background: var(--bg-alt); }
.detail-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
