/* =========================================================================
   FILE: plugins-styles.css
   PURPOSE: Plugin listing and readme pages.
   AUTHOR: Jack Ewers / bloodweb.net

   Everything here is built on the --bw-* tokens in shared/assets/styles.css.
   The previous version hardcoded white cards and #2c3e50 text, which is why
   the listing sat as a bright block in the middle of a dark site and ignored
   the theme toggle entirely.
   ========================================================================= */

.plugins-section {
  max-width: var(--bw-container);
  margin: 0 auto 56px;
  padding: 0 16px;
}

.plugins-hero p {
  max-width: 62ch;
}

.plugins-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--bw-line);
}

.plugins-header h2 {
  margin: 0;
  font-size: 24px;
}

/* ── Spotlight ─────────────────────────────────────────────────────────── */

.plugins-spotlight-section {
  margin-bottom: 48px;
}

.plugin-spotlight {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 0;
  background: linear-gradient(180deg, var(--bw-surface), var(--bw-elev));
  border: 1px solid var(--bw-line);
  border-radius: var(--bw-radius-lg);
  overflow: hidden;
  box-shadow: 0 18px 56px rgba(0, 0, 0, .35);
}

.plugin-spotlight.is-local {
  border-color: rgba(124, 58, 237, .45);
}

.spotlight-media {
  display: flex;
  min-height: 260px;
  background: var(--bw-muted-bg);
}

/* The card image is a 3.2:1 banner. Letting it fill a tall panel would crop
   the title out, so it sits at its own ratio and centres in the column. */
.spotlight-media img {
  width: 100%;
  object-fit: cover;
  display: block;
}

.spotlight-body {
  padding: 32px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
}

.spotlight-body h3 {
  margin: 0;
  font-size: 30px;
  line-height: 1.2;
}

.spotlight-desc {
  margin: 0;
  color: var(--bw-subtle);
  font-size: 17px;
  line-height: 1.6;
}

/* ── Grid ──────────────────────────────────────────────────────────────── */

.plugins-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
}

/* The card shell, owned here rather than inherited from .bw-card. That shared
   class paints every descendant anchor as a gradient button, which put pills
   over the artwork and over each heading. */
.plugin-card {
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--bw-surface), var(--bw-elev));
  border: 1px solid var(--bw-line);
  border-radius: var(--bw-radius-lg);
  overflow: hidden;
  box-shadow: 0 14px 44px rgba(0, 0, 0, .35);
  transition: transform var(--bw-slow), box-shadow var(--bw-slow), border-color var(--bw-fast);
}

.plugin-card:hover {
  transform: translateY(-2px);
  border-color: rgba(124, 58, 237, .35);
  box-shadow: 0 18px 56px rgba(0, 0, 0, .45);
}

.plugin-card.is-local {
  border-color: rgba(124, 58, 237, .45);
}

.plugin-image {
  display: block;
  overflow: hidden;
  background: var(--bw-muted-bg);
  border-bottom: 1px solid var(--bw-line);
}

/* The ratio belongs on the image, not the wrapper. On the wrapper it loses:
   a replaced child with height:100% against an auto-height parent falls back
   to its own intrinsic height, so a 640x414 card came out 80px taller than a
   1280x400 one sitting beside it. */
.plugin-image img {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 7;
  object-fit: cover;
  display: block;
}

.plugin-content {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.plugin-content h3 {
  margin: 0;
  font-size: var(--bw-h3);
  line-height: 1.3;
}

.plugin-content h3 a,
.spotlight-body h3 a {
  color: var(--bw-text);
  text-decoration: none;
}

.plugin-content h3 a:hover,
.spotlight-body h3 a:hover {
  color: var(--bw-accent-2);
}

.plugin-content > p {
  margin: 0;
  color: var(--bw-subtle);
  line-height: 1.6;
  font-size: 15px;
}

/* ── Tags and flags ────────────────────────────────────────────────────── */

.plugin-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
  padding-top: 4px;
}

.plugin-category,
.plugin-version,
.plugin-updated {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .2px;
  border: 1px solid var(--bw-line);
  background: var(--bw-muted-bg);
  color: var(--bw-subtle);
}

