/* ═══════════════════════════════════════════════════════════════════════════
   ESO Housing — Community Gallery Redesign · "Modern Showcase"
   Photographic, presentation-grade. The screenshot leads.

   Scoped under body.gallery-modern-page so the existing site header and
   the hub/view actions stay untouched. Loaded after gallery-cards-v2.css
   and gallery-dock.css; overrides where needed.
   ═══════════════════════════════════════════════════════════════════════════ */

body.gallery-modern-page {
  /* ── surfaces: cool near-black, lets cool-toned screenshots glow ──────── */
  --gr-bg-deep:   #0a0b10;
  --gr-bg:        #0c0e14;
  --gr-bg-card:   #14161e;
  --gr-bg-elev:   #1a1d27;
  --gr-line:      rgba(255,255,255,.07);
  --gr-line-2:    rgba(255,255,255,.12);

  /* ── ink ──────────────────────────────────────────────────────────────── */
  --gr-ink:       #edeef2;
  --gr-ink-soft:  #aab0bd;
  --gr-ink-mute:  #71768a;
  --gr-ink-faint: #4d5160;

  /* ── accent: amber-gold (locked decision) ─────────────────────────────── */
  --gr-accent:      #e0a64e;
  --gr-accent-ink:  #0c0e14;
  --gr-accent-glow: color-mix(in srgb, #e0a64e 38%, transparent);
  --gr-accent-soft: color-mix(in srgb, #e0a64e 16%, transparent);

  /* ── type ─────────────────────────────────────────────────────────────── */
  --gr-display: 'Newsreader', 'Cinzel', Georgia, serif;
  --gr-body:    'Manrope', 'Inter', system-ui, -apple-system, sans-serif;
  --gr-mono:    'JetBrains Mono', 'IBM Plex Mono', ui-monospace, monospace;

  --gr-r-sm: 8px;
  --gr-r-md: 14px;
  --gr-r-lg: 20px;
  --gr-r-xl: 26px;

  --gr-ease:   cubic-bezier(.22,.78,.27,1);
  --gr-t-fast: 180ms var(--gr-ease);
  --gr-t-med:  340ms var(--gr-ease);
  --gr-t-slow: 620ms var(--gr-ease);

  --gr-maxw: 1380px;
}

/* ── page chrome: replace any existing background with the atmospheric backdrop ── */
body.gallery-modern-page {
  background: var(--gr-bg-deep);
  color: var(--gr-ink);
  font-family: var(--gr-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* atmospheric backdrop: faint amber + cool blue radial blooms over near-black */
body.gallery-modern-page::before {
  content: '';
  position: fixed; inset: 0; z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(1100px 620px at 78% -8%, color-mix(in srgb, var(--gr-accent) 12%, transparent), transparent 60%),
    radial-gradient(900px 700px at 8% 4%, rgba(90,120,200,.10), transparent 62%),
    var(--gr-bg-deep);
}
/* SVG fractal grain overlay (3.5% opacity, overlay blend) */
body.gallery-modern-page::after {
  content: '';
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  opacity: .035; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}
body.gallery-modern-page.no-grain::after { display: none; }

body.gallery-modern-page ::selection { background: var(--gr-accent); color: var(--gr-accent-ink); }

/* ── scope wrapper: every redesigned block lives inside .gr ───────────── */
.gr-wrap { max-width: var(--gr-maxw); margin: 0 auto; padding: 0 32px; }
@media (max-width: 720px) { .gr-wrap { padding: 0 18px; } }

/* ── neutralize existing community page wrappers that fight our layout ── */
body.gallery-modern-page .page-content {
  max-width: none !important;
  padding: 0 !important;
}
body.gallery-modern-page .page-content > div[style*="max-width:960px"] {
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
}
body.gallery-modern-page .detail-back.gallery-back {
  display: block;
  max-width: var(--gr-maxw);
  margin: 18px auto 0;
  padding: 0 32px;
  font-family: var(--gr-mono);
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--gr-ink-mute);
  text-decoration: none;
  transition: color var(--gr-t-fast);
}
body.gallery-modern-page .detail-back.gallery-back:hover { color: var(--gr-accent); }

/* ═══════════════════════════════════════════════════════════════════════
   1. HERO — atmospheric, photographic, italic-word headline
   ═══════════════════════════════════════════════════════════════════════ */

body.gallery-modern-page .gr-hero {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--gr-line);
  margin: 26px 0 0;
}
.gr-hero__bg {
  position: absolute; inset: 0; z-index: 0;
  background-size: cover; background-position: center 38%;
  filter: saturate(1.05);
}
.gr-hero__bg::after {
  content: ''; position: absolute; inset: 0;
  background:
    linear-gradient(90deg, var(--gr-bg-deep) 8%, rgba(10,11,16,.55) 48%, rgba(10,11,16,.30) 100%),
    linear-gradient(0deg, var(--gr-bg-deep) 2%, transparent 55%);
}
.gr-hero__inner {
  position: relative; z-index: 1;
  max-width: var(--gr-maxw); margin: 0 auto;
  padding: 64px 32px 52px;
}
.gr-hero__eyebrow {
  display: inline-flex; align-items: center; gap: 9px;
  font-family: var(--gr-mono); font-size: 11px;
  letter-spacing: .22em; text-transform: uppercase;
  color: var(--gr-accent); margin-bottom: 18px;
}
.gr-hero__eyebrow::before {
  content: ''; width: 22px; height: 1px;
  background: var(--gr-accent); opacity: .7;
}
.gr-hero__title {
  font-family: var(--gr-display); font-weight: 500;
  font-size: clamp(2.4rem, 5vw + .4rem, 4.4rem);
  line-height: .98; letter-spacing: -.018em;
  margin: 0; color: #fff;
  text-shadow: 0 2px 40px rgba(0,0,0,.5);
}
.gr-hero__title em {
  font-style: italic;
  color: color-mix(in srgb, var(--gr-accent) 70%, #fff);
  font-weight: 400;
}
.gr-hero__sub {
  margin: 18px 0 0; max-width: 52ch;
  font-size: 16px; color: var(--gr-ink-soft); line-height: 1.6;
}
.gr-hero__stats {
  display: flex; gap: 38px; margin-top: 34px;
  flex-wrap: wrap; align-items: stretch;
}
.gr-hero__stat { display: flex; flex-direction: column; gap: 4px; }
.gr-hero__stat b {
  font-family: var(--gr-display); font-weight: 500;
  font-size: 30px; color: #fff; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.gr-hero__stat span {
  font-family: var(--gr-mono); font-size: 10.5px;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--gr-ink-mute);
}
.gr-hero__stat--div { width: 1px; align-self: stretch; background: var(--gr-line); }

@media (max-width: 720px) {
  .gr-hero__inner { padding: 44px 18px 36px; }
  .gr-hero__stats { gap: 22px; }
  .gr-hero__stat b { font-size: 24px; }
  .gr-hero__stat--div { display: none; }
}

/* ═══════════════════════════════════════════════════════════════════════
   2. FEATURED — Three.js linear coverflow stage
   ═══════════════════════════════════════════════════════════════════════ */

body.gallery-modern-page .gr-featured {
  position: relative;
  padding: 46px 0 8px;
  max-width: var(--gr-maxw); margin: 0 auto;
}
.gr-featured__head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 22px;
  padding: 0 32px;
}
.gr-section-kicker {
  font-family: var(--gr-mono); font-size: 11px;
  letter-spacing: .2em; text-transform: uppercase;
  color: var(--gr-ink-mute);
  display: flex; align-items: center; gap: 10px;
}
.gr-section-kicker b { color: var(--gr-accent); font-weight: 500; }
.gr-section-title {
  font-family: var(--gr-display); font-weight: 500;
  font-size: clamp(1.5rem, 2.4vw, 2.1rem);
  letter-spacing: -.01em; color: #fff;
  margin: 5px 0 0;
}
.gr-feat-nav { display: flex; gap: 8px; }
.gr-feat-nav button {
  width: 42px; height: 42px; border-radius: 50%;
  background: rgba(255,255,255,.05); border: 1px solid var(--gr-line);
  color: var(--gr-ink-soft); font-size: 17px;
  transition: all var(--gr-t-fast);
  display: grid; place-items: center;
  cursor: pointer;
}
.gr-feat-nav button:hover {
  background: var(--gr-accent); color: var(--gr-accent-ink);
  border-color: var(--gr-accent);
  box-shadow: 0 6px 18px var(--gr-accent-glow);
}

/* coverflow stage */
.gr-feat3d {
  position: relative;
  padding: 0 32px;
}
.gr-feat3d__stage {
  position: relative;
  width: 100%; height: 600px;
  touch-action: pan-y;
  -webkit-user-select: none; user-select: none;
}
.gr-feat3d__stage::before {
  content: ''; position: absolute; inset: 0; z-index: 0;
  pointer-events: none;
  background: radial-gradient(64% 70% at 50% 42%,
    color-mix(in srgb, var(--gr-accent) 12%, transparent), transparent 72%);
}
/* soft side fades so panels melt into the page */
.gr-feat3d__stage::after {
  content: ''; position: absolute; inset: 0; z-index: 2;
  pointer-events: none;
  background: linear-gradient(90deg, var(--gr-bg-deep) 0%, transparent 14%, transparent 86%, var(--gr-bg-deep) 100%);
}
.gr-feat3d__stage canvas {
  display: block; outline: none;
  position: relative; z-index: 1;
  cursor: grab;
}
.gr-feat3d__stage canvas:active { cursor: grabbing; }
.gr-feat3d__stage.is-loading::before {
  background: radial-gradient(64% 70% at 50% 42%, rgba(255,255,255,.04), transparent 72%);
}

.gr-feat3d__loader {
  position: absolute; inset: 0; z-index: 3;
  display: grid; place-items: center;
  pointer-events: none;
  opacity: 1; transition: opacity 480ms var(--gr-ease);
}
.gr-feat3d__loader::after {
  content: ''; width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid var(--gr-line-2);
  border-top-color: var(--gr-accent);
  animation: gr-spin 720ms linear infinite;
}
.gr-feat3d__stage.is-ready .gr-feat3d__loader { opacity: 0; }
@keyframes gr-spin { to { transform: rotate(360deg); } }

/* caption + dots */
.gr-feat3d__caption {
  max-width: 720px; margin: -6px auto 0;
  text-align: center;
  position: relative; z-index: 3;
  padding: 0 32px;
  animation: gr-capfade .5s var(--gr-ease);
}
@keyframes gr-capfade {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.gr-feat3d__style {
  font-family: var(--gr-mono); font-size: 11px;
  letter-spacing: .18em; text-transform: uppercase;
  color: var(--gr-ink-mute); margin-bottom: 6px;
}
.gr-feat3d__style b { color: var(--gr-accent); font-weight: 500; }
.gr-feat3d__name {
  font-family: var(--gr-display); font-weight: 500;
  font-size: clamp(1.7rem, 3vw, 2.5rem);
  line-height: 1.05; color: #fff;
  letter-spacing: -.01em; margin: 4px 0 16px;
  text-shadow: 0 2px 24px rgba(0,0,0,.6);
}
.gr-feat3d__meta {
  display: flex; align-items: center; gap: 18px;
  flex-wrap: wrap; justify-content: center;
}
.gr-feat3d__builder { display: flex; align-items: center; gap: 10px; }
.gr-feat3d__builder .av {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--gr-mono); font-size: 11px; font-weight: 700;
  color: #fff; background: linear-gradient(135deg, #3a4150, #20242f);
  box-shadow: 0 0 0 2px rgba(255,255,255,.1);
}
.gr-feat3d__builder .av img { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }
.gr-feat3d__builder span {
  font-size: 14px; color: var(--gr-ink); font-weight: 600;
  text-align: left; line-height: 1.2;
}
.gr-feat3d__builder small {
  display: block; font-family: var(--gr-mono);
  font-size: 10.5px; color: var(--gr-ink-mute);
  letter-spacing: .08em;
}
.gr-feat3d__stats {
  display: flex; gap: 14px;
  font-family: var(--gr-mono); font-size: 12px;
  color: var(--gr-ink-soft);
}
.gr-feat3d__stats b { color: #fff; font-weight: 500; }
.gr-feat3d__cta {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 20px; border-radius: 999px;
  background: var(--gr-accent); color: var(--gr-accent-ink);
  font-family: var(--gr-body); font-weight: 600; font-size: 13.5px;
  transition: all var(--gr-t-fast);
  box-shadow: 0 8px 22px var(--gr-accent-glow);
}
.gr-feat3d__cta:hover { transform: translateY(-2px); }

.gr-feat3d__dots {
  display: flex; gap: 9px; justify-content: center;
  margin-top: 22px;
}
.gr-feat3d__dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--gr-line-2); transition: all var(--gr-t-fast);
  border: none; padding: 0; cursor: pointer;
}
.gr-feat3d__dot:hover { background: var(--gr-ink-mute); }
.gr-feat3d__dot.on {
  width: 26px; border-radius: 4px;
  background: var(--gr-accent);
  box-shadow: 0 0 12px var(--gr-accent-glow);
}
.gr-feat3d__hint {
  text-align: center; margin-top: 14px;
  font-family: var(--gr-mono); font-size: 11px;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--gr-ink-mute);
}

