/* OpenAgentLock Rules Registry — light, editorial, minimal.
 * Inspired by smithery.ai's clean serif headline + cream surface. The
 * registry is just files in a git repo, so the site keeps that
 * "open-source library catalog" feel.
 */

/* Theme tokens. The site supports `light`, `dark`, and `system` —
 * controlled by a [data-theme] attribute set on <html> by app.js (which
 * persists the choice in localStorage). `system` removes the attribute
 * so the prefers-color-scheme media query takes over.
 */
:root,
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f3ee;
  --surface: #fbfaf6;
  --surface-2: #f0ece1;
  --border: #e6e0d3;
  --border-strong: #d6cdb8;
  --text: #1a1c1f;
  --text-muted: #6b6f76;
  --accent: #c75c1f;
  --accent-soft: #fce8d6;
  --critical: #c4302b;
  --high: #d97315;
  --medium: #b08400;
  --low: #4f9d52;
  --info: #5176a8;
  --code-bg: #ebe5d6;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
  --serif: "Newsreader", "Charter", "Iowan Old Style", "Source Serif Pro", Georgia, serif;
  --sans:
    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #15171b;
  --surface: #1c1f24;
  --surface-2: #23262d;
  --border: #2c3038;
  --border-strong: #3a3f49;
  --text: #ecedef;
  --text-muted: #9ca0aa;
  --accent: #ffb068;
  --accent-soft: rgba(255, 176, 104, 0.14);
  --critical: #ff6b6b;
  --high: #ff9c4d;
  --medium: #ffd166;
  --low: #6cd4a0;
  --info: #6aa9ff;
  --code-bg: #23262d;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #15171b;
    --surface: #1c1f24;
    --surface-2: #23262d;
    --border: #2c3038;
    --border-strong: #3a3f49;
    --text: #ecedef;
    --text-muted: #9ca0aa;
    --accent: #ffb068;
    --accent-soft: rgba(255, 176, 104, 0.14);
    --critical: #ff6b6b;
    --high: #ff9c4d;
    --medium: #ffd166;
    --low: #6cd4a0;
    --info: #6aa9ff;
    --code-bg: #23262d;
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.55;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border-strong);
  transition: border-color 120ms ease, color 120ms ease;
}
a:hover {
  border-bottom-color: var(--accent);
  color: var(--accent);
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 32px;
}

/* ---------- header ---------- */

header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0;
  gap: 24px;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  border-bottom: none;
  color: var(--text);
}
.brand .accent {
  color: var(--accent);
}
.brand .meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.header-nav {
  display: flex;
  gap: 22px;
  font-size: 14px;
  align-items: center;
}
.header-nav a {
  border-bottom: none;
  color: var(--text-muted);
}
.header-nav a:hover {
  color: var(--text);
}
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
}
.theme-toggle button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 9px;
  font-size: 12px;
  border-radius: 999px;
  font-family: var(--sans);
  transition: background 120ms, color 120ms;
}
.theme-toggle button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}
.theme-toggle button:hover:not([aria-pressed="true"]) {
  color: var(--text);
}

/* ---------- hero ---------- */

.hero {
  padding: 88px 0 56px;
}
.hero h1 {
  font-family: var(--serif);
  font-size: 56px;
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-weight: 500;
  margin: 0 0 20px;
  max-width: 760px;
}
.hero h1 em {
  font-style: italic;
  color: var(--accent);
}
.hero .lede {
  font-size: 18px;
  color: var(--text-muted);
  max-width: 620px;
  margin: 0 0 32px;
  line-height: 1.55;
}
.search-row {
  position: relative;
  max-width: 620px;
}
#q {
  width: 100%;
  padding: 16px 18px 16px 46px;
  font-size: 16px;
  font-family: var(--sans);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  color: var(--text);
  outline: none;
  transition: border-color 120ms, box-shadow 120ms;
}
#q:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search-row::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b6f76' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='7'/><path d='m20 20-3.5-3.5'/></svg>")
    center / contain no-repeat;
  pointer-events: none;
}
.filters {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-muted);
  flex-wrap: wrap;
}
.filters label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
  user-select: none;
  transition: border-color 120ms, color 120ms;
}
.filters label:has(input:checked) {
  border-color: var(--text);
  color: var(--text);
}
.filters input {
  appearance: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid currentColor;
  margin: 0;
}
.filters input:checked {
  background: currentColor;
}

/* ---------- result list ---------- */

main section.results-section {
  padding: 16px 0 64px;
}
.results-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.results-meta .count {
  font-family: var(--mono);
  font-size: 12px;
}
.results-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.results-controls label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.results-controls select {
  font-family: var(--sans);
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
}

#results {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.rule {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: start;
  transition: border-color 120ms, background 120ms;
}
.rule:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.rule-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.rule-name {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0;
}
.rule-id {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.rule-desc {
  margin: 0 0 12px;
  color: var(--text-muted);
  font-size: 14px;
  white-space: pre-wrap;
  line-height: 1.55;
  max-width: 560px;
}
.rule-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-muted);
  align-items: center;
}
.tag {
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-family: var(--sans);
}
.severity {
  font-family: var(--sans);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 9px;
  border-radius: 4px;
  font-size: 10.5px;
  border: 1px solid currentColor;
}
.severity.critical { color: var(--critical); }
.severity.high     { color: var(--high); }
.severity.medium   { color: var(--medium); }
.severity.low      { color: var(--low); }
.severity.info     { color: var(--info); }