.plugin-category {
  border-color: rgba(34, 211, 238, .35);
  color: var(--bw-accent-3);
}

.plugin-version {
  border-color: rgba(217, 70, 239, .35);
  color: var(--bw-accent-2);
}

.plugin-flag {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--bw-accent-2);
}

.plugin-flag::before {
  content: "\2605";
  margin-right: 6px;
}

/* ── Actions ───────────────────────────────────────────────────────────── */

.plugin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 6px;
}

.plugin-actions .bw-btn {
  padding: 9px 18px;
  font-size: 14px;
}

.bw-btn-ghost {
  background: transparent;
  color: var(--bw-subtle);
  border-color: var(--bw-line);
  text-decoration: none;
  display: inline-block;
  border-radius: var(--bw-radius-md);
  font-weight: 600;
  transition: all var(--bw-fast);
}

.bw-btn-ghost:hover {
  color: var(--bw-text);
  border-color: var(--bw-accent);
  background: var(--bw-muted-bg);
}

/* ── Category filter ───────────────────────────────────────────────────── */

.category-filter {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 7px 16px;
  border: 1px solid var(--bw-line);
  background: var(--bw-muted-bg);
  color: var(--bw-subtle);
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  transition: all var(--bw-fast);
}

.filter-btn:hover {
  color: var(--bw-text);
  border-color: var(--bw-accent);
}

.filter-btn.is-active {
  background: linear-gradient(90deg, var(--bw-accent), var(--bw-accent-2));
  border-color: transparent;
  color: #fff;
}

.plugins-empty {
  color: var(--bw-subtle);
  padding: 32px 0;
  text-align: center;
}

/* ── CTA ───────────────────────────────────────────────────────────────── */

.cta-section {
  max-width: var(--bw-container);
  margin: 0 auto 64px;
  background: linear-gradient(135deg, var(--bw-accent), var(--bw-accent-2));
  color: #fff;
  padding: 48px 32px;
  border-radius: var(--bw-radius-lg);
  text-align: center;
}

.cta-section h2 {
  margin: 0 0 12px;
  font-size: 30px;
}

.cta-section p {
  margin: 0 auto 26px;
  font-size: 17px;
  opacity: .92;
  max-width: 62ch;
}

.cta-button {
  display: inline-block;
  padding: 14px 30px;
  background: #fff;
  color: var(--bw-accent);
  text-decoration: none;
  border-radius: 999px;
  font-weight: 700;
  transition: transform var(--bw-fast), box-shadow var(--bw-fast);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
}

.cta-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 26px rgba(0, 0, 0, .35);
}

/* ── Readme page ───────────────────────────────────────────────────────── */

.readme-main {
  max-width: var(--bw-container);
  margin: 0 auto;
  padding: 24px 16px 64px;
}

.readme-crumbs {
  font-size: 14px;
  color: var(--bw-subtle);
  margin-bottom: 18px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.readme-crumbs a {
  color: var(--bw-subtle);
  text-decoration: none;
}

.readme-crumbs a:hover {
  color: var(--bw-accent-2);
}

.readme-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  flex-wrap: wrap;
  padding-bottom: 22px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--bw-line);
}

.readme-head h1 {
  margin: 0 0 8px;
  font-size: 34px;
}

.readme-sub {
  margin: 0 0 12px;
  color: var(--bw-subtle);
  max-width: 68ch;
}

.readme-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.readme-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 44px;
  align-items: start;
}

.readme-layout:only-child,
.readme-layout > .readme-body:only-child {
  grid-column: 1 / -1;
}

.readme-toc {
  position: sticky;
  top: 90px;
  font-size: 14px;
}

.readme-toc h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--bw-subtle);
  margin: 0 0 10px;
}

.readme-toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--bw-line);
}

.readme-toc li a {
  display: block;
  padding: 6px 12px;
  color: var(--bw-subtle);
  text-decoration: none;
  border-left: 2px solid transparent;
  margin-left: -1px;
}

.readme-toc li a:hover {
  color: var(--bw-text);
  border-left-color: var(--bw-accent);
}