/* fallback flat rail (no WebGL / reduced motion) */
.gr-feat-rail {
  display: flex; gap: 22px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 0 32px 10px;
  scrollbar-width: none;
}
.gr-feat-rail::-webkit-scrollbar { display: none; }
.gr-feat-rail .gr-feat-card {
  flex: 0 0 84%; max-width: 720px;
  scroll-snap-align: start;
}
.gr-feat-card {
  position: relative; border-radius: var(--gr-r-lg);
  overflow: hidden; aspect-ratio: 16 / 10;
  isolation: isolate; cursor: pointer;
  background: var(--gr-bg-card);
}
.gr-feat-card__img {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
}
.gr-feat-card__scrim {
  position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(0deg,
    rgba(7,8,12,.92) 4%, rgba(7,8,12,.35) 42%, rgba(7,8,12,0) 70%);
}
.gr-feat-card__body { position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; padding: 22px 24px; }
.gr-feat-card__name {
  font-family: var(--gr-display); font-weight: 500;
  font-size: clamp(1.3rem, 2vw, 1.8rem);
  color: #fff; margin: 0; line-height: 1.1;
}

@media (max-width: 720px) {
  .gr-feat3d__stage { height: 400px; }
  .gr-feat3d, .gr-featured__head, .gr-feat3d__caption { padding-left: 18px; padding-right: 18px; }
}

