/* ── JS Libraries Hub — Studio shell + welcome landing ──
   Relaunch retheme (RELAUNCH_PLAN §6.2, step 1: shell + hub home page).
   Loaded AFTER hub.css + memphis-overrides.css so it owns the page shell and
   the landing page; library-detail content keeps the old styling until the
   next step. All values reference the shared tokens in static/css/theme/tokens.css. */

/* hub.css declares its own dark palette on :root (loaded after tokens.css).
   Re-map the whole var set to studio values here so every hub.css component
   rule (cards, tabs, chips — they all read these vars) resolves light/studio. */
:root {
  --bg: var(--c-paper);
  --surface: var(--c-paper);
  --surface-2: var(--c-cream);
  --surface-3: #f0ece6;
  --border: rgba(26, 26, 46, 0.12);
  --border-hover: rgba(26, 26, 46, 0.28);
  --text-primary: var(--c-ink);
  --text-secondary: #494960;
  --muted: var(--c-muted);
  --accent: var(--c-indigo);
  --accent-strong: var(--c-indigo-strong);
  --accent-dim: rgba(99, 102, 241, 0.08);
  --accent-mid: rgba(99, 102, 241, 0.16);
  --red: #d05568;
  --yellow: #a8851a;
  --blue: #7a5fa8;
  --green: #2e8d7f;
  --code-bg: var(--c-ink);
  --display: var(--font-display-studio);
  --sans: var(--font-body-studio);
}

body {
  background: var(--surface) !important;
  color: var(--ink);
  font-family: var(--font-body);
  overflow-x: hidden;
}

/* Kill the legacy noise/polka-dot overlay from hub.css / memphis-overrides */
body::before { display: none !important; }

/* Studio scrollbars (memphis-overrides paints them teal/pink globally) */
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line);
  border: none;
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ══ Shell — matches the navbar content box (max-w-7xl + px-4/6/8) ══ */
.jsl-shell {
  display: flex;
  max-width: 80rem;            /* navbar max-w-7xl */
  margin: 0 auto;
  padding: 0 1rem;             /* navbar px-4 */
}
@media (min-width: 640px)  { .jsl-shell { padding: 0 1.5rem; } }  /* sm:px-6 */
@media (min-width: 1024px) { .jsl-shell { padding: 0 2rem; } }    /* lg:px-8 */

.jsl-main {
  flex: 1;
  min-width: 0;
}

/* Neutralize old shell padding from hub.css (the shell provides the gutters) */
.jsl-main .content-area { padding: 0; min-height: 0; }
@media (max-width: 1023px) {
  .jsl-main .content-area { padding: 0; }
}

/* ══ Sidebar ══ */
.jsl-sidebar {
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

/* Desktop: sticky rail below the navbar, inside the contained shell */
@media (min-width: 1024px) {
  .jsl-sidebar {
    width: 248px;
    flex-shrink: 0;
    position: sticky;
    top: var(--nav-height, 4rem);
    height: calc(100vh - var(--nav-height, 4rem));
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 1.75rem 1.25rem 2rem 0;
    /* Firefox: hide the scrollbar until hovered */
    scrollbar-width: none;
  }
  .jsl-sidebar:hover { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
  .jsl-sidebar::-webkit-scrollbar { width: 0; }
  .jsl-sidebar:hover::-webkit-scrollbar { width: 6px; }

  /* Tapered separator instead of a hard border */
  .jsl-sidebar::after {
    content: "";
    position: absolute;
    top: 2rem; right: 0; bottom: 2rem;
    width: 1px;
    background: linear-gradient(180deg, transparent 0%, var(--line) 12%, var(--line) 88%, transparent 100%);
    pointer-events: none;
  }

  .jsl-main { padding-left: 2.5rem; }
}

/* Mobile: slide-in drawer */
@media (max-width: 1023px) {
  .jsl-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 18rem;
    max-width: 85vw;
    z-index: 70;                 /* above the sticky navbar (z-50) */
    padding: 1.25rem 1rem 2rem;
    overflow-y: auto;
    border-right: 1px solid var(--line);
    box-shadow: var(--shadow);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }
  .jsl-sidebar.jsl-open { transform: none; }
}

.jsl-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 46, 0.35);
  backdrop-filter: blur(2px);
  z-index: 65;
}
@media (min-width: 1024px) { .jsl-overlay { display: none; } }

