/* ============================================================================
 * base.css — SLQ.dk
 * Theme-AGNOSTIC layout & geometry. Everything visual (colours, bevels,
 * gradients, fonts, radius) lives in themes.css, keyed off html[data-theme].
 *
 * Rule of thumb when maintaining this:
 *   base.css  = where things are, how big, how they stack   (structure)
 *   themes.css = what they look like                         (skin)
 * ========================================================================== */

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

:root {
  --topbar-h: 40px;
  --maxw: 1200px;
  --side-w: 248px;
}

html, body { margin: 0; padding: 0; height: 100%; }

body {
  min-height: 100%;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* font, colour & background come from the theme */
}

a { color: inherit; }

img, svg, canvas { display: block; max-width: 100%; }

/* ── Left sidebar (Explorer-style tree) ───────────────────────────────────
 * Injected by slq.js into #slq-top. Fixed on the left; the page content is
 * pushed right via body padding. Colours live in themes.css. */
#slq-top { min-height: 0; }
body { padding-left: var(--side-w); }
.sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: var(--side-w); display: flex; flex-direction: column; z-index: 100; }
.side-head { display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 6px 0 10px; flex: none; font-weight: 700; letter-spacing: .4px; font-size: .9rem; }
.side-head .side-title { text-decoration: none; }
.side-head .side-title .dot { opacity: .7; font-weight: 400; }
.side-x { margin-left: auto; display: none; border: 0; background: none; color: inherit; cursor: pointer; font-size: .85rem; line-height: 1; padding: 4px 6px; }
.tree { flex: 1 1 auto; overflow-y: auto; }
.tree ul { list-style: none; margin: 0; padding: 0; }
.tree > ul { padding: 6px 0; }
.tree .children { display: none; padding-left: 16px; }
.tree li.folder.open > .children { display: block; }
.tree .row { display: flex; align-items: center; gap: 6px; padding: 3px 10px 3px 6px; cursor: pointer; text-decoration: none; white-space: nowrap; font-size: .85rem; line-height: 1.45; user-select: none; }
.tree .row .lbl { overflow: hidden; text-overflow: ellipsis; }
.tree .ic { width: 15px; height: 15px; flex: none; }
.tree .twist { position: relative; width: 12px; height: 12px; flex: none; display: inline-flex; align-items: center; justify-content: center; border: 0; background: none; padding: 0; cursor: pointer; }
.tree .twist::before { content: ''; width: 0; height: 0; border-left: 5px solid currentColor; border-top: 4px solid transparent; border-bottom: 4px solid transparent; transition: transform .15s; }
.tree li.folder.open > .row .twist::before { transform: rotate(90deg); }
.tree .leaf .twist { visibility: hidden; }
.side-foot { flex: none; display: flex; align-items: center; gap: 6px; padding: 7px 10px; font-size: .8rem; }
.side-foot select { flex: 1 1 auto; min-width: 0; }
.side-toggle { position: fixed; top: 8px; left: 8px; z-index: 130; display: none; align-items: center; justify-content: center; width: 40px; height: 34px; cursor: pointer; font-size: 1.1rem; }
.side-overlay { position: fixed; inset: 0; z-index: 95; display: none; background: rgba(0,0,0,.45); }

@media (max-width: 980px) {
  body { padding-left: 0; }
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: 0 0 40px rgba(0,0,0,.45); }
  .sidebar.open { transform: none; }
  .side-toggle { display: inline-flex; }
  .side-x { display: inline-flex; }
  .side-overlay.open { display: block; }
}

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 12px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar .brand {
  font-weight: 700;
  letter-spacing: 0.5px;
  display: flex;
  align-items: baseline;
  gap: 8px;
  text-decoration: none;
  white-space: nowrap;
}
.topbar .brand .dot { opacity: 0.65; font-weight: 400; }
.topbar nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1 1 auto;
  flex-wrap: wrap;
  overflow: hidden;
}
.topbar nav a {
  text-decoration: none;
  padding: 5px 10px;
  white-space: nowrap;
  font-size: 0.86rem;
}
.topbar .theme-pick {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  font-size: 0.8rem;
  white-space: nowrap;
}

/* ── Page container ───────────────────────────────────────────────────── */
.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 20px 16px 56px;
}

.page-head { margin: 6px 2px 18px; }
.page-head h1 { margin: 0 0 6px; font-size: 1.5rem; line-height: 1.15; }
.page-head p  { margin: 0; max-width: 70ch; }

/* ── Window (the universal panel) ─────────────────────────────────────────
 * <div class="win">
 *   <div class="win-titlebar"><span class="win-title">…</span>
 *        <span class="win-controls"><i>_</i><i>▢</i><i>✕</i></span></div>
 *   <div class="win-body"> … </div>
 *   <div class="statusbar"> … </div>   (optional)
 * </div>                                                                     */
.win { margin: 0 0 18px; }
.win-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 6px 4px 8px;
  user-select: none;
}
.win-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.win-title .ico {
  width: 14px; height: 14px;
  flex: 0 0 auto;
  display: inline-block;
}
.win-controls { display: flex; gap: 3px; flex: 0 0 auto; }
.win-controls i {
  width: 18px; height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-style: normal;
  font-size: 9px;
  line-height: 1;
  cursor: default;
}
.win-body { padding: 16px; }

