/* ============================================================
   User Stories — card wall
   Scoped entirely under .stories-* so it never leaks into
   other docs pages. Tuned for the ayu (dark) theme but degrades
   gracefully on light themes via var() fallbacks.
   ============================================================ */

.stories-wrap {
  --mono: var(--mono, "Source Code Pro", ui-monospace, SFMono-Regular, Menlo, monospace);
  margin: 1.5rem 0 3rem;
}

/* ---- intro strip ------------------------------------------------ */
.stories-lede {
  max-width: 62ch;
  font-size: 1.06rem;
  line-height: 1.7;
  color: var(--fg);
}

.stories-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.6rem;
  margin: 1.4rem 0 0.4rem;
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--table-border-color, rgba(255, 255, 255, 0.1));
  border-left: 3px solid var(--links, #0096cf);
  border-radius: 8px;
  background: var(--theme-popup-bg, rgba(255, 255, 255, 0.03));
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
}
.stories-stats b {
  color: var(--links, #0096cf);
  font-weight: 700;
}
.stories-stats span {
  color: var(--fg);
  opacity: 0.85;
}

/* ---- filter pills (Hermes-style) --------------------------------- */
.stories-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1.6rem 0 0.2rem;
}
.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.42rem 1.05rem;
  border: 1px solid var(--table-border-color, rgba(255, 255, 255, 0.16));
  border-radius: 999px;
  background: transparent;
  color: var(--fg);
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.filter-pill b {
  font-size: 0.72rem;
  font-weight: 700;
  opacity: 0.6;
}
.filter-pill:hover {
  border-color: var(--links, #0096cf);
  color: var(--links, #0096cf);
  transform: translateY(-1px);
}
.filter-pill.active {
  background: var(--links, #0096cf);
  border-color: var(--links, #0096cf);
  color: var(--bg, #0f1419);
}
.filter-pill.active b { opacity: 0.85; }
.story-card.is-hidden { display: none; }

/* ---- the wall --------------------------------------------------- */
.stories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 1.3rem;
  margin-top: 2rem;
}

/* each card is a native <details> — click to expand the breakdown */
.story-card {
  --sc: var(--links, #0096cf);           /* per-card accent, set inline */
  position: relative;
  background: var(--theme-popup-bg, #14191f);
  border: 1px solid var(--table-border-color, rgba(255, 255, 255, 0.09));
  border-top: 3px solid var(--sc);
  border-radius: 10px;
  overflow: hidden;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  animation: story-rise 0.5s ease both;
}
.story-card:nth-child(1) { animation-delay: 0.02s; }
.story-card:nth-child(2) { animation-delay: 0.08s; }
.story-card:nth-child(3) { animation-delay: 0.14s; }
.story-card:nth-child(4) { animation-delay: 0.20s; }
.story-card:nth-child(5) { animation-delay: 0.26s; }
.story-card:nth-child(6) { animation-delay: 0.32s; }
@keyframes story-rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.story-card:hover {
  transform: translateY(-4px);
  border-color: var(--sc);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45), 0 0 0 1px var(--sc);
}
.story-card[open] {
  border-color: var(--sc);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

/* featured card spans the full row on wide screens */
@media (min-width: 900px) {
  .story-card.featured { grid-column: span 2; }
}

/* ---- card face (the <summary>) ---------------------------------- */
.story-card summary {
  list-style: none;
  cursor: pointer;
  padding: 1.15rem 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  height: 100%;
}
.story-card summary::-webkit-details-marker { display: none; }
.story-card summary::marker { content: ""; }

.story-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
.story-source {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--fg);
  opacity: 0.9;
}
.story-source .dot {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--sc);
  box-shadow: 0 0 8px var(--sc);
  flex: none;
}
.story-cat {
  color: var(--sc);
  border: 1px solid var(--sc);
  border-radius: 999px;
  padding: 0.14rem 0.6rem;
  white-space: nowrap;
}

.story-title {
  margin: 0;
  font-size: 1.28rem;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--fg);
}
.story-card:hover .story-title { color: var(--sc); }

.story-excerpt {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--fg);
  opacity: 0.82;
}

.story-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding-top: 0.5rem;
  font-family: var(--mono);
  font-size: 0.74rem;
}
.story-author { color: var(--links, #0096cf); font-weight: 600; }
.story-more {
  color: var(--fg);
  opacity: 0.6;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: opacity 0.18s ease;
}
.story-card:hover .story-more { opacity: 1; color: var(--sc); }
.story-more .chev {
  display: inline-block;
  transition: transform 0.22s ease;
}
.story-card[open] .story-more .chev { transform: rotate(90deg); }
.story-card[open] .story-more .label::after { content: ""; }

/* ---- expanded breakdown ----------------------------------------- */
.story-body {
  border-top: 1px dashed var(--table-border-color, rgba(255, 255, 255, 0.12));
  padding: 1.1rem 1.25rem 1.3rem;
  background: color-mix(in srgb, var(--sc) 4%, transparent);
  animation: story-body-in 0.28s ease both;
}
@keyframes story-body-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.story-body blockquote {
  margin: 0 0 1rem;
  padding: 0.7rem 1rem;
  border-left: 3px solid var(--sc);
  background: var(--quote-bg, rgba(255, 255, 255, 0.03));
  border-radius: 0 8px 8px 0;
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--fg);
}
.story-body blockquote p { margin: 0.35rem 0; }
.story-body > p { font-size: 0.92rem; line-height: 1.65; }
.story-body ul { margin: 0.4rem 0 0.9rem; font-size: 0.92rem; line-height: 1.6; }
.story-body strong { color: var(--sc); }

.story-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.4rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--sc);
  border-radius: 8px;
  color: var(--sc);
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-decoration: none;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}
.story-link:hover {
  background: var(--sc);
  color: var(--bg, #0f1419);
  transform: translateX(3px);
  text-decoration: none;
}

/* ---- share CTA --------------------------------------------------- */
.stories-share {
  margin-top: 2.6rem;
  padding: 1.6rem 1.5rem;
  border: 1px dashed var(--table-border-color, rgba(255, 255, 255, 0.18));
  border-radius: 12px;
  background: var(--theme-popup-bg, rgba(255, 255, 255, 0.02));
  text-align: center;
}
.stories-share h2 {
  margin: 0 0 0.5rem;
  font-size: 1.35rem;
  border: none;
}
.stories-share p { margin: 0.3rem auto 1rem; max-width: 52ch; }
.stories-share .share-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  justify-content: center;
}
.stories-share .share-row a {
  padding: 0.5rem 1.1rem;
  border: 1px solid var(--links, #0096cf);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}
.stories-share .share-row a:hover {
  background: var(--links, #0096cf);
  color: var(--bg, #0f1419);
  transform: translateY(-2px);
  text-decoration: none;
}
