/* Community on the SHOWCASE look (as-lgcd). Presentation only: loaded after
   community.css and community-polish.css on all six community pages, so it wins
   at equal specificity. Markup hooks and the state machine in community.js are
   untouched.

   What it does
   - Hero: the same stage language as the home and pricing heroes (gold and
     night poster, rotated glass panes, drifting chips, gold-edged eyebrow chip,
     tight display headline) without the WebGL canvas. The hub adds three glass
     doors so the right half of the first screen is never empty.
   - Hub feeds: two equal columns on one subgrid, so both section heads share a
     row and card i of each list shares one row (top and height) even when the
     lists hold different counts; the longer list continues alone below.
   - Cards: one component for news, conversations and mods: same padding, radius
     and glass surface; the meta/footer row is pinned to the card bottom.
   Dark is the default. Every light value sits under html[data-theme="light"]. */

body.community-page {
  --ch-edge: rgba(239, 240, 244, .14);
  --ch-gold-edge: rgba(226, 169, 69, .42);
  --ch-glass: linear-gradient(155deg, rgba(34, 37, 55, .74), rgba(15, 16, 26, .82));
  --ch-card: linear-gradient(155deg, rgba(30, 33, 49, .62), rgba(17, 18, 29, .78));
  --ch-chip-bg: rgba(21, 23, 36, .72);
  --ch-glow: 0 30px 60px -34px rgba(0, 0, 0, .85), inset 0 1px 0 rgba(255, 255, 255, .06);
}
html[data-theme="light"] body.community-page {
  --ch-edge: var(--border);
  --ch-gold-edge: rgba(122, 82, 0, .5);
  --ch-glass: #fff;
  --ch-card: var(--bg-1);
  --ch-chip-bg: rgba(255, 255, 255, .86);
  --ch-glow: 0 1px 2px rgba(17, 19, 24, .05);
}

/* ---------- hero stage ---------- */
body.community-page.reading .community-masthead {
  position: relative;
  isolation: isolate;
  overflow: clip;
  display: grid;
  align-items: center;
  min-height: clamp(300px, 40svh, 460px);
  border-bottom: 1px solid var(--border);
  background: var(--bg-0);
}
body.community-page.reading.community-overview-page .community-masthead { min-height: clamp(420px, 62svh, 640px); }

