/* =========================================================
   HOME (LOCAL) — Desktop editorial layout (HomeV2)
   ========================================================= */

/* ---------- 0. Primitives & scope ---------- */
.HomeV2 {
  --gap: 16px;
  --r: 16px;
  --shadow: 0 6px 18px rgba(0,0,0,.08);
}
.HomeV2 a { text-decoration: none; color: inherit; }
.HomeV2 .section-title { font-size: 1.25rem; font-weight: 700; margin: 24px 0 12px; }

/* ---------- 1. Page grid (content + sidebar) ---------- */
.HomeV2 .wrap { display: grid; gap: var(--gap); }
@media (min-width:1100px) {
  .HomeV2 .wrap { grid-template-columns: 3fr 1.2fr; align-items: start; }
}

/* =========================================================
   2. HERO — Mobile/Tablet: carousel, Desktop: grid
   ========================================================= */

/* 2.1 Carousel (mobile/tablet) */
.HomeV2 .hero-carousel {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow);
  margin-top: 10px;
}
.HomeV2 .hero-track{
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 100%;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.HomeV2 .hero-track::-webkit-scrollbar{ display: none; }

.HomeV2 .hero-slide{
  position: relative;
  height: clamp(220px, 48vw, 520px);
  scroll-snap-align: center;
  isolation: isolate;
}
.HomeV2 .hero-slide img{
  width: 100%; height: 100%;
  object-fit: cover; object-position: center;
  display: block;
}

/* Overlay */
.HomeV2 .hero-overlay{
  position: absolute; inset: auto 0 0 0;
  padding: 14px 16px 18px;
  background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,.55) 60%, rgba(0,0,0,.85) 100%);
  color: #fff;
}
.HomeV2 .hero-h { font-size: clamp(1.05rem, 2.2vw, 1.6rem); font-weight: 800; line-height: 1.15; margin: 4px 0 0; }
.HomeV2 .by { display: flex; align-items: center; gap: 8px; font-size: .9rem; opacity: .95; }
.HomeV2 .by img { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 2px rgba(255,255,255,.65); }

/* Carousel controls */
.HomeV2 .hero-btn{
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--hairline);
  background: color-mix(in srgb, var(--surface) 70%, #000 30%);
  color: #fff; display: grid; place-items: center; cursor: pointer;
  box-shadow: var(--shadow); opacity: .85;
}
.HomeV2 .hero-btn:hover{ opacity: 1; }
.HomeV2 .hero-btn:focus-visible{ outline: 2px solid var(--link); outline-offset: 2px; }
.HomeV2 .hero-btn.prev{ left: 10px; }
.HomeV2 .hero-btn.next{ right: 10px; }

/* Dots */
.HomeV2 .hero-dots{
  position: absolute; left: 0; right: 0; bottom: 8px;
  display: flex; gap: 6px; justify-content: center;
  padding: 0; margin: 0; list-style: none; pointer-events: auto;
}
.HomeV2 .hero-dots li button{
  width: 8px; height: 8px; border-radius: 999px; border: 0; cursor: pointer;
  background: rgba(255,255,255,.45);
}
.HomeV2 .hero-dots li button[aria-selected="true"]{ background: #fff; }

/* Safety: don’t inherit global art-frame pseudo-elements */
.HomeV2 .hero-slide::before,
.HomeV2 .hero-slide::after{ content: none !important; }

/* 2.2 Desktop hero grid */
.HomeV2 .hero-grid { display: none !important; }

@media (min-width:1100px){
  .HomeV2 .hero-carousel { display: none !important; }
  .HomeV2 .hero-grid {
    display: grid !important;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: 16px; align-items: stretch; min-width: 0;
  }

  .HomeV2 .hero-lead{
    position: relative; display: block; aspect-ratio: 16/9;
    border-radius: 16px; overflow: hidden;
    background: var(--card); border: 1px solid var(--hairline);
  }
  .HomeV2 .hero-lead img{ width: 100%; height: 100%; display: block; object-fit: cover; object-position: center; }

  .HomeV2 .hero-side{
    display: grid; grid-template-rows: 1fr 1fr; gap: 16px; min-height: 0;
  }
  .HomeV2 .hero-side > a{
    position: relative; display: block; aspect-ratio: 16/9;
    border-radius: 16px; overflow: hidden;
    background: var(--card); border: 1px solid var(--hairline);
  }
  .HomeV2 .hero-side > a img{ width:100%; height:100%; display:block; object-fit:cover; object-position:center; }

  .HomeV2 .hero-lead .hero-overlay,
  .HomeV2 .hero-side > a .hero-overlay{
    position: absolute; inset: auto 0 0 0;
    padding: 16px 18px 18px;
    background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,.55) 58%, rgba(0,0,0,.88) 100%);
    color: #fff;
  }
  .HomeV2 .hero-lead .hero-h{ font-size: clamp(1.2rem, 1.8vw, 1.9rem); font-weight: 800; line-height: 1.15; margin: 4px 0 0; }
  .HomeV2 .hero-side .hero-h{ font-size: clamp(1rem, 1.2vw, 1.1rem); font-weight: 800; line-height: 1.2; margin: 2px 0 0; }

  /* Safety against inherited pseudo overlays */
  .HomeV2 .hero-lead::before,
  .HomeV2 .hero-lead::after,
  .HomeV2 .hero-side > a::before,
  .HomeV2 .hero-side > a::after { content: none !important; }
}