/* ═══════════════════════════════════════════════════════════════════════
   3. CONTROLS BAR — sticky, tabs · search · selects · density
   ═══════════════════════════════════════════════════════════════════════ */

body.gallery-modern-page .gr-controls {
  position: sticky; top: 56px; z-index: 50;
  margin-top: 44px; padding: 14px 0;
  background: linear-gradient(180deg, rgba(10,11,16,.96), rgba(10,11,16,.86));
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  backdrop-filter: blur(14px) saturate(150%);
  border-top: 1px solid var(--gr-line);
  border-bottom: 1px solid var(--gr-line);
}
.gr-controls__row {
  display: flex; align-items: center; gap: 14px;
  flex-wrap: wrap;
}
.gr-controls__spacer { flex: 1; }

/* tabs (segmented pill container) */
.gr-tabs {
  display: flex; gap: 3px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--gr-line);
  border-radius: 11px; padding: 3px;
}
.gr-tab {
  appearance: none;
  padding: 8px 15px; border-radius: 8px;
  font-family: var(--gr-body); font-size: 13.5px; font-weight: 600;
  color: var(--gr-ink-soft);
  background: transparent; border: none;
  transition: all var(--gr-t-fast);
  white-space: nowrap;
  display: flex; align-items: center; gap: 7px;
  cursor: pointer; text-decoration: none;
}
.gr-tab:hover { color: var(--gr-ink); }
.gr-tab.is-active {
  background: var(--gr-bg-elev); color: var(--gr-ink);
  box-shadow: 0 1px 0 rgba(255,255,255,.05) inset;
}
.gr-tab.is-active .gr-tab__dot {
  background: var(--gr-accent);
  box-shadow: 0 0 8px var(--gr-accent-glow);
}
.gr-tab__dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--gr-ink-mute);
  transition: all var(--gr-t-fast);
}

