/*
 * This data is highly confidential and entirely the personal creation and property of
 * Vlad Tanasescu, born 5th of December 1996 in Bucharest, Romania. This document,
 * information, concepts, and all the code are confidential, proprietary IP, and may not
 * be copied, distributed, or used.
 */

.library-category-bar,
.engineering-library-section {
  --engineering-bg: var(--paper, #e8eae0);
  --engineering-surface: var(--raised, #f2f4ec);
  --engineering-line: rgba(22, 24, 28, .12);
  --engineering-line-strong: rgba(22, 24, 28, .24);
  --engineering-text: #16181c;
  --engineering-muted: #565d65;
  --engineering-blue: #1a7a9a;
  box-sizing: border-box;
  color-scheme: light;
}

.library-category-bar *,
.engineering-library-section * {
  box-sizing: border-box;
}

.library-category-bar {
  position: relative;
  z-index: 20;
  margin-top: 34px;
  padding: 27px 24px 0;
  border-bottom: 1px solid var(--engineering-line);
  background: var(--engineering-bg);
}

.library-category-inner {
  display: flex;
  width: min(1460px, 100%);
  margin: 0 auto;
  gap: 16px;
}

.library-category-tabs {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  gap: clamp(24px, 6vw, 76px);
  overflow-x: auto;
  scrollbar-width: none;
}

.library-category-tabs::-webkit-scrollbar {
  display: none;
}

.library-category-tabs button {
  position: relative;
  flex: 0 0 auto;
  min-height: 58px;
  padding: 0 0 18px;
  border: 0;
  background: transparent;
  color: rgba(22, 24, 28, .64);           /* 4.9:1 on paper: the tabs drop below 18.66px bold on phones (was .56, 3.9) */
  cursor: pointer;
  font: inherit;
  font-size: clamp(15px, 1.7vw, 20px);
  font-weight: 720;
  letter-spacing: -.02em;
  white-space: nowrap;
  transition: color .18s ease;
}

.library-category-tabs button:hover,
.library-category-tabs button:focus-visible,
.library-category-tabs button.is-active {
  color: var(--engineering-text);
}

.library-category-tabs button::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--engineering-blue);
  content: "";
  opacity: 0;
  transform: scaleX(.35);
  transition: opacity .18s ease, transform .18s ease;
}

.library-category-tabs button.is-active::after {
  opacity: 1;
  transform: scaleX(1);
}

.library-category-tabs button:focus-visible,
.engineering-library-section button:focus-visible,
.engineering-library-section a:focus-visible {
  outline: 2px solid var(--engineering-blue);
  outline-offset: 3px;
}

/* A filtered deep link (?category=, #everyday-things, …): library.html's head marks the page before
   first paint, so the "All" grid the cards arrive in stays invisible until the script shows the
   category (engineering-library.js setLibraryFilter clears the mark). Should the script never get
   there, the grid shows again after 3 s, so no visitor is left without the cards. */
:root[data-library-boot="filtered"] #all-products {
  visibility: hidden;
  animation: library-boot-reveal 0s 3s forwards;
}

@keyframes library-boot-reveal {
  to { visibility: visible; }
}

.library-filtered-section[hidden] {
  display: none !important;
}

.engineering-library-section {
  position: relative;
  padding: 28px 0 48px;
  overflow: clip;
  background: var(--engineering-bg);
  color: var(--engineering-text);
}

.engineering-library-section--ambitious,
.engineering-library-section--experiment {
  padding-bottom: 72px;
  border-top: 1px solid var(--engineering-line);
}

.engineering-library-shell {
  width: min(1460px, calc(100% - 48px));
  margin: 0 auto;
}

.engineering-product-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  align-items: stretch;
  gap: 22px;
}

/* A category grid is empty until the script moves its cards in from the "All" grid: it holds a
   screen of space meanwhile, so the footer never moves up into view and back down (the twin rule
   for the sculpt grid is in organic-sculpts.css). */
.engineering-product-grid:empty {
  min-height: 100vh;
}

.engineering-product-card {
  display: flex;
  height: 100%;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--engineering-line);
  border-radius: 20px;
  background: var(--engineering-surface);
  box-shadow: 0 8px 28px rgba(22, 24, 28, .055);
  transition: transform .22s ease, border-color .22s ease, box-shadow .22s ease;
}

