/* Page-specific styles (search + home/listings polish). Loaded after site.css so these rules win.
   Owned by the search designer agent. Use the site CSS variables; do not hardcode colors. */

/* ============================================================
   Shared card / interactive polish (cards, rows, results)
   ============================================================ */

.grid {
  gap: 1rem;
}

.card,
.result,
.row,
.format-item {
  border-radius: 0.5rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.card:hover,
.card:focus-visible,
.result:hover,
.result:focus-within,
.row:hover,
.row:focus-visible,
.format-item:hover,
.format-item:focus-visible {
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.card:focus-visible,
.row:focus-visible,
.format-item:focus-visible {
  outline: none;
  box-shadow: 0 0 0 0.18rem var(--focus-ring), var(--shadow);
}

/* Listing cards: consistent title + clamped summary for even, scannable rows. */
.grid .card {
  display: flex;
  flex-direction: column;
  padding: 1.1rem 1.15rem;
}

.card strong {
  font-size: 1.06rem;
  font-weight: 700;
  line-height: 1.28;
}

.grid .card span {
  margin-top: 0.45rem;
  font-size: 0.98rem;
  line-height: 1.5;
}

/* Clamp long summaries so a single verbose card can't blow out a row. */
.grid .card > span:not(.card-tags) {
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ============================================================
   Home: hero + "Explore by format" list
   ============================================================ */

.lede {
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
}

.home-search {
  margin-top: 2rem;
}

.home-search input[type="search"] {
  min-height: 3rem;
}

.quick-actions {
  margin-top: 1.1rem;
}

/* "Explore by format" — group title + description together on the left,
   with a chevron affordance on the right (replaces the disconnected
   space-between .row layout). */
.format-list {
  display: grid;
  gap: 0.65rem;
  margin: 1.25rem 0 0;
}

.format-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--line);
  background: var(--panel);
}

.format-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.format-text strong {
  color: var(--heading);
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.25;
}

.format-text span {
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.4;
}

.format-arrow {
  flex-shrink: 0;
  margin-left: auto;
  color: var(--muted);
  font-size: 1.35rem;
  line-height: 1;
  transform: translateX(-2px);
  transition: transform 0.15s ease, color 0.15s ease;
}

.format-item:hover .format-arrow,
.format-item:focus-visible .format-arrow {
  color: var(--link);
  transform: translateX(2px);
}

/* ============================================================
   Special Pages: tag filter + tag pills
   ============================================================ */

.tag-filter {
  justify-content: center;
  margin: 1.5rem 0 0.75rem;
}

.tag-btn {
  min-height: 0;
  padding: 0.4rem 1rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
}

.tag-btn:hover {
  background: var(--btn-secondary-bg-hover);
}

.tag-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--btn-fg);
}

html.dark .tag-btn.active {
  color: var(--bg);
}

.filter-count {
  margin: 0 0 1.75rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-align: center;
  text-transform: uppercase;
}

.special-card {
  padding: 1.1rem 1.15rem;
}

.special-card .card-tags {
  margin-top: auto;
  padding-top: 0.7rem;
}

.special-card .card-tags em {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  font-weight: 700;
}

/* ============================================================
   Search page: panel, states, results
   ============================================================ */

.search-panel {
  margin-bottom: 0.5rem;
}

.search-panel input[type="search"] {
  min-height: 3rem;
}

#search-status {
  min-height: 1.25rem;
  margin-top: 1.25rem;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

#search-status[data-state="error"] {
  color: #c0392b;
}

html.dark #search-status[data-state="error"] {
  color: #ff9b8a;
}

.results {
  margin-top: 1rem;
}

.result {
  padding: 1.1rem 1.2rem;
}

.result h2 {
  font-size: 1.2rem;
  line-height: 1.3;
}

.result h2 a {
  color: var(--link);
  font-weight: 700;
}

.result-meta {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0.3rem 0 0.55rem;
  font-size: 0.85rem;
}

.result-badge {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.result-meta-text {
  color: var(--muted);
  font-weight: 700;
}

.result p {
  margin: 0;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.5;
}

.result mark,
.result h2 mark {
  padding: 0 0.1em;
  border-radius: 0.15rem;
  background: rgba(40, 167, 69, 0.18);
  color: inherit;
}

html.dark .result mark,
html.dark .result h2 mark {
  background: rgba(142, 216, 173, 0.22);
}

/* Empty state */
.search-empty {
  margin-top: 1.5rem;
  padding: 2.5rem 1.5rem;
  border: 1px dashed var(--line-strong);
  border-radius: 0.5rem;
  background: var(--panel-soft);
  text-align: center;
}

.search-empty strong {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--heading);
  font-family: "Raleway", "Segoe UI", system-ui, sans-serif;
  font-size: 1.25rem;
  font-weight: 500;
}

.search-empty span {
  color: var(--muted);
}

/* Loading skeletons */
.result.is-skeleton {
  pointer-events: none;
  transform: none;
}

.result.is-skeleton .sk {
  display: block;
  height: 0.85rem;
  border-radius: 0.3rem;
  background: linear-gradient(
    90deg,
    var(--panel-soft) 25%,
    var(--line) 37%,
    var(--panel-soft) 63%
  );
  background-size: 400% 100%;
  animation: sk-shimmer 1.3s ease infinite;
}

.result.is-skeleton .sk-title {
  width: 55%;
  height: 1.1rem;
  margin-bottom: 0.6rem;
}

.result.is-skeleton .sk-meta {
  width: 30%;
  margin-bottom: 0.85rem;
}

.result.is-skeleton .sk-line {
  margin-bottom: 0.5rem;
}

.result.is-skeleton .sk-line.short {
  width: 70%;
  margin-bottom: 0;
}

@keyframes sk-shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: 0 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .card,
  .result,
  .row,
  .format-item,
  .format-arrow {
    transition: none;
  }
  .card:hover,
  .result:hover,
  .row:hover,
  .format-item:hover {
    transform: none;
  }
  .result.is-skeleton .sk {
    animation: none;
  }
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 768px) {
  .format-item {
    padding: 0.9rem 1rem;
  }
  .format-arrow {
    display: none;
  }
  .tag-filter {
    justify-content: flex-start;
  }
}
