/* Docs: document tabs (the tab list), footnotes, equations and the equation dialog, drawings and the drawing dialog,
   smart chips, the "@" menu and chip cards (docs.js, docs_tabs.js, docs_math.js, docs_draw.js, docs_chips.js). Theme
   variables only: light and dark alike (a drawing is on white, like a picture). */

/* ---------------------------------------------------------------- the tab list (left of the page) */
.doc-area.doc-with-tabs { flex-direction: row; }
.doc-tabs-box { flex: none; display: none; }
.doc-area.doc-with-tabs .doc-tabs-box { display: block; width: 232px; border-right: 1px solid var(--border); background: var(--surface);
  overflow: auto; min-height: 0; }
.dt-panel { padding: 10px 8px 16px; }
.dt-head { display: flex; align-items: center; gap: 2px; padding: 0 2px 8px 8px; }
.dt-title { flex: 1; font-size: 13px; font-weight: 600; color: var(--text-2); }
.dt-list { display: flex; flex-direction: column; gap: 1px; }
.dt-item { display: flex; align-items: center; border-radius: 8px; }
.dt-item:hover { background: var(--surface-2); }
.dt-item.on { background: var(--accent-weak); }
.dt-item.child { margin-left: 18px; }
.dt-name { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 7px 4px 7px 10px; border: 0;
  background: transparent; color: var(--text); font: inherit; font-size: 13.5px; text-align: left; cursor: pointer; border-radius: 8px; }
.dt-item.on .dt-name { color: var(--accent); font-weight: 600; }
.dt-name:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.dt-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dt-more { opacity: 0; flex: none; }
.dt-item:hover .dt-more, .dt-item.on .dt-more, .dt-more:focus-visible { opacity: 1; }

@media (max-width: 860px) {
  .doc-area.doc-with-tabs { flex-direction: column; }
  .doc-area.doc-with-tabs .doc-tabs-box { width: auto; border-right: 0; border-bottom: 1px solid var(--border); max-height: 34vh; }
  .dt-panel { padding: 6px 8px; }
  .dt-list { flex-direction: row; overflow-x: auto; gap: 4px; }
  .dt-item { flex: none; max-width: 70vw; }
  .dt-item.child { margin-left: 0; }
  .dt-more { opacity: 1; }
}

/* ---------------------------------------------------------------- footnotes */
/* a footnote's number in the text */
.doc-page .doc-fnref { font-size: .7em; vertical-align: super; line-height: 0; color: var(--accent); cursor: pointer;
  padding: 0 1px; user-select: none; white-space: nowrap; }
.doc-page .doc-fnref:hover { text-decoration: underline; }
/* a footnote: its number left of its first paragraph, its paragraphs smaller, below the tab's text */
.doc-page .doc-fn { float: left; clear: left; min-width: 1.3em; margin: 0 4px 0 0; font-size: 10pt; line-height: 1.5;
  color: var(--text-2); cursor: pointer; user-select: none; }
.doc-page .doc-fn .doc-fn-num { font-size: .78em; vertical-align: super; }
.doc-page .doc-fn.first { clear: both; margin-top: 2.4em; position: relative; }
.doc-page .doc-fn.first::before { content: ''; position: absolute; left: 0; top: -1.1em; width: 180px; max-width: 40vw;
  border-top: 1px solid var(--border-strong); }
.doc-page [data-fnp] { font-size: 10pt; line-height: 1.5; margin-top: 0; margin-bottom: 2pt; }
/* (the first footnote's paragraph starts as low as its number: the float's top margin alone left the text above the
   line, the number under it) */
.doc-page .doc-fn.first + [data-fnp] { margin-top: 2.4em; }
.doc-page li[data-fnp] { margin-bottom: 0; }

/* ---------------------------------------------------------------- equations */
.doc-page .doc-eq { display: inline-block; padding: 0 2px; margin: 0 1px; border-radius: 4px; cursor: pointer; line-height: 1.2;
  vertical-align: middle; text-indent: 0; }
