/* xLambda.io page-level styles (#179). Component-level shapes that
   aren't in kit_base.css — formula card, hero grid, docs grid, lambda
   catalog, workbook shop, tag pill. */

@import url('kit_base.css');

/* ---------- Tag pill (lambda catalog filter) ---------- */
.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-3);
  background: transparent;
  border: 1px solid var(--border-faint);
  text-decoration: none;
  white-space: nowrap;
}
.tag-pill:hover { background: var(--bg-hover); text-decoration: none; }
.tag-pill--active {
  background: var(--brand-50);
  color: var(--brand-700);
  border-color: var(--brand-200);
}
.tag-pill__count {
  font-variant-numeric: tabular-nums;
  color: var(--fg-muted);
  font-size: 11px;
}
.tag-pill--active .tag-pill__count { color: var(--brand-700); }

/* ---------- Hero formula card (homepage mini-spreadsheet) ---------- */
.formula-card {
  background: #fff;
  border: 1px solid var(--border-1);
  border-radius: 8px;
  box-shadow: var(--sh-2);
  overflow: hidden;
}
.formula-card__bar {
  display: flex;
  align-items: stretch;
  height: 40px;
  border-bottom: 1px solid var(--border-1);
}
.formula-card__fx,
.formula-card__addr {
  width: 64px;
  background: var(--bg-sunken);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  color: var(--fg-muted);
}
.formula-card__fx { border-right: 1px solid var(--border-1); font-size: 14px; font-style: italic; }
.formula-card__addr { border-left: 1px solid var(--border-1); font-size: 11px; }
.formula-card__formula {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 0 14px;
  font-family: var(--font-mono);
  font-size: 13.5px;
  color: var(--brand-700);
}
.formula-card__sheet {
  display: grid;
  grid-template-columns: 32px repeat(4, 1fr);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.4;
}
.formula-card__cell {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-faint);
  border-right: 1px solid var(--border-faint);
  background: #fff;
  color: var(--fg-3);
  font-variant-numeric: tabular-nums;
  position: relative;
}
.formula-card__cell:last-child { border-right: none; }
.formula-card__cell--head {
  background: var(--bg-sunken);
  color: var(--fg-muted);
  font-weight: 500;
  text-align: center;
  font-size: 11px;
}
.formula-card__cell--row {
  background: var(--bg-sunken);
  color: var(--fg-2);
  font-weight: 500;
  text-align: center;
}
.formula-card__cell--selected { background: var(--bg-selected); }
.formula-card__cell--selected::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 2px solid var(--brand-500);
  pointer-events: none;
}
.formula-card__cell--num { text-align: right; }

/* ---------- Hero ---------- */
.hero-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 64px;
  align-items: center;
}
@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; }
}
.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  margin-top: 40px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-muted);
}
.hero-stats__num {
  color: var(--fg-1);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ---------- Function reference 3-column layout ---------- */
.docs-grid {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 200px;
  gap: 48px;
  align-items: start;
}
@media (max-width: 1100px) { .docs-grid { grid-template-columns: 240px minmax(0, 1fr); } .docs-grid > .docs-onthispage { display: none; } }
@media (max-width: 700px)  { .docs-grid { grid-template-columns: 1fr; } .docs-grid > .docs-sidebar { display: none; } }
.docs-sidebar, .docs-onthispage { position: sticky; top: 80px; max-height: calc(100vh - 96px); overflow-y: auto; }
.docs-sidebar__cat { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-muted); font-weight: 500; margin-top: 24px; margin-bottom: 8px; }
.docs-sidebar__cat:first-child { margin-top: 0; }
.docs-sidebar__item { display: block; padding: 4px 8px; font-family: var(--font-mono); font-size: 13px; color: var(--fg-3); border-radius: 4px; text-decoration: none; border-left: 2px solid transparent; }
.docs-sidebar__item:hover { background: var(--bg-hover); text-decoration: none; }
.docs-sidebar__item.active { background: var(--brand-50); color: var(--brand-700); border-left-color: var(--brand-500); font-weight: 600; }
.docs-onthispage h5 { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-muted); font-weight: 500; margin: 0 0 12px 0; }
.docs-onthispage a { display: block; font-family: var(--font-mono); font-size: 12.5px; color: var(--fg-4); padding: 3px 0; text-decoration: none; }
.docs-onthispage a:hover { color: var(--fg-1); }

/* ---------- Formula block (large code-display) ---------- */
.formula-block {
  background: var(--bg-code);
  border: 1px solid var(--border-1);
  border-radius: var(--r-3);
  padding: var(--sp-4) var(--sp-5);
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--brand-700);
  overflow-x: auto;
  white-space: pre-wrap;
  margin: 8px 0;
}

