/* svgp-floating-panel: the shared shell for the floating / dockable tool
   panels (Icons, SVG Code editor), built on tokens.css and the .svgp-panel
   surface in svgedit.css. Linked from the <head> of index.*.html, after
   components.css. Behaviour and builders live in floating-panel.js.

   Markup (class names in brackets are the legacy hooks the panels keep):

     <div class="svgp-panel svgp-floating-panel" id="…">
       <div class="svgp-floating-panel__header svgp-panel-header">
         <span class="svgp-floating-panel__title svgp-panel-title">Title</span>
         <div class="svgp-floating-panel__controls svgp-panel-controls">
           <button type="button" class="svgp-floating-panel__btn svgp-panel-icon-btn"
                   aria-label="Close">…svg…</button>
         </div>
       </div>
       <div class="svgp-floating-panel__body">…</div>         (or a custom body)
       <div class="svgp-floating-panel__footer">
         <span class="svgp-floating-panel__footer-text">Powered by <a>…</a></span>
         <span class="svgp-floating-panel__footer-meta">Size: 4 KB</span>
       </div>
     </div>

   Parts
   - header: uppercase title (left) + icon-button group (right). Title size,
     tracking and line height, button size, gap, icon size and the hover /
     focus ring all come from --svgp-panel-* tokens. Floating panels drag by
     the header (--draggable); a docked panel keeps the default cursor.
   - body: inset by --svgp-panel-pad on both sides, --svgp-panel-gap between
     rows. Scrolls inside (__scroll) with the shared thin scrollbar.
   - toolbar: a row of controls under the header, same inset as the body.
   - controls: ONE look for inputs, selects and toolbar buttons
     (__control): --svgp-panel-control-height, 6px radius, the panel control
     border and fill, a 2px focus ring.
   - section: muted heading + subtle link (__section-head / -title / -link).
   - footer: fixed --svgp-panel-footer-height bar with a top divider and
     muted small text; optional right-aligned meta.
   - scrollbar and resize: __scroll (and the CodeMirror scroller) share one
     8px rounded thumb; docked panels share the .svgp-resize-handle, floating
     ones the native corner grip (resize: both, via --resizable). */

.svgp-floating-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--svgp-color-text);
  font-family: var(--svgp-font);
  font-size: var(--svgp-font-size-13);
  line-height: var(--svgp-line-13);
}

.svgp-floating-panel[hidden] {
  display: none !important;
}

/* A floating panel that the user can resize with the browser's corner grip.
   Docked panels turn it off (.svgp-docked sets resize: none !important). */
.svgp-floating-panel--resizable {
  resize: both;
}

/* ---------- Header ---------- */

.svgp-floating-panel__header {
  font-size: var(--svgp-panel-title-size);
  letter-spacing: var(--svgp-panel-title-tracking);
}

.svgp-floating-panel__header--draggable {
  cursor: grab;
  touch-action: none;
}

.svgp-floating-panel__header--draggable:active {
  cursor: grabbing;
}

.svgp-floating-panel.svgp-docked > .svgp-floating-panel__header--draggable {
  cursor: default;
}

.svgp-floating-panel__title {
  font-size: var(--svgp-panel-title-size);
  line-height: var(--svgp-panel-title-line);
  letter-spacing: var(--svgp-panel-title-tracking);
  font-weight: var(--svgp-weight-semibold);
}

.svgp-floating-panel__controls {
  gap: var(--svgp-panel-controls-gap);
}

.svgp-floating-panel__btn {
  width: var(--svgp-panel-btn-size);
  height: var(--svgp-panel-btn-size);
  border-radius: var(--svgp-radius-6);
  font-size: var(--svgp-panel-icon-size);
}

.svgp-floating-panel__btn svg {
  width: var(--svgp-panel-icon-size);
  height: var(--svgp-panel-icon-size);
}

.svgp-floating-panel__btn:hover {
  background: var(--svgp-hover-bg);
  color: var(--svgp-icon-hover);
}

.svgp-floating-panel__btn:focus-visible {
  outline: var(--svgp-focus-width) solid var(--svgp-color-focus);
  outline-offset: 1px;
}

/* ---------- Body and toolbar ---------- */

.svgp-floating-panel__body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: var(--svgp-panel-gap);
  min-height: 0;
  box-sizing: border-box;
  padding: 0 var(--svgp-panel-pad) var(--svgp-panel-pad);
}

.svgp-floating-panel__toolbar {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--svgp-panel-gap);
  box-sizing: border-box;
  min-width: 0;
  padding: 0 var(--svgp-panel-pad) var(--svgp-panel-gap);
}

/* ---------- Controls: inputs, selects, toolbar buttons ---------- */

