/* ============================================
   FitForgeFlow — Blog Hub Styles
   ============================================ */

.blog-header {
  padding-top: var(--space-xl);
  padding-bottom: var(--space-md);
}

.blog-mark-wrap {
  max-width: 320px;
  margin: 0 auto var(--space-sm);
}

.blog-mark {
  width: 100%;
  height: auto;
  display: block;
}

.blog-header-lede {
  max-width: 580px;
  margin: var(--space-sm) auto 0;
}

/* Blog landing sections sit closer together than the site default, and each
   transition gets a faint radial glow instead of empty dark space. Scoped
   under .blog-featured/.blog-browse/.blog-latest so nothing else on the
   site is affected. */
.blog-featured,
.blog-browse,
.blog-latest {
  padding: var(--space-lg) 0;
  position: relative;
}

/* Keeps the category-result heading clear of the sticky site header when a
   category link scrolls this section into view on load. */
.blog-latest { scroll-margin-top: 90px; }

.blog-browse::before,
.blog-latest::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: min(900px, 90%);
  height: 1px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, transparent, var(--color-border), transparent);
}

.blog-browse {
  background: radial-gradient(ellipse at 50% 0%, rgba(0, 168, 255, 0.05), transparent 60%);
}

/* ============ Utility ============ */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ============ Smart search (Content Library) ============ */

.blog-search-section { padding: 0 0 var(--space-lg); }

.blog-search-form {
  max-width: 640px;
  margin: 0 auto;
}

.blog-search-field {
  position: relative;
  display: flex;
  align-items: center;
}

.blog-search-icon {
  position: absolute;
  left: 1.1rem;
  width: 20px;
  height: 20px;
  color: var(--color-text-faint);
  pointer-events: none;
}

.blog-search-input {
  width: 100%;
  height: 56px;
  padding: 0 3rem 0 3rem;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 1.02rem;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.blog-search-input::placeholder { color: var(--color-text-faint); }

/* Suppress the browser's own native search-cancel icon (Chrome/Safari add
   one automatically to type="search" inputs) so only our single, custom,
   keyboard-accessible #blogSearchClear button shows -- otherwise the two
   render stacked on top of each other. */
.blog-search-input::-webkit-search-cancel-button,
.blog-search-input::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

.blog-search-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(0, 200, 180, 0.18);
}

.blog-search-clear {
  position: absolute;
  right: 0.6rem;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--color-text-dim);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.blog-search-clear:hover,
.blog-search-clear:focus-visible {
  background: var(--color-surface-raised);
  color: var(--color-text);
  outline: none;
}

/* Without this, the class's own `display: flex` (same specificity as the
   browser's default `[hidden] { display: none }`, but declared later)
   would win the cascade and show the button even while `hidden` is set. */
.blog-search-clear[hidden] { display: none; }

.blog-search-results { scroll-margin-top: 90px; }

.blog-search-suggestions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
  margin-top: var(--space-sm);
}

/* ============ Category tag (shown on cards + article headers) ============ */

.category-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: rgba(0, 200, 180, 0.15);
  color: var(--color-accent);
  text-decoration: none;
}

.category-tag:hover { background: rgba(0, 200, 180, 0.25); }

/* ============ Browse Articles ============ */

.browse-top-row {
  display: flex;
  justify-content: center;
  margin-bottom: var(--space-md);
}

.browse-all-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.75rem 1.75rem;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 800;
  text-decoration: none;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.browse-all-btn:hover { border-color: var(--color-accent); color: var(--color-text); }

.browse-all-btn-active {
  background: var(--gradient-brand);
  border-color: transparent;
  color: #051018;
}

.browse-groups {
  display: grid;
  /* auto-fit rather than a hardcoded column count -- five subject groups
     wrap cleanly at any width without a bespoke breakpoint per group count. */
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.browse-group {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.1rem 1.25rem;
}

.browse-group-summary {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  list-style: none;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--color-text);
  padding: 0.2rem 0;
  margin-bottom: 0.85rem;
}

.browse-group-summary::-webkit-details-marker { display: none; }

.browse-group-summary:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

.browse-group-accent {
  flex-shrink: 0;
  width: 22px;
  height: 3px;
  border-radius: 999px;
  background: var(--gradient-brand);
}

