/* Tags Page — Faceted Browse Layout */

#tags-page {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 3rem;
  padding: 1rem 0;
  min-height: 70vh;
}

/* Override default link underlines inside tags page */
#static #tags-page a {
  text-decoration: none;
}

.sidebar-home {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0 0.75rem;
  margin-bottom: 0.5rem;
  display: block;
}
.sidebar-home:hover {
  color: var(--text);
}

/* ── Sidebar ── */
.tags-sidebar {
  position: sticky;
  top: 2rem;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
}

/* ── Facet Groups ── */
.facet-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 0.5rem;
}

.facet-group:last-child {
  margin-bottom: 0;
}

.facet-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: orange;
  padding: 0 0.75rem;
  margin-bottom: 0.15rem;
}

/* ── Tag Buttons ── */
.tag-tab {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.75rem;
  border: none;
  background: none;
  font: inherit;
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  border-radius: 4px;
  z-index: 0;
}

.tag-tab::before {
  content: '';
  position: absolute;
  inset: 0;
  width: var(--fill, 0%);
  background: var(--bg-soft);
  border-radius: 4px;
  z-index: -1;
  transition: width 0.2s ease;
}

.tag-tab:hover {
  background: var(--bg-soft);
}

.tag-tab.active {
  font-weight: 600;
  background: var(--text);
  color: var(--bg);
}

.tag-tab.active::before {
  display: none;
}

.tag-tab .tag-count {
  margin-left: auto;
  font-size: 0.8rem;
  opacity: 0.6;
}

.tag-tab.active .tag-count {
  opacity: 0.8;
}

/* ── Panels ── */
.tags-panels {
  min-width: 0;
}

/* ── Search ── */
.tags-search {
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 11;
  padding: 0.5rem 0;
}

.tags-search input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-soft);
  color: var(--text);
  outline: none;
  box-sizing: border-box;
}

.tags-search input:focus {
  border-color: var(--text-muted);
}

.breadcrumb-bar {
  position: sticky;
  top: 2.75rem;
  background: var(--bg);
  z-index: 10;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.5rem 0;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid transparent;
}
.breadcrumb-bar.has-crumbs {
  border-bottom-color: var(--border);
}

.crumb {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.5rem;
  font: inherit;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text);
  cursor: pointer;
}
.crumb:hover {
  background: var(--text);
  color: var(--bg);
}

.result-count {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-left: auto;
}

.panel-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
}

.tag-posts {
  list-style: none;
  padding: 0;
  margin: 0;
}

.tag-post {
  border-bottom: 1px solid var(--border);
}

.tag-post:last-child {
  border-bottom: none;
}

.tag-post a {
  display: block;
  padding: 1rem 0;
  color: inherit;
  transition: opacity 0.15s ease;
}

.tag-post a:hover {
  opacity: 0.7;
}

.post-title {
  display: block;
  font-size: 1.15rem;
  font-weight: 500;
}

/* ── Rich Card Layout ── */
.tag-post .sentiment-strip {
  height: 4px;
  width: 100%;
  border-radius: 2px 2px 0 0;
  margin-bottom: 0.5rem;
}

.tag-post-body {
  display: flex;
  gap: 1rem;
}

.tag-post-thumb {
  width: 160px;
  height: 120px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
  order: 1;
}

.tag-post-info {
  flex: 1;
  min-width: 0;
}

.tag-post .subtext {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.2rem;
}

.tag-post .card-pills {
  margin: 0.3rem 0;
}

.post-description {
  display: block;
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  line-height: 1.4;
}

/* ── No-JS Fallback ── */
noscript .tag-panel {
  display: block;
  margin-bottom: 2rem;
}

/* ── Mobile (<768px) ── */
@media (max-width: 768px) {
  #tags-page {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    padding: 1rem 0;
  }

  .tags-sidebar {
    position: static;
    flex-direction: column;
    overflow-y: visible;
    max-height: none;
    gap: 0.75rem;
  }

  .facet-group {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 0.5rem;
    padding-bottom: 0.25rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin-bottom: 0;
    flex-wrap: nowrap;
  }

  .facet-group::-webkit-scrollbar {
    display: none;
  }

  .facet-label {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    margin-bottom: 0;
    padding: 0;
    font-size: 0.65rem;
  }

  .tag-tab {
    flex-shrink: 0;
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    border-radius: 999px;
    white-space: nowrap;
    border: 1px solid var(--border);
  }

  /* Hide fill bars on mobile */
  .tag-tab::before {
    display: none;
  }

  .tag-tab.active {
    border-color: var(--text);
  }

  .tag-post-thumb {
    display: none;
  }

  .panel-title {
    font-size: 1.3rem;
    margin-bottom: 1rem;
  }
}