.install {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
  min-width: 280px;
}
.cmd-row {
  display: flex;
  align-items: stretch;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.cmd-row code {
  font-family: var(--mono);
  font-size: 12px;
  padding: 9px 11px;
  user-select: all;
  white-space: nowrap;
  overflow-x: auto;
  color: var(--text);
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
}
.copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  flex-shrink: 0;
  background: transparent;
  border: none;
  border-left: 1px solid var(--border);
  cursor: pointer;
  color: var(--text-muted);
  transition: background 120ms, color 120ms;
}
.copy-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}
.copy-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.copy-btn.copied {
  color: var(--low);
}
.copy-btn svg {
  width: 16px;
  height: 16px;
  pointer-events: none;
}

.empty {
  color: var(--text-muted);
  text-align: center;
  padding: 64px 0;
  font-style: italic;
  font-family: var(--serif);
}

/* ---------- pagination ---------- */

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-top: 28px;
  flex-wrap: wrap;
}
.pagination button {
  font-family: var(--sans);
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 12px;
  min-width: 36px;
  cursor: pointer;
  transition: background 120ms, color 120ms, border-color 120ms;
}
.pagination button:hover:not(:disabled):not([aria-current="page"]) {
  border-color: var(--border-strong);
  background: var(--surface-2);
}
.pagination button[aria-current="page"] {
  background: var(--text);
  color: var(--surface);
  border-color: var(--text);
  cursor: default;
}
.pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.pagination .ellipsis {
  color: var(--text-muted);
  padding: 0 4px;
  font-family: var(--mono);
  font-size: 13px;
}
.page-size {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}
.page-size select {
  font-family: var(--sans);
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
}

/* ---------- explainer sections ---------- */

.explainer {
  border-top: 1px solid var(--border);
  padding: 56px 0;
}
.explainer h2 {
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0 0 16px;
}
.explainer p {
  color: var(--text-muted);
  font-size: 16px;
  max-width: 680px;
  margin: 0 0 16px;
}
.explainer ol,
.explainer ul {
  color: var(--text-muted);
  font-size: 15px;
  max-width: 680px;
  padding-left: 22px;
  line-height: 1.8;
}
.explainer code {
  font-family: var(--mono);
  font-size: 13px;
  background: var(--code-bg);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--text);
}
.explainer pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  overflow-x: auto;
  font-size: 13px;
  margin: 0 0 20px;
  color: var(--text);
}
.explainer pre code {
  background: none;
  padding: 0;
  white-space: pre;
}
.explainer .muted {
  color: var(--text-muted);
  font-size: 13px;
  font-style: italic;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 56px;
  align-items: start;
}

footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 24px 0;
  color: var(--text-muted);
  font-size: 13px;
}
footer .container {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: space-between;
}
footer a {
  border-bottom: none;
  color: var(--text-muted);
}
footer a:hover {
  color: var(--text);
}

/* ---------- responsive ---------- */

@media (max-width: 1100px) {
  .container { max-width: none; padding: 0 28px; }
}
@media (max-width: 900px) {
  .hero h1 { font-size: 46px; }
  .rule { gap: 18px; }
  .install { min-width: 240px; }
}
@media (max-width: 720px) {
  .container { padding: 0 24px; }
  .header-inner { padding: 14px 0; gap: 12px; }
  .header-nav { gap: 14px; font-size: 13px; flex-wrap: wrap; }
  .hero { padding: 48px 0 32px; }
  .hero h1 { font-size: 36px; }
  .hero .lede { font-size: 16px; }
  .rule {
    grid-template-columns: 1fr;
    padding: 18px;
    gap: 14px;
  }
  .rule-name { font-size: 18px; }
  .install { min-width: 0; }
  .split { grid-template-columns: 1fr; gap: 32px; }
  .explainer { padding: 40px 0; }
  .explainer h2 { font-size: 22px; }
  /* Long command samples in the explainer sections need to wrap on
   * narrow viewports — left as-is they overflow the viewport and force
   * a horizontal page scroll. */
  .explainer pre,
  .explainer pre code {
    white-space: pre-wrap;
    word-break: break-word;
  }
  .results-meta { font-size: 12px; }
  .results-controls { gap: 10px; }
  footer .container {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  .pagination button { padding: 7px 10px; min-width: 34px; }
}
@media (max-width: 460px) {
  .container { padding: 0 20px; }
  .hero h1 { font-size: 26px; letter-spacing: -0.01em; }
  .hero h1 em { font-style: italic; }
  .header-nav a:not(:last-child) { display: none; }
  .filters { gap: 6px; }
  .filters label { padding: 5px 9px; }

  /* Compact rule cards on phone: hide the long description and the
   * meta row so each card is just title / id / severity / install
   * command. The full README is one tap away on the GitHub repo. */
  .rule-desc,
  .rule-meta {
    display: none;
  }
  .rule { padding: 16px; gap: 10px; }
  .rule-id { margin-bottom: 6px; }
  .cmd-row code {
    font-size: 11.5px;
    padding: 8px 10px;
  }
  .copy-btn { width: 32px; }

  /* Hero copy is a bit long — let the lede shrink so search bar is
   * still above the fold on a 4.7" viewport. */
  .hero { padding: 36px 0 24px; }
  .hero .lede { font-size: 14.5px; line-height: 1.5; }

  /* Section command samples can be tiny in landscape phone — keep the
   * text usable. */
  .explainer pre { padding: 12px 14px; font-size: 12px; }
  .explainer h2 { font-size: 20px; }
  .explainer p,
  .explainer ol { font-size: 14px; }
}
