/* Preserve Chirpy's columns and navigation; add only filters and article previews. */
.lab-blog [hidden] {
  display: none !important;
}
/* Mobile: the sidebar (and its author card) is hidden behind the menu, so show a byline. */
.lab-author-mobile { display: none; }
@media (max-width: 849.98px) {
  .lab-author-mobile {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 18px;
    padding: 8px 12px 8px 8px;
    border: 1px solid var(--main-border-color);
    border-radius: 999px;
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 13px;
    text-decoration: none;
  }
  .lab-author-mobile strong { color: var(--heading-color); }
  .lab-author-photo {
    flex: 0 0 34px;
    height: 34px;
    border-radius: 50%;
    background: center 20% / cover no-repeat;
    box-shadow: 0 0 0 2px var(--lab-accent);
  }
  .lab-author-arrow { margin-left: auto; color: var(--lab-accent); }
}
/* Toolbar: post count left, search right. */
.lab-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}
.lab-blog .lab-toolbar .results-count { margin: 0; }
.lab-toolbar .lab-search { flex: 0 1 260px; }
/* Right panel topics (xl): stacked list above Recently Updated. */
@media (min-width: 1200px) {
  #panel-wrapper:has(.lab-panel-topics) { display: flex; flex-direction: column; }
  #panel-wrapper:has(.lab-panel-topics) .access { margin-top: 3rem; }
  .lab-panel-topics { order: -1; margin-top: 3rem; padding-left: 1rem; border-left: 1px solid var(--main-border-color); }
}
.lab-panel-topics .topic-filters { flex-direction: column; gap: 6px; padding-right: 1rem; }
.lab-panel-topics .topic-filter { width: 100%; font-size: 13px; padding: 7px 10px; }
.lab-panel-topics .topic-filter > [data-topic-count] { margin-left: auto; }
.lab-panel-topics .topic-filter img { width: 20px; height: 20px; object-fit: contain; }
.lab-panel-topics .topic-filter img[src$='.png'] { transform: scale(1.8); }
.lab-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.lab-view-filters { display:flex; flex-wrap:wrap; gap:8px; width:100%; }
.lab-view-help { width:100%; margin:0 0 4px; color:var(--text-muted-color); font-size:13px; line-height:1.6; }
.lab-series-count { color:var(--lab-accent); font-size:13px; margin:0 0 16px; }
.lab-parent-context { padding:12px 20px; border-bottom:1px solid var(--main-border-color); color:var(--text-muted-color); font-size:12px; background:var(--card-header-bg); }
.lab-parent-context a { color:var(--link-color); }
#post-list[data-view='recent'] .pin { display:none; }
.topic-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.topic-filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  border: 1px solid var(--main-border-color);
  border-radius: 6px;
  background: transparent;
  color: var(--text-color);
  font-size: 13px;
  line-height: 1.4;
  transition:
    border-color 0.18s,
    background-color 0.18s;
}
.lab-blog .topic-filter > .preview-img {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  margin: 0;
  border-radius: 0;
  background: transparent;
  overflow: visible;
}
.lab-blog .topic-filter > .preview-img::before {
  display: none;
}
.lab-blog .topic-filter img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  border-radius: 0;
}
.topic-filter img[src$='.png'] {
  transform: scale(1.8);
}
.topic-filter > [data-topic-count] {
  color: var(--text-muted-color);
  font-size: 11px;
}
.topic-filter.active {
  background: var(--lab-selected);
  border-color: var(--lab-accent);
  color: var(--lab-accent);
}
.topic-filter:not(:disabled):hover {
  border-color: var(--lab-accent);
}
.topic-filter:disabled {
  color: var(--text-muted-color);
  border-color: var(--main-border-color);
  cursor: default;
}
.topic-filter:disabled > [data-topic-count] {
  font-size: 10px;
  padding: 2px 4px;
  background: var(--lab-selected);
  border-radius: 3px;
}
.lab-search {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 1;
  min-width: 150px;
  max-width: 230px;
  padding: 8px 11px;
  border: 1px solid var(--main-border-color);
  border-radius: 6px;
  color: var(--text-muted-color);
  font-size: 12px;
}
.lab-search:focus-within {
  border-color: var(--lab-accent);
}
.lab-search input {
  width: 100%;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--heading-color);
  font: inherit;
}
/* iOS Safari zooms into inputs below 16px on focus and stays zoomed in. */
@media (pointer: coarse) {
  .lab-search input { font-size: 16px; }
}
.lab-search input::placeholder {
  color: var(--text-muted-color);
}
.lab-blog .results-count {
  color: var(--text-muted-color);
  font-size: 12px;
  margin: 0 0 16px;
}
#post-list .lab-post-preview {
  display: flex;
  align-items: stretch;
}
#post-list .lab-post-preview .card-body {
  width: 60%;
  flex: 1;
  min-width: 0;
}
#post-list .lab-post-preview .card-title {
  font-size: 1.25rem;
}
#post-list .lab-post-preview .post-meta {
  font-size: 12px;
}
#post-list .lab-preview-media {
  width: 40%;
  flex-shrink: 0;
  min-height: 225px;
  border-left: 1px solid var(--main-border-color);
  overflow: hidden;
  position: relative;
}
.lab-map-preview {
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
}
.preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  padding: 10px;
  color: var(--lab-toolbar-text);
  font:
    9px ui-monospace,
    Consolas,
    monospace;
  border-bottom: 1px solid var(--main-border-color);
  background: var(--lab-toolbar-bg);
}
.preview-toolbar > span:first-child {
  display: flex;
  gap: 4px;
}
.preview-toolbar i,
.terminal-bar i {
  display: block;
  width: 4px;
  height: 4px;
  background: var(--text-muted-color);
  border-radius: 50%;
}
.preview-toolbar i:first-child {
  background: var(--lab-accent);
}
.flow-preview {
  flex: 1;
  position: relative;
  min-height: 190px;
}
#post-list .flow-preview > .preview-img {
  position: absolute;
  inset: 0;
  margin: 0;
  border-radius: 0;
}
#post-list .flow-preview img {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 12%;
  border-radius: 0;
  opacity: 0.9;
  transition: transform 0.25s;
}
.flow-preview::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(transparent 35%, var(--lab-fade));
}
.preview-open {
  position: absolute;
  bottom: 14px;
  left: 10px;
  right: 10px;
  z-index: 1;
  border: 1px solid var(--main-border-color);
  border-radius: 5px;
  padding: 8px;
  text-align: center;
  color: var(--text-color);
  background: var(--card-bg);
  font-size: 11px;
  line-height: 1.4;
}
.preview-open span {
  margin-left: 3px;
  color: var(--lab-accent);
}
.lab-post-preview:hover .flow-preview img {
  transform: scale(1.025);
}
.lab-terminal-preview {
  background:
    var(--lab-visual);
}
.visual-label {
  display: block;
  margin: 19px 15px 0;
  font:
    9px ui-monospace,
    Consolas,
    monospace;
  color: var(--lab-accent);
  letter-spacing: 0.05em;
}
.terminal {
  position: absolute;
  left: 7%;
  right: 7%;
  top: 51px;
  background: var(--lab-terminal-bg);
  border: 1px solid var(--main-border-color);
  border-radius: 6px;
  transform: rotate(-2deg);
  box-shadow: 0 10px 25px #00000025;
  font:
    10px ui-monospace,
    Consolas,
    monospace;
  padding-bottom: 10px;
}
.terminal-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 9px;
  border-bottom: 1px solid var(--main-border-color);
  color: var(--lab-terminal-text);
}
.terminal-bar > span {
  margin-left: 5px;
  font-size: 8px;
}
.terminal-bar i:first-child {
  background: var(--lab-terminal-accent);
}
.lab-blog .terminal p {
  margin: 0;
  padding: 9px 9px 0;
  color: var(--lab-terminal-text);
  font-size: 9px;
  line-height: 1.4;
}
.terminal p b {
  color: var(--lab-terminal-accent);
  margin-right: 3px;
  font-weight: 400;
}
.terminal-prompt {
  padding: 12px 9px 0;
  color: var(--lab-terminal-accent);
  font-size: 9px;
}
.lab-empty {
  padding: 25px;
  border: 1px dashed var(--main-border-color);
  border-radius: 8px;
  text-align: center;
  background: var(--card-bg);
}
.lab-empty button {
  background: var(--lab-selected);
  color: var(--lab-accent);
  border: 1px solid var(--lab-accent);
  border-radius: 5px;
  padding: 8px 14px;
}
@media (max-width: 767px) {
  #post-list .lab-post-preview {
    flex-direction: column-reverse;
  }
  #post-list .lab-post-preview .card-body {
    width: 100%;
  }
  #post-list .lab-preview-media {
    width: 100%;
    min-height: 200px;
    border-left: 0;
    border-bottom: 1px solid var(--main-border-color);
  }
  .flow-preview {
    min-height: 170px;
  }
  .terminal {
    left: 9%;
    right: 9%;
    top: 42px;
  }
  .lab-search {
    max-width: none;
  }
  .topic-filters {
    width: 100%;
  }
}
@media (max-width: 420px) {
  .topic-filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .topic-filter {
    font-size: 12px;
    padding: 8px;
  }
  .topic-filter > [data-topic-count] {
    margin-left: auto;
  }
}
@media (prefers-reduced-motion: reduce) {
  .lab-blog *,
  .lab-blog *::after {
    transition: none !important;
  }
  .lab-post-preview:hover .flow-preview img {
    transform: none;
  }
}
/* Bootstrap utilities used in home.html. The production build ships a purged Bootstrap without them
   (development loads the full Bootstrap from the CDN), so they are defined here to match both. */
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
@media (min-width: 1200px) {
  .d-xl-none {
    display: none !important;
  }
}
/* Phones: one compact, sticky filter row (product logos + filter field) instead of three rows of buttons,
   and the blog views as light tabs. Tablets and desktop keep the layout above. */