/* search input */
.gr-search { position: relative; flex: 1; min-width: 190px; max-width: 340px; }
.gr-search input {
  width: 100%;
  padding: 10px 36px 10px 38px; border-radius: 11px;
  background: rgba(255,255,255,.04); border: 1px solid var(--gr-line);
  color: var(--gr-ink); font-family: var(--gr-body); font-size: 14px;
  transition: all var(--gr-t-fast);
  outline: none;
}
.gr-search input::placeholder { color: var(--gr-ink-mute); }
.gr-search input:focus {
  border-color: color-mix(in srgb, var(--gr-accent) 55%, transparent);
  background: rgba(255,255,255,.06);
  box-shadow: 0 0 0 3px var(--gr-accent-soft);
}
.gr-search__icon {
  position: absolute; left: 13px; top: 50%;
  transform: translateY(-50%);
  color: var(--gr-ink-mute); font-size: 14px;
  pointer-events: none;
}
.gr-search__kbd {
  position: absolute; right: 10px; top: 50%;
  transform: translateY(-50%);
  font-family: var(--gr-mono); font-size: 11px; color: var(--gr-ink-mute);
  border: 1px solid var(--gr-line); border-radius: 5px;
  padding: 1px 6px;
}

/* custom selects */
.gr-selectbox { position: relative; }
.gr-selectbox select {
  appearance: none; -webkit-appearance: none;
  padding: 10px 32px 10px 13px; border-radius: 11px;
  background: rgba(255,255,255,.04); border: 1px solid var(--gr-line);
  color: var(--gr-ink-soft);
  font-family: var(--gr-body); font-size: 13.5px; font-weight: 500;
  cursor: pointer; transition: all var(--gr-t-fast);
  outline: none;
}
.gr-selectbox select:hover { color: var(--gr-ink); border-color: var(--gr-line-2); }
.gr-selectbox select:focus { border-color: color-mix(in srgb, var(--gr-accent) 55%, transparent); box-shadow: 0 0 0 3px var(--gr-accent-soft); }
.gr-selectbox::after {
  content: '▾';
  position: absolute; right: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--gr-ink-mute); pointer-events: none;
  font-size: 11px;
}
.gr-selectbox select option { background: var(--gr-bg-elev); color: var(--gr-ink); }