/* ── Rendered markdown ─────────────────────────────────────────────────── */

.readme-body {
  min-width: 0;
  line-height: 1.7;
}

.readme-body h1,
.readme-body h2,
.readme-body h3,
.readme-body h4 {
  line-height: 1.3;
  scroll-margin-top: 90px;
}

.readme-body h1 { font-size: 30px; margin: 40px 0 14px; }
.readme-body h2 {
  font-size: 23px;
  margin: 40px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--bw-line);
}
.readme-body h3 { font-size: 18px; margin: 28px 0 10px; }
.readme-body h4 { font-size: 16px; margin: 22px 0 8px; color: var(--bw-subtle); }

.readme-body > :first-child { margin-top: 0; }

.readme-body p,
.readme-body li {
  color: var(--bw-subtle);
}

.readme-body strong {
  color: var(--bw-text);
  font-weight: 700;
}

.readme-body ul {
  padding-left: 22px;
  margin: 12px 0;
}

.readme-body li {
  margin: 7px 0;
}

.readme-body ul.ord {
  list-style: none;
  padding-left: 0;
}

.readme-body ul.ord .num {
  color: var(--bw-accent-2);
  font-weight: 700;
  margin-right: 8px;
}

/* An indented bullet under a numbered step. The list model is flat, so the
   indent and marker are drawn rather than nested. */
.readme-body li.sub {
  padding-left: 30px;
  position: relative;
  margin: 4px 0;
}

.readme-body li.sub::before {
  content: "";
  position: absolute;
  left: 14px;
  top: .72em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--bw-line);
  box-shadow: 0 0 0 1px var(--bw-subtle) inset;
}

.readme-body ul:not(.ord) li.sub {
  padding-left: 18px;
}

.readme-body a {
  color: var(--bw-accent-2);
}

.readme-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .89em;
  background: var(--bw-muted-bg);
  border: 1px solid var(--bw-line);
  border-radius: 5px;
  padding: 1px 6px;
  color: var(--bw-text);
}

.readme-body .code {
  position: relative;
  margin: 18px 0;
}

.readme-body .code pre {
  margin: 0;
  overflow-x: auto;
  background: var(--bw-bg);
  border: 1px solid var(--bw-line);
  border-radius: var(--bw-radius-md);
  padding: 16px 18px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--bw-text);
}

.readme-body .code .copy {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--bw-subtle);
  background: var(--bw-surface);
  border: 1px solid var(--bw-line);
  border-radius: 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--bw-fast);
}

.readme-body .code:hover .copy,
.readme-body .code .copy:focus {
  opacity: 1;
}

.readme-body blockquote {
  margin: 16px 0;
  padding: 10px 18px;
  border-left: 3px solid var(--bw-accent);
  background: var(--bw-muted-bg);
  border-radius: 0 var(--bw-radius-sm) var(--bw-radius-sm) 0;
  color: var(--bw-subtle);
}

.readme-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0;
  font-size: 15px;
  display: block;
  overflow-x: auto;
}

.readme-body th,
.readme-body td {
  border: 1px solid var(--bw-line);
  padding: 9px 12px;
  text-align: left;
}

.readme-body th {
  background: var(--bw-muted-bg);
  color: var(--bw-text);
}

.readme-body hr {
  border: 0;
  border-top: 1px solid var(--bw-line);
  margin: 34px 0;
}

/* ── Responsive ────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .plugin-spotlight {
    grid-template-columns: 1fr;
  }

  .spotlight-media {
    min-height: 0;
  }

  .spotlight-media img {
    max-height: 200px;
  }

  .spotlight-body {
    padding: 24px;
  }

  .spotlight-body h3 {
    font-size: 24px;
  }

  .readme-layout {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .readme-toc {
    position: static;
  }
}

@media (max-width: 560px) {
  .plugins-grid {
    grid-template-columns: 1fr;
  }

  .plugins-header {
    align-items: flex-start;
  }

  .plugin-actions .bw-btn {
    flex: 1 1 auto;
    text-align: center;
  }

  .cta-section {
    padding: 32px 20px;
  }

  .readme-head h1 {
    font-size: 26px;
  }
}