.lab-filter-bar { display: contents; }
@media (max-width: 767.98px) {
  /* A sticky element only sticks within its parent, so lift the filter controls into .lab-blog,
     which spans the whole post list. ([hidden] still hides them until the script runs.) */
  .lab-filters { display: contents; }
  /* Card details (gold top edge, "Explore" pill) use z-index; keep them inside the list so they pass under the bar. */
  #post-list { isolation: isolate; }
  .lab-view-filters {
    gap: 20px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--main-border-color);
  }
  .lab-view-help { margin-bottom: 12px; }
  .lab-view-filters .topic-filter {
    min-height: 44px;
    margin-bottom: -1px;
    padding: 0 2px;
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    background: none;
  }
  .lab-view-filters .topic-filter.active {
    border-bottom-color: var(--lab-accent);
    background: none;
    font-weight: 600;
  }
  .lab-filter-bar {
    position: sticky;
    top: 3rem; /* below the sticky top bar (Chirpy's $topbar-height) */
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    width: calc(100% + var(--bs-gutter-x, 1.5rem));
    /* Full-bleed background, content still on the column's gutter. */
    margin: 0 calc(var(--bs-gutter-x, 1.5rem) * -0.5) 16px;
    padding: 8px calc(var(--bs-gutter-x, 1.5rem) * 0.5);
    border-bottom: 1px solid var(--main-border-color);
    background: var(--topbar-bg);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
  }
  .lab-filter-bar .topic-filters {
    display: flex;
    flex: 0 0 auto;
    flex-wrap: nowrap;
    gap: 6px;
    width: auto;
  }
  .lab-filter-bar .topic-filter {
    justify-content: center;
    min-width: 44px;
    height: 44px;
    padding: 0 10px;
    font-size: 13px;
  }
  /* Logos only; the product name stays in the accessible name (and the title tooltip). */
  .lab-filter-bar .topic-name:not(.topic-name-all) {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }
  .lab-filter-bar .topic-filter > [data-topic-count] { display: none; }
  .lab-filter-bar .lab-toolbar { flex: 1 1 auto; min-width: 0; width: auto; }
  .lab-filter-bar .lab-search { flex: 1 1 auto; min-width: 0; max-width: none; height: 44px; }
  /* The count is still announced to screen readers (aria-live), the cards below show the result. */
  .lab-filter-bar .results-count {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }
}
/* Phones: calmer cards. Preview visuals become a slim strip above the text (they were ~200px, as tall as the text),
   and the byline is a single quiet line instead of a bordered pill. */