/* ── Two-column tool layout: controls left, visual right ───────────────── */
.tool-grid {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
@media (max-width: 860px) {
  .tool-grid { grid-template-columns: 1fr; }
}

/* ── Fieldsets / groups ───────────────────────────────────────────────── */
fieldset {
  margin: 0 0 14px;
  padding: 12px 12px 6px;
  border-width: 1px;
  border-style: solid;
}
fieldset:last-child { margin-bottom: 0; }
legend { padding: 0 6px; font-size: 0.78rem; font-weight: 600; }

/* ── Field rows (label · input · unit) ────────────────────────────────── */
.field {
  display: grid;
  grid-template-columns: 1fr 92px 44px;
  align-items: center;
  gap: 8px;
  margin-bottom: 9px;
}
.field:last-child { margin-bottom: 2px; }
.field > label { font-size: 0.84rem; }
.field .unit { font-size: 0.76rem; opacity: 0.8; }
.field input[type="text"],
.field input[type="number"],
.field select { width: 100%; }
.field.wide { grid-template-columns: 1fr; }
.field.wide select { width: 100%; }

input[type="text"], input[type="number"], select {
  font: inherit;
  padding: 5px 7px;
  width: 100%;
}

/* ── Sliders ──────────────────────────────────────────────────────────── */
.slider {
  margin-bottom: 12px;
}
.slider .head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.8rem;
  margin-bottom: 3px;
}
.slider .head .val { font-weight: 600; }
.slider input[type="range"] { width: 100%; }

/* ── Buttons ──────────────────────────────────────────────────────────── */
button, .btn {
  font: inherit;
  padding: 6px 16px;
  cursor: pointer;
  min-width: 84px;
}
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

/* ── Segmented toggle (motor type, etc.) ──────────────────────────────── */
.seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-bottom: 12px;
}
.seg button { min-width: 0; padding: 5px 14px; }

/* ── Tabs ─────────────────────────────────────────────────────────────── */
.tabs { display: flex; flex-wrap: wrap; gap: 2px; margin-bottom: 16px; }
.tab {
  padding: 6px 14px;
  cursor: pointer;
  font-size: 0.84rem;
  text-decoration: none;
  white-space: nowrap;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Chart / canvas card ──────────────────────────────────────────────── */
.viz { display: flex; flex-direction: column; gap: 10px; }
.viz .toggles {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 0.82rem;
}
.viz .toggles label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
canvas.chart { width: 100%; height: 340px; }
@media (max-width: 540px) { canvas.chart { height: 260px; } }

.legend-row {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 0.78rem;
  align-items: center;
}
.legend-row .key { display: inline-flex; align-items: center; gap: 6px; }
.legend-row .swatch { width: 18px; height: 3px; display: inline-block; border-radius: 1px; }
.legend-row .swatch.dot { width: 10px; height: 10px; border-radius: 50%; }

/* ── Results strip ────────────────────────────────────────────────────── */
.results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  padding: 14px 16px;
  margin-top: 16px;
}
.result { display: flex; flex-direction: column; gap: 2px; }
.result .lbl { font-size: 0.7rem; letter-spacing: 0.5px; text-transform: uppercase; opacity: 0.75; }
.result .val { font-size: 1.3rem; font-weight: 700; line-height: 1.1; }
.result .unit { font-size: 0.72rem; opacity: 0.7; }

/* ── Formula / explanation block ──────────────────────────────────────── */
.formula {
  padding: 12px 14px;
  margin-top: 14px;
  font-size: 0.86rem;
  line-height: 1.9;
  overflow-x: auto;
}
.formula .row { display: grid; grid-template-columns: 190px 1fr; gap: 12px; }
.formula .row .name { opacity: 0.8; }
.formula b.hl { font-weight: 700; }
@media (max-width: 540px) {
  .formula .row { grid-template-columns: 1fr; gap: 0; }
}

/* ── Tables ───────────────────────────────────────────────────────────── */
table.grid { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
table.grid th, table.grid td { padding: 7px 10px; text-align: left; }
table.grid th { font-weight: 700; }
.table-wrap { overflow-x: auto; margin-top: 14px; }

/* ── Status bar (inside windows) ──────────────────────────────────────── */
.statusbar {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 4px 10px;
  font-size: 0.76rem;
}
.statusbar .sb-cell { white-space: nowrap; }
.statusbar .grow { flex: 1 1 auto; }

/* ── Landing tiles ────────────────────────────────────────────────────── */
.hero { padding: 26px 4px 10px; }
.hero h1 { margin: 0 0 8px; font-size: 1.9rem; line-height: 1.1; }
.hero p { margin: 0; max-width: 68ch; }

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
  margin-top: 22px;
}
.tile { text-decoration: none; display: flex; }
.tile .win { margin: 0; width: 100%; display: flex; flex-direction: column; }
.tile .win-body { flex: 1 1 auto; }
.tile .tile-tag { font-size: 0.7rem; letter-spacing: 0.6px; text-transform: uppercase; opacity: 0.7; }
.tile h3 { margin: 4px 0 6px; font-size: 1.05rem; }
.tile p { margin: 0; font-size: 0.85rem; opacity: 0.9; }
.tile.soon { pointer-events: none; }
.tile.soon .badge {
  font-size: 0.68rem; padding: 1px 7px; margin-left: 6px;
  vertical-align: middle;
}

/* numeric values read nicely in the UI font's tabular form */
.mono, .result .val, .formula, .slider .head .val, .field .unit {
  font-variant-numeric: tabular-nums;
}

/* ── Footer ───────────────────────────────────────────────────────────── */
.footer { padding: 22px 16px 30px; text-align: center; font-size: 0.78rem; opacity: 0.8; }

/* ── Accessibility: visible keyboard focus & reduced motion ───────────── */
:focus-visible { outline: 2px solid currentColor; outline-offset: 1px; }
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* ── Small-screen topbar ──────────────────────────────────────────────── */
@media (max-width: 620px) {
  :root { --topbar-h: auto; }
  .topbar { flex-wrap: wrap; padding: 6px 10px; gap: 8px; }
  .topbar nav { order: 3; flex-basis: 100%; }
  .topbar nav a { padding: 5px 8px; font-size: 0.8rem; }
}
