/* =========================================================================
   Data type tabs
   The tabs on the data types landing page: a tab for each data type, and a
   panel with its name, its animation, and its text. The animation's own
   styles are in data-type-animation.css.

   The shortcode writes the sections one after the other, each under its
   heading, and that is how they show on a page with no script. A line of
   script in the page adds `is-tabbed` before anything is painted, and the
   rules for tabs all hang on that class.

   In a narrow column the tabs are rows of pills above the panel. In a
   column with room for it, they are a list down the side, in one frame
   with the panel.
   ========================================================================= */

.dtt {
  --dtt-ink: #091a23;
  --dtt-text: #163341;
  --dtt-row: #2d4754;
  --dtt-muted: #5c707a;
  --dtt-line: #b9c2c6;
  --dtt-line-soft: #e8ebec;
  --dtt-tree: #c3ccd1;
  --dtt-wash: #f9f9f9;
  --dtt-hover: #e9edef;
  position: relative;
  container-type: inline-size;
  margin: 1.5rem 0;
}
.dtt:not(.is-tabbed) .dtt-pick, .dtt:not(.is-tabbed) .dta, .dtt-name { display: none; }

/* ---- tabs, in a narrow column: rows of pills ---- */
/* The data types wrap over as many rows as they need. A data type that belongs under another one, such
   as bitfields under strings, goes in a row of its own below them. It shows only while the tab above
   it, or a tab next to it, is the one on show. That row keeps its height when it is empty, so the
   animation doesn't move as the reader goes from tab to tab. */