/* density toggle */
.gr-density {
  display: flex; gap: 2px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--gr-line);
  border-radius: 10px; padding: 3px;
}
.gr-density button {
  width: 34px; height: 30px; border-radius: 7px;
  display: grid; place-items: center;
  color: var(--gr-ink-mute);
  background: transparent; border: none;
  transition: all var(--gr-t-fast);
  cursor: pointer;
}
.gr-density button.is-active {
  background: var(--gr-bg-elev); color: var(--gr-ink);
}
.gr-density button:hover { color: var(--gr-ink-soft); }
.gr-density i { display: grid; gap: 2px; font-style: normal; }
.gr-density i span { display: block; height: 2px; border-radius: 1px; background: currentColor; }

/* result line + chips */
.gr-resultbar {
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap; margin-top: 13px;
}
.gr-resultbar__count {
  font-family: var(--gr-body); font-size: 14px; color: var(--gr-ink-soft);
}
.gr-resultbar__count b {
  font-family: var(--gr-display); font-weight: 500;
  color: #fff; font-size: 17px;
  margin-right: 4px;
}
.gr-chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.gr-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 8px 5px 12px; border-radius: 999px;
  font-family: var(--gr-body); font-size: 12.5px; font-weight: 500;
  color: var(--gr-ink);
  background: var(--gr-accent-soft);
  border: 1px solid color-mix(in srgb, var(--gr-accent) 35%, transparent);
  transition: all var(--gr-t-fast);
  text-decoration: none;
}
.gr-chip span {
  color: var(--gr-ink-mute);
  font-family: var(--gr-mono); font-size: 10px;
  text-transform: uppercase; letter-spacing: .1em;
}
.gr-chip__x {
  width: 17px; height: 17px; border-radius: 50%;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--gr-accent) 24%, transparent);
  color: var(--gr-ink); font-size: 11px; line-height: 1;
  transition: all var(--gr-t-fast);
}
.gr-chip:hover .gr-chip__x { background: var(--gr-accent); color: var(--gr-accent-ink); }
.gr-chip--clear {
  background: transparent;
  border-color: var(--gr-line);
  color: var(--gr-ink-soft);
  padding: 5px 13px;
}
.gr-chip--clear:hover { border-color: var(--gr-line-2); color: var(--gr-ink); }

/* ═══════════════════════════════════════════════════════════════════════
   4. GRID — overlay card layout, parallax + reveal on hover
   ═══════════════════════════════════════════════════════════════════════ */

body.gallery-modern-page .gr-grid {
  display: grid;
  gap: 22px;
  padding: 30px 0 0;
  max-width: var(--gr-maxw);
  margin: 0 auto;
  grid-template-columns: repeat(var(--gr-cols, 3), minmax(0, 1fr));
  padding-left: 32px; padding-right: 32px;
}
@media (max-width: 980px) { body.gallery-modern-page .gr-grid { grid-template-columns: repeat(2, 1fr) !important; } }
@media (max-width: 600px) { body.gallery-modern-page .gr-grid { grid-template-columns: 1fr !important; padding-left: 18px; padding-right: 18px; } }

/* === OVERLAY card === the live page's .community-card markup, restyled === */
body.gallery-modern-page .community-card {
  position: relative;
  border-radius: var(--gr-r-md);
  overflow: hidden;
  cursor: pointer;
  display: block;
  background: #0a0b10 !important;
  border: 1px solid var(--gr-line) !important;
  /* kill the legacy glass + colored glow */
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  box-shadow: none !important;
  transition: transform var(--gr-t-med), border-color var(--gr-t-med), box-shadow var(--gr-t-med);
}
body.gallery-modern-page .community-card * { box-sizing: border-box; }

/* hide legacy featured strip + corner sigils (per locked decision: neutral grid cards) */
body.gallery-modern-page .community-card .featured-strip,
body.gallery-modern-page .community-card .featured-corner { display: none !important; }

