/* Funktioner: the tab bar as a ruled line the pen writes on. Without script none of this applies and the demos stack under the jump list. */
/* The fit rule (direction.css) scales each stage so that header + tab bar + figure fit one screen; the tab bar and its gaps (and on a phone what the demo bar takes besides the kit's one row) are --fit-up. */
/* One unit (README section 4): the head stands a sheet's paper above the group labels' cap height (64 px, 48 on a phone; direction.css), and inside the unit every
   box is 12 px from the next: the tab row (its 44 px tabs) to the demo bar's buttons, the buttons to the window (--bar-gap, direction.css). 8 px on a phone and a short screen. */
.showcase { --tabs-top: 4px; --accent-room: 8px; }   /* the bar's top, under the header; the strip scrolls, so it clips: room above the labels' cap height for Ä's dots (the head's margin counts both) */
.showcase-body {
  container: showcase demo / inline-size;
  position: relative;
  --tab-pad: 14px;           /* a tab's padding, each side: the strip reaches this far beyond the text's edge, so the first word stands on the edge */
  --pill-inset: 4px;         /* the highlight inside the tab's box: it reaches 10 px beyond the edge */
  --label-h: 18px;           /* from a group label's cap height to its tab's top: the label's box starts at its cap height (text-box), and its baseline is 7 px over the pill */
  --tabs-bar: calc(var(--label-h) + 44px);
  --tabs-gap: 12px;          /* between the tab row and the demo bar */
  --tabs-bar-phone: calc(var(--label-h) + 44px);
  --tabs-gap-phone: 8px;
}
@media (max-height: 800px) {   /* a short screen: 8 px inside the unit; on a desktop with a fine pointer, tabs of 36 px */
  .showcase-body { --tabs-gap: 8px; }
  @media (min-width: 900px) and (pointer: fine) { .showcase-body { --tabs-bar: calc(var(--label-h) + 36px); } .showcase-body .tab { min-height: 36px; } }
}
@media (max-height: 420px) {   /* the header scrolls away with the page here (direction.css) */
  .showcase { --tabs-top: 0px; }
  .showcase-body { --tabs-gap: 6px; --tabs-gap-phone: 6px; }
}

.tabs-bar { margin: var(--tabs-top) calc(var(--tab-pad) * -1) var(--tabs-gap); }   /* the strip starts a tab's padding left of the text's edge: the first word stands on it, its pill beyond it */
/* The groups (Skapa, Ändra, Variera) are small labels over their tabs: the heading names them in order, so they carry no numerals (the demo bar's numerals are the steps).
   The selected tab sits on one highlight that slides from tab to tab (showcase.js places it), with the header's curve; the pen keeps its tick for a demo that was seen. */