.dtt-tabs { display: flex; flex-wrap: wrap; column-gap: 8px; margin: 0 0 8px; }
.dtt-tabs::before { content: ""; order: 1; flex: 0 0 100%; height: 0; }                              /* ends the rows of top-level tabs */
.dtt-tabs::after { content: ""; order: 2; width: 0; height: 28px; margin: 0 0 6px -8px; }            /* holds the lower row open */
.dtt-tab {
  appearance: none; margin: 0 0 8px; padding: 5px 13px;
  border: 1px solid var(--dtt-line); border-radius: 999px; background: #fff; color: var(--dtt-text);
  font-family: inherit; font-size: 14px; line-height: 20px; font-weight: 500; white-space: nowrap; cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s;
}
.dtt-tab:hover { border-color: var(--dtt-muted); background: var(--dtt-wash); }
.dtt-tab[aria-selected="true"] { border-color: var(--dtt-ink); background: var(--dtt-ink); color: #fff; }
.dtt-tab:focus-visible { outline: 2px solid #5961ff; outline-offset: 2px; }
/* A tab with others under it has a small chevron. While one of those is on show, it is outlined. */
.dtt-tab[data-kids]::after {
  content: ""; display: inline-block; width: 6px; height: 6px; margin: 0 1px 3px 8px;
  border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); opacity: .7;
}
.dtt-tab.has-on { border-color: var(--dtt-ink); box-shadow: inset 0 0 0 1px var(--dtt-ink); color: var(--dtt-ink); }
.dtt-tab.is-sub { order: 2; display: none; margin-bottom: 6px; padding: 3px 9px; font-size: 13px; }
.dtt-tab.is-sub.is-open { display: block; }
.dtt-tab.is-first { position: relative; margin-left: 22px; }
.dtt-tab.is-first::before {   /* an arrow from the tab above to the first one under it */
  content: "\21B3"; position: absolute; left: -22px; top: 50%; transform: translateY(-50%);
  color: var(--dtt-muted); font-size: 15px; line-height: 1; font-weight: 400;
}

/* ---- panels ---- */
/* A panel that isn't on show keeps its width, so its animation is laid out and ready, but has no height.
   The animation inside stops by itself, as it does when it is scrolled out of view. */
.dtt.is-tabbed .dtt-panel { visibility: hidden; height: 0; overflow: hidden; }
.dtt.is-tabbed .dtt-panel.is-on { visibility: visible; height: auto; overflow: visible; }
/* The tab names the panel, so its heading isn't shown. The heading keeps the section's ID and sits at the
   top of the tabs, which is where a link to that ID should land. That is also why the title a reader
   sees in the panel is a separate element, .dtt-name: a heading down inside the panel would put the
   top of the tabs under the page's fixed header. */
.dtt.is-tabbed .dtt-title { position: absolute; left: 0; top: 0; width: 1px; height: 1px; margin: 0; overflow: hidden; visibility: hidden; scroll-margin-top: 6rem; }
.dtt .dta { margin: 0 0 18px; }
.dtt-text > :first-child { margin-top: 0; }
.dtt-text > :last-child { margin-bottom: 0; }

/* ---- tabs, in a column with room for it: a list down the side ---- */
/* The list and the panel share one frame, and the list is a grey column in it. Every data type is on
   show, with a line from each nested one to the tab it belongs under. */
@container (min-width: 561px) {
  .dtt.is-tabbed .dtt-body {
    display: grid; grid-template-columns: 210px minmax(0, 1fr); align-items: stretch;
    border: 1px solid var(--dtt-line); border-radius: 12px; overflow: hidden; background: #fff;
  }
  .dtt-pick { border-right: 1px solid var(--dtt-line-soft); background: var(--dtt-wash); }
  .dtt-pick .dtt-tabs { flex-direction: column; flex-wrap: nowrap; row-gap: 2px; margin: 0; padding: 10px 8px; }
  .dtt-pick .dtt-tabs::before, .dtt-pick .dtt-tabs::after, .dtt-pick .dtt-tab[data-kids]::after { display: none; }
  .dtt-pick .dtt-tab {
    order: 0; display: block; margin: 0; padding: 4px 10px; border: 0; border-radius: 8px; box-shadow: none;
    background: none; color: var(--dtt-row); text-align: left; font-size: 14px; font-weight: 400;
  }
  .dtt-pick .dtt-tab:hover { background: var(--dtt-hover); color: var(--dtt-ink); }
  .dtt-pick .dtt-tab.has-on { color: var(--dtt-ink); font-weight: 500; }
  .dtt-pick .dtt-tab[aria-selected="true"] { background: var(--dtt-ink); color: #fff; font-weight: 500; }
  .dtt-pick .dtt-tab:focus-visible { outline-offset: -2px; }
  .dtt-pick .dtt-tab.is-sub { position: relative; margin-left: 24px; }
  .dtt-pick .dtt-tab.is-sub::before {   /* a line from the row above down to this one, then across to it */
    content: ""; display: block; position: absolute; left: -12px; top: calc(-50% - 2px); bottom: 50%; width: 8px;
    border: solid var(--dtt-tree); border-width: 0 0 1.5px 1.5px; border-bottom-left-radius: 6px; transform: none;
  }
  .dtt-pick .dtt-tab.is-first::before { top: -1px; }   /* the first starts just under the tab it belongs to */
  .dtt.is-tabbed .dtt-panels { padding: 16px 18px 18px; }
  .dtt.is-tabbed .dtt-name { display: block; margin: 0 0 12px; font-size: 24px; line-height: 32px; font-weight: 600; color: var(--dtt-ink); }
}

/* ---- print: every section under its heading, as on a page with no script ---- */
@media print {
  .dtt .dtt-pick, .dtt .dta, .dtt.is-tabbed .dtt-name { display: none; }
  .dtt.is-tabbed .dtt-body { display: block; border: 0; border-radius: 0; overflow: visible; }
  .dtt.is-tabbed .dtt-panels { padding: 0; }
  .dtt.is-tabbed .dtt-panel { visibility: visible; height: auto; overflow: visible; }
  .dtt.is-tabbed .dtt-title { position: static; width: auto; height: auto; margin: 1.6em 0 .6em; overflow: visible; visibility: visible; }
}
