/* Showcase + Blog sections — homepage-only. Tokens/base come from panel.css;
   grid + .card base come from style.css (linked before this in index.html).
   .sec-head/.sec-sub and the media-card styles are shared by both sections. */

.showcase,
.blog { margin-top: 56px; }

/* Compact grid: more, smaller cards than the sites grid above it. */
.showcase .grid,
.blog .grid {
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 12px;
}

/* Collapsible section header — <summary> is the click target (native toggle,
   keyboard, ARIA). Default marker hidden; a chevron SVG rotates on open. */
.sec-head {
  display: block;
  margin: 0 -12px;        /* extend the hover band into main's 24px gutter */
  padding: 8px 12px;      /* band padding; margin cancels it → no content shift */
  cursor: pointer;
  list-style: none; /* Firefox: drop the default disclosure triangle */
  border-radius: 12px;
  transition: background 160ms ease;
}
.sec-head::-webkit-details-marker { display: none; } /* Chrome/Safari */
/* Hover lights up the whole header — signals it's the expand/collapse target. */
.sec-head:hover { background: var(--accent-soft); }
.sec-head:hover .chev,
.sec-head:hover .sec-title-row h2 { color: var(--accent); }
.sec-head:hover .sec-sub { color: var(--text); }
/* Closed + hover: nudge the chev toward "open" (rotate(90deg) wins once open). */
details:not([open]) > .sec-head:hover .chev { transform: translateX(3px); }

.sec-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sec-title-row h2 {
  margin: 0;
  font-size: clamp(1.4rem, 2.5vw, 1.8rem);
  letter-spacing: -0.02em;
  transition: color 160ms ease;
}
/* Item-count pill — populated by JS after the section's data loads. */
.sec-count {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.chev {
  width: 18px;
  height: 18px;
  margin-left: auto;
  color: var(--text-dim);
  flex: none;
  transition: transform 160ms ease, color 160ms ease;
}
details[open] > .sec-head .chev { transform: rotate(90deg); }

.sec-sub {
  margin: 6px 0 0;
  color: var(--text-dim);
  font-size: 0.95rem;
  line-height: 1.5;
  transition: color 160ms ease;
}

/* Body spacing + reveal only matter once expanded. */
.sec-body { margin-top: 16px; }
@keyframes sec-reveal {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}
/* No height-slide: animating auto height on a card grid is janky. Fade only. */
details[open] > .sec-body { animation: sec-reveal 160ms ease; }

/* Filter chips (Showcase only) */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 18px;
  padding: 0;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-dim);
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 120ms, color 120ms, background 120ms;
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip[aria-selected="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b0d12;
  font-weight: 600;
}
.chip-count { font-size: 0.7rem; opacity: 0.8; }

/* Media card variant — banner image + body. Shares .card base from style.css
   (border, radius, shadow, hover lift). Override padding/gap so image is flush. */
/* height:100% fills the stretched grid cell so every card in a row matches
   the tallest — equal card heights. .card-body flex:1 + .card-foot
   margin-top:auto then pin each card's foot to a common baseline. */
.card--media { padding: 0; gap: 0; overflow: hidden; height: 100%; }
.card-media {
  aspect-ratio: 16 / 10;
  width: 100%;
  overflow: hidden;
  background: var(--bg-elev);
}
.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 200ms ease;
}
/* Broken/missing banner image (remote Unsplash 404, etc.) — degrade to a soft
   branded wash instead of a torn-image icon. Applies to every media card. */
.card-media.is-noimg {
  background:
    radial-gradient(circle at 28% 32%, var(--accent-soft), transparent 62%),
    var(--bg-elev);
}
.card-media.is-noimg img { display: none; }
.card--media:hover .card-media img { transform: scale(1.04); }

.card-body {
  padding: 11px 13px 13px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.card--media .card-title {
  font-size: 0.9rem;
  margin: 0;
  line-height: 1.25;
  font-weight: 600;
  /* Exactly 2 lines every time: line-clamp caps overflow, min-height reserves
     the 2nd line for short titles → uniform card heights across the grid. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.5em; /* 2 × line-height */
}
.card-cat {
  flex: 0 0 auto;
  font-size: 0.64rem;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.card--media .card-tagline {
  font-size: 0.8rem;
  margin: 0;
  line-height: 1.4;
  color: var(--text-dim);
  flex: 1;
  /* Clamp to 2 lines so small cards stay uniform height. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.8em; /* 2 × line-height: reserve 2 lines for uniform height */
}
.card--media .card-foot {
  margin-top: auto;
  padding-top: 2px;
  font-size: 0.76rem;
  line-height: 1.4;
  color: var(--text-dim);
  /* Reserve 2 lines so a wrapping details label ("Open Source Projects") can't
     make one card taller than its neighbours — uniform heights. */
  min-height: 2.8em;
}
.card-cta { color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  .card--media:hover .card-media img { transform: none; }
  .card--media:hover { transform: none; }
  .chev { transition: none; }
  details[open] > .sec-body { animation: none; }
}

@media (max-width: 480px) {
  .showcase,
  .blog { margin-top: 40px; }
}