.jsl-sidebar-close {
  position: absolute;
  top: 0.85rem; right: 0.85rem;
  display: flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
}
.jsl-sidebar-close:hover { background: var(--surface-2); color: var(--ink); }
@media (min-width: 1024px) { .jsl-sidebar-close { display: none; } }

.jsl-sidebar-brand {
  padding: 0.25rem 0.75rem 1rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--line);
}
.jsl-sidebar-brand a {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.jsl-sidebar-brand a:hover { color: var(--accent-strong); }
.jsl-sidebar-brand .jsl-brand-accent { color: var(--accent); }

.jsl-cat-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}
.jsl-cat-btn:hover { background: var(--surface-2); }
.jsl-cat-btn .jsl-cat-btn-icon { font-size: 0.95rem; }
.jsl-cat-btn .jsl-cat-btn-name { flex: 1; }
.jsl-cat-btn svg {
  width: 0.85rem; height: 0.85rem;
  color: var(--muted);
  transition: transform 0.2s;
}
.jsl-cat-btn svg.jsl-rotated { transform: rotate(180deg); }

.jsl-lib-list { margin: 0.15rem 0 0.85rem; padding-left: 0.6rem; }

.jsl-lib-btn {
  display: block;
  width: 100%;
  padding: 0.4rem 0.75rem;
  background: none;
  border: none;
  border-left: 2px solid var(--line);
  border-radius: 0;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.jsl-lib-btn:hover { color: var(--ink); border-left-color: var(--muted); }
.jsl-lib-btn.jsl-active {
  color: var(--accent-strong);
  font-weight: 600;
  border-left-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, transparent);
}

.jsl-sidebar-label {
  display: block;
  padding: 0.5rem 0.75rem 0.25rem;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

/* ══ Mobile browse bar (in-flow, sticky under the navbar) ══ */
.jsl-mobilebar {
  display: none;
}
@media (max-width: 1023px) {
  .jsl-mobilebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    position: sticky;
    top: var(--nav-height, 4rem);
    z-index: 30;
    margin: 0 -1rem 0.5rem;        /* full-bleed across the shell padding */
    padding: 0.6rem 1rem;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
  }
}
@media (min-width: 640px) and (max-width: 1023px) {
  .jsl-mobilebar { margin: 0 -1.5rem 0.5rem; padding: 0.6rem 1.5rem; }
}
.jsl-mobilebar-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}
.jsl-mobilebar-btn:hover { border-color: var(--accent); color: var(--accent-strong); }
.jsl-mobilebar-btn svg { width: 1rem; height: 1rem; }
.jsl-mobilebar-current {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ══ Loading overlay ══ */
.jsl-loading {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--surface) 75%, transparent);
  backdrop-filter: blur(3px);
}
.jsl-spinner {
  width: 38px; height: 38px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: jsl-spin 0.8s linear infinite;
}
@keyframes jsl-spin { to { transform: rotate(360deg); } }

/* ══ Welcome landing ══ */
.jsl-landing {
  padding: 2.75rem 0 3.5rem;
  animation: jsl-fade-up 0.45s ease-out both;
}
@media (max-width: 1023px) { .jsl-landing { padding-top: 1.5rem; } }

@keyframes jsl-fade-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .jsl-landing { animation: none; }
}

.jsl-eyebrow {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-bottom: 0.85rem;
}

.jsl-h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4.5vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.12;
  color: var(--ink);
  margin-bottom: 0.85rem;
}

.jsl-sub {
  font-size: 1.02rem;
  line-height: 1.65;
  color: var(--muted);
  max-width: 38rem;
  margin-bottom: 1.6rem;
}

.jsl-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.jsl-stat {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  padding: 0.45rem 0.95rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
}
.jsl-stat-value {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
}
.jsl-stat-label {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted);
}

