/* Otter Component Library (/library/ and /library/<slug>/) */
/* Integrates seamlessly with docs-enhancements.css and the Otter palette (#0b1d36, #2563eb, #f4f7fb). */

.lib-app-root {
  width: 100%;
  color: #0f1f36;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.lib-controls-bar {
  background: #ffffff;
  border: 1px solid #dce5f0;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 8px 24px rgba(15, 31, 54, 0.05);
  margin-bottom: 22px;
}

.lib-search-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}

.lib-search-input {
  flex: 1 1 240px;
  min-width: 0;
  max-width: 100%;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font: inherit;
  font-size: 15px;
  color: #0f1f36;
  background: #f8fafc;
}

.lib-search-input:focus {
  outline: 2px solid #2563eb;
  outline-offset: 1px;
  background: #ffffff;
}

.lib-select {
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #ffffff;
  color: #0f1f36;
  font: inherit;
  font-size: 14px;
}

.lib-select:focus {
  outline: 2px solid #2563eb;
  outline-offset: 1px;
}

.lib-reset-btn {
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #f1f5f9;
  color: #1e293b;
  font: 600 13px/1 inherit;
  cursor: pointer;
}

.lib-reset-btn:hover { background: #e2e8f0; }

.lib-cat-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.lib-cat-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #1e293b;
  font: 600 13px/1 inherit;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}

.lib-cat-tab:hover { border-color: #93c5fd; background: #eff6ff; }
.lib-cat-tab[aria-pressed="true"] {
  background: #0b1d36;
  border-color: #0b1d36;
  color: #ffffff;
}

.lib-cat-tab .lib-tab-count {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.22);
}

.lib-cat-tab[aria-pressed="true"] .lib-tab-count {
  background: rgba(255, 255, 255, 0.18);
}

.lib-lang-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.lib-lang-label {
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-right: 4px;
}

.lib-lang-pill {
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid #dbe4f0;
  background: #f8fafc;
  color: #334155;
  font: 600 12px/1 inherit;
  cursor: pointer;
}

.lib-lang-pill[aria-pressed="true"] {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
}

.lib-summary-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 0 16px;
  font-size: 14px;
  color: #475569;
}

.lib-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.lib-card {
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border: 1px solid #dce5f0;
  border-radius: 16px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 6px 18px rgba(15, 31, 54, 0.045);
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
}

.lib-card:hover,
.lib-card:focus-visible {
  transform: translateY(-3px);
  border-color: #93c5fd;
  box-shadow: 0 14px 30px rgba(37, 99, 235, 0.12);
  outline: none;
}

.lib-card-media {
  position: relative;
  aspect-ratio: 16 / 9;
  width: 100%;
  background: #0b162a;
  overflow: hidden;
  border-bottom: 1px solid #dce5f0;
}

.lib-card-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 220ms ease;
}

.lib-card:hover .lib-card-img {
  transform: scale(1.025);
}

