/* ============================================================
   HULULX — v4.0 LAYER "Home + Articles Index redesign"
   Builds on the Nebula design system (hululx-v2.css tokens).
   Everything here is additive — no v2/v3 class is redefined.
   ============================================================ */

/* ── Deterministic article covers ─────────────────────────────
   All seed articles have NULL featured_image. Instead of
   repeating one default JPEG 7 times per page, each article
   gets a stable, seeded gradient + category glyph cover. */
.hx-cover {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 85% 10%, var(--cv-a, rgba(99,102,241,.55)) 0%, transparent 55%),
    radial-gradient(110% 100% at 15% 90%, var(--cv-b, rgba(124,58,237,.5)) 0%, transparent 60%),
    linear-gradient(150deg, #1e1b4b 0%, #2a1f63 55%, #3b2a86 100%);
}
.hx-cover::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px);
  background-size: 26px 26px;
  opacity: .5;
}
.hx-cover::after {
  content: '';
  position: absolute;
  width: 210%; aspect-ratio: 1;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,.10);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) rotate(24deg);
  pointer-events: none;
}
.hx-cover > img {
  position: relative;
  width: 100%; height: 100%;
  object-fit: cover;
  z-index: 1;
}
.hx-cover .hx-cover-emoji {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  z-index: 1;
  filter: drop-shadow(0 6px 16px rgba(0,0,0,.35));
  user-select: none;
}
[dir="rtl"] .hx-cover .hx-cover-emoji { transform: scaleX(-1); }
.hx-cover .hx-cover-cat {
  position: absolute; bottom: .65rem; inset-inline-start: .75rem;
  z-index: 2;
  font-size: .68rem; font-weight: 800;
  color: #fff;
  background: rgba(12, 10, 29, .55);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.16);
  padding: .2rem .6rem;
  border-radius: var(--hx-r-full, 999px);
}

/* seeded cover variants (assigned by article id % 6) */
.hx-cover--0 { --cv-a: rgba(99,102,241,.60); --cv-b: rgba(167,139,250,.42); }
.hx-cover--1 { --cv-a: rgba(20,184,166,.55); --cv-b: rgba(79,70,229,.45); }
.hx-cover--2 { --cv-a: rgba(244,63,94,.48); --cv-b: rgba(124,58,237,.50); }
.hx-cover--3 { --cv-a: rgba(245,158,11,.50); --cv-b: rgba(244,63,94,.35); }
.hx-cover--4 { --cv-a: rgba(59,130,246,.55); --cv-b: rgba(20,184,166,.40); }
.hx-cover--5 { --cv-a: rgba(167,139,250,.55); --cv-b: rgba(59,130,246,.40); }

/* ── Section shell (consistent rhythm across v4 sections) ── */
.hx-v4-section { margin-top: clamp(3.5rem, 8vw, 6rem); }
.hx-v4-section:first-child { margin-top: 0; }

