/* ==========================================================================
   BLOG PAGE — SMART, POLISHED, THEME-AWARE
   Focus: category (radio) chips under the search bar with silky hover/active,
   zero “golden dot”, subtle scroll-fades, and accessible focus rings.
   Uses tokens from assets/css/styles.css (Luxury Silver × Gold × Yellow).
   ========================================================================== */

/* ---------- Local tokens (safe fallbacks) ---------- */
:root {
  --chip-bg: #fdfdfd;
  --chip-bd: var(--border, #e5e7ec);
  --chip-tx: var(--text, #0c0f14);
  --chip-muted: var(--muted, #646b78);

  /* Active/hover accents tuned for clarity on white */
  --chip-active-from: #d4a017;
  /* warm gold (brighter but not neon) */
  --chip-active-to: #f0c83a;
  /* soft highlight yellow */
  --chip-active-bd: #e0b646;
  --chip-ring: rgba(239, 210, 106, .30);

  /* Subtle shadows */
  --chip-shadow-hov: 0 6px 14px rgba(16, 24, 40, .08);
  --chip-shadow-act: 0 10px 22px rgba(212, 160, 23, .22);
}

/* =================== HERO =================== */
.blog-hero {
  padding-block: clamp(32px, 6vw, 64px);
  background:
    radial-gradient(1200px 300px at 10% -10%, rgba(239, 210, 106, .10), transparent 60%),
    radial-gradient(1200px 300px at 80% -10%, rgba(217, 221, 229, .35), transparent 60%),
    #fff;
  border-bottom: 1px solid var(--border);
}

.blog-hero h1 {
  margin: 0 0 .4rem;
}

.blog-hero .blog-filters {
  margin-top: clamp(12px, 1.6vw, 18px);
}

/* =================== FILTERS (search on top, categories below) =================== */
.blog-filters {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 860px) {
  .blog-filters {
    gap: 16px;
  }
}

/* ---------- Search ---------- */
.search {
  position: relative;
  width: 100%;
}

.search input {
  width: 100%;
  padding: 12px 42px 12px 14px;
  border: 2px solid var(--border);
  border-radius: 14px;
  font-size: 1rem;
  background: #fff;
  color: var(--text);
  transition:
    border-color .22s cubic-bezier(.22, .61, .36, 1),
    box-shadow .22s cubic-bezier(.22, .61, .36, 1),
    background-color .22s cubic-bezier(.22, .61, .36, 1);
}

.search input::placeholder {
  color: var(--muted);
}

.search input:focus,
.search input:focus-visible {
  outline: none;
  border-color: var(--accent-solid, #c19213);
  box-shadow: 0 0 0 3px var(--chip-ring);
  background: #fffdf5;
}

.search::after {
  content: "🔍";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1rem;
  color: var(--muted);
  pointer-events: none;
}

/* =================== CATEGORIES — RADIO CHIP GROUP ===================
   JS should inject: <input type="radio" id="x" name="cat"><label for="x">Label</label>
   inside <div class="tags" id="blogTagBar">…</div>
   ------------------------------------------------------------------- */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  min-height: 44px;

  /* graceful horizontal scroll on tiny screens */
  overflow-x: auto;
  padding: 2px 2px 6px 2px;
  scroll-snap-type: x proximity;

  /* Edge fade so the scroll feels polished (Safari/WebKit + others) */
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 14px, #000 calc(100% - 14px), transparent);
  mask-image: linear-gradient(90deg, transparent, #000 14px, #000 calc(100% - 14px), transparent);
}

/* Hide native radios; labels become interactive chips */
.tags input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* Base chip (no golden dot) */
.tags label {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  min-height: 40px;
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--chip-tx);
  border: 1px solid var(--chip-bd);
  font-weight: 700;
  letter-spacing: .1px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  scroll-snap-align: start;
  transition:
    background-color .22s cubic-bezier(.22, .61, .36, 1),
    border-color .22s cubic-bezier(.22, .61, .36, 1),
    color .22s cubic-bezier(.22, .61, .36, 1),
    box-shadow .22s cubic-bezier(.22, .61, .36, 1),
    transform .22s cubic-bezier(.22, .61, .36, 1),
    filter .22s cubic-bezier(.22, .61, .36, 1);
}

/* ensure any old pseudo accents are gone */
.tags label::before,
.tags label::after {
  display: none !important;
}

/* Hover */
.tags label:hover {
  background: #ffffff;
  border-color: var(--silver-300, #d9dde5);
  box-shadow: var(--chip-shadow-hov);
  transform: translateY(-1px);
}

/* Focus (keyboard) */
.tags input[type="radio"]:focus+label,
.tags label:focus-visible {
  outline: none;
  border-color: var(--accent-solid, #c19213);
  box-shadow: 0 0 0 3px var(--chip-ring);
}

/* Active / Checked — brighter luxury gradient with white text */
.tags input[type="radio"]:checked+label {
  background: linear-gradient(135deg, var(--chip-active-from), var(--chip-active-to));
  color: #ffffff;
  border-color: var(--chip-active-bd);
  box-shadow: var(--chip-shadow-act);
  transform: translateY(-1px);
}

/* Pressed feel */
.tags label:active {
  transform: translateY(0) scale(.99);
}

/* Optional tonal nudges via data-cat on the input (small hue shifts) */
.tags input[type="radio"][data-cat="lighting"]:checked+label {
  filter: hue-rotate(10deg) saturate(1.03);
}

.tags input[type="radio"][data-cat="materials"]:checked+label {
  filter: hue-rotate(-12deg) saturate(1.03);
}

.tags input[type="radio"][data-cat="workflow"]:checked+label {
  filter: hue-rotate(28deg) saturate(1.03);
}

.tags input[type="radio"][data-cat="rendering"]:checked+label {
  filter: hue-rotate(56deg) saturate(1.03);
}

/* Fallback: if your JS outputs anchor chips instead of radios, match the look */
.tags .tag {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  min-height: 40px;
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--chip-tx);
  border: 1px solid var(--chip-bd);
  font-weight: 700;
  transition:
    background-color .22s cubic-bezier(.22, .61, .36, 1),
    border-color .22s cubic-bezier(.22, .61, .36, 1),
    color .22s cubic-bezier(.22, .61, .36, 1),
    box-shadow .22s cubic-bezier(.22, .61, .36, 1),
    transform .22s cubic-bezier(.22, .61, .36, 1);
}

.tags .tag:hover {
  background: #ffffff;
  border-color: var(--silver-300, #d9dde5);
  box-shadow: var(--chip-shadow-hov);
  transform: translateY(-1px);
}

.tags .tag[aria-current="true"],
.tags .tag.is-active {
  background: linear-gradient(135deg, var(--chip-active-from), var(--chip-active-to));
  color: #ffffff;
  border-color: var(--chip-active-bd);
  box-shadow: var(--chip-shadow-act);
  transform: translateY(-1px);
}

/* Compact sizing for very small screens */
@media (max-width: 640px) {
  .tags {
    gap: 8px;
  }

  .tags label,
  .tags .tag {
    padding: 8px 12px;
    font-size: .95rem;
  }
}

/* =================== GRID & CARDS (polish only; global grid remains) =================== */
#blogGrid {
  gap: clamp(14px, 2vw, 22px);
}

#blogGrid,
.blog-card {
  content-visibility: auto;
}

/* perf hint for long lists */

.blog-card.card {
  cursor: pointer;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 10px;
  transition:
    transform .28s cubic-bezier(.22, .61, .36, 1),
    box-shadow .28s cubic-bezier(.22, .61, .36, 1),
    border-color .28s cubic-bezier(.22, .61, .36, 1),
    background-color .28s cubic-bezier(.22, .61, .36, 1);
}

.blog-card .media {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--silver-300, #d9dde5);
  aspect-ratio: 16/9;
  background: linear-gradient(135deg, #f2f4f8, #fff);
  transition: transform .28s cubic-bezier(.22, .61, .36, 1), box-shadow .28s cubic-bezier(.22, .61, .36, 1);
}

.blog-card .media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.blog-card.card:hover {
  transform: translateY(-6px);
  box-shadow: 0 16px 38px rgba(16, 24, 40, .14), 0 6px 14px rgba(16, 24, 40, .08);
  border-color: #d8bd62;
  /* harmonizes with global hover */
}

.blog-card.card:hover .media {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(16, 24, 40, .10);
}

.blog-card h3 {
  transition: color .22s cubic-bezier(.22, .61, .36, 1);
}

.blog-card.card:hover h3 {
  color: #6f5200;
}

/* Inline links in excerpts — soft gold underline on hover */
.blog-card a {
  position: relative;
  transition: color .2s cubic-bezier(.22, .61, .36, 1);
}

.blog-card a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 2px;
  background: linear-gradient(90deg, #7a724f, #e9c457, #fff0a8);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .28s cubic-bezier(.22, .61, .36, 1);
  border-radius: 2px;
}

.blog-card a:hover::after {
  transform: scaleX(1);
}

/* =================== MODAL (injected by JS) =================== */
.blog-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 30, 0.65);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s cubic-bezier(.22, .61, .36, 1);
  z-index: 1000;
}

.blog-modal.open {
  opacity: 1;
  pointer-events: auto;
}

.blog-dialog {
  width: min(900px, 95%);
  max-height: 90vh;
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateY(20px);
  transition:
    transform .28s cubic-bezier(.22, .61, .36, 1),
    box-shadow .28s cubic-bezier(.22, .61, .36, 1);
  box-shadow: 0 18px 48px rgba(16, 24, 40, .18);
}

.blog-modal.open .blog-dialog {
  transform: translateY(0);
}

.modal-head {
  padding: 14px 18px;
  background: #f9fbff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.modal-title h2 {
  margin: 0;
  font-size: 1.4rem;
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 6px;
  border-radius: 10px;
  transition: transform .22s cubic-bezier(.22, .61, .36, 1), background-color .22s cubic-bezier(.22, .61, .36, 1);
}

.modal-close:hover {
  transform: rotate(90deg) scale(1.05);
}

.modal-close:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--chip-ring);
}

.modal-body {
  padding: 18px;
  overflow-y: auto;
  flex: 1;
}

.modal-body img,
.modal-body video {
  width: 100%;
  border-radius: 10px;
  margin: 10px 0;
  transition: transform .28s cubic-bezier(.22, .61, .36, 1), box-shadow .28s cubic-bezier(.22, .61, .36, 1);
}

.modal-body img:hover,
.modal-body video:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(16, 24, 40, .12);
}

.modal-nav {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 20px;
}

.modal-nav button {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  transition:
    transform .22s cubic-bezier(.22, .61, .36, 1),
    box-shadow .22s cubic-bezier(.22, .61, .36, 1),
    background .22s cubic-bezier(.22, .61, .36, 1),
    color .22s cubic-bezier(.22, .61, .36, 1),
    border-color .22s cubic-bezier(.22, .61, .36, 1);
}

.modal-nav button:hover {
  background: linear-gradient(180deg, #ffffff, var(--silver-200, #eef1f6));
  color: var(--text);
  border-color: var(--gold-500, #c89b1c);
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(16, 24, 40, .10);
}

.modal-nav button:focus-visible {
  outline: none;
  border-color: var(--accent-solid, #c19213);
  box-shadow: 0 0 0 3px var(--chip-ring);
}

/* Mobile fullscreen modal */
@media (max-width: 720px) {
  .blog-dialog {
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
  }

  .modal-body {
    padding: 14px;
  }
}

/* =================== ACCESSIBILITY & MOTION =================== */
/* Strong keyboard-only ring without forcing rings on mouse users */
:where(.tags label, .tags .tag, .search input, .modal-close, .modal-nav button):focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--chip-ring);
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}