.lib-card-kicker {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.lib-kicker-cat {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #475569;
}

.lib-thumb-kind {
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.lib-thumb-kind-live {
  background: #dcfce7;
  color: #166534;
}

.lib-thumb-kind-diagram {
  background: #f1f5f9;
  color: #334155;
}

.lib-view-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 18px;
  padding: 6px;
  background: #ffffff;
  border: 1px solid #dce5f0;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(15, 31, 54, 0.04);
}

.lib-view-tab {
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #334155;
  font: 600 13.5px/1 Inter, system-ui, sans-serif;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}

.lib-view-tab:hover {
  background: #eff6ff;
  color: #1d4ed8;
}

.lib-view-tab.is-active,
.lib-view-tab[aria-selected="true"] {
  background: #0b1d36;
  color: #ffffff;
}

.lib-view-section.is-hidden {
  display: none;
}

.lib-card-thumb {
  height: 118px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: linear-gradient(135deg, #0b1d36 0%, #17345e 100%);
  color: #e2e8f0;
}

.lib-card-thumb-web { background: linear-gradient(135deg, #1e3a8a 0%, #0284c7 100%); }
.lib-card-thumb-effects { background: linear-gradient(135deg, #4c1d95 0%, #2563eb 100%); }
.lib-card-thumb-desktop { background: linear-gradient(135deg, #0f172a 0%, #334155 100%); }
.lib-card-thumb-games { background: linear-gradient(135deg, #064e3b 0%, #0f766e 100%); }
.lib-card-thumb-otter { background: linear-gradient(135deg, #0b1d36 0%, #1d4ed8 100%); }

.lib-thumb-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.lib-thumb-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
}

.lib-thumb-preview-type {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.82);
}

.lib-thumb-code {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11px;
  color: #bae6fd;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lib-card-body {
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.lib-card-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: #0b1d36;
  line-height: 1.3;
}

.lib-card-desc {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: #475569;
  flex: 1;
}

.lib-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.lib-cat-chip, .lib-sub-chip, .lib-lang-chip, .lib-ver-chip, .lib-pill {
  display: inline-flex;
  align-items: center;
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 999px;
}

.lib-cat-chip { background: #dbeafe; color: #1d4ed8; }
.lib-sub-chip { background: #f1f5f9; color: #334155; }
.lib-lang-chip { background: #ede9fe; color: #5b21b6; }
.lib-pill { background: #e2e8f0; color: #1e293b; }

.lib-badge-verified { background: #dcfce7; color: #166534; }
.lib-badge-tested { background: #dbeafe; color: #1e40af; }
.lib-badge-contract { background: #fef3c7; color: #92400e; }
.lib-badge-reviewed { background: #f1f5f9; color: #334155; }

.lib-provenance-bar {
  margin-top: 28px;
  padding: 14px 18px;
  background: #ffffff;
  border: 1px solid #dce5f0;
  border-radius: 12px;
  font-size: 12.5px;
  color: #475569;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
}

.lib-provenance-bar code {
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}

.lib-empty {
  background: #ffffff;
  border: 1px dashed #cbd5e1;
  border-radius: 14px;
  padding: 42px 24px;
  text-align: center;
  color: #475569;
}

/* Detail Pages */
.lib-detail-main {
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 32px 24px;
  box-sizing: border-box;
}

.lib-crumbs {
  font-size: 13.5px;
  color: #64748b;
  margin-bottom: 18px;
}

.lib-crumbs a { color: #2563eb; text-decoration: none; font-weight: 500; }
.lib-crumbs a:hover { text-decoration: underline; }

.lib-detail-hero {
  background: #ffffff;
  border: 1px solid #dce5f0;
  border-radius: 18px;
  padding: 28px 30px;
  margin-bottom: 22px;
  box-shadow: 0 8px 24px rgba(15, 31, 54, 0.045);
}

.lib-detail-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.lib-detail-hero h1 { margin: 0 0 10px; font-size: 34px; font-weight: 800; letter-spacing: -0.025em; color: #0b1d36; }
.lib-detail-desc { margin: 0 0 16px; font-size: 16.5px; line-height: 1.6; color: #334155; max-width: 820px; }
.lib-detail-quickmeta { display: flex; flex-wrap: wrap; gap: 18px; font-size: 13.5px; color: #475569; }
.lib-detail-quickmeta code { background: #f1f5f9; padding: 2px 6px; border-radius: 5px; color: #0f1f36; }

.lib-detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 22px;
  align-items: start;
}

.lib-panel, .lib-aside-card {
  background: #ffffff;
  border: 1px solid #dce5f0;
  border-radius: 16px;
  padding: 22px 24px;
  margin-bottom: 20px;
  box-shadow: 0 6px 18px rgba(15, 31, 54, 0.04);
}

.lib-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.lib-panel h2 { margin: 0; font-size: 20px; font-weight: 800; color: #0b1d36; letter-spacing: -0.015em; }
.lib-aside-card h3 { margin: 0 0 10px; font-size: 15px; font-weight: 700; color: #0b1d36; }
.lib-aside-copy { margin: 0; font-size: 13.5px; line-height: 1.55; color: #475569; }
.lib-aside-copy code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

.lib-preview-box {
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  overflow: hidden;
  background: #0b162a;
}

.lib-sandbox-frame {
  display: block;
  width: 100%;
  border: 0;
}

.lib-preview-caption {
  margin: 12px 0 0;
  font-size: 13.5px;
  color: #475569;
  line-height: 1.5;
}

.lib-customizer {
  margin-top: 14px;
  padding: 14px 16px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
}

.lib-customizer-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: #475569; margin-bottom: 10px; }
.lib-customizer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.lib-ctrl { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: #1e293b; font-weight: 500; }

.lib-table-wrap { overflow-x: auto; margin-top: 12px; }
.lib-contract-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.lib-contract-table th, .lib-contract-table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid #e2e8f0; }
.lib-contract-table th { background: #f8fafc; font-weight: 700; color: #334155; }
.lib-contract-table code { font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace; font-size: 12px; color: #0f1f36; }

.lib-arch-list { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.lib-arch-step { display: flex; align-items: center; gap: 12px; padding: 11px 14px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px; font-size: 14px; color: #1e293b; }
.lib-arch-num { width: 24px; height: 24px; border-radius: 999px; background: #2563eb; color: #ffffff; font-weight: 700; font-size: 12px; display: inline-grid; place-items: center; flex-shrink: 0; }
.lib-project-ref { margin-top: 14px; padding: 12px 14px; background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 10px; font-size: 13.5px; color: #1e3a8a; }
.lib-preview-img, .lib-preview-video { width: 100%; border-radius: 10px; margin-top: 12px; border: 1px solid #cbd5e1; }

/* File Tabs & Syntax Highlighted Code */
.lib-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border-bottom: 1px solid #dce5f0;
  padding-bottom: 10px;
  margin-bottom: 12px;
}

.lib-tab {
  padding: 7px 13px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  color: #334155;
  font: 600 13px/1 'JetBrains Mono', ui-monospace, Consolas, monospace;
  cursor: pointer;
}

.lib-tab.is-active,
.lib-tab[aria-selected="true"] {
  background: #0b1d36;
  border-color: #0b1d36;
  color: #ffffff;
}

.lib-code-panel.is-hidden { display: none; }

.lib-code-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 9px 14px;
  background: #16263f;
  color: #cbd5e1;
  border-radius: 12px 12px 0 0;
  font-size: 12px;
}

.lib-code-actions { display: flex; gap: 8px; }

.lib-btn-copy {
  padding: 6px 12px;
  border-radius: 7px;
  border: 1px solid #35507a;
  background: #22375a;
  color: #f1f5f9;
  font: 600 12px/1 Inter, system-ui, sans-serif;
  cursor: pointer;
}

.lib-btn-copy:hover { background: #2d4873; }
.lib-copy-live { font-size: 12.5px; font-weight: 600; color: #166534; }

.lib-code-pre {
  margin: 0;
  padding: 16px 18px;
  background: #0f1b2e;
  color: #e5edf8;
  border-radius: 0 0 12px 12px;
  overflow-x: auto;
  font: 13px/1.65 'JetBrains Mono', ui-monospace, SFMono-Regular, Consolas, monospace;
}

.lib-raw-code { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.lib-usage-text { margin: 14px 0 0; font-size: 14.5px; line-height: 1.6; color: #334155; white-space: pre-wrap; }

/* Syntax Token Colors */
.tok-kw { color: #7dd3fc; font-weight: 600; }
.tok-str { color: #86efac; }
.tok-num { color: #fcd34d; }
.tok-com { color: #94a3b8; font-style: italic; }
.tok-tag { color: #60a5fa; }
.tok-attr { color: #c4b5fd; }
.tok-key { color: #93c5fd; }

.lib-ver-badge-block {
  display: inline-block;
  padding: 6px 11px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 700;
  margin: 0 0 10px;
}

.lib-meta-list { margin: 0; padding-left: 18px; font-size: 13.5px; line-height: 1.7; color: #334155; }
.lib-meta-list code { overflow-wrap: anywhere; word-break: break-word; background: #f1f5f9; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.lib-meta-muted { margin: 0; font-size: 13.5px; color: #64748b; }
.lib-tags-wrap { display: flex; flex-wrap: wrap; gap: 6px; }
.lib-tag { font-size: 12px; color: #1d4ed8; background: #eff6ff; padding: 4px 9px; border-radius: 999px; text-decoration: none; font-weight: 500; }
.lib-tag:hover { background: #dbeafe; }
.lib-back-link { display: inline-block; margin-top: 12px; color: #2563eb; font-weight: 600; font-size: 13.5px; text-decoration: none; }
.lib-back-link:hover { text-decoration: underline; }

.lib-related-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 12px; }
.lib-related-card { display: flex; flex-direction: column; gap: 5px; padding: 14px; border: 1px solid #dce5f0; border-radius: 12px; text-decoration: none; color: inherit; background: #f8fafc; }
.lib-related-card:hover { border-color: #93c5fd; background: #eff6ff; }
.lib-related-cat { font-size: 11px; font-weight: 700; text-transform: uppercase; color: #2563eb; }
.lib-related-card strong { font-size: 14.5px; color: #0b1d36; }
.lib-related-card span:last-child { font-size: 12.5px; color: #475569; line-height: 1.45; }

.lib-noscript-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; margin-top: 12px; }
.lib-noscript-link { padding: 10px 12px; border: 1px solid #dce5f0; border-radius: 8px; text-decoration: none; color: #1d4ed8; }

@media (max-width: 1024px) {
  .lib-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lib-detail-layout { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .lib-grid { grid-template-columns: 1fr; }
  .lib-controls-bar { padding: 14px; }
  .lib-search-input, .lib-select, .lib-reset-btn { width: 100%; max-width: 100%; }
  .lib-detail-main { padding: 20px 16px; }
  .lib-detail-hero { padding: 20px; }
  .lib-detail-hero h1 { font-size: 26px; }
  .lib-panel, .lib-aside-card { padding: 18px 16px; }
  #heroInner { padding: 28px 16px 32px !important; }
  #heroTitle { font-size: 32px !important; }
  #heroSub { font-size: 15.5px !important; }
  #libraryMount { padding: 20px 16px !important; }
}