/* A product's anchor (/library#<id>, generated by scripts/library/build-library-page.mjs) lands
   below the sticky nav, the sculpt cards included. */
.engineering-product-card,
.organic-sculpt-library .product-card {
  scroll-margin-top: calc(var(--nav-h, 72px) + 16px);
}

.engineering-product-card:hover {
  z-index: 2;
  border-color: var(--engineering-line-strong);
  transform: translateY(-4px);
  box-shadow: 0 22px 52px rgba(22, 24, 28, .13);
}

.engineering-card-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 11;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 38%, rgba(255, 255, 255, .92), transparent 48%),
    #eef0f5;
  isolation: isolate;
}

.engineering-card-three,
.engineering-card-render {
  position: absolute;
  inset: 0;
}

/* The render shows until the card is live (on screen, hovered, keyboard-focused or fullscreen) and
   its viewer has drawn its first frame (engineering-library.js goLive). Hidden, not only transparent, the rest
   of the time, so its focusable canvas never takes keyboard focus while the render is showing. */
.engineering-card-three {
  z-index: 2;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 38%, rgba(255, 255, 255, .92), transparent 48%),
    #eef0f5;
  transition: opacity .16s ease, visibility 0s linear .16s;
}

.engineering-card-stage.is-live.is-ready .engineering-card-three {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}

.engineering-card-three forge-viewer {
  width: 100%;
  height: 100%;
  background: #eef0f5;
  cursor: grab;
}

.engineering-card-three forge-viewer:active {
  cursor: grabbing;
}

.engineering-card-render {
  z-index: 1;
  display: block;
  background: #eef0f5;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  opacity: 1;
  transition: opacity .16s ease;
}

.engineering-card-stage.is-live.is-ready .engineering-card-render {
  opacity: 0;
  pointer-events: none;
}

.engineering-card-render img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
  transform: scale(var(--poster-scale, 1));
  transform-origin: center;
}

.engineering-card-render img.is-retrying,
.engineering-card-render img.is-unavailable {
  opacity: 0;
}

.engineering-card-toolbar {
  position: absolute;
  bottom: 12px;
  z-index: 8;
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, .19);
  border-radius: 11px;
  background: rgba(15, 15, 17, .75);
  backdrop-filter: blur(12px);
}

.engineering-card-toolbar {
  right: 12px;
}

.engineering-card-toolbar button {
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, .70);
  cursor: pointer;
  font: inherit;
  font-size: 10px;
  font-weight: 780;
}

.engineering-card-toolbar button {
  width: 32px;
  padding: 0;
  font-size: 15px;
}

.engineering-card-toolbar button[data-pinned="true"] {
  background: rgba(84, 184, 220, .72);
  color: white;
}

.engineering-card-toolbar button:hover {
  background: rgba(255, 255, 255, .12);
  color: white;
}

.engineering-card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 23px 22px 20px;
}