/* media: 4/5 aspect, fills the card top */
body.gallery-modern-page .community-card .community-card__img-wrap {
  position: relative;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  background: #0a0b10;
}
body.gallery-modern-page .community-card .community-card__img-wrap::after {
  content: none;  /* kill the legacy bottom gradient — the body provides its own scrim */
}
body.gallery-modern-page .community-card .community-card__img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: var(--obj, center);
  transition: transform 600ms var(--gr-ease);
  will-change: transform;
}

/* hide the over-image like buttons — per locked decision the footer heart is the only like control */
body.gallery-modern-page .community-card .card-action-group,
body.gallery-modern-page .community-card > .community-card__img-wrap > .card-like-btn {
  display: none !important;
}

/* corner tags: style label (top-left) + image count (top-right) */
body.gallery-modern-page .community-card .community-card__size-badge {
  position: absolute;
  top: 11px; left: 11px;
  font-family: var(--gr-mono); font-size: 10px;
  letter-spacing: .1em; text-transform: uppercase;
  padding: 5px 9px; border-radius: 7px;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  background: rgba(8,9,13,.55);
  border: 1px solid rgba(255,255,255,.14);
  color: #fff; font-weight: 500;
}
body.gallery-modern-page .community-card .community-card__imgcount {
  position: absolute;
  top: 11px; right: 11px;
  font-family: var(--gr-mono); font-size: 10px;
  letter-spacing: .1em; text-transform: uppercase;
  padding: 5px 9px; border-radius: 7px;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  background: rgba(8,9,13,.55);
  border: 1px solid rgba(255,255,255,.14);
  color: #fff; font-weight: 500;
}

/* "View build →" pill — fades up on hover, bottom-right of media */
body.gallery-modern-page .community-card .community-card__view-btn {
  position: absolute;
  bottom: calc(50% - 28px); /* sits above the body scrim */
  right: 14px;
  z-index: 4;
  font-family: var(--gr-body); font-size: 12.5px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: 999px;
  background: var(--gr-accent); color: var(--gr-accent-ink);
  opacity: 0; transform: translateY(6px);
  transition: all var(--gr-t-med);
  box-shadow: 0 6px 18px rgba(0,0,0,.3);
  pointer-events: none;
}
@media (hover: hover) {
  body.gallery-modern-page .community-card:hover .community-card__view-btn {
    opacity: 1; transform: translateY(0);
  }
}

/* body: absolute over the bottom of the image with a gradient scrim */
body.gallery-modern-page .community-card .community-card__body {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 3;
  padding: 18px 18px 16px;
  background: linear-gradient(0deg,
    rgba(7,8,12,.94) 12%,
    rgba(7,8,12,.5) 55%,
    transparent);
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
  display: flex; flex-direction: column; gap: 0;
}
body.gallery-modern-page .community-card .community-card__house {
  font-family: var(--gr-display); font-weight: 500;
  font-size: 20px; color: #fff;
  letter-spacing: -.005em; line-height: 1.18;
  text-shadow: 0 2px 16px rgba(0,0,0,.7);
  margin: 0;
  /* clamp to 2 lines so long names don't blow up the card */
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
body.gallery-modern-page .community-card .community-card__meta-row {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 6px;
  font-family: var(--gr-mono); font-size: 10.5px;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--gr-ink-mute);
  align-items: center;
}
body.gallery-modern-page .community-card .community-card__server { font-weight: 500; }
body.gallery-modern-page .community-card .community-card__style-tag {
  color: var(--gr-accent); font-weight: 500;
  border: none !important; background: none !important; padding: 0 !important;
}
body.gallery-modern-page .community-card .community-card__meta-row > * + *::before {
  content: '·'; margin-right: 8px; color: var(--gr-ink-faint);
}

/* description hidden in overlay layout */
body.gallery-modern-page .community-card .community-card__desc { display: none; }

