/* SubdivisionEngine_BDMH: the look of nijatmahamaliyev.com and the HTMAA site. Dark, monochrome,
   IBM Plex Mono, 1px lines, uppercase letter-spaced labels, dashed borders for what is empty. */
@font-face { font-family: "IBM Plex Mono"; src: url("../fonts/IBMPlexMono-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("../fonts/IBMPlexMono-Medium.ttf") format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("../fonts/IBMPlexMono-SemiBold.ttf") format("truetype"); font-weight: 600; font-display: swap; }

:root {
  --bg: #0b0b0b; --bg2: #141414; --bg3: #1b1b1b; --line: #232323; --line2: #3a3a3a;
  --fg: #d2d2d2; --hi: #f4f4f4; --dim: #8a8a8a; --faint: #4a4a4a; --warn: #d09a4e; --ok: #8fb58a;
  --nav: 268px; --insp: 400px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4f4f2; --bg2: #ebebe8; --bg3: #e2e2df; --line: #d6d6d2; --line2: #b4b4b0;
  --fg: #2b2b2b; --hi: #0b0b0b; --dim: #6e6e6c; --faint: #a6a6a2; --warn: #a8661a; --ok: #3f7a3a;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); }
body { font: 13px/1.45 "IBM Plex Mono", ui-monospace, Menlo, monospace; overflow: hidden; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }

#app { display: grid; grid-template-columns: var(--nav) 1fr var(--insp); height: 100vh; height: 100dvh; }
.boot { padding: 28px; color: var(--hi); }
.fatal { padding: 28px; color: var(--warn); white-space: pre-wrap; }

/* ---------------------------------------------------------------- sidebar */
#nav { border-right: 1px solid var(--line); padding: 26px 20px 20px; overflow-y: auto; display: flex; flex-direction: column; }
.navhead .name { font-weight: 600; font-size: 15px; color: var(--hi); margin-bottom: 4px; }
.navfoot { margin-top: auto; padding-top: 22px; border-top: 1px dashed var(--line2); display: flex; flex-direction: column; gap: 2px; }
.navfoot a { text-decoration: none; }
.navfoot a:hover { color: var(--fg); }

/* ---------------------------------------------------------------- stage */
#stage { position: relative; min-width: 0; overflow: hidden; }
#view { position: absolute; inset: 0; }
#view canvas { display: block; }
#toolbar, #statusbar { position: absolute; left: 0; right: 0; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(6px); z-index: 2; }
#toolbar { top: 0; border-bottom: 1px solid var(--line); padding: 10px 16px 8px; }
#statusbar { bottom: 0; border-top: 1px solid var(--line); padding: 8px 16px 10px; }
#hint { display: none; position: absolute; left: 14px; bottom: 10px; color: var(--faint); font-size: 11.5px; z-index: 2; pointer-events: none; }
.tbline, .stline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-height: 28px; }
.tbline + .tbline { margin-top: 4px; }
.stline.small { min-height: 20px; font-size: 11.5px; gap: 12px; }
.prompt { font-size: 12px; color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prompt b { color: var(--hi); font-weight: 500; }
.cursor { display: inline-block; width: 7px; height: 13px; margin-left: 3px; vertical-align: -2px; background: var(--hi); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.tbright { margin-left: auto; display: flex; gap: 6px; }
.colourby { display: flex; align-items: center; gap: 6px; }
.legend { display: inline-block; width: 70px; height: 8px; border: 1px solid var(--line2); }
.cutbox { position: relative; display: flex; gap: 0; }
.popover { position: absolute; top: 34px; left: 0; width: 360px; max-width: 80vw; background: var(--bg2); border: 1px solid var(--line2); padding: 14px 16px; z-index: 5; }
.trunc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 70%; }

/* ---------------------------------------------------------------- inspector */
#inspector { border-left: 1px solid var(--line); padding: 24px 20px 20px; overflow-y: auto; overflow-x: hidden; }
.kicker { font-size: 11px; letter-spacing: .14em; color: var(--dim); }
.title { font-weight: 500; font-size: 21px; color: var(--hi); margin: 2px 0 8px; }
.dash { border-top: 1px dashed var(--line2); margin: 6px 0 10px; }
.subhead { display: flex; align-items: center; gap: 8px; margin: 18px 0 8px; font-size: 11px; letter-spacing: .14em; color: var(--dim); }
.subhead i { flex: 1; border-top: 1px dashed var(--line2); }
.spaced { font-size: 11px; letter-spacing: .14em; }
.note { color: var(--dim); margin: 4px 0 6px; }
.small { font-size: 11.5px; line-height: 1.45; }
.explain { display: none; color: var(--dim); border-left: 1px solid var(--line2); padding: 2px 0 2px 10px; margin: 6px 0 8px; }
body.help .explain { display: block; }
.warn { color: var(--warn); margin: 4px 0; }
.okline { color: var(--ok); margin: 4px 0; }
.empty { border: 1px dashed var(--line2); color: var(--faint); padding: 10px 12px; margin: 6px 0; }
.card { border: 1px solid var(--line2); padding: 10px 12px; margin: 6px 0 10px; }
.medium { font-weight: 500; font-size: 14px; }
.hi { color: var(--hi); } .fg { color: var(--fg); } .dim { color: var(--dim); } .faint { color: var(--faint); }

.row { display: grid; grid-template-columns: 112px 1fr auto; align-items: center; gap: 8px; min-height: 28px; margin: 2px 0; }
.row > label { color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row > .val { grid-column: 2 / 4; }
.row > select, .row > .seg, .row > .txt, .row > .vec3, .row > .range, .row > .plot, .row > .vsl, .row > .bars { grid-column: 2 / 4; }
.row > .num { grid-column: 2 / 3; }
.unit { color: var(--dim); }

.bar { position: relative; height: 22px; border: 1px solid var(--line); background: var(--bg2); cursor: ew-resize; outline: none; touch-action: none; }
.bar:hover, .bar.active, .bar:focus-visible { border-color: var(--line2); background: var(--bg3); }
.bar .fill { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--dim) 35%, transparent); }
.bar.active .fill { background: color-mix(in srgb, var(--hi) 35%, transparent); }
.bar .mark { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--hi); }
.bar .zero { position: absolute; top: 4px; bottom: 4px; width: 1px; background: var(--line2); }
.barval { min-width: 64px; text-align: right; color: var(--fg); font-variant-numeric: tabular-nums; cursor: text; }

.btn, .seg button, .stepper button, .check { background: transparent; border: 1px solid var(--line2); color: var(--fg); padding: 3px 9px; cursor: pointer; white-space: nowrap; border-radius: 0; }
.btn:hover, .seg button:hover, .stepper button:hover { background: var(--bg3); }
.btn.primary { border-color: var(--hi); color: var(--hi); }
.btn.on, .seg button.on { background: var(--hi); color: var(--bg); border-color: var(--hi); }
.btn:disabled, .stepper button:disabled { opacity: .4; cursor: default; }
.btn.x { padding: 0 6px; }
#inspector > .btn { margin: 4px 0; }
.check { border: none; padding: 3px 2px; color: var(--fg); }
.check .box { color: var(--dim); }
.check.on .box { color: var(--hi); }
.check:hover { color: var(--hi); }
.inline { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0; }
.inline .grow { flex: 1; min-width: 0; }
.seg { display: flex; flex-wrap: wrap; }
.seg button { margin-left: -1px; padding: 3px 8px; }
.seg button:first-child { margin-left: 0; }
.seg.full { margin: 4px 0; }
.seg.joined { display: flex; }
.seg.joined .btn { margin-left: -1px; }
.stepper { display: inline-flex; align-items: center; gap: 2px; }
.stepper button { padding: 1px 7px; }
select { background: var(--bg2); border: 1px solid var(--line2); padding: 3px 6px; border-radius: 0; min-width: 0; max-width: 100%; }
.txt, .num { background: var(--bg2); border: 1px solid var(--line2); padding: 3px 6px; border-radius: 0; min-width: 0; width: 100%; outline: none; }
.txt:focus, .num:focus { border-color: var(--hi); }
.vec3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.range { display: flex; align-items: center; gap: 4px; }
.range .num { width: 64px; }

.list { margin: 4px 0; }
.lrow { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; padding: 3px 8px; cursor: pointer; border: 1px solid transparent; }
.lrow .left { grid-column: 2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lrow .lnum { color: var(--faint); }
.lrow .right { color: var(--dim); }
.lrow:hover { background: var(--bg2); }
.lrow.sel { background: var(--bg2); color: var(--hi); }
.lrow.faint .left, .lrow.faint .right { color: var(--faint); }
#nav .lrow { padding: 3px 6px; grid-template-columns: auto max-content minmax(0, 1fr); }
#nav .lrow .right { text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ihead { display: flex; align-items: center; gap: 8px; margin: 12px 0 4px; }
.ihead i { flex: 1; border-top: 1px dashed var(--line2); }

.bars { display: flex; gap: 2px; height: 24px; }
.bars .b { position: relative; flex: 1; background: var(--bg2); }
.bars .b i { position: absolute; left: 0; right: 0; background: var(--dim); }
.bars .b.hl i { background: var(--hi); }
.plot { width: 100%; height: 52px; display: block; }
.vsl { display: flex; gap: 6px; }
.vs { position: relative; width: 26px; height: 64px; border: 1px solid var(--line2); background: var(--bg2); cursor: ns-resize; touch-action: none; }
.vs i { position: absolute; left: 0; right: 0; bottom: 0; background: var(--dim); }

.tooltip { position: fixed; z-index: 50; max-width: 340px; background: var(--bg2); border: 1px solid var(--line2); color: var(--fg); padding: 7px 9px; font-size: 11.5px; white-space: pre-wrap; pointer-events: none; opacity: 0; transition: opacity .1s; }
.tooltip.show { opacity: 1; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line2); }
::-webkit-scrollbar-track { background: transparent; }

/* tab: hide the panels (screenshots, presenting) */
body.hidden-panels #app { grid-template-columns: 0 1fr 0; }
body.hidden-panels #nav, body.hidden-panels #inspector, body.hidden-panels #toolbar, body.hidden-panels #statusbar { display: none; }
body.hidden-panels #hint { display: block; }

/* ---------------------------------------------------------------- narrow screens */
@media (max-width: 1100px) { :root { --nav: 220px; --insp: 360px; } }
@media (max-width: 820px) {
  body { overflow: auto; }
  #app { display: flex; flex-direction: column; height: auto; min-height: 100dvh; }
  #nav { order: 1; border-right: none; border-bottom: 1px solid var(--line); padding: 12px 16px; flex-direction: row; flex-wrap: wrap; gap: 0 10px; overflow: visible; }
  #nav .navhead, #nav .navfoot, #nav .spaced, #nav > div[style] { display: none; }
  #nav .lrow { grid-template-columns: auto auto; border: 1px solid var(--line); margin: 2px 0; }
  #nav .lrow .right { display: none; }
  #stage { order: 2; height: 62vh; min-height: 360px; }
  #inspector { order: 3; border-left: none; padding: 18px 16px 40px; overflow: visible; }
  .popover { position: fixed; left: 16px; right: 16px; top: auto; width: auto; }
  .row { grid-template-columns: 96px 1fr auto; }
  .trunc { max-width: 100%; }
}
.colourby select { width: 190px; }
