/* molecules.css · molecule viewer for erinacine A, hericenone C and hericenone D (src/molecules.js, DESIGN.md §14, DESIGN-v3.md §C).
   Every token falls back to the DESIGN-v3 §1 value, so src/molecules-demo.html renders on its own.
   Type (DESIGN-v4-type): all text is the site's text face through var(--f-text); numbers (formula, molar mass, CAS,
   InChIKey) use var(--num). The family is named only in the fallback below, which mirrors the site.css token.
   The figure sits straight on the section ground: no frame, no box, no shadow, radius 0.
   v5 (DESIGN-v5.md §5, §6): hosted in .fig-panel.is-live (tokens from there); figure text 14 px --fg-2 with the name in --fg;
   controls 2 px radius, no press offset, no letter-spacing. Oxygen stays amber. */
.gblm{
  --gblm-fg:var(--fg,#F4FBF7);
  --gblm-fg2:var(--fg-2,#CDEFDC);
  --gblm-fg3:var(--fg-3,#CDEFDC);
  --gblm-ground:var(--ground,#0A7549);
  --gblm-o:var(--oxygen,#FFC266);
  --gblm-trace:var(--trace,#A8E8FF);
  --gblm-focus:var(--focus,#FFCB52);
  --gblm-gold:var(--gold,#FFCB52);
  --gblm-field:var(--field,#085232);
  --gblm-ft:var(--f-text,"Funnel Sans",ui-sans-serif,system-ui,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif);
  --gblm-num:var(--num,tabular-nums lining-nums);
  --gblm-gap:var(--col-gap,clamp(12px,1.6vw,24px));
  display:block;margin:0;padding:0;min-width:0;max-width:100%;
  color:var(--gblm-fg);font-family:var(--gblm-ft);
}
.gblm *,.gblm *::before,.gblm *::after{box-sizing:border-box}

/* instrument family: theme:'dark' (UPLC-PDA run lens), or a popover on --rail whose host did not re-declare tokens */
.gblm--dark,.gblm--ondark{
  --gblm-fg:var(--eluent,#F4FBF7);--gblm-fg2:var(--eluent-2,#CDEFDC);--gblm-fg3:var(--eluent-2,#CDEFDC);
  --gblm-ground:var(--rail,#062F1B);--gblm-o:var(--amber,#FFC266);
  --gblm-trace:var(--ice,#A8E8FF);--gblm-focus:var(--gold,#FFCB52);--gblm-field:var(--rail,#062F1B);
  color-scheme:dark;
}
/* kept for API compatibility only: there is no light ground in v3, so it carries the emerald values */
.gblm--onlight{
  --gblm-fg:var(--eluent,#F4FBF7);--gblm-fg2:var(--eluent-2,#CDEFDC);--gblm-fg3:var(--eluent-2,#CDEFDC);
  --gblm-ground:var(--g-l0,#0A7549);--gblm-o:var(--amber,#FFC266);
  --gblm-trace:var(--ice,#A8E8FF);--gblm-focus:var(--gold,#FFCB52);--gblm-field:var(--field,#085232);
  color-scheme:dark;
}

/* stage: one view at a time (3d | 2d) inside a fixed aspect, or both side by side.
   The 3D frame is capped (480 px tall, 72 % of the small viewport) so a full-width slot never yields a model taller than the screen. */
.gblm{--gblm-maxh:min(480px,72vh);--gblm-maxh:min(480px,72svh)}
.gblm-stage{position:relative;aspect-ratio:var(--gblm-ar,4/3);max-width:calc(var(--gblm-maxh) * var(--gblm-ar,1.3333))}
.gblm--sized .gblm-stage,.gblm--both .gblm-stage{max-width:none}
.gblm--both .gblm-v3d{max-width:calc(var(--gblm-maxh) * var(--gblm-ar,1.3333))}
.gblm-v{min-width:0}
.gblm-v[hidden]{display:none!important}
.gblm--both .gblm-stage{aspect-ratio:auto;display:grid;grid-template-columns:minmax(0,1fr);row-gap:clamp(8px,2vw,16px)}
.gblm--both.gblm--wide .gblm-stage{grid-template-columns:repeat(2,minmax(0,1fr));column-gap:var(--gblm-gap);align-items:center}
.gblm--both .gblm-v3d{position:relative;aspect-ratio:var(--gblm-ar,4/3)}
.gblm--both .gblm-v2d{aspect-ratio:720/460}

/* 3D canvas: atoms and bonds in DEPTH colors (molecules.js), rimmed with the ground */
.gblm-cv{display:block;cursor:grab;touch-action:pan-y;-webkit-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent}
.gblm-cv:not([tabindex]){cursor:default}
.gblm-cv.is-drag{cursor:grabbing}
.gblm-cv:focus-visible{outline:3px solid var(--gblm-focus);outline-offset:2px}

/* 2D depiction (RDKit SVG; colors rewritten when embedded: ink -> currentColor, O -> --gblm-o) */
.gblm-v2d{color:var(--gblm-fg)}
.gblm-svg{display:block;width:100%;height:100%;overflow:visible}
.gblm--hl .gblm-hl{stroke:var(--gblm-trace)!important;stroke-width:3px!important;vector-effect:non-scaling-stroke}

/* controls: small toggle chips (DESIGN-v4-type §3: text face 500, .875rem, line-height 1; the same as .uh-chips .uh-btn) */
.gblm-ctrl{display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin-top:12px}
.gblm-seg{display:inline-flex}
.gblm-seg{gap:8px}
.gblm-btn{
  -webkit-appearance:none;appearance:none;position:relative;margin:0;min-height:40px;padding:0 12px;
  border:1.5px solid var(--gblm-fg2);border-radius:2px;background:transparent;color:var(--gblm-fg);
  font:500 .875rem/1 var(--gblm-ft);letter-spacing:0;text-transform:none;cursor:pointer;
  transition:background-color var(--t-fast,160ms),border-color var(--t-fast,160ms);
}
.gblm-btn:hover{border-color:var(--gblm-gold);color:var(--gblm-fg);z-index:1}
.gblm-btn[aria-pressed="true"]{background:var(--gblm-field);border:2px solid var(--gblm-gold);padding:0 11.5px;color:var(--gblm-fg);z-index:1}
.gblm-btn:focus-visible{outline:3px solid var(--gblm-focus);outline-offset:2px;z-index:2}
.gblm-btn[hidden]{display:none}
@media (pointer:coarse){.gblm-btn{min-height:44px}}

/* caption (DESIGN-v4-type §3: captions 400 at .9375rem / 1.5; label lines 500 at .875rem / 1.35, never smaller) */
.gblm .gblm-cap{display:block;margin:12px 0 0;padding:0;max-width:none;font:400 .875rem/1.5 var(--gblm-ft);color:var(--gblm-fg2);text-wrap:pretty}
.gblm-ctrl+.gblm-cap{margin-top:14px}
.gblm-cap1{display:block}
.gblm-cap b{font-weight:600;color:var(--gblm-fg)}
.gblm-cap i{font-style:italic}
.gblm-cap sub{font-size:.75em;line-height:0;vertical-align:-.28em}
.gblm-nw{white-space:nowrap}
.gblm-key{display:flex;align-items:center;gap:8px;margin-top:6px;font:500 .875rem/1.35 var(--gblm-ft);color:var(--gblm-fg2)}
.gblm:not(.gblm--hl) .gblm-key{display:none}
.gblm-key svg{flex:none;width:22px;height:10px;fill:none;stroke:var(--gblm-trace);stroke-width:2.5;stroke-linejoin:round}
.gblm-cap2{display:block;margin-top:4px;font:500 .875rem/1.35 var(--gblm-ft);color:var(--gblm-fg2);overflow-wrap:anywhere}
.gblm .gblm-cap--compact{margin-top:6px;font:500 .875rem/1.35 var(--gblm-ft);color:var(--gblm-fg2)}
/* the font shorthands above reset font-variant-numeric: every caption line and control keeps tabular, lining figures */
.gblm .gblm-cap,.gblm .gblm-cap *,.gblm .gblm-btn{font-variant-numeric:var(--gblm-num)}

@media (prefers-reduced-motion:reduce){
  .gblm-btn{transition:none}
}
/* paper is white: the 2D structure and the caption print black */
@media print{
  .gblm-ctrl{display:none}
  .gblm{--gblm-fg:#000;--gblm-fg2:#000;--gblm-fg3:#000;--gblm-o:#000;--gblm-trace:#000}
}
