/* Virdant docs-site "try dock" — boot-time styles for the tab strip
   with the persistent "Try Virdant" tab (the dock's own styles ship
   inside /trydock/trydock.js).  Works on both docs themes; the dock
   itself follows the page's theme (light palette on light pages).

   Layout: the strip hugs the bottom-left corner of the viewport and is
   ALWAYS visible — dock closed or open, bundle loaded or not.  Once
   the bundle loads it swaps this stand-in for its own strip with
   identical geometry (see ui.css .td-tabstrip), so the handover is
   invisible.  On mobile (≤520px) the mobile block at the bottom of
   this file styles a full-width band instead of a corner tab. */

@media (min-width: 769px) {
  /* The page scrollbar must stop at the strip instead of running
     behind it down to the viewport bottom.  The theme lays the page
     out in .wy-grid-for-nav (position:absolute, height:100%) with the
     document as the scroller; make the grid the scroller instead,
     ending exactly at the strip's top edge.  (The dock bundle uses
     the same handover while the dock is open.)  trydock-boot.js
     forwards the keyboard scrolling keys, which otherwise target the
     unscrollable root. */
  /* The page scroller ends at the minimized bar's top edge; the tab
     strip (150px wide) is the only thing overlaying the last 40px of
     it — no dead band, no clipped-content stripe. */
  .wy-grid-for-nav {
    height: calc(100% - 42px);
    overflow-y: auto;
    overflow-x: hidden; /* matches the theme's root overflow-x */
  }

  /* The ToC sidebar's own scroller ends above the tab strip, so ToC
     links are never hidden behind the Try Virdant tab; the theme
     pads .wy-nav-side by 2em below its scroller (space for the RTD
     version badge, absent here); drop it. */
  .wy-side-scroll {
    height: calc(100% - 82px);
  }
  .wy-nav-side {
    padding-bottom: 0;
    /* The sidebar's own background must end at the minimized bar too —
       the theme pins it with top:0/bottom:0 AND min-height:100% (which
       beats any height), which would otherwise paint a dark rectangle
       beside the tab strip (the strip only covers its own 150px).
       Height + min-height:0 + bottom:auto ends it at the bar exactly. */
    height: calc(100% - 42px);
    min-height: 0;
    bottom: auto;
  }

  /* The minimized panel: a slim collapsed edge along the bottom.
     Always visible; the open dock covers it.  Geometry mirrors the
     bundle's #trydock-minbar handling in ui.css. */
  #trydock-minbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 42px;
    z-index: 9998;
    background: #f4f5f7;
    border-top: 1px solid #d5d9e0;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
    cursor: pointer;
  }

  [data-theme="dark"] #trydock-minbar {
    background: #21242b;
    border-top-color: #31353f;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.4);
  }

  /* The bar's reopen affordance: a chevron-up at the right edge —
     the spot where the dock toolbar's X sits when open — hinting
     that the panel unfolds upward from the bar.  (Colors hardcoded:
     the theme variables live on .trydock-root, which the bundle
     introduces; this styles the pre-bundle bar.) */
  #trydock-minbar-open {
    position: absolute;
    /* Same box as the toolbar's X button: the toolbar's 12px right
       padding, the X's 31x34 box (22px glyph + 6px/9px padding), and
       the 42px toolbar's vertical centering (4px top in the 42px bar). */
    right: 12px;
    top: 4px;
    transform: none;
    width: 31px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: none;
    border: 1px solid transparent;
    border-radius: 4px;
    color: #666d7a;
    cursor: pointer;
  }
  #trydock-minbar-open:hover {
    color: #262a31;
    background: #e9ebee;
    border-color: #d5d9e0;
  }
  #trydock-minbar-open svg path {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  [data-theme="dark"] #trydock-minbar-open {
    color: #8f95a1;
  }
  [data-theme="dark"] #trydock-minbar-open:hover {
    color: #d7dae0;
    background: #2a2e37;
    border-color: #31353f;
  }

  /* Working icon buttons where Settings and the panel maximize sit
     in the toolbar: same boxes as their counterparts, functional —
     clicking opens the dock and performs the action.  (Colors
     hardcoded: the theme variables live on .trydock-root, which the
     bundle introduces; this styles the pre-bundle bar.) */
  #trydock-minbar-settings {
    position: absolute;
    right: 140.25px; /* 12 + close 31.25 + 10 + max 32 + 10 + popout 35 + 10 */
    top: 3.5px;
    padding: 6px 9px;
    font-size: 22px;
    line-height: 22px;
    /* Same font as the toolbar so the ⚙ glyph advance matches the X
       button's box exactly. */
    font-family: "Fira Mono", "Fira Code", "SF Mono", Menlo, Consolas, monospace;
    background: none;
    border: none;
    border-radius: 4px;
    color: #666d7a;
    cursor: pointer;
  }
  #trydock-minbar-settings:hover {
    color: #262a31;
    background: #e9ebee;
  }
  #trydock-minbar-popout {
    position: absolute;
    right: 95.25px; /* 12 + close 31.25 + 10 + max 32 + 10 */
    /* The popout carries the toolbar's 17px icon (29px box):
       (42-29)/2 less the 1px border-top shift. */
    top: 6px;
    padding: 6px 9px;
    background: none;
    border: none;
    border-radius: 4px;
    color: #666d7a;
    cursor: pointer;
  }
  #trydock-minbar-popout:hover {
    color: #262a31;
    background: #e9ebee;
  }
  #trydock-minbar-max {
    position: absolute;
    right: 53.25px; /* 12 + close 31.25 + 10 */
    top: 7.5px;
    padding: 6px 9px;
    background: none;
    border: none;
    border-radius: 4px;
    color: #666d7a;
    cursor: pointer;
  }
  #trydock-minbar-max:hover {
    color: #262a31;
    background: #e9ebee;
  }
  #trydock-minbar-popout .td-svg,
  #trydock-minbar-max .td-svg {
    display: block; /* no inline-svg baseline gap: box height matches */
  }
  #trydock-minbar-popout svg path,
  #trydock-minbar-max svg path {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  [data-theme="dark"] #trydock-minbar-settings,
  [data-theme="dark"] #trydock-minbar-popout,
  [data-theme="dark"] #trydock-minbar-max {
    color: #8f95a1;
  }
  [data-theme="dark"] #trydock-minbar-settings:hover,
  [data-theme="dark"] #trydock-minbar-popout:hover,
  [data-theme="dark"] #trydock-minbar-max:hover {
    color: #d7dae0;
    background: #2a2e37;
  }
  [data-theme="dark"] #trydock-minbar-setph,
  [data-theme="dark"] #trydock-minbar-maxph {
    background: #31353f;
  }

  /* The stand-in strip: fixed above the minimized bar, tab-shaped.
     Geometry (40px height, 8px top radius, 4px top padding, 150px
     min-width, dock shadow) mirrors ui.css .td-tabstrip exactly. */
  #trydock-strip {
    position: fixed;
    left: 12px;
    bottom: 42px;
    z-index: 9999;
    display: flex;
    align-items: flex-end;
    /* Same 12px between tabs as the bundle's .td-tabstrip — the
       handover must be invisible. */
    gap: 12px;
    font-family: "Fira Mono", ui-monospace, SFMono-Regular, Menlo,
      Consolas, monospace;
  }

  #trydock-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    height: 40px;
    min-width: 150px;
    padding: 0 20px;
    border: 3px solid #ffffff;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    /* The brand lime (logo / docs header), dark ink — matches the
       bundle's #td-brand (--td-brand) exactly for the handover. */
    background: #8fc225;
    color: #333333;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    box-shadow: 0 -3px 8px rgba(0, 0, 0, 0.15);
    transition: filter 0.15s ease;
  }

  #trydock-pill:hover { filter: brightness(1.08); }

  #trydock-pill.trydock-loading {
    opacity: 0.6;
    pointer-events: none;
  }

  [data-theme="dark"] #trydock-pill {
    /* The dark logo's nighttime green — the pill hands over to the
       bundle's --td-brand, which recolors the same way. */
    background: #7ab545;
    color: #333333;
    box-shadow: 0 -3px 8px rgba(0, 0, 0, 0.35);
  }
}