@media (max-width: 767.98px) {
  .lab-author-mobile {
    gap: 8px;
    margin: 0 0 14px;
    padding: 4px 0;
    min-height: 36px;
    border: 0;
    border-radius: 0;
    background: none;
    font-size: 12.5px;
  }
  .lab-author-photo {
    flex: 0 0 26px;
    height: 26px;
    box-shadow: 0 0 0 1.5px var(--lab-accent);
  }
  #post-list .lab-post-preview .card-title { font-size: 1.15rem; }
  #post-list .lab-preview-media { height: 104px; min-height: 0; }
  .flow-preview { min-height: 0; }
  .preview-toolbar { padding: 7px 10px; }
  .lab-map-preview .preview-open { display: none; }
  .visual-label { margin: 10px 14px 0; }
  .terminal { top: 28px; }
  /* Show the terminal's title bar and first line only, rather than cutting it off mid-line. */
  .terminal p ~ p,
  .terminal-prompt { display: none; }
}
/* Phones: a little air between the blue top bar and the (also blue) banner. */
@media (max-width: 849.98px) {
  .lab-blog > .vault-banner,
  .lab-blog > .pipboy-banner { margin-top: 12px; }
}
/* Phones: the banner runs edge to edge, straight under the top bar's gold rule, as one hero block. */
@media (max-width: 767.98px) {
  .lab-blog > .vault-banner,
  .lab-blog > .pipboy-banner {
    margin-top: 0;
    margin-left: calc(var(--bs-gutter-x, 1.5rem) * -0.5);
    margin-right: calc(var(--bs-gutter-x, 1.5rem) * -0.5);
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }
}
/* Blog views and byline share one row below 850px; on wider screens the byline is the sidebar's author card. */
.lab-view-row { margin-bottom: 12px; } /* keeps the gap the views had before the help text */
@media (max-width: 849.98px) {
  .lab-view-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }
  .lab-view-row .lab-view-filters { flex: 0 1 auto; width: auto; }
  /* The byline keeps its natural width: as a shrinkable flex item with an ellipsis, Safari cut it to
     "By Redouan…" although it fits. Below 360px only the photo shows (see further down). */
  .lab-view-row .lab-author-mobile { flex: 0 0 auto; margin: 0; }
  .lab-author-name { white-space: nowrap; }
}
/* Phones: the row is the tab strip (one underline across it); the byline is photo + name only. */
@media (max-width: 767.98px) {
  .lab-view-row {
    gap: 10px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--main-border-color);
  }
  .lab-view-row .lab-view-filters {
    flex-wrap: nowrap;
    gap: 16px;
    margin-bottom: 0;
    border-bottom: 0;
  }
  .lab-view-row .lab-view-filters .topic-filter { white-space: nowrap; }
  .lab-view-row .lab-author-mobile {
    gap: 6px;
    min-height: 44px;
    padding: 0;
    font-size: 12px;
  }
  .lab-author-role,
  .lab-view-row .lab-author-arrow { display: none; }
  .lab-view-row .lab-author-photo { flex-basis: 24px; height: 24px; }
}
/* Phones, full-width banner: Vault Boy is shown whole. The art panel takes the image's own proportions
   (744x540), so it fills the panel exactly with nothing cropped or letterboxed, and sets the banner's height.
   The heading drops its fixed line break and balances over three lines in the space beside him, sized to the
   screen so the longest line ("your tenant.", about 6.6x the font size) always fits. */