.doc-page .doc-eq:hover { background: var(--accent-weak); }
.doc-eq math { font-size: 1.08em; }
.doc-eq merror, .dm-preview merror { color: var(--danger, #d93025); background: var(--danger-weak, #fce8e6);
  border: 1px solid var(--danger, #d93025); padding: 0 2px; }

/* suggested footnotes and equations, in their author's colour (docs-menus.css draws the rest) */
.doc-page .doc-eq[data-si], .doc-page .doc-fnref[data-si] { outline: 2px solid var(--sg-ins, #188038); outline-offset: 1px; }
.doc-page .doc-eq[data-sd], .doc-page .doc-fnref[data-sd] { outline: 2px dashed var(--sg-del, #c5221f); outline-offset: 1px; opacity: .55; }

/* ---------------------------------------------------------------- the equation dialog */
.dm-editor { display: flex; flex-direction: column; gap: 10px; min-width: min(560px, 82vw); }
.dm-toolbar { display: flex; flex-wrap: wrap; gap: 4px; }
.dm-source { width: 100%; min-height: 54px; font-family: Consolas, 'Roboto Mono', monospace; font-size: 14px; resize: vertical; }
.dm-preview { min-height: 64px; padding: 14px 10px; border: 1px dashed var(--border-strong); border-radius: 8px; background: var(--page);
  color: var(--page-text); overflow-x: auto; text-align: center; font-size: 18px; }
.dm-note { min-height: 1em; font-size: 12.5px; color: var(--danger, #d93025); }
.dm-help { margin: 0; font-size: 12.5px; }
.dm-grid { display: grid; grid-template-columns: repeat(8, 38px); gap: 2px; padding: 6px; max-width: 92vw; max-height: 60vh; overflow: auto; }
.dm-sym { height: 34px; border: 0; border-radius: 6px; background: transparent; color: var(--text); font: 16px/1 'Cambria Math', 'STIX Two Math',
  'Latin Modern Math', serif; cursor: pointer; white-space: nowrap; overflow: hidden; }
.dm-sym:hover, .dm-sym:focus-visible { background: var(--accent-weak); color: var(--accent); outline: none; }

@media (max-width: 520px) {
  .dm-grid { grid-template-columns: repeat(6, 38px); }
}

/* ---------------------------------------------------------------- drawings (docs_draw.js) */
.doc-page .doc-drawing { display: inline-block; max-width: 100%; vertical-align: bottom; line-height: 0; margin: 2px 1px;
  border-radius: 2px; cursor: default; text-indent: 0; }
/* (on white, like a picture, in the dark theme too: its colours were picked on white, as Word shows them) */
.doc-page .doc-drawing svg { max-width: 100%; height: auto; display: block; background: #fff; }
.doc-page .doc-drawing:hover { outline: 1px solid var(--border-strong); outline-offset: 1px; }
.doc-page .doc-drawing[data-si] { outline: 2px solid var(--sg-ins, #188038); outline-offset: 2px; }
.doc-page .doc-drawing[data-sd] { outline: 2px dashed var(--sg-del, #c5221f); outline-offset: 2px; opacity: .55; }

/* the drawing dialog (wider than a wide dialog's 640 px: its canvas, text box and alt text ran past the right edge) */
.modal.wide:has(.dd-editor) { max-width: min(760px, 96vw); }
.dd-editor { display: flex; flex-direction: column; gap: 8px; min-width: min(680px, 86vw); }
.dd-toolbar, .dd-props { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.dd-group { display: flex; align-items: center; gap: 3px; flex-wrap: wrap; }
.dd-tool { width: 32px; height: 32px; display: inline-grid; place-items: center; border: 1px solid transparent; border-radius: 6px;
  background: transparent; color: var(--text); cursor: pointer; font: inherit; }
.dd-tool:hover { background: var(--surface-2); }
.dd-tool[aria-pressed="true"] { background: var(--accent-weak); color: var(--accent); border-color: var(--accent); }
.dd-tool .icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.dd-btn:disabled { opacity: .45; }
.dd-lbl { font-size: 12.5px; color: var(--text-2); margin-right: 2px; }
.dd-color { width: 30px; height: 26px; padding: 0 2px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); cursor: pointer; }
.dd-check { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--text-2); cursor: pointer; }
.dd-select { width: auto; min-width: 64px; }
.dd-num { width: 72px; }
.dd-stage { overflow: auto; max-height: min(62vh, 640px); border: 1px solid var(--border); border-radius: 8px; background: var(--surface-3);
  padding: 10px; outline: none; }
.dd-stage:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.dd-svg { display: block; margin: 0 auto; max-width: 100%; height: auto; touch-action: none; user-select: none;
  box-shadow: var(--shadow-1); background: #fff; cursor: default; }
.dd-svg[data-tool]:not([data-tool="select"]) { cursor: crosshair; }
.dd-svg .dd-grid line { stroke: rgba(60, 64, 67, .12); stroke-width: .5; }
.dd-svg .dd-frame { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; }
.dd-svg .dd-stem { stroke: var(--accent); stroke-width: 1; vector-effect: non-scaling-stroke; }
.dd-svg .dd-handle { fill: var(--surface); stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; cursor: nwse-resize; }
.dd-svg .dd-rot { fill: var(--accent); stroke: var(--surface); stroke-width: 1.5; vector-effect: non-scaling-stroke; cursor: grab; }
.dd-text { width: 100%; min-height: 44px; resize: vertical; }
.dd-text:disabled { opacity: .6; }
.dd-alt { width: 100%; }
.dd-status { min-height: 1.3em; font-size: 12.5px; }

/* ---------------------------------------------------------------- smart chips (docs_chips.js) */
.doc-page .doc-chip { display: inline-flex; align-items: center; gap: 3px; max-width: 100%; padding: 0 7px; margin: 0 1px;
  border-radius: 999px; background: var(--surface-2); color: var(--text); font-size: .92em; line-height: 1.55;
  vertical-align: baseline; cursor: pointer; white-space: nowrap; text-indent: 0; user-select: none; }
.doc-page .doc-chip:hover { filter: brightness(.95); box-shadow: 0 0 0 1px var(--border-strong) inset; }
.doc-page .doc-chip .dc-label { overflow: hidden; text-overflow: ellipsis; }
.doc-page .doc-chip .dc-at { color: var(--text-2); }
.doc-page .doc-chip .dc-icon { width: 15px; height: 15px; flex: none; }
.doc-page .doc-chip .dc-caret { font-size: .8em; opacity: .7; }
.doc-page .doc-chip.dc-person { background: var(--accent-weak); color: var(--accent); }
.doc-page .doc-chip.dc-date { background: var(--surface-2); }
.doc-page .doc-chip.dc-dropdown { border-radius: 6px; }
.doc-page .doc-chip[data-si] { outline: 2px solid var(--sg-ins, #188038); outline-offset: 1px; }
.doc-page .doc-chip[data-sd] { outline: 2px dashed var(--sg-del, #c5221f); outline-offset: 1px; opacity: .55; }

/* the "@" menu */
.dc-menu { position: fixed; width: 330px; max-width: calc(100vw - 16px); max-height: 320px; padding: 4px 0; }
.dc-list { display: flex; flex-direction: column; }
.dc-group { padding: 8px 14px 4px; font-size: 11.5px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; color: var(--text-3); }
.dc-item { display: flex; align-items: center; gap: 10px; padding: 6px 14px; cursor: pointer; min-height: 36px; }
.dc-item.on { background: var(--surface-2); }
.dc-lead { width: 26px; text-align: center; flex: none; }
.dc-text { display: flex; flex-direction: column; min-width: 0; }
.dc-name { font-size: 13.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dc-sub { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dc-empty { padding: 10px 14px; font-size: 13px; }

/* a chip's card */
.dc-card { position: fixed; z-index: 1001; width: 290px; max-width: calc(100vw - 16px); padding: 14px; background: var(--surface);
  color: var(--text); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-3); font-size: 13.5px; }
.dc-card-body { display: flex; flex-direction: column; gap: 8px; }
.dc-card-head { display: flex; align-items: center; gap: 10px; }
.dc-card-title { min-width: 0; }
.dc-card-name { font-weight: 600; overflow-wrap: anywhere; }
.dc-card-row { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.dc-card-actions { display: flex; gap: 6px; }

/* the dropdown editor */
.dc-dropdown-editor { min-width: min(440px, 84vw); }
.dc-opts { display: flex; flex-direction: column; gap: 6px; max-height: 46vh; overflow: auto; }
.dc-opt { display: flex; align-items: center; gap: 6px; }
.dc-opt-label { flex: 1; min-width: 0; }
.dc-opt-color { width: 34px; height: 30px; padding: 0 2px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }

@media (max-width: 520px) {
  .dd-editor { min-width: 0; }
  .dd-props { gap: 6px; }
}

@media print {
  .doc-tabs-box { display: none !important; }
  .doc-area.doc-with-tabs { display: block; }
  .doc-page .doc-fnref { color: inherit; }
  .doc-page .doc-eq:hover { background: none; }
  .doc-page .doc-drawing:hover { outline: none; }
  .doc-page .doc-chip { box-shadow: none; filter: none; }
}