/* Sections */
.jsl-section { margin-top: 3rem; }
.jsl-section-head { margin-bottom: 1.25rem; }
.jsl-kicker {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-bottom: 0.35rem;
}
.jsl-h2 {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.jsl-section-sub {
  font-size: 0.88rem;
  color: var(--muted);
  margin-top: 0.35rem;
}

/* Category overview cards (anchor links into the grouped list below) */
.jsl-cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 0.85rem;
}
.jsl-cat-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  padding: 1.1rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.jsl-cat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: color-mix(in srgb, var(--cat-tone, var(--accent)) 45%, var(--line));
}
.jsl-cat-icon { font-size: 1.35rem; margin-bottom: 0.35rem; }
.jsl-cat-name {
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink);
}
.jsl-cat-count {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: var(--cat-tone, var(--accent));
}

/* Library cards */
.jsl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 0.85rem;
}
.jsl-card {
  display: block;
  padding: 1.15rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.jsl-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}
.jsl-card-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.6rem;
}
.jsl-card-logo {
  width: 2.25rem; height: 2.25rem;
  border-radius: var(--radius-sm);
  object-fit: contain;
  flex-shrink: 0;
}
.jsl-card-logo--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
}
.jsl-card-name {
  font-family: var(--font-display);
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.25;
}
.jsl-card-tagline {
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.jsl-card-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.7rem;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--accent);
}
.jsl-card:hover .jsl-card-cta { color: var(--accent-strong); }