@media (max-width: 767.98px) {
  :root[data-bs-theme='light'] .lab-blog > .vault-banner { grid-template-columns: 48% minmax(0, 1fr); min-height: 0; }
  .lab-blog .vault-boy-art { aspect-ratio: 744 / 540; background-size: cover; background-position: center; }
  .lab-blog .vault-banner-copy { padding: 12px 14px 12px 16px; }
  .lab-blog .vault-banner h2 {
    font-size: min(28px, calc((52vw - 30px) / 6.6));
    line-height: 1.12;
    text-wrap: balance;
  }
  .lab-blog .vault-banner h2 br { display: none; }
}
/* Phones: the byline is always one line, "By Redouan Bulaid", and drops only "Bulaid" when the room beside the
   views is too narrow. The row is a grid whose second column is whatever is left beside the views; the byline fills
   it and lays its parts out as a right-aligned wrapping row that is one line tall, so a part that does not fit moves
   to a hidden second line instead of being cut off. This uses the real leftover width, not the text's measured
   width, which Safari got wrong (the name ran off the screen). Screen readers still get the full name. */
@media (max-width: 767.98px) {
  .lab-view-row {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    align-items: center;
  }
  .lab-view-row .lab-author-mobile {
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    align-content: flex-start;
    column-gap: 0;
    min-width: 0;
    height: 32px; /* the 26px photo plus room for its 1.5px ring, which the clip would otherwise cut */
    min-height: 0;
    overflow: hidden;
    line-height: 32px;
  }
  .lab-view-row .lab-author-name { display: contents; }
  .lab-view-row .lab-author-first,
  .lab-view-row .lab-author-last { white-space: nowrap; }
  .lab-view-row .lab-author-photo { flex: 0 0 26px; height: 26px; margin-right: 6px; }
  .lab-view-row .lab-author-last { margin-left: 0.25em; } /* an ordinary word space */
}