/* Prevent grid bits from leaking on small screens */
@media (max-width:1099px){
  .HomeV2 .hero-lead,
  .HomeV2 .hero-side { display: none !important; }
}

/* =========================================================
   3. Generic grids & cards
   ========================================================= */
.HomeV2 .grid { display: grid; gap: var(--gap); }

.HomeV2 .card{
  background: var(--card); color: var(--text);
  border-radius: var(--r); overflow: hidden;
  box-shadow: var(--shadow); border: 1px solid var(--hairline);
}
.HomeV2 .thumb{ aspect-ratio: 16/9; background: #000; overflow: hidden; }
.HomeV2 .thumb img{ width: 100%; height: 100%; object-fit: cover; object-position: 60% center; display: block; }
.HomeV2 .body{ padding: 12px 14px 14px; }
.HomeV2 .t{ font-size: 1rem; font-weight: 700; line-height: 1.2; margin: 2px 0 6px; }
.HomeV2 .dek{ font-size: .95rem; opacity: .9; }
.HomeV2 .meta{ display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: .85rem; opacity: .9; }
.HomeV2 .avatar{ width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }

/* =========================================================
   4. Trending & Latest grids
   ========================================================= */

/* Shared trend-card (deduped) */
.HomeV2 .trend-card{
  padding: 0; display: flex; flex-direction: column; overflow: hidden;
  transition: transform .12s ease, box-shadow .15s ease;
  position: relative; /* for rank badge */
}
.HomeV2 .trend-card:hover{ transform: translateY(-2px); box-shadow: var(--shadow); }

.HomeV2 .trend-card .thumb{
  flex: 0 0 auto; aspect-ratio: 16/9; background: #0d0f14; position: relative; overflow: hidden;
}
.HomeV2 .trend-card .thumb img{
  width: 100%; height: 100%; object-fit: cover; object-position: center; display: block;
  transform: scale(1); transition: transform .35s ease;
}
.HomeV2 .trend-card:hover .thumb img{ transform: scale(1.04); }
.HomeV2 .trend-card .thumb.is-empty{
  background: linear-gradient(135deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
}

/* Body stacks */
.HomeV2 .trend-card .body{
  flex: 1 1 auto; display: flex; flex-direction: column;
  padding: 12px 14px 14px;
}
.HomeV2 .trend-card .t{
  font-size: 1rem; font-weight: 800; line-height: 1.2; margin: 2px 0 6px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: calc(1.2em * 2);
}
.HomeV2 .trend-card .dek{
  font-size: .95rem; opacity: .9; margin: 0 0 8px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.HomeV2 .trend-card .meta{
  margin-top: auto; display: flex; align-items: center; gap: 10px;
  font-size: .85rem; opacity: .9;
}
.HomeV2 .trend-card .avatar{ width: 22px; height: 22px; border-radius: 50%; object-fit: cover; }

/* Rank badge */
.HomeV2 .trend-card::after{
  content: attr(data-rank);
  position: absolute; top: 10px; left: 10px;
  width: 24px; height: 24px; border-radius: 999px; display: grid; place-items: center;
  background: rgba(0,0,0,.55); color: #fff; font-size: .85rem; font-weight: 800;
  border: 1px solid rgba(255,255,255,.2); box-shadow: 0 2px 8px rgba(0,0,0,.35);
}

/* Grid columns */
.HomeV2 .grid.trending > .trend-card{ height: 100%; }
.HomeV2 .grid.trending { grid-template-columns: repeat(4, minmax(0,1fr)); }
@media (min-width:700px) and (max-width:1099px){
  .HomeV2 .grid.trending { grid-template-columns: repeat(3, minmax(0,1fr)); }
}
@media (max-width:699px){
  .HomeV2 .grid.trending { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

/* Latest */
.HomeV2 .grid.latest > * { grid-column: auto !important; }
@media (min-width:1100px){ .HomeV2 .grid.latest { grid-template-columns: repeat(4, minmax(0,1fr)); } }
@media (min-width:700px) and (max-width:1099px){ .HomeV2 .grid.latest { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width:699px){ .HomeV2 .grid.latest { grid-template-columns: 1fr; } }

/* Nuke any global grid-span leakage inside Home grids */
.HomeV2 .grid.trending > *,
.HomeV2 .grid.latest   > * { grid-column: auto !important; }

/* =========================================================
   5. Sidebar
   ========================================================= */
.HomeV2 .sidebar { display: grid; gap: var(--gap); }
.HomeV2 .panel{
  border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow);
  background: var(--card); border: 1px solid var(--hairline);
}
.HomeV2 .panel .thumb{ height: 200px; }
.HomeV2 .panel .thumb img{ width: 100%; height: 100%; object-fit: cover; object-position: 60% center; display: block; }
.HomeV2 .panel .box{ padding: 12px 14px; }

.HomeV2 .supporters{
  padding: 10px 12px; border-radius: 12px;
  background: linear-gradient(90deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  display: flex; flex-wrap: wrap; gap: 8px;
}
.HomeV2 .pill{ padding: 6px 10px; border-radius: 999px; background: rgba(255,255,255,.08); font-size: .9rem; }

/* =========================================================
   6. Utilities & shared UI bits
   ========================================================= */

/* Search strip */
.HomeV2 .search-strip{ display: flex; gap: 8px; align-items: center; margin: 14px 0 6px; }
.HomeV2 .search-strip input[type="search"]{
  flex: 1 1 420px; min-width: 220px; padding: .6rem .8rem; border: 1px solid var(--hairline-2);
  border-radius: 10px; background: transparent; color: var(--text);
}

/* Row headers + actions */
.HomeV2 .row-head{
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-top: 18px;
}
.HomeV2 .row-actions{ display: flex; align-items: center; gap: 10px; }
.HomeV2 .row-more{ color: var(--link); font-weight: 600; white-space: nowrap; font-size: 12px; }
.HomeV2 .row-more:hover{ text-decoration: underline; }

/* Diagnostics box */
.sp-diag{
  margin: 10px 0; padding: 8px 10px; border-radius: 8px;
  border: 1px dashed var(--hairline-2); background: rgba(255,255,255,.03);
  color: var(--muted); font-size: .85rem; max-height: 180px; overflow: auto;
}

/* =========================================================
   7. Horizontal rails (Section Rows)
   ========================================================= */
.HomeV2 .hrail{
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: clamp(240px, 26vw, 360px);
  gap: 16px;
  overflow-x: auto; overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
  padding-bottom: 4px; scrollbar-width: none;
}
.HomeV2 .hrail::-webkit-scrollbar{ display: none; }

.HomeV2 .hrail .hcard{
  grid-column: auto !important; scroll-snap-align: start;
  padding: 0; display: flex; flex-direction: column; overflow: hidden;
}
.HomeV2 .hrail .hcard .thumb{ aspect-ratio: 16/9; background: #0d0f14; overflow: hidden; }
.HomeV2 .hrail .hcard .thumb img{ width: 100%; height: 100%; object-fit: cover; object-position: center; display: block; }
.HomeV2 .hrail .hcard .body{ padding: 12px 14px 14px; display: flex; flex-direction: column; }
.HomeV2 .hrail .hcard .t{
  font-size: 1rem; font-weight: 800; line-height: 1.2; margin: 2px 0 6px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: calc(1.2em * 2);
}
.HomeV2 .hrail .hcard .dek{
  font-size: .95rem; opacity: .9; margin: 0 0 8px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.HomeV2 .hrail .hcard .meta{ margin-top: auto; font-size: .85rem; opacity: .9; }

/* Rail nav buttons */
.HomeV2 .row-nav{ display: flex; gap: 6px; }
.HomeV2 .row-btn{
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--hairline);
  background: color-mix(in srgb, var(--surface) 75%, #000 25%);
  color: #fff; display: grid; place-items: center; cursor: pointer;
  box-shadow: var(--shadow); opacity: .9;
}
.HomeV2 .row-btn:hover{ opacity: 1; }
.HomeV2 .row-btn:disabled{ opacity: .4; cursor: not-allowed; }
.HomeV2 .row-btn:focus-visible{ outline: 2px solid var(--link); outline-offset: 2px; }

/* =========================================================
   8. Writers (cards)
   ========================================================= */
.HomeV2 .card.writer .writer-head{ display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.HomeV2 .card.writer .avatar.xl{ width: 48px; height: 48px; border-radius: 50%; object-fit: cover; border: 1px solid var(--hairline-2); }
.HomeV2 .card.writer .muted{ color: var(--muted); font-size: .9rem; }

/* Optional tighter variant */
.card.writer .body.center { text-align: left; }
.card.writer .avatar.xl { width: 64px; height: 64px; }
.card.writer .t { font-size: 1.125rem; font-weight: 700; line-height: 1.2; }

/* =========================================================
   9. Legacy rail (kept for compatibility)
   ========================================================= */
.row-rail { overflow: hidden; }
.row-rail .rail {
  display: flex; gap: var(--gap, 16px);
  overflow-x: auto; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
  padding: 4px var(--page-pad, 16px) 8px;
}
.row-rail .rail .card { flex: 0 0 280px; scroll-snap-align: start; }
@media (max-width:640px) {
  .row-rail .rail .card { flex-basis: 78vw; }
  .row-rail .rail { padding-left: 12px; padding-right: 12px; }
}

/* =========================================================
   10. Misc
   ========================================================= */
.HomeV2 .more{
  display: inline-block; margin: 14px auto 0; padding: 10px 16px;
  border-radius: 10px; background: #222; color: #fff; border: 1px solid #333;
}

/* Note: If this is duplicated elsewhere, prefer the global version. */
.container{ max-width: 1320px; padding: 16px; margin: 0 auto; }

/* Hide horizontal scrollbar on rails (Writers uses one of these) */
.HomeV2 .hrail,
.row-rail .rail {
  scrollbar-width: none;        /* Firefox */
  -ms-overflow-style: none;     /* IE/old Edge */
}
.HomeV2 .hrail::-webkit-scrollbar,
.row-rail .rail::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;                /* Chrome/Safari */
}
/* HERO: lock byline avatar size/position so global avatar rules can't leak in */
.HomeV2 .hero-grid .by .avatar,
.HomeV2 .hero-carousel .by .avatar,
.HomeV2 .hero-grid .by img,
.HomeV2 .hero-carousel .by img {
  width: 24px !important;
  height: 24px !important;
  flex: 0 0 24px;
  border-radius: 50%;
  object-fit: cover;
  position: static !important;
  inset: auto !important;
  transform: none !important;
  box-shadow: 0 0 0 2px rgba(255,255,255,.65);
  z-index: auto;
}

/* If any 'XL' avatar class is present, neutralize it inside the hero */
.HomeV2 .hero-grid .avatar.xl,
.HomeV2 .hero-carousel .avatar.xl {
  width: 24px !important;
  height: 24px !important;
}

/* Make sure overlay sits above the image (and avatars stay inside overlay) */
.HomeV2 .hero-lead,
.HomeV2 .hero-side > a,
.HomeV2 .hero-slide { position: relative; }
.HomeV2 .hero-overlay { position: absolute; inset: auto 0 0 0; z-index: 2; }
.HomeV2 .hero-lead img,
.HomeV2 .hero-side > a img,
.HomeV2 .hero-slide img { position: relative; z-index: 1; }

/* If your card-frame adds decorative ::before/::after, kill them just in hero */
.HomeV2 .hero-grid .card::before,
.HomeV2 .hero-grid .card::after,
.HomeV2 .hero-grid .thumb::before,
.HomeV2 .hero-grid .thumb::after,
.HomeV2 .hero-carousel .card::before,
.HomeV2 .hero-carousel .card::after,
.HomeV2 .hero-carousel .thumb::before,
.HomeV2 .hero-carousel .thumb::after {
  content: none !important;
  background: none !important;
  -webkit-mask: none !important;
  mask: none !important;
  clip-path: none !important;
  box-shadow: none !important;
}