/* Mobile (at or below 520px — the `.. vcd::` waveform viewer's mobile
   breakpoint): the compact, read-only Try panel's pre-bundle face.
   No minimized bar and no icon cluster here — the full-width green
   "Try Virdant" tab is the whole open affordance; the open panel's
   own close bar is the close half of the pair (both styled by the
   bundle's ui.css once it loads). */
@media (max-width: 520px) {
  /* The band (and the page space it reserves) exists ONLY on pages
     that pin an example with `.. project::` — trydock-boot.js builds
     the strip just there, and this :has() gate reserves the matching
     42px just there too.  Everywhere else the page keeps the full
     viewport; when the panel opens on such a page (a goto button),
     the bundle's syncPageScroller does the handover itself.

     Same page-scroller handover as the desktop block above: the
     scrollbar stops at the band's top edge, so it never hides the
     page's last line. */
  body:has([data-virdant-page-project]) .wy-grid-for-nav {
    height: calc(100% - 42px);
    overflow-y: auto;
    overflow-x: hidden;
  }
  body:has([data-virdant-page-project]) .wy-side-scroll {
    height: calc(100% - 82px);
  }
  body:has([data-virdant-page-project]) .wy-nav-side {
    padding-bottom: 0;
    height: calc(100% - 42px);
    min-height: 0;
    bottom: auto;
  }

  /* The stand-in strip: a full-width band along the viewport's bottom
     edge — a thumb-sized open button, not a corner tab.  The bundle's
     .trydock-root.trydock-mobile .td-tabstrip rules take over
     identical geometry once it loads. */
  #trydock-strip {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    display: flex;
    align-items: flex-end;
    padding: 0 8px;
    font-family: "Fira Mono", ui-monospace, SFMono-Regular, Menlo,
      Consolas, monospace;
  }

  #trydock-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 100%;
    height: 42px;
    /* Same white rim as the bundle's mobile band (border-bottom off:
       flush with the viewport's bottom edge). */
    border: 3px solid #ffffff;
    border-bottom: none;
    border-radius: 0;
    /* The brand lime, dark ink — same surface as the bundle's
       #td-brand (--td-brand) for an invisible handover. */
    background: #8fc225;
    color: #333333;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    box-shadow: 0 -3px 8px rgba(0, 0, 0, 0.15);
    transition: filter 0.15s ease;
  }

  #trydock-pill:hover { filter: brightness(1.08); }

  #trydock-pill.trydock-loading {
    opacity: 0.6;
    pointer-events: none;
  }

  [data-theme="dark"] #trydock-pill {
    /* The dark logo's nighttime green — same handover note as the
       desktop pill above. */
    background: #7ab545;
    color: #333333;
    box-shadow: 0 -3px 8px rgba(0, 0, 0, 0.35);
  }
}