/* A small rotating chevron gives the summary a disclosure affordance
   without adding any script or library. */
.browse-group-summary::after {
  content: "";
  width: 8px;
  height: 8px;
  margin-left: auto;
  border-right: 2px solid var(--color-text-faint);
  border-bottom: 2px solid var(--color-text-faint);
  transform: rotate(45deg);
  transition: transform 0.15s ease;
}

.browse-group[open] > .browse-group-summary::after { transform: rotate(-135deg); }

.browse-group-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.browse-pill {
  display: inline-block;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--color-text-dim);
  text-decoration: none;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.browse-pill:hover { border-color: var(--color-accent); color: var(--color-text); }

.browse-pill:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.browse-pill-active {
  background: var(--gradient-brand);
  border-color: transparent;
  color: #051018;
}

/* ============ Post grid (Latest Articles) ============ */

.blog-post-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-lg);
}

.blog-post-card {
  display: block;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  text-decoration: none;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.blog-post-card:hover {
  border-color: var(--color-accent);
  transform: translateY(-2px);
}

/* The image lives in a ratio-locked wrapper rather than carrying width/height
   attributes itself, so the HTML width/height attributes (needed to avoid a
   layout-shift before the image loads) can never fight the intended 3:2
   card shape the way a bare <img aspect-ratio> rule can. */
.blog-post-card-media { width: 100%; aspect-ratio: 3 / 2; overflow: hidden; }
.blog-post-card-media img { display: block; width: 100%; height: 100%; object-fit: cover; }
.blog-post-card-body { padding: var(--space-lg); }

.blog-post-card h3 {
  color: var(--color-text);
  font-size: 1.1rem;
  margin: 0.6rem 0 0.5rem;
}

.blog-post-card p {
  color: var(--color-text-dim);
  font-size: 0.92rem;
  margin: 0 0 0.8rem;
}

.blog-post-card-meta {
  display: flex;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--color-text-faint);
  margin-bottom: 0.7rem;
}

.post-read-more {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--color-accent);
}

.blog-empty-state {
  text-align: center;
  padding: var(--space-xl) 0;
  color: var(--color-text-dim);
}

.blog-empty-state a {
  color: var(--color-accent);
  font-weight: 600;
}

/* ============ Featured Articles ============ */

.blog-featured-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1.25rem;
}

.blog-featured-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  color: var(--color-text);
  text-decoration: none;
  transition: transform .15s ease, border-color .15s ease;
}

.blog-featured-card:hover { transform: translateY(-2px); border-color: var(--color-accent); }

/* Same ratio-locked-wrapper fix as the post grid: the image fills the
   wrapper with object-fit: cover, and per-card object-position (set inline
   from js/blog-index.js's FEATURED_FOCUS map) points the crop at the actual
   subject in each photo instead of a blanket center-center. */
.blog-featured-card-media { width: 100%; aspect-ratio: 3 / 2; overflow: hidden; }
.blog-featured-card-media img { display: block; width: 100%; height: 100%; object-fit: cover; }

.blog-featured-card-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.5rem;
  padding: 1.1rem 1rem 1.25rem;
  flex: 1;
}

.blog-featured-card-body .category-tag { margin: 0; }

.blog-featured-card-body h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.35;
}

.blog-featured-card-body .post-read-more {
  margin-top: auto;
  padding-top: 0.5rem;
}

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

/* Mid desktop / small laptop: five columns get cramped, so the five cards
   flow as a centered "3 + 2" instead of squeezing into five thin columns. */
@media (max-width: 1280px) {
  .blog-featured-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
  }
  .blog-featured-card { flex: 0 1 calc(33.333% - 0.84rem); min-width: 200px; }
}

@media (max-width: 860px) {
  .blog-post-grid { grid-template-columns: 1fr; }

  .blog-featured-grid { flex-wrap: wrap; }
  .blog-featured-card { flex: 0 1 calc(50% - 0.625rem); min-width: 160px; }

  /* Hard floor at phone/tablet widths: auto-fit alone would still be free
     to show two narrow columns here, but a guaranteed single column reads
     far more cleanly at this width, with no horizontal scrolling ever. */
  .browse-groups { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .blog-featured-card { flex: 1 1 100%; }
}