body.community-page.reading .community-masthead::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -3;
  pointer-events: none;
  background:
    radial-gradient(60vw 46vh at 78% 14%, rgba(226, 169, 69, .16), transparent 70%),
    radial-gradient(48vw 56vh at 6% 82%, rgba(60, 74, 150, .34), transparent 72%),
    radial-gradient(70vw 40vh at 50% 120%, rgba(226, 169, 69, .10), transparent 70%),
    linear-gradient(180deg, #0A0B12 0%, #0D0F1B 56%, #090A10 100%);
}
body.community-page.reading .community-masthead::after {
  content: '';
  position: absolute;
  inset: 55% 0 0;
  z-index: -2;
  pointer-events: none;
  opacity: .5;
  background: repeating-linear-gradient(180deg, rgba(226, 169, 69, .20) 0 1px, transparent 1px 34px);
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 45%, #000);
  mask-image: linear-gradient(180deg, transparent, #000 45%, #000);
}
html[data-theme="light"] body.community-page.reading .community-masthead::before {
  background:
    radial-gradient(56vw 44vh at 80% 8%, rgba(226, 169, 69, .18), transparent 70%),
    radial-gradient(46vw 50vh at 4% 100%, rgba(155, 178, 217, .26), transparent 72%),
    linear-gradient(180deg, #fff 0%, #F6F7FA 100%);
}
html[data-theme="light"] body.community-page.reading .community-masthead::after { content: none; }

/* decorative layers (aria-hidden in the markup) */
.community-hero-layers {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.community-hero-layers > span { position: absolute; display: block; }
.community-hero-pane {
  border-radius: 28px;
  border: 1px solid rgba(226, 169, 69, .22);
  background: linear-gradient(140deg, rgba(226, 169, 69, .07), rgba(155, 178, 217, .03) 60%, transparent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05);
}
.community-hero-chip {
  width: var(--w, 22px);
  height: var(--h, 22px);
  border-radius: 6px;
  border: 1px solid rgba(226, 169, 69, .5);
  background: linear-gradient(135deg, rgba(226, 169, 69, .30), rgba(155, 178, 217, .08));
  box-shadow: 0 0 24px rgba(226, 169, 69, .22);
  rotate: var(--r, 20deg);
  animation: community-hero-float var(--t, 9s) ease-in-out infinite alternate;
}
.community-hero-chip.is-air {
  border-color: rgba(155, 178, 217, .5);
  background: linear-gradient(135deg, rgba(155, 178, 217, .26), rgba(60, 74, 150, .10));
  box-shadow: 0 0 24px rgba(155, 178, 217, .18);
}
html[data-theme="light"] .community-hero-pane { border-color: rgba(154, 106, 0, .22); background: linear-gradient(140deg, rgba(226, 169, 69, .10), rgba(155, 178, 217, .06) 60%, transparent); box-shadow: none; }
html[data-theme="light"] .community-hero-chip { border-color: rgba(154, 106, 0, .4); box-shadow: none; }
html[data-theme="light"] .community-hero-chip.is-air { border-color: rgba(54, 90, 146, .4); }
@keyframes community-hero-float { from { translate: 0 -10px; } to { translate: 0 12px; } }

/* hero copy: same scale and chip as the home hero */
body.community-page.reading .community-masthead-inner {
  width: 100%;
  max-width: none;
  margin: 0;
  padding-inline: var(--shell-gutter);
  padding-block: clamp(40px, 5.5vw, 96px) clamp(36px, 4.4vw, 80px);
}
body.community-page.reading.community-overview-page .community-masthead-inner {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
  align-items: center;
  gap: clamp(28px, 4vw, 88px);
}
body.community-page.reading .community-masthead-copy { max-width: 60ch; }
body.community-page.reading .community-eyebrow {
  display: inline-flex;
  align-items: center;
  margin: 0 0 22px;
  padding: 6px 14px;
  border: 1px solid var(--ch-gold-edge);
  border-radius: 999px;
  background: var(--ch-chip-bg);
  color: var(--text-1);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: none;
  line-height: 1.4;
  backdrop-filter: blur(8px);
}
body.community-page.reading .community-masthead h1 {
  max-width: 16ch;
  margin: 0;
  font-size: clamp(36px, 4.2vw, 96px);
  font-weight: 600;
  line-height: 1.04;
  letter-spacing: -.045em;
  text-wrap: balance;
  overflow-wrap: break-word;
}
body.community-page.reading .community-masthead-lead {
  max-width: 54ch;
  margin: 22px 0 0;
  color: var(--text-1);
  opacity: .9;
  font-size: clamp(16px, 1.2vw, 22px);
  line-height: 1.6;
}
body.community-page.reading .community-masthead .community-actions { margin-top: 30px; }
body.community-page.reading .community-masthead .community-context-note { margin-top: 22px; max-width: 56ch; }

/* ---------- hub doors ---------- */
.community-doors {
  position: relative;
  display: grid;
  gap: 14px;
  width: min(100%, 560px);
  justify-self: end;
}
.community-door {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 20px 22px;
  border: 1px solid var(--ch-edge);
  border-radius: 20px;
  background: var(--ch-glass);
  box-shadow: var(--ch-glow);
  color: var(--text-1);
  text-decoration: none;
  transition: transform .3s cubic-bezier(.16, 1, .3, 1), border-color .25s, box-shadow .25s;
}
.community-door:hover { transform: translateY(-3px); border-color: var(--ch-gold-edge); }
.community-door:focus-visible { outline: 2px solid var(--air); outline-offset: 3px; }
.community-door-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  border: 1px solid var(--ch-gold-edge);
  background: rgba(226, 169, 69, .10);
  color: var(--accent);
}
html[data-theme="light"] .community-door-icon { background: rgba(226, 169, 69, .14); }
.community-door-text { display: grid; gap: 4px; min-width: 0; }
.community-door-title { font-size: 18px; font-weight: 650; letter-spacing: -.015em; line-height: 1.25; }
.community-door-copy { color: var(--text-2); font-size: 14px; line-height: 1.5; }
.community-door-arrow { color: var(--accent); font-size: 20px; line-height: 1; transition: translate .25s; }
.community-door:hover .community-door-arrow { translate: 4px 0; }

/* ---------- hub feeds: one grid, shared rows ---------- */
/* The Mods band is its own section: a section gap above it, not the card gap. */
.community-overview-grid > .community-overview-span { margin-top: clamp(20px, 3vw, 48px); }
@media (min-width: 961px) {
  /* Row i of the news column and row i of the conversations column are the same
     grid row, so a pair always shares its top and height. The two lists can hold
     different counts (the server allows 3 news and 8 threads): the longer list
     simply continues in rows the shorter one leaves empty, and no card is
     stretched to fill them. Track gaps are zero because a list holds at most
     --overview-rows cards and unused rows must not add height; card spacing is a
     bottom margin that travels with the card (the last card keeps it too, so a
     pair never differs in height; the Mods band margin below accounts for it). */
  .community-overview-grid {
    --overview-rows: 13; /* heading row + up to 12 cards per list */
    --overview-card-gap: 14px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: clamp(24px, 3vw, 56px);
    row-gap: 0;
    align-items: stretch;
  }
  .community-overview-grid > .community-overview-span { margin-top: calc(var(--overview-card-gap) + clamp(20px, 3vw, 48px)); }
  .community-overview-grid > .community-panel:not(.community-overview-span) {
    display: grid;
    grid-row: span var(--overview-rows);
    grid-template-rows: subgrid;
    gap: 0;
  }
  .community-overview-grid .community-section-heading { align-items: flex-start; margin-bottom: 20px; }
  .community-overview-grid .state-stack {
    display: grid;
    grid-row: 2 / -1;
    grid-template-rows: subgrid;
    gap: 0;
    min-height: 0;
  }
  /* A loading, empty or error panel occupies the first card row only. */
  .community-overview-grid .state-panel { grid-row: 1; grid-column: 1; margin-bottom: var(--overview-card-gap); }
  .community-overview-grid .state-panel[hidden] { display: none; }
  .community-overview-grid .feed-list,
  .community-overview-grid .conversation-list {
    grid-row: 1 / -1;
    grid-column: 1;
    grid-template-rows: subgrid;
    gap: 0;
  }
  .community-overview-grid .feed-list > *,
  .community-overview-grid .conversation-list > * { margin-bottom: var(--overview-card-gap); }
  .community-overview-grid .feed-list[hidden],
  .community-overview-grid .conversation-list[hidden] { display: none; }
  @supports not (grid-template-rows: subgrid) {
    .community-overview-grid { --overview-rows: 2; row-gap: 28px; }
    .community-overview-grid > .community-overview-span { margin-top: clamp(20px, 3vw, 48px); }
    /* Without subgrid the two panels only share the outer row, so nothing may
       stretch to fill it: every track is auto and packs at the top, which keeps
       each card at its natural height beside a longer list. */
    .community-overview-grid > .community-panel:not(.community-overview-span) { grid-row: auto; grid-template-rows: auto auto; align-content: start; }
    .community-overview-grid .state-stack { grid-row: auto; grid-template-rows: none; align-content: start; }
    .community-overview-grid .state-panel,
    .community-overview-grid .feed-list,
    .community-overview-grid .conversation-list { grid-row: auto; grid-template-rows: none; align-content: start; gap: 14px; }
    .community-overview-grid .state-panel,
    .community-overview-grid .feed-list > *,
    .community-overview-grid .conversation-list > * { margin-bottom: 0; }
    .community-overview-grid .community-section-heading { min-height: 112px; }
  }
}

/* ---------- one card component ---------- */
/* Padding and radius come from community.css, identical for all three cards. */
html:not([data-theme="light"]) :is(.editorial-card, .conversation-card, .mod-card) {
  background: var(--ch-card);
  border-color: var(--ch-edge);
  box-shadow: var(--ch-glow);
}
html:not([data-theme="light"]) :is(.editorial-card, .conversation-card, .mod-card):is(:hover, :focus-within) { border-color: var(--ch-gold-edge); }
.editorial-card { display: flex; flex-direction: column; }
.conversation-main { display: flex; flex-direction: column; }
:is(.editorial-card, .mod-card, .conversation-main) .card-summary {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
}
.editorial-card .card-meta,
.conversation-main .card-meta { margin-top: auto; padding-top: 16px; }
.editorial-card .card-summary,
.conversation-main .card-summary { margin-bottom: 0; }
.mod-card-footer { margin-top: auto; padding-top: 16px; min-height: 44px; align-items: center; }
.mod-card .card-summary { flex: 0 1 auto; margin-bottom: 0; }
.mod-card { min-height: 0; }
.mod-grid { align-items: stretch; }

body.community-page .conversation-card { grid-template-columns: minmax(0, 1fr) 112px; gap: 20px; align-items: stretch; }
body.community-page .conversation-stats {
  align-content: center;
  padding-left: 18px;
  border-left: 1px solid var(--border);
}

/* List pagination: centered, spaced from the cards (was unstyled). */
nav[id$="Pagination"] { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 16px; margin-top: 28px; color: var(--text-2); }
nav[id$="Pagination"][hidden] { display: none; }

/* ---------- narrow screens ---------- */
@media (max-width: 960px) {
  body.community-page.reading.community-overview-page .community-masthead-inner { grid-template-columns: minmax(0, 1fr); }
  .community-doors { width: 100%; justify-self: stretch; }
  .community-hero-chip { display: none; }
}
@media (max-width: 600px) {
  body.community-page.reading .community-masthead { min-height: 0; }
  body.community-page.reading.community-overview-page .community-masthead { min-height: 0; }
  body.community-page.reading .community-masthead h1 { font-size: 34px; max-width: none; }
  .community-door { padding: 16px; gap: 14px; }
  .community-door-icon { width: 40px; height: 40px; }
}
@media (max-width: 560px) {
  /* community.css stacks the reply count under the card here. */
  body.community-page .conversation-card { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  body.community-page .conversation-stats { padding-left: 0; border-left: 0; align-content: start; }
}

@media (prefers-reduced-motion: reduce) {
  .community-hero-chip { animation: none; }
  .community-door { transition: none; }
  .community-door:hover { transform: none; }
}