/* builder row inside body (avatar + name); .card-stats wraps to its own line */
body.gallery-modern-page .community-card .community-card__footer {
  display: flex; flex-wrap: wrap;
  align-items: center; gap: 9px;
  margin-top: 13px; padding-top: 0; border-top: none !important;
  font-family: var(--gr-body); color: rgba(255,255,255,.85);
}
body.gallery-modern-page .community-card .community-card__avatar {
  width: 27px; height: 27px; border-radius: 50%;
  flex-shrink: 0; display: grid; place-items: center;
  font-family: var(--gr-mono); font-size: 10.5px; font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #3a4150, #20242f) !important;
  object-fit: cover;
  overflow: hidden;
}
body.gallery-modern-page .community-card img.community-card__avatar { background: none !important; }
body.gallery-modern-page .community-card .community-card__name {
  font-size: 13px; color: #fff; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0; flex: 0 1 auto;
}
body.gallery-modern-page .community-card .community-card__guild-badge {
  width: 25px; height: 25px; border-radius: 7px;
  display: grid; place-items: center; flex-shrink: 0;
  font-size: 12px; color: #fff; text-decoration: none;
  background: color-mix(in srgb, var(--guild-badge-color, #a09c94) 26%, transparent);
  border: 1px solid color-mix(in srgb, var(--guild-badge-color, #a09c94) 50%, transparent);
}
body.gallery-modern-page .community-card .community-card__badge {
  font-family: var(--gr-mono); font-size: 9.5px;
  letter-spacing: .08em; text-transform: uppercase;
  padding: 3px 7px; border-radius: 5px;
  border: 1px solid currentColor;
  background: rgba(8,9,13,.4);
  white-space: nowrap;
}

/* stats — sit on their own row below the builder, revealed on hover (locked spec) */
body.gallery-modern-page .community-card .card-stats {
  flex: 1 0 100%;
  display: flex; gap: 14px; align-items: center;
  font-family: var(--gr-mono); font-size: 11.5px;
  color: rgba(255,255,255,.7);
}
body.gallery-modern-page .community-card .card-stat {
  display: inline-flex; align-items: center; gap: 5px;
}
body.gallery-modern-page .community-card .card-stat--likes { color: var(--gr-accent); }

/* HOVER — card lift + image zoom + parallax (JS sets transform) */
@media (hover: hover) {
  body.gallery-modern-page .community-card:hover {
    transform: translateY(-5px);
    border-color: var(--gr-line-2) !important;
    box-shadow: 0 18px 44px rgba(0,0,0,.5) !important;
  }
  body.gallery-modern-page .community-card:hover .community-card__img {
    transform: scale(1.08);
  }
}

/* "reveal stats" mode: hide the stats row until hover, slide it in
   with a hairline border-top (handoff spec). */
body.gallery-modern-page .gr-grid[data-reveal="true"] .community-card .card-stats {
  max-height: 0; opacity: 0; overflow: hidden;
  margin-top: 0; padding-top: 0; border-top: none;
  transition:
    max-height var(--gr-t-med),
    opacity var(--gr-t-med),
    margin-top var(--gr-t-med),
    padding-top var(--gr-t-med);
}
@media (hover: hover) {
  body.gallery-modern-page .gr-grid[data-reveal="true"] .community-card:hover .card-stats {
    max-height: 40px; opacity: 1;
    margin-top: 11px; padding-top: 12px;
    border-top: 1px solid var(--gr-line);
  }
}

/* card entry animation: staggered fade-up, triggered by existing gallery-v2.js
   adding .is-visible when the card enters the viewport. */
body.gallery-modern-page .gr-grid .community-card.gallery-card-animate {
  opacity: 0;
  transform: translateY(22px);
  transition:
    opacity .55s var(--gr-ease) var(--gr-d, 0ms),
    transform .55s var(--gr-ease) var(--gr-d, 0ms),
    border-color var(--gr-t-med),
    box-shadow var(--gr-t-med);
}
body.gallery-modern-page .gr-grid .community-card.gallery-card-animate.is-visible {
  opacity: 1; transform: translateY(0);
}
@media (hover: hover) {
  body.gallery-modern-page .gr-grid .community-card.gallery-card-animate.is-visible:hover {
    transform: translateY(-5px);
  }
}

/* ═══════════════════════════════════════════════════════════════════════
   5. LOAD MORE / FOOTER / EMPTY
   ═══════════════════════════════════════════════════════════════════════ */

body.gallery-modern-page .community-load-more {
  display: flex; justify-content: center;
  padding: 40px 0 14px;
  max-width: var(--gr-maxw); margin: 0 auto;
}
body.gallery-modern-page .community-load-more__btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 13px 26px; border-radius: 999px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--gr-line-2);
  color: var(--gr-ink); font-family: var(--gr-body);
  font-weight: 600; font-size: 14px;
  transition: all var(--gr-t-fast);
  cursor: pointer;
}
body.gallery-modern-page .community-load-more__btn:hover {
  background: var(--gr-accent);
  color: var(--gr-accent-ink);
  border-color: var(--gr-accent);
  box-shadow: 0 10px 30px var(--gr-accent-glow);
}
body.gallery-modern-page .community-load-more__btn small {
  font-family: var(--gr-mono); font-size: 11px; opacity: .7;
}

body.gallery-modern-page .gallery-footer-ornament {
  text-align: center; padding: 40px 0 80px;
  color: var(--gr-ink-mute);
  font-family: var(--gr-mono); font-size: 12px;
  letter-spacing: .25em;
}

body.gallery-modern-page .gallery-empty-v2 {
  text-align: center; padding: 80px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
body.gallery-modern-page .gallery-empty-v2__icon {
  font-size: 34px; color: var(--gr-ink-mute);
  width: auto; height: auto; opacity: 1;
}
body.gallery-modern-page .gallery-empty-v2__text {
  font-family: var(--gr-display); font-size: 22px;
  color: var(--gr-ink); font-weight: 500;
}
body.gallery-modern-page .gallery-empty-v2__hint {
  color: var(--gr-ink-mute); font-size: 14px;
  max-width: 40ch;
}

/* ═══════════════════════════════════════════════════════════════════════
   6. RESPONSIVE + REDUCED MOTION + LEGACY OVERRIDES
   ═══════════════════════════════════════════════════════════════════════ */

/* hide the legacy gallery-hero (we render gr-hero instead) */
body.gallery-modern-page .gallery-hero { display: none !important; }

/* the dock is replaced by gr-controls — hide the whole shell side panel */
body.gallery-modern-page .gallery-shell {
  display: block;
  grid-template-columns: none;
  gap: 0;
}
body.gallery-modern-page .gallery-shell > .dock,
body.gallery-modern-page .gallery-shell > .dock-backdrop {
  display: none !important;
}
body.gallery-modern-page .gallery-shell > .results { display: contents; }
body.gallery-modern-page .results > .results__bar { display: none !important; }
/* drop the old featured ring fallback if it's still in markup */
body.gallery-modern-page section.featured.is-fallback { display: none; }
/* spotlight/event banners get a tighter modern look */
body.gallery-modern-page .spotlight-banner,
body.gallery-modern-page .event-banner {
  max-width: var(--gr-maxw); margin-left: auto; margin-right: auto;
  border-radius: var(--gr-r-md);
  border-color: var(--gr-line);
  background: linear-gradient(180deg, rgba(20,22,30,.6), rgba(12,14,20,.85));
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}

/* foryou fallback notice */
body.gallery-modern-page .foryou-fallback-notice {
  max-width: var(--gr-maxw); margin: 0 auto 18px !important;
  background: var(--gr-accent-soft) !important;
  border: 1px solid color-mix(in srgb, var(--gr-accent) 35%, transparent) !important;
  border-radius: var(--gr-r-md) !important;
}

/* pagination */
body.gallery-modern-page .gallery-pagination {
  display: flex; justify-content: center; gap: 6px;
  margin: 36px auto 0; max-width: var(--gr-maxw); padding: 0 32px;
  font-family: var(--gr-body);
}
body.gallery-modern-page .gallery-pagination__btn {
  padding: 8px 14px; border-radius: 8px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--gr-line);
  color: var(--gr-ink-soft); font-size: 13px;
  transition: all var(--gr-t-fast);
  text-decoration: none;
}
body.gallery-modern-page .gallery-pagination__btn:hover {
  background: var(--gr-bg-elev); color: var(--gr-ink);
  border-color: var(--gr-line-2);
}
body.gallery-modern-page .gallery-pagination__btn.active {
  background: var(--gr-accent); color: var(--gr-accent-ink);
  border-color: var(--gr-accent);
}
body.gallery-modern-page .gallery-pagination__btn.disabled {
  opacity: .35; pointer-events: none;
}
body.gallery-modern-page .gallery-pagination__dots { color: var(--gr-ink-mute); padding: 8px 4px; }

@media (prefers-reduced-motion: reduce) {
  body.gallery-modern-page .community-card,
  body.gallery-modern-page .community-card__img,
  body.gallery-modern-page .gr-feat-card__img,
  body.gallery-modern-page .gallery-card-animate {
    animation: none !important;
    transition: none !important;
  }
  body.gallery-modern-page .gallery-card-animate { opacity: 1; }
}

@media (max-width: 720px) {
  body.gallery-modern-page .gr-controls { top: 0; }
  body.gallery-modern-page .gr-controls__row { gap: 10px; }
  body.gallery-modern-page .gr-search { max-width: none; }
  body.gallery-modern-page .gr-density { display: none; }
  body.gallery-modern-page .gr-tabs { order: -1; width: 100%; justify-content: space-between; }
}