/* ---------- Args / changelog tables ---------- */
.args-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 13px;
}
.args-table th,
.args-table td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-faint);
  vertical-align: top;
}
.args-table thead th {
  background: var(--bg-sunken);
  color: var(--fg-muted);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.args-table tbody tr:nth-child(even) { background: var(--bg-stripe); }
.args-table .args-name { color: var(--fg-1); font-weight: 600; }
.args-table .args-type { color: var(--accent-blue-500); }
.args-table .args-desc { color: var(--fg-3); font-family: var(--font-body); }

/* ---------- Edge-case callout ---------- */
.edge-case {
  border-left: 3px solid var(--warn-500);
  background: var(--warn-50);
  padding: 12px 16px;
  border-radius: 4px;
  margin: 16px 0;
}
.edge-case--err { border-left-color: var(--error-500); background: var(--error-50); }
.edge-case__title { font-family: var(--font-mono); font-weight: 700; font-size: 13px; color: var(--fg-1); }
.edge-case__body { font-family: var(--font-body); font-size: 14px; color: var(--fg-3); margin-top: 4px; line-height: 1.5; }
.edge-case code { font-family: var(--font-mono); background: var(--bg-code); padding: 1px 5px; border-radius: 3px; font-size: 12.5px; color: var(--brand-700); border: 1px solid var(--border-faint); }

/* ---------- Lambda catalog filter bar ---------- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-1);
  border-radius: var(--r-3);
  margin-bottom: 24px;
  align-items: center;
}

/* ---------- Lambda grid + card ---------- */
.lambda-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.lambda-card {
  display: block;
  background: var(--bg-surface);
  border: 1px solid var(--border-1);
  border-radius: var(--r-4);
  padding: 16px;
  text-decoration: none;
  color: inherit;
  transition: border-color var(--dur-1) var(--ease-out), box-shadow var(--dur-1) var(--ease-out);
}
.lambda-card:hover { border-color: var(--brand-300); box-shadow: var(--sh-1); text-decoration: none; }
.lambda-card__head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.lambda-card__name { font-family: var(--font-mono); font-weight: 700; font-size: 15px; color: var(--fg-1); }
.lambda-card__sig  { font-family: var(--font-mono); font-size: 12px; color: var(--fg-muted); }
.lambda-card__desc { font-family: var(--font-body); font-size: 14px; color: var(--fg-3); line-height: 1.5; margin: 4px 0 10px 0; }
.lambda-card__tags { display: flex; flex-wrap: wrap; gap: 6px; }
.lambda-card__meta { display: flex; align-items: center; gap: 12px; margin-top: 10px; font-family: var(--font-mono); font-size: 11.5px; color: var(--fg-muted); font-variant-numeric: tabular-nums; }

/* ---------- Lambda table (grid+table toggle) ---------- */
.lambda-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--bg-surface);
  border: 1px solid var(--border-1);
  border-radius: var(--r-3);
  overflow: hidden;
}
.lambda-table th, .lambda-table td { padding: 10px 12px; border-bottom: 1px solid var(--border-faint); text-align: left; vertical-align: middle; }
.lambda-table thead th { background: var(--bg-sunken); color: var(--fg-muted); font-weight: 500; font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; }
.lambda-table tbody tr:hover { background: var(--bg-hover); }
.lambda-table tbody tr:last-child td { border-bottom: none; }
.lambda-table .l-name { color: var(--fg-1); font-weight: 700; }
.lambda-table .l-sig  { color: var(--fg-muted); }
.lambda-table .l-desc { font-family: var(--font-body); color: var(--fg-3); }
.lambda-table .l-stars { color: var(--fg-muted); font-variant-numeric: tabular-nums; text-align: right; }

/* ---------- Workbook shop grid + card ---------- */
.workbook-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}
.workbook-card {
  display: block;
  background: var(--bg-surface);
  border: 1px solid var(--border-1);
  border-radius: var(--r-4);
  text-decoration: none;
  color: inherit;
  overflow: hidden;
  transition: border-color var(--dur-1) var(--ease-out), box-shadow var(--dur-1) var(--ease-out);
}
.workbook-card:hover { border-color: var(--brand-300); box-shadow: var(--sh-2); text-decoration: none; }
.workbook-card__preview {
  aspect-ratio: 4 / 3;
  /* Split into background-color + background-image — the shorthand `background:
     <color> <image>, <image>` is invalid CSS (per spec, <color> can only appear
     in the FINAL layer of a multi-layer background), so browsers were dropping
     the whole declaration → no grid rendered. Splitting works around the parse. */
  background-color: var(--bg-sunken);
  background-image:
    repeating-linear-gradient(0deg, transparent 0 31px, var(--border-faint) 31px 32px),
    repeating-linear-gradient(90deg, transparent 0 31px, var(--border-faint) 31px 32px);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-muted);
  font-family: var(--font-mono);
  font-size: 11px;
}
.workbook-card__body { padding: 14px 16px; }
.workbook-card__title { font-family: var(--font-mono); font-weight: 700; font-size: 14.5px; color: var(--fg-1); line-height: 1.3; }
.workbook-card__meta { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; font-family: var(--font-mono); font-size: 12px; color: var(--fg-muted); }
.workbook-card__price { color: var(--brand-700); font-weight: 700; font-variant-numeric: tabular-nums; }
.workbook-card__buys { color: var(--fg-muted); font-variant-numeric: tabular-nums; }

/* ---------- Site shell + functions strip ---------- */
.site-main { min-height: 60vh; }
.featured-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.fn-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.fn-strip a {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 10px;
  border-radius: 4px;
  background: var(--bg-sunken);
  border: 1px solid var(--border-faint);
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--fg-2);
  text-decoration: none;
}
.fn-strip a:hover { background: var(--bg-hover); border-color: var(--border-1); color: var(--fg-1); text-decoration: none; }
