/* ==========================================================================
   Data Lab stylesheet.

   Deliberately minimal: a neutral, near-blank light theme so contributors
   can take the design anywhere. All tokens live on :root; components
   reference the classes below via `class_=` props in app/.

   After editing, run `make manifest` so the stylesheet's cache buster
   updates.
   ========================================================================== */

/* ----- Reset + tokens ----------------------------------------------------- */

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

:root {
  --bg: #ffffff;
  --surface: #f6f8fa;
  --border: #d9dee3;
  --text-1: #1f2328;
  --text-2: #59636e;
  --accent: #0b62d6;
  --error: #b42318;

  --radius: 8px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    monospace;

  --max-w: 1040px;
  --gutter: clamp(1rem, 4vw, 2rem);
}

html {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-1);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

#app > div {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

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

a:hover {
  text-decoration: underline;
}

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1em 0.35em;
}

.container {
  width: 100%;
  max-width: var(--max-w);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.muted {
  color: var(--text-2);
}

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

.em {
  font-weight: 600;
}

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

/* ----- Loading overlay ------------------------------------------------------ */

#loading {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 0.9rem;
  background: var(--bg);
  transition: opacity 0.4s ease;
}

#loading.fade-out {
  opacity: 0;
  pointer-events: none;
}

.loading-logo {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.loading-label {
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 0.75rem;
  color: var(--text-2);
}

.loading-progress {
  width: min(300px, 70vw);
  height: 4px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
}

#loading-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.35s ease;
}

.loading-status {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-2);
  min-height: 1.4em;
}

/* ----- No-JavaScript wall ---------------------------------------------------- */

.noscript-wall {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: grid;
  place-items: center;
  padding: 2rem;
  text-align: center;
  background: var(--bg);
}

.noscript-card {
  max-width: 46ch;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
}

/* ----- Header + footer -------------------------------------------------------- */

.site-header {
  border-bottom: 1px solid var(--border);
}

.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-block: 0.75rem;
}

.brand-name {
  font-weight: 700;
}

.tag {
  color: var(--text-2);
  font-size: 0.82rem;
  margin-left: 0.6rem;
  padding-left: 0.6rem;
  border-left: 1px solid var(--border);
}

nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav-link {
  color: var(--text-2);
  font-size: 0.9rem;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius);
}

.nav-link:hover {
  color: var(--text-1);
  background: var(--surface);
  text-decoration: none;
}

.nav-link.active {
  color: var(--text-1);
  font-weight: 600;
}

.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-2);
}

.footer-links {
  display: flex;
  gap: 1rem;
}

/* ----- Layout + panels ---------------------------------------------------------- */

.page {
  padding-block: 1.5rem 3rem;
  flex: 1;
}

.stack {
  display: grid;
  gap: 1rem;
}

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
}

.panel h2 {
  font-size: 1.25rem;
  margin-bottom: 0.35rem;
}

.panel h3 {
  font-size: 1.02rem;
  margin-bottom: 0.25rem;
}

.panel > p {
  margin-bottom: 0.6rem;
}

.doc-list {
  padding-left: 1.2rem;
  display: grid;
  gap: 0.4rem;
  color: var(--text-2);
}

.empty {
  color: var(--text-2);
  text-align: center;
  padding: 1.5rem;
}

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

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-block: 0.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-1);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.45rem 0.9rem;
  cursor: pointer;
}

.btn:hover {
  background: var(--surface);
  text-decoration: none;
}

.btn-primary {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
}

.btn-primary:hover {
  background: #0a56bc;
}

input[type="text"] {
  font: inherit;
  font-size: 0.9rem;
  color: var(--text-1);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.45rem 0.7rem;
  min-width: min(260px, 100%);
  outline: none;
}

input[type="text"]:focus {
  border-color: var(--accent);
}

.pill {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
}

.summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.9rem;
  font-size: 0.9rem;
  color: var(--text-2);
}

/* ----- Tables ------------------------------------------------------------------------- */

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

#schema-table {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

th,
td {
  text-align: left;
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

thead th {
  background: var(--surface);
  font-weight: 600;
  position: sticky;
  top: 0;
}

tbody tr:last-child td {
  border-bottom: none;
}

/* ----- Boot fallback + errors ------------------------------------------------------------ */

.boot-fallback {
  text-align: center;
  padding-block: 2.5rem;
}

.boot-title {
  font-weight: 600;
}

.error-box {
  border-color: var(--error);
}

.error-text {
  color: var(--error);
  white-space: pre-wrap;
  word-break: break-word;
  margin-block: 0.5rem;
}

.load-error {
  color: var(--error);
  font-size: 0.9rem;
}

.load-error:empty {
  display: none;
}

/* ----- Small screens ------------------------------------------------------------------------ */

@media (max-width: 560px) {
  .tag {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  #loading,
  #loading-bar {
    transition: none;
  }
}