.engineering-card-body h3 {
  display: -webkit-box;
  min-height: 50px;
  overflow: hidden;
  margin: 0;
  color: var(--engineering-text);
  font-size: 21px;
  line-height: 1.2;
  letter-spacing: -.025em;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.engineering-card-body p {
  display: -webkit-box;
  height: 56px;
  min-height: 56px;
  overflow: hidden;
  margin: 9px 0 16px;
  color: var(--engineering-muted);
  font-size: 12px;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.engineering-card-proof {
  display: flex;
  margin: 0 0 18px;
}

.engineering-card-proof span {
  padding: 5px 8px;
  border: 1px solid var(--engineering-line);
  border-radius: 999px;
  color: rgba(22, 24, 28, .64);
  font-size: 9px;
  font-weight: 720;
  letter-spacing: .03em;
}

.engineering-step-download {
  display: inline-flex;
  width: 100%;
  min-height: 40px;
  margin-top: auto;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 14px;
  border: 1px solid var(--engineering-line);
  border-radius: 10px;
  background: transparent;
  color: var(--engineering-muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 760;
  text-decoration: none;
}

.engineering-step-download:hover {
  border-color: var(--engineering-line-strong);
  background: rgba(255, 255, 255, .045);
  color: var(--engineering-text);
}

@media (max-width: 1120px) {
  .engineering-product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .library-category-bar {
    padding-right: 14px;
    padding-left: 14px;
  }

  .library-category-tabs {
    gap: 28px;
  }

  .engineering-library-shell {
    width: min(100% - 28px, 1460px);
  }

  .engineering-product-grid {
    grid-template-columns: 1fr;
  }
}

/* Dark (System / Dark): the page and cards go to the brand charcoal; the stages stay the daylight studio the
   photoreal renders were shot in, so 3D and Render swap seamlessly and read as product photography on dark. */
:root[data-theme="dark"] .library-category-bar,
:root[data-theme="dark"] .engineering-library-section {
  --engineering-line: rgba(255, 255, 255, .10);
  --engineering-line-strong: rgba(255, 255, 255, .22);
  --engineering-text: #FFFFFF;
  --engineering-muted: #A6A8AC;
  --engineering-blue: #2391B5;
  color-scheme: dark;
}
:root[data-theme="dark"] .library-category-tabs button { color: rgba(255, 255, 255, .56); }
:root[data-theme="dark"] .library-category-tabs button:is(:hover, :focus-visible, .is-active) { color: #FFFFFF; }
:root[data-theme="dark"] .engineering-product-card { box-shadow: 0 8px 28px rgba(0, 0, 0, .28); }
:root[data-theme="dark"] .engineering-product-card:hover { box-shadow: 0 22px 52px rgba(0, 0, 0, .5); }
:root[data-theme="dark"] .engineering-card-proof span { color: rgba(255, 255, 255, .66); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .library-category-bar,
  :root:not([data-theme="light"]) .engineering-library-section {
    --engineering-line: rgba(255, 255, 255, .10);
    --engineering-line-strong: rgba(255, 255, 255, .22);
    --engineering-text: #FFFFFF;
    --engineering-muted: #A6A8AC;
    --engineering-blue: #2391B5;
    color-scheme: dark;
  }
  :root:not([data-theme="light"]) .library-category-tabs button { color: rgba(255, 255, 255, .56); }
  :root:not([data-theme="light"]) .library-category-tabs button:is(:hover, :focus-visible, .is-active) { color: #FFFFFF; }
  :root:not([data-theme="light"]) .engineering-product-card { box-shadow: 0 8px 28px rgba(0, 0, 0, .28); }
  :root:not([data-theme="light"]) .engineering-product-card:hover { box-shadow: 0 22px 52px rgba(0, 0, 0, .5); }
  :root:not([data-theme="light"]) .engineering-card-proof span { color: rgba(255, 255, 255, .66); }
}

/* ── OS mode symbols (Build / Experiment / Fun) ─────────────────────────────────────────────
   The app's Signal badge restated on the library: the tab carries its mode glyph and an
   underline in the mode colour, and every card carries a tinted mode chip. Colours are the exact
   OS hues (frontend-shell ForgeCartBadge); chip text is a darker shade of each hue so it stays
   legible on the light website, where the OS card is near-black. Written into library.html with the
   cards (scripts/library/build-library-page.mjs). */
:root {
  --mode-build: #4a90d9;
  --mode-experiment: #e0913f;
  --mode-fun: #9a7bd0;
  --mode-build-ink: #285f9e;       /* chip text, light: 5.1:1 on the chip (was #2f6fb3, 4.1) */
  --mode-experiment-ink: #8f5414;  /* 4.9:1 (was #b36a1c, 3.4) */
  --mode-fun-ink: #6c4ea6;         /* 5.0:1 (was #7556b0, 4.4) */
  --mode-build-on-dark: #69a5e2;   /* chip text, dark: 5.1:1 on the chip (the hue #4a90d9 is 4.0) */
  --mode-fun-on-dark: #ad93da;     /* 5.1:1 (the hue #9a7bd0 is 3.9) */
}

.mode-glyph {
  display: block;
  flex: 0 0 auto;
}

.mode-glyph :where(polygon, polyline, line, path) {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7px;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.mode-glyph .mode-dashed :where(polygon, polyline, line) {
  stroke-dasharray: 3.2 2.6;
}

/* Tab: glyph before the label, mode-coloured; the active underline takes the mode colour. */
.library-category-tabs button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.library-category-tabs button .mode-glyph {
  width: clamp(16px, 1.5vw, 19px);
  height: clamp(16px, 1.5vw, 19px);
  opacity: .8;
  transition: opacity .18s ease;
}

.library-category-tabs button:hover .mode-glyph,
.library-category-tabs button.is-active .mode-glyph {
  opacity: 1;
}

.library-category-tabs button[data-mode="build"] .mode-glyph { color: var(--mode-build); }
.library-category-tabs button[data-mode="experiment"] .mode-glyph { color: var(--mode-experiment); }
.library-category-tabs button[data-mode="fun"] .mode-glyph { color: var(--mode-fun); }

.library-category-tabs button.is-active[data-mode="build"]::after { background: var(--mode-build); }
.library-category-tabs button.is-active[data-mode="experiment"]::after { background: var(--mode-experiment); }
.library-category-tabs button.is-active[data-mode="fun"]::after { background: var(--mode-fun); }

/* Card: a tinted mode chip beside the geometry chip (hue fill at .14, border at .5 — the OS recipe). */
.engineering-card-proof {
  align-items: center;
  gap: 6px;
}

.library-mode-chip-row {
  display: flex;
  margin: 0 0 14px;
}

/* The chip is a <span> that also sits inside .engineering-card-proof, whose own `span` rule would
   otherwise claim its border, colour and padding. The doubled class clears that rule's specificity. */
.library-mode-chip.library-mode-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px 4px 7px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 720;
  letter-spacing: .02em;
  line-height: 1.2;
  white-space: nowrap;
}

.library-mode-chip .mode-glyph {
  width: 12px;
  height: 12px;
}

.library-mode-chip.library-mode-chip--build {
  color: var(--mode-build-ink);
  background: rgba(74, 144, 217, .14);
  border-color: rgba(74, 144, 217, .5);
}
.library-mode-chip--build .mode-glyph { color: var(--mode-build); }

.library-mode-chip.library-mode-chip--experiment {
  color: var(--mode-experiment-ink);
  background: rgba(224, 145, 63, .14);
  border-color: rgba(224, 145, 63, .5);
}
.library-mode-chip--experiment .mode-glyph { color: var(--mode-experiment); }

.library-mode-chip.library-mode-chip--fun {
  color: var(--mode-fun-ink);
  background: rgba(154, 123, 208, .14);
  border-color: rgba(154, 123, 208, .5);
}
.library-mode-chip--fun .mode-glyph { color: var(--mode-fun); }

/* the mode chips on the dark library: the hue itself reads on charcoal (the darker ink is for the light page) */
:root[data-theme="dark"] .library-mode-chip.library-mode-chip--build { color: var(--mode-build-on-dark); }
:root[data-theme="dark"] .library-mode-chip.library-mode-chip--experiment { color: var(--mode-experiment); }
:root[data-theme="dark"] .library-mode-chip.library-mode-chip--fun { color: var(--mode-fun-on-dark); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .library-mode-chip.library-mode-chip--build { color: var(--mode-build-on-dark); }
  :root:not([data-theme="light"]) .library-mode-chip.library-mode-chip--experiment { color: var(--mode-experiment); }
  :root:not([data-theme="light"]) .library-mode-chip.library-mode-chip--fun { color: var(--mode-fun-on-dark); }
}

/* Phones (2026-11-13): readable labels (12 px; 11 px for the uppercase pills) and bigger card
   controls. Last in the file so it outranks the chip rule above. */
@media (max-width: 720px), (pointer: coarse) {
  /* the short "All" tab is 19 px wide: widen every tab's hit area into the 24 px+ gap beside it */
  .library-category-tabs button::before { content: ""; position: absolute; top: 0; bottom: 0; left: -12px; right: -12px; }
}
@media (max-width: 720px) {
  .engineering-card-toolbar button { width: 36px; height: 36px; }
  .engineering-card-proof span { font-size: 11px; }
  .library-mode-chip.library-mode-chip { font-size: 12px; }
  .engineering-step-download { font-size: 12px; }
}