.tablist {
  --fade-w: 32px;   /* the edge fade where the strip scrolls */
  position: relative; isolation: isolate; display: flex; align-items: flex-end; column-gap: var(--s4); min-height: calc(var(--tabs-bar) + var(--accent-room)); padding: var(--accent-room) 0 0;
  overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; scroll-snap-type: x proximity;
}
.tablist::-webkit-scrollbar { display: none; }
@media (min-width: 900px) {   /* the row on the head's two columns: Skapa and Ändra under the h2's, Variera's word on the lede's column (8), the two gaps between the groups equal (README section 7) */
  .tablist {
    display: grid; grid-template-columns: max-content minmax(var(--s4), 1fr) max-content minmax(var(--s4), 1fr) calc((100% + var(--s3)) * 5 / 12 - var(--s3));
    column-gap: 0; padding-inline: var(--tab-pad);
  }
  .tab-group { margin-left: calc(var(--tab-pad) * -1); }
  .tab-group:nth-of-type(2) { grid-column: 3; }
  .tab-group:nth-of-type(3) { grid-column: 5; }
}
/* A bar that scrolls sideways shows a cut tab by a fade at that edge (showcase.js, fade(), names the side; none when all fits) */
.tablist[data-fade="end"] { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - var(--fade-w)), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - var(--fade-w)), transparent); }
.tablist[data-fade="start"] { -webkit-mask-image: linear-gradient(90deg, transparent, #000 var(--fade-w)); mask-image: linear-gradient(90deg, transparent, #000 var(--fade-w)); }
.tablist[data-fade="both"] { -webkit-mask-image: linear-gradient(90deg, transparent, #000 var(--fade-w), #000 calc(100% - var(--fade-w)), transparent); mask-image: linear-gradient(90deg, transparent, #000 var(--fade-w), #000 calc(100% - var(--fade-w)), transparent); }
.tab-group { position: relative; display: flex; flex: none; align-items: center; gap: 2px; padding-top: var(--label-h); }
.tab-group-name { position: absolute; top: 0; left: var(--tab-pad); color: var(--ink-2); font: italic 400 15px/1.2 var(--serif); white-space: nowrap; text-box: trim-start cap alphabetic; }   /* over the first tab's word; its box starts at its cap height, the tab row's top */
.tab {
  position: relative; flex: none; min-height: 44px; padding: 0 var(--tab-pad); scroll-snap-align: center; border: 0; border-radius: var(--radius-pill); background: none;
  color: var(--ink-2); font: 500 15px/1.2 var(--sans); white-space: nowrap; cursor: pointer; transition: color 0.2s ease;
  scroll-margin-top: calc(var(--tabs-top) - 16px);   /* focusing a tab must not scroll the page */
}
.tab:hover, .tab[aria-selected="true"] { color: var(--ink); }
.tab:focus-visible { outline-offset: -3px; }   /* inside the tab: the strip clips anything outside */
/* The highlight is drawn as the header's cell: 36 px high, centred in the 44 px tab, and --pill-inset narrower than the tab on each side, so it reaches 10 px beyond the
   text's edge (8 on a phone), half the paper beside the content, not the tab's whole 14 px padding */
.tab-glide {
  --pill-h: min(36px, var(--glide-h, 44px));
  position: absolute; z-index: -1; top: calc((var(--glide-h, 44px) - var(--pill-h)) / 2); left: var(--pill-inset); width: calc(var(--glide-w, 0px) - 2 * var(--pill-inset)); height: var(--pill-h); border-radius: var(--radius-pill); pointer-events: none;
  background: rgba(27, 32, 38, 0.06); box-shadow: inset 0 0 0 0.5px rgba(27, 32, 38, 0.05);
  transform: translate(var(--glide-x, 0px), var(--glide-y, 0px));
  transition: transform 0.42s var(--ease-glide), width 0.42s var(--ease-glide);
}
.tab-glide.is-placing { transition: none; }

@media (forced-colors: active) {
  .tab-glide { display: none; }
  .tab[aria-selected="true"] { outline: 2px solid Highlight; outline-offset: -2px; }
}

/* One panel at a time; its heading and lede stay for screen readers. A switch cross-fades: the old panel stays painted under the new one. */
.showcase-body[data-tabs-ready] > .showcase-item { position: relative; z-index: 1; margin: 0; padding: 0; border: 0; transition: opacity 0.2s ease-out; }
.showcase-body[data-tabs-ready] > .showcase-item[data-entering] { opacity: 0; transition: none; }
.showcase-body[data-tabs-ready] > .showcase-item[hidden][data-leaving] { display: block !important; position: absolute; z-index: 0; left: 0; right: 0; opacity: 1; transition: none; pointer-events: none; }
.showcase-body[data-tabs-ready] > .showcase-item[data-leaving] .dk-demo > :not(.dk-stage) { visibility: hidden; }   /* only the old window stays under the new one: its bar's words would show through the new bar's while that fades in */
.showcase-body[data-tabs-ready] .showcase-head {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

/* The tab bar in the fit rule's budget (direction.css); every demo has the same authored window height there (--fit-a), so the page below does not move when a tab changes */
.showcase-body[data-tabs-ready] .dk-demo {
  --tabs-above: calc(var(--tabs-top) + var(--accent-room) + var(--tabs-bar) + var(--tabs-gap));
  --fit-up: var(--tabs-above);
}

/* Nästa: the way forward, always in the bar. Quiet like the control (hairline, ink text), with the rest's pen line under it (autoplay.css). Where nothing moves on by itself
   (the demo is over and no rest runs: autoplay off after a visitor's choice, a held advance, reduced motion) it turns to ink, the one thing to do. */
.tabs-next {
  position: relative; display: inline-flex; align-items: center; min-height: var(--bar-row, 36px); padding: 0 16px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-ctl); background: none; color: var(--ink);
  font: 500 15px/1 var(--sans); white-space: nowrap; cursor: pointer; transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.tabs-next:hover { border-color: var(--ink-2); background: rgba(255, 255, 255, 0.55); }
.tabs-next:not([data-show]) { visibility: hidden; }   /* keeps its room, so nothing moves when it appears (the last tab has none) */
.dk-demo:is([data-dk-state="done"], [data-dk-state="static"]) > .tabs-next:not([data-resting]) { border-color: var(--btn); background: var(--btn); color: var(--btn-ink); }
.dk-demo:is([data-dk-state="done"], [data-dk-state="static"]) > .tabs-next:not([data-resting]):hover { border-color: var(--btn-hover); background: var(--btn-hover); }
.dk-demo:not(.dk-live) > .tabs-next { grid-column: 1 / -1; grid-row: auto; justify-self: end; margin-top: 14px; }   /* not live (reduced motion): after the captions */

/* A phone: one row of tabs that scrolls sideways above the stage; Nästa is on the demo bar's first line, so nothing sits under the window */
@container showcase (max-width: 760px) {
  .tabs-bar { margin: var(--tabs-top) calc(max(var(--gutter) - var(--sheet-min), var(--tab-pad)) * -1) var(--tabs-gap-phone); }   /* the strip runs to the sheet's edges, which are --sheet-min from the screen's in the phone layout (at 320 px, where the gutter is 16, 2 px past them, so the first word still stands on the edge) */
  .tablist { --fade-w: 56px; --pill-inset: 6px; --edge: max(0px, var(--gutter) - var(--sheet-min) - var(--tab-pad)); min-height: calc(var(--tabs-bar-phone) + var(--accent-room)); column-gap: var(--s3); padding: var(--accent-room) var(--edge) 0; scroll-padding-inline: var(--edge); }   /* the first tab's word stands on the content's edge */
  .showcase-body[data-tabs-ready] .dk-demo {
    --tabs-above: calc(var(--tabs-top) + var(--accent-room) + var(--tabs-bar-phone) + var(--tabs-gap-phone));
    --fit-up: calc(var(--tabs-above) + var(--bar-extra));   /* --bar-extra (direction.css): what the two-line bar takes besides the kit's one row */
  }
  .tabs-next { min-height: 44px; }
}
@container showcase (max-width: 599.98px) {   /* in the bar Nästa is the one word; the tab's name is in its aria-label (listed under the window, in reduced motion, it has room for both) */
  .dk-live > .tabs-next { padding: 0 12px; }
  .dk-live > .tabs-next .tabs-next-name { display: none; }
}

/* The captions of the seven demos differ in length, so the bar's caption row is two lines high wherever a caption can wrap (the longest is 58 characters, about 400 px
   at 15 px): the stage's top is the same in every tab. One line is enough from a bar 481 px wide to 760 and from 941 px (README section 7).
   Upgrade trigger: a caption longer than 58 characters. The gate's `tab-stage-stable` measures 1440, 390 and 360 px; measure 320 to 480 and 761 to 940 by hand. */
@container showcase (max-width: 480px) { .showcase-body[data-tabs-ready] .dk-demo.dk-live > .dk-steps { min-height: calc(15px * 1.45 * 2); } }
/* A two-line caption (761 to 940 px): the control and numerals stand at the row's top and the caption's first line is moved onto their line with `top`; the caption's room is that much taller, so its second line stays inside the bar and the bar's gap to the window is the unit's 12 or 8 px (README section 7) */
@container showcase (min-width: 761px) and (max-width: 940px) {
  .showcase-body[data-tabs-ready] .dk-demo.dk-live { align-items: start; }
  .showcase-body[data-tabs-ready] .dk-demo.dk-live > .dk-control { align-self: start; }   /* the kit centres it */
  .showcase-body[data-tabs-ready] .dk-demo.dk-live > .dk-steps { min-height: calc(15px * 1.45 * 2 + (var(--bar-row) - 15px * 1.45) / 2); align-self: start; }
  .showcase-body[data-tabs-ready] .dk-demo.dk-live > .dk-steps > li { top: calc((var(--bar-row) - 15px * 1.45) / 2); }
  .showcase-body[data-tabs-ready] .dk-demo.dk-live > .dk-marks { margin-top: calc((var(--bar-row) - 28px) / 2); }
}