/* ── Filter chips rail (articles index) ─────────────────────── */
.hx-rail {
  display: flex; gap: .5rem;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  padding-bottom: .35rem;
}
.hx-rail > * { scroll-snap-align: start; }
.hx-rail::-webkit-scrollbar { height: 5px; }
.hx-rail::-webkit-scrollbar-thumb { background: var(--hx-border); border-radius: 99px; }
.hx-rail::-webkit-scrollbar-thumb:hover { background: var(--hx-indigo-300, #a5b4fc); }

/* Active state is visible regardless of :hover capability */
.hx-chip[aria-pressed="true"],
.hx-chip.is-active {
  background: var(--hx-gradient);
  color: #fff;
  border-color: transparent;
  box-shadow: var(--hx-shadow-sm);
}

/* ── Articles list view (rows instead of cards) ─────────────── */
.hx-row-card {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 1rem;
  align-items: stretch;
}
@media (min-width: 640px) {
  .hx-row-card { grid-template-columns: 208px 1fr; gap: 1.25rem; }
}
.hx-row-card .hx-row-cover { border-radius: var(--hx-r-md, 14px); overflow: hidden; min-height: 118px; }
.hx-row-card:hover .hx-row-cover img,
.hx-row-card:hover .hx-cover-emoji { transform: scale(1.05); }
.hx-row-card .hx-cover-emoji { transition: transform .6s var(--hx-ease); }

/* ── Pagination (v4: big touch targets, current page pill) ─── */
.hx-pg {
  display: flex; align-items: center; justify-content: center;
  gap: .4rem; flex-wrap: wrap;
  margin-top: clamp(2rem, 5vw, 3.5rem);
}
.hx-pg a,
.hx-pg span.hx-pg-cur {
  min-width: 2.75rem; height: 2.75rem;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 .75rem;
  border-radius: var(--hx-r-full, 999px);
  font-weight: 800; font-size: .875rem;
  border: 1px solid var(--hx-border);
  background: var(--hx-surface);
  color: var(--hx-ink-muted);
  transition: all .2s var(--hx-ease);
}
.hx-pg a:hover {
  border-color: var(--hx-indigo-500, #6366f1);
  color: var(--hx-indigo-600, #4f46e5);
  transform: translateY(-1px);
  box-shadow: var(--hx-shadow-sm);
}
.hx-pg a:focus-visible,
.hx-rail a:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--hx-ring, rgba(99,102,241,.35));
  outline-offset: 2px;
  border-radius: 6px;
}
.hx-pg .hx-pg-cur {
  background: var(--hx-gradient);
  color: #fff;
  border-color: transparent;
  box-shadow: var(--hx-glow);
  cursor: default;
}
.hx-pg .hx-pg-gap { color: var(--hx-ink-faint); padding: 0 .15rem; }

/* ── Search input (articles index) ──────────────────────────── */
.hx-search {
  position: relative;
  flex: 1 1 240px;
  max-width: 420px;
}
.hx-search svg {
  position: absolute; top: 50%; inset-inline-start: .85rem;
  transform: translateY(-50%);
  color: var(--hx-ink-faint);
  pointer-events: none;
}
.hx-search input {
  width: 100%;
  height: 2.9rem;
  border-radius: var(--hx-r-full, 999px);
  border: 1.5px solid var(--hx-border);
  background: var(--hx-surface);
  color: var(--hx-ink);
  padding-inline: 2.6rem 1rem;
  font-weight: 600; font-size: .9rem;
  transition: border-color .2s, box-shadow .2s;
}
.hx-search input::placeholder { color: var(--hx-ink-faint); }
.hx-search input:focus {
  outline: none;
  border-color: var(--hx-indigo-500, #6366f1);
  box-shadow: 0 0 0 4px var(--hx-ring, rgba(99,102,241,.18));
}
.hx-search input::-webkit-search-cancel-button { cursor: pointer; }

/* ── FAQ accordion (GEO-friendly: real content, JS-enhanced) ── */
.hx-faq details {
  border: 1px solid var(--hx-border);
  border-radius: var(--hx-r-lg, 20px);
  background: var(--hx-surface);
  overflow: hidden;
  transition: box-shadow .25s var(--hx-ease), border-color .25s;
}
.hx-faq details + details { margin-top: .75rem; }
.hx-faq details[open] {
  border-color: rgba(99,102,241,.4);
  box-shadow: var(--hx-shadow-md);
}
.hx-faq summary {
  display: flex; align-items: center; gap: .9rem;
  padding: 1.05rem 1.25rem;
  cursor: pointer;
  font-weight: 800;
  font-size: .95rem;
  color: var(--hx-ink);
  list-style: none;
  user-select: none;
}
.hx-faq summary::-webkit-details-marker { display: none; }
.hx-faq summary .hx-faq-q {
  flex: 1;
}
.hx-faq summary .hx-faq-ico {
  width: 1.9rem; height: 1.9rem;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--hx-gradient-soft);
  color: var(--hx-indigo-600, #4f46e5);
  transition: transform .3s var(--hx-ease);
  flex-shrink: 0;
}
.hx-faq details[open] summary .hx-faq-ico { transform: rotate(45deg); }
.hx-faq .hx-faq-a {
  padding: 0 1.25rem 1.15rem;
  padding-inline-start: calc(1.25rem + 2.8rem);
  color: var(--hx-ink-muted);
  line-height: 1.75;
  font-size: .9rem;
}
@media (max-width: 480px) {
  .hx-faq .hx-faq-a { padding-inline-start: 1.25rem; }
}

/* ── Tag pills (home + articles) ────────────────────────────── */
.hx-tag {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .32rem .8rem;
  border-radius: var(--hx-r-full, 999px);
  background: var(--hx-surface-2);
  border: 1px solid var(--hx-border);
  color: var(--hx-ink-muted);
  font-weight: 700; font-size: .78rem;
  transition: all .2s var(--hx-ease);
}
.hx-tag:hover {
  border-color: var(--hx-indigo-500, #6366f1);
  color: var(--hx-indigo-600, #4f46e5);
  background: var(--hx-surface);
  transform: translateY(-1px);
}
.hx-tag .hx-tag-n {
  font-size: .65rem;
  color: var(--hx-ink-faint);
  font-weight: 800;
}

/* ── Stat counters (home hero) ──────────────────────────────── */
.hx-stat-num {
  font-size: clamp(1.5rem, 3.2vw, 2.1rem);
  font-weight: 800;
  line-height: 1.1;
  background: var(--hx-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

/* ── View toggle (grid/list) — segmented control ────────────── */
.hx-seg {
  display: inline-flex;
  border: 1.5px solid var(--hx-border);
  border-radius: var(--hx-r-full, 999px);
  background: var(--hx-surface);
  padding: 3px;
  gap: 2px;
}
.hx-seg button {
  min-width: 2.4rem; height: 2.15rem;
  border-radius: var(--hx-r-full, 999px);
  display: inline-grid; place-items: center;
  color: var(--hx-ink-faint);
  transition: all .2s var(--hx-ease);
}
.hx-seg button.is-on {
  background: var(--hx-gradient);
  color: #fff;
  box-shadow: var(--hx-shadow-sm);
}

/* ── Skeleton shimmer (initial paint before reveal) ─────────── */
.hx-skel {
  position: relative;
  overflow: hidden;
  background: var(--hx-surface-2);
  border-radius: var(--hx-r-md, 14px);
}
.hx-skel::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.35), transparent);
  animation: hx-skel 1.4s infinite;
}
.dark .hx-skel::after {
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.06), transparent);
}
@keyframes hx-skel {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
[dir="rtl"] .hx-skel::after { animation-direction: reverse; }

/* ── Editorial badge ────────────────────────────────────────── */
.hx-badge-edit {
  position: absolute; top: .8rem; inset-inline-end: .8rem;
  z-index: 2;
  display: inline-flex; align-items: center; gap: .3rem;
  background: rgba(245,158,11,.92);
  color: #1e1b4b;
  font-size: .65rem; font-weight: 800;
  padding: .25rem .6rem;
  border-radius: var(--hx-r-full, 999px);
  box-shadow: 0 4px 14px rgba(245,158,11,.4);
}

/* ── Reading progress ring on cards (subtle) ────────────────── */
.hx-card-meta {
  display: flex; align-items: center; gap: .9rem;
  color: var(--hx-ink-faint);
  font-size: .74rem;
  font-weight: 700;
}
.hx-card-meta svg { opacity: .75; }

/* ── Featured hero spotlight improvements ───────────────────── */
.hx-hero-spot .hx-cover { border-radius: var(--hx-r-xl, 28px); }

/* ── Empty state ────────────────────────────────────────────── */
.hx-empty {
  text-align: center;
  padding: clamp(3rem, 8vw, 5rem) 1.5rem;
  border: 2px dashed var(--hx-border);
  border-radius: var(--hx-r-xl, 28px);
  background: var(--hx-surface);
}

/* ── Newsletter inline (home CTA) ───────────────────────────── */
.hx-nl-input {
  height: 3.25rem;
  border-radius: var(--hx-r-full, 999px);
  border: 1.5px solid rgba(255,255,255,.35);
  background: rgba(255,255,255,.12);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: #fff;
  padding-inline: 1.25rem;
  font-weight: 600;
  width: 100%;
}
.hx-nl-input::placeholder { color: rgba(255,255,255,.65); }
.hx-nl-input:focus {
  outline: none;
  border-color: #fff;
  box-shadow: 0 0 0 4px rgba(255,255,255,.22);
}

/* ── Accessibility: motion ──────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .hx-skel::after { animation: none; }
  .hx-reveal { transition: none !important; opacity: 1 !important; transform: none !important; }
  .hx-pg a:hover { transform: none; }
  .hx-cover > img, .hx-row-card .hx-cover-emoji { transition: none !important; }
}

/* ── Print: hide interactive-only chrome ────────────────────── */
@media print {
  .hx-rail, .hx-seg, .hx-pg, .hx-search, .back-to-top { display: none !important; }
  .hx-card { box-shadow: none !important; border: 1px solid #ddd; }
}

/* ── v4.1: admin discovery table ─────────────────────────────── */
.hx-table th { font-weight: 800; letter-spacing: .02em; }
.hx-table td, .hx-table th { padding: .45rem .5rem; text-align: start; }
.hx-table tbody tr:hover { background: color-mix(in srgb, var(--hx-surface-2) 60%, transparent); }
