/* Copyright (c) August 2026 Andres Patrignani. */
/*
 * base.css — reset, typography, and the app frame: a thin top bar (brand,
 * Home link, tool name), a fixed compact control sidebar, and a tabbed main
 * canvas.
 * Component-level styling lives in components.css.
 */

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

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p { margin: 0; }
h1 { font-size: 1.15rem; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 0.95rem; font-weight: 600; }
h3 { font-size: 0.82rem; font-weight: 600; }
a { color: var(--neon); text-decoration: none; }
a:hover { color: var(--neon-bright); }
code, .mono { font-family: var(--font-mono); font-size: 0.86em; }
small, .hint { color: var(--muted); font-size: 0.72rem; line-height: 1.4; }

:focus-visible { outline: 1.5px solid var(--neon); outline-offset: 1px; }
::selection { background: var(--neon-wash); }

/* thin scrollbars everywhere, themed */
* { scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 999px; }
*::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── App frame ─────────────────────────────────────────────────────────── */

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

/* Full-width bar; its content is capped and centered to match the workbench
   so the brand lines up with the sidebar on large screens. */
.topbar {
  flex-shrink: 0;
  height: var(--bar-h);
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.topbar__inner {
  height: 100%;
  max-width: var(--app-max);
  margin: 0 auto;
  padding: 0 0.9rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.topbar__brand {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.topbar__brand:hover { color: var(--ink); }
.topbar__name { font-weight: 700; font-size: 0.95rem; letter-spacing: 0.02em; }
.topbar__name::before {
  content: "";
  display: inline-block;
  width: 7px; height: 7px;
  margin-right: 0.5rem;
  border-radius: 50%;
  background: var(--neon);
  box-shadow: 0 0 6px var(--neon);
  vertical-align: middle;
}
/* Wordmark: neon "DualKc", muted "Studio". */
.brandmark__dualkc { color: var(--neon); }
.brandmark__studio { color: #9aa2ae; }

/* Landing hero: the wordmark as the page title, tagline beneath. */
.home-hero { font-size: 2.4rem; font-weight: 700; letter-spacing: -0.01em; margin: 0; }
.home-hero__tag { color: var(--ink-2); font-size: 1.05rem; margin: 0.35rem 0 0; }

.topbar__tag { color: var(--muted); font-size: 0.7rem; display: none; }
@media (min-width: 72rem) { .topbar__tag { display: inline; } }

/* Current tool name, with a divider before it. */
.topbar__tool { color: var(--ink); font-size: 0.85rem; font-weight: 600; white-space: nowrap; }
.topbar__tool:not(:empty)::before {
  content: "";
  display: inline-block;
  width: 1px; height: 0.9rem;
  margin-right: 0.85rem;
  background: var(--border-2);
  vertical-align: middle;
}

.navlink {
  padding: 0 0.85rem;
  height: var(--bar-h);
  display: inline-flex;
  align-items: center;
  color: var(--ink-2);
  font-weight: 550;
  font-size: 0.78rem;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.navlink:hover { color: var(--ink); background: var(--panel-2); }

.topbar__actions { display: flex; align-items: center; gap: 0.4rem; }
.topbar__icon-btn { display: inline-flex; align-items: center; justify-content: center; padding: 0 0.45rem; }
.topbar__icon-btn svg { display: block; }

/* ── View outlet ───────────────────────────────────────────────────────── */

.outlet { flex: 1; min-height: 0; display: flex; }
.view { flex: 1; min-width: 0; display: flex; }
.view[hidden] { display: none; }

/* Document-style view (home, spatial): centered column, own scroll */
.view--doc {
  flex-direction: column;
  overflow-y: auto;
}
.view--doc .doc-inner {
  width: 100%;
  max-width: 60rem;
  margin: 0 auto;
  padding: 2.5rem 2rem 4rem;
}

/* ── Workbench: sidebar + tabbed canvas ────────────────────────────────── */

.workbench { flex: 1; min-width: 0; display: flex; max-width: var(--app-max); margin: 0 auto; width: 100%; }

.sidebar {
  flex-shrink: 0;
  width: var(--sidebar-w);
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sidebar__scroll {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}
.sidebar__foot {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  padding: 0.6rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--panel);
}

.canvas {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.canvas__tabs {
  flex-shrink: 0;
  height: 2.4rem;
  display: flex;
  align-items: stretch;
  gap: 0;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  padding: 0 0.75rem;
}
.canvas__tab {
  border: none;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 550;
  padding: 0 0.9rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.canvas__tab:hover { color: var(--ink); }
.canvas__tab.is-active { color: var(--neon); border-bottom-color: var(--neon); }
.canvas__tab[disabled] { opacity: 0.4; cursor: default; }
.canvas__tabsp { flex: 1; }
.canvas__head {
  flex-shrink: 0;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--ink-2);
  font-size: 0.76rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  min-height: 2.1rem;
}
.canvas__body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 1rem;
}
.canvas__pane[hidden] { display: none; }

/* ── Docs drawer ───────────────────────────────────────────────────────── */

.docs-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0; pointer-events: none;
  transition: opacity 0.18s ease;
}
.docs-backdrop.is-open { opacity: 1; pointer-events: auto; }

.docs {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 61;
  width: min(var(--docs-w), 92vw);
  background: var(--panel);
  border-left: 1px solid var(--border);
  transform: translateX(102%);
  transition: transform 0.2s ease;
  display: flex;
  flex-direction: column;
}
.docs.is-open { transform: translateX(0); }
.docs__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 0.8rem 1.1rem;
  border-bottom: 1px solid var(--border);
}
.docs__head h2 { font-size: 0.9rem; }
.docs__body {
  overflow-y: auto;
  padding: 1rem 1.15rem 2.5rem;
  font-size: 0.82rem;
  color: var(--ink-2);
}
.docs__body h3 { color: var(--ink); margin: 1.3rem 0 0.4rem; font-size: 0.83rem; }
.docs__body h3:first-child { margin-top: 0; }
.docs__body p { margin: 0 0 0.6rem; }
.docs__body ul, .docs__body ol { margin: 0 0 0.6rem; padding-left: 1.15rem; }
.docs__body li { margin-bottom: 0.25rem; }
.docs__body table { width: 100%; border-collapse: collapse; margin: 0.4rem 0 0.8rem; font-size: 0.78rem; }
.docs__body th, .docs__body td { text-align: left; padding: 0.3rem 0.45rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.docs__body th { color: var(--muted); font-weight: 600; }
.docs__body code { background: var(--panel-2); padding: 0.05em 0.3em; border-radius: 3px; color: var(--ink); }
/* Input-file variable names highlighted so they stand out in the docs. */
.docs__body code.var { color: #34d1b5; font-weight: 600; }
.docs__body .docs-note {
  background: var(--neon-wash);
  border: 1px solid var(--border-2);
  border-left: 2px solid var(--neon);
  border-radius: var(--radius);
  padding: 0.55rem 0.7rem;
  margin: 0.4rem 0 0.8rem;
}

/* ── Utility ───────────────────────────────────────────────────────────── */

.row { display: flex; align-items: center; gap: 0.5rem; }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 0.9rem; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  clip: rect(0 0 0 0); overflow: hidden; white-space: nowrap;
}

/* stacked responsive fallback: sidebar over canvas on very narrow screens */
@media (max-width: 52rem) {
  .workbench { flex-direction: column; }
  .sidebar { width: 100%; max-height: 50vh; border-right: none; border-bottom: 1px solid var(--border); }
}