.svgp-floating-panel__control {
  box-sizing: border-box;
  height: var(--svgp-panel-control-height);
  margin: 0;
  padding: 0 var(--svgp-panel-control-padding);
  border: 1px solid var(--svgp-panel-control-border);
  border-radius: var(--svgp-radius-6);
  background-color: var(--svgp-panel-control-bg);
  color: var(--svgp-color-text);
  font-family: var(--svgp-panel-font);
  font-size: var(--svgp-font-size-12);
  line-height: var(--svgp-line-12);
  font-weight: var(--svgp-weight-medium);
  outline: none;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.svgp-floating-panel__control::placeholder {
  color: var(--svgp-text-muted);
  opacity: 1;
}

/* Select: keep the chevron from .svgp-select, make room for it. */
select.svgp-floating-panel__control {
  padding-right: 22px;
}

button.svgp-floating-panel__control {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
}

.svgp-floating-panel__control:hover:not(:disabled) {
  border-color: var(--svgp-color-focus);
  background-color: var(--svgp-color-focus-soft);
}

.svgp-floating-panel__control:focus-visible {
  border-color: var(--svgp-color-focus);
  outline: var(--svgp-focus-width) solid var(--svgp-color-focus);
  outline-offset: 1px;
}

.svgp-floating-panel__control:disabled {
  opacity: 0.55;
  cursor: default;
}

/* ---------- Section label: muted heading + subtle link ---------- */

.svgp-floating-panel__section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--svgp-space-8);
  min-width: 0;
  margin-bottom: var(--svgp-space-4);
}

.svgp-floating-panel__section-title {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--svgp-text-muted);
  font-family: var(--svgp-panel-font);
  font-size: var(--svgp-font-size-12);
  line-height: var(--svgp-line-12);
  font-weight: var(--svgp-weight-semibold);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.svgp-floating-panel__section-link {
  flex: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--svgp-text-muted);
  font-family: var(--svgp-panel-font);
  font-size: var(--svgp-font-size-11);
  line-height: var(--svgp-line-12);
  font-weight: var(--svgp-weight-regular);
  cursor: pointer;
  border-radius: 2px;
}

.svgp-floating-panel__section-link::after {
  content: " \203A";
}

.svgp-floating-panel__section-link:hover {
  color: var(--svgp-color-link);
  text-decoration: underline;
}

.svgp-floating-panel__section-link:focus-visible {
  outline: var(--svgp-focus-width) solid var(--svgp-color-focus);
  outline-offset: 2px;
}

/* ---------- Footer ---------- */

.svgp-floating-panel__footer {
  display: flex;
  flex: 0 0 var(--svgp-panel-footer-height);
  align-items: center;
  justify-content: space-between;
  gap: var(--svgp-space-8);
  box-sizing: border-box;
  height: var(--svgp-panel-footer-height);
  padding: 0 var(--svgp-panel-pad);
  overflow: hidden;
  border-top: 1px solid var(--svgp-divider);
  background: transparent;
  color: var(--svgp-text-muted);
  font-family: var(--svgp-panel-font);
  font-size: var(--svgp-panel-footer-size);
  line-height: var(--svgp-line-12);
  white-space: nowrap;
}

.svgp-floating-panel__footer-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.svgp-floating-panel__footer-meta {
  flex: none;
  font-size: var(--svgp-font-size-11);
  font-variant-numeric: tabular-nums;
}

.svgp-floating-panel__footer a {
  display: inline;
  min-height: 0;
  color: inherit;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  border-radius: 2px;
}

.svgp-floating-panel__footer a:hover {
  color: var(--svgp-color-text);
}

.svgp-floating-panel__footer a:focus-visible {
  outline: var(--svgp-focus-width) solid var(--svgp-color-focus);
  outline-offset: 2px;
}

/* ---------- Scrollbar: one thin rounded thumb for every panel scroller ---------- */

.svgp-floating-panel__scroll,
.svgp-floating-panel .cm-scroller {
  scrollbar-width: thin;
  scrollbar-color: var(--svgp-scrollbar-thumb) transparent;
}

.svgp-floating-panel__scroll::-webkit-scrollbar,
.svgp-floating-panel .cm-scroller::-webkit-scrollbar {
  width: var(--svgp-scrollbar-size);
  height: 0;
}

.svgp-floating-panel__scroll::-webkit-scrollbar-track,
.svgp-floating-panel__scroll::-webkit-scrollbar-corner,
.svgp-floating-panel .cm-scroller::-webkit-scrollbar-track,
.svgp-floating-panel .cm-scroller::-webkit-scrollbar-corner {
  background: transparent;
}

.svgp-floating-panel__scroll::-webkit-scrollbar-thumb,
.svgp-floating-panel .cm-scroller::-webkit-scrollbar-thumb {
  background-color: var(--svgp-scrollbar-thumb);
  background-clip: padding-box;
  border: 2px solid transparent;
  border-radius: 999px;
}

.svgp-floating-panel__scroll::-webkit-scrollbar-thumb:hover,
.svgp-floating-panel .cm-scroller::-webkit-scrollbar-thumb:hover {
  background-color: var(--svgp-scrollbar-thumb-hover);
}

@media (prefers-reduced-motion: reduce) {
  .svgp-floating-panel__control {
    transition: none;
  }
}