/* Category tone variants (studio-tinted; text tones darkened for contrast) */
.jsl-accent-pink   { --cat-tone: #c75d77; }
.jsl-accent-teal   { --cat-tone: #2e8d7f; }
.jsl-accent-purple { --cat-tone: #7a5fa8; }
.jsl-accent-yellow { --cat-tone: #a8851a; }
.jsl-accent-coral  { --cat-tone: #c2734a; }

.jsl-badge {
  display: inline-block;
  margin-top: 0.2rem;
  padding: 0.08rem 0.5rem;
  border-radius: var(--radius-pill);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--cat-tone, var(--accent));
  background: color-mix(in srgb, var(--cat-tone, var(--accent)) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--cat-tone, var(--accent)) 25%, transparent);
}

/* Grouped "All libraries" listing */
.jsl-group { margin-top: 1.9rem; scroll-margin-top: calc(var(--nav-height, 4rem) + 4.5rem); }
.jsl-group:first-of-type { margin-top: 0; }
.jsl-group-head {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  padding-bottom: 0.6rem;
  margin-bottom: 0.9rem;
  border-bottom: 1px solid var(--line);
}
.jsl-group-icon { font-size: 1rem; }
.jsl-group-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
}
.jsl-group-count {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: var(--muted);
}

@media (max-width: 640px) {
  .jsl-cat-grid { grid-template-columns: repeat(2, 1fr); }
  .jsl-grid { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════════════════════════
   Library detail page — studio grammar on top of hub.css.
   hub.css already reads the re-mapped vars above for its colors;
   the rules below fix the grammar bits (serif italics, radii,
   shadows, chips) that vars alone can't reach.
   ══════════════════════════════════════════════════════════════ */

/* Headings: hub.css uses italic Instrument Serif — switch to studio display */
.hero h1,
.section-heading h2,
.section-title,
.hub-title,
.category-hero-title {
  font-style: normal;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.hero h1 { font-size: 2.6rem; }
.section-heading h2 { font-size: 1.35rem; letter-spacing: -0.01em; }

.section-badge {
  border-radius: var(--radius-pill);
  letter-spacing: 0.08em;
}
.hero-version { border-radius: var(--radius-pill); }

/* Stat chips (bundle size etc.) */
.stat-chip { box-shadow: var(--shadow-sm); background: var(--surface); }

/* Definition callout: soft accent tint instead of the old gradient */
.definition-callout {
  background: color-mix(in srgb, var(--accent) 5%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 18%, transparent);
  border-radius: var(--radius);
}
.definition-callout p { font-size: 0.95rem; }

/* Cards */
.feature-card,
.compare-card,
.related-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.feature-card:hover,
.compare-card:hover,
.related-card:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  box-shadow: var(--shadow);
}

/* Playground frame */
.playground {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.playground-header { background: var(--surface-2); }
.window-dots span { opacity: 0.9; }
.btn-run {
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-pill);
  padding: 0.35rem 0.9rem;
}
.btn-run:hover { background: var(--accent-strong); opacity: 1; }

/* Example tabs */
.example-tab {
  background: var(--surface);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
}
.example-tab:hover:not(.active) { border-color: var(--border-hover); color: var(--text-primary); }
.example-tab.active {
  background: var(--accent-dim);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--accent-strong);
  font-weight: 600;
}

/* When to use / avoid */
.usage-item { color: var(--text-secondary); }
.usage-icon { border-radius: 6px; }
.usage-icon.use {
  background: color-mix(in srgb, var(--c-teal) 14%, transparent);
  border-color: color-mix(in srgb, var(--c-teal) 35%, transparent);
  color: var(--green);
}
.usage-icon.avoid {
  background: color-mix(in srgb, #d05568 10%, transparent);
  border-color: color-mix(in srgb, #d05568 30%, transparent);
  color: var(--red);
}

/* Comparison chips */
.compare-chip { border-radius: var(--radius-sm); }
.compare-chip.primary {
  background: color-mix(in srgb, var(--c-teal) 8%, transparent);
  border-color: color-mix(in srgb, var(--c-teal) 25%, transparent);
}
.compare-chip.other {
  background: color-mix(in srgb, var(--c-violet) 8%, transparent);
  border-color: color-mix(in srgb, var(--c-violet) 25%, transparent);
}
.compare-full-link:hover { color: var(--accent-strong); }

/* Install tabs + code blocks (code stays dark for readability) */
.install-tab { border-radius: var(--radius-sm); background: var(--surface-2); }
.install-tab.active { background: var(--accent-dim); color: var(--accent-strong); font-weight: 600; }

.code-block {
  background: var(--code-bg);
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.code-block-header { border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.code-block-lang { color: rgba(255, 255, 255, 0.55); }
.code-block pre { color: #e2e8f0; }
.btn-copy {
  color: var(--c-ink-300);
  border-color: rgba(255, 255, 255, 0.22);
  border-radius: 6px;
}
.btn-copy:hover { border-color: var(--accent); color: #fff; }

/* Native feature notice (browser-built-in libraries, e.g. CSS Animations) */
.native-feature-notice {
  background: color-mix(in srgb, var(--c-teal) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--c-teal) 30%, transparent);
  border-radius: var(--radius);
  padding: 1.1rem 1.35rem;
  margin-bottom: 1.25rem;
}
.native-badge {
  display: inline-block;
  background: color-mix(in srgb, var(--c-teal) 15%, transparent);
  color: var(--green);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-pill);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.native-feature-notice p {
  color: var(--text-primary);
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.6;
}

/* Category listing page (library grid + category pills) */
.library-card,
.category-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.library-card:hover,
.category-card:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  box-shadow: var(--shadow);
}
.library-card-logo-placeholder {
  background: var(--surface-2);
  border: 1px solid var(--border);
}
/* Category badge tones: darker text for contrast on the light theme */
.library-card-category.category-pink   { background: rgba(232, 135, 159, 0.12); color: #c75d77; }
.library-card-category.category-teal   { background: rgba(77, 184, 168, 0.12);  color: #2e8d7f; }
.library-card-category.category-purple { background: rgba(155, 124, 196, 0.12); color: #7a5fa8; }
.library-card-category.category-yellow { background: rgba(245, 215, 110, 0.18); color: #a8851a; }
.library-card-category.category-coral  { background: rgba(232, 160, 122, 0.12); color: #c2734a; }
.library-card-stars { color: #a8851a; }

.category-pill {
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.category-pill:hover { border-color: var(--border-hover); color: var(--text-primary); }
.category-pill.active {
  background: var(--accent-dim);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--accent-strong);
  font-weight: 600;
}

/* Misc */
.no-examples {
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.ext-link { box-shadow: var(--shadow-sm); border-radius: var(--radius-sm); }
.ext-link:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); color: var(--accent-strong); }
.related-card { cursor: pointer; }
