.community-voices {
  --community-rule: color-mix(in srgb, var(--ink) 18%, transparent);
  --facebook-blue: #0866ff;
  --community-type-body: var(--type-body);
  --community-type-label: var(--type-label);
  position: relative;
  overflow: clip;
  background: var(--paper-deep);
}

.community-voices::before {
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  background: var(--community-rule);
  content: "";
}

.community-voices__heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: var(--heading-copy-gap, 16px);
  margin-bottom: var(--heading-content-gap, 48px);
}

.community-voices__heading h2 {
  max-width: 780px;
  margin: 0;
  font-size: var(--type-headline);
  line-height: var(--leading-headline);
  letter-spacing: -.03em;
}

.community-voices__intro {
  max-width: 62ch;
}

.community-voices__intro p {
  margin: 0;
  color: var(--ink);
  font-size: var(--type-body);
  line-height: var(--leading-body);
}

.community-voices__intro span {
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: var(--type-label);
  line-height: var(--leading-label);
  letter-spacing: .1em;
  text-transform: uppercase;
}

.community-voices__intro [data-community-count] {
  display: block;
}

.community-rail-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-top: 20px;
}

.community-rail-controls[hidden] { display: none; }

.community-rail-buttons {
  display: flex;
  gap: 8px;
}

.community-rail-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--community-rule);
  border-radius: 0;
  background: transparent;
  color: var(--deep);
  transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}

.community-rail-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.community-rail-button:hover:not(:disabled) {
  border-color: var(--deep);
  background: var(--deep);
  color: var(--white);
}

.community-rail-button:focus-visible {
  outline: 2px solid var(--coral);
  outline-offset: 3px;
}

.community-rail-button:disabled {
  cursor: default;
  opacity: .38;
}

.community-post-grid,
.x-feed-grid {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: clamp(320px, 28vw, 380px);
  grid-template-rows: 1fr;
  align-items: stretch;
  gap: 24px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  padding: 6px 0 8px;
  scroll-padding-inline: 1px;
  scroll-snap-type: inline mandatory;
  scrollbar-width: none;
}

.community-post-grid::-webkit-scrollbar,
.x-feed-grid::-webkit-scrollbar {
  display: none;
}

.community-card,
.x-feed-card {
  min-width: 0;
  height: 100%;
  scroll-snap-align: start;
}

.community-card__open,
.x-feed-card__open {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--community-rule);
  border-radius: 14px;
  background: var(--white);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform .3s cubic-bezier(.22, 1, .36, 1), border-color .3s ease;
}

.community-card__open:hover,
.x-feed-card__open:hover {
  border-color: var(--deep);
  transform: translateY(-2px);
}

.community-card__open:focus-visible,
.x-feed-card__open:focus-visible {
  outline: 3px solid var(--coral);
  outline-offset: 4px;
}

.community-post__header {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 16px 18px 12px;
}

.community-post__avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  border-radius: 50%;
  background: var(--mint);
  color: var(--deep);
  font-size: var(--community-type-body);
  font-weight: 700;
  letter-spacing: -.02em;
  text-transform: uppercase;
}

.community-post__identity {
  min-width: 0;
  flex: 1;
}

.community-post__identity strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: var(--community-type-body);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.community-post__identity span,
.community-post__date {
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: var(--community-type-label);
  line-height: 1.3;
}

.community-post__visibility {
  width: 13px;
  height: 13px;
  margin-left: 3px;
  vertical-align: -2px;
  fill: currentColor;
}

.community-post__brand {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  flex: 0 0 28px;
  border-radius: 50%;
  background: var(--facebook-blue);
  color: var(--white);
}

.community-post__brand svg {
  width: 8px;
  height: 17px;
  fill: currentColor;
}

.community-post__copy {
  display: -webkit-box;
  min-height: 118px;
  overflow: hidden;
  margin: 0;
  padding: 0 18px 22px;
  color: var(--ink);
  font-size: var(--type-body);
  line-height: var(--leading-body);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.community-post__media {
  position: relative;
  aspect-ratio: 16 / 10;
  flex: 0 0 auto;
  overflow: hidden;
  margin: 0;
  background: var(--paper);
}

.community-post__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .55s cubic-bezier(.22, 1, .36, 1);
}

.community-card__open:hover .community-post__media img {
  transform: scale(1.025);
}

.community-post__media-empty {
  height: 100%;
  display: grid;
  place-items: center;
  padding: 28px;
  background: var(--deep);
  color: color-mix(in srgb, var(--white) 82%, transparent);
  font-family: var(--serif);
  font-size: 25px;
  font-style: italic;
  text-align: center;
}

.community-post__image-count,
.community-post__pending,
.community-post__local {
  position: absolute;
  top: 12px;
  padding: 6px 9px;
  border-radius: 0;
  font-size: 10px;
  font-weight: 700;
}

.community-post__image-count {
  right: 12px;
  background: color-mix(in srgb, var(--ink) 82%, transparent);
  color: var(--white);
}

.community-post__pending {
  left: 12px;
  background: var(--coral);
  color: var(--ink);
  text-transform: uppercase;
}

.community-post__local {
  left: 12px;
  border: 1px solid var(--community-rule);
  background: var(--white);
  color: var(--deep);
  text-transform: uppercase;
}

.community-card__cta {
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: auto;
  padding: 12px 18px;
  border-top: 1px solid var(--community-rule);
  color: var(--deep);
  font-size: var(--community-type-body);
  font-weight: 700;
}

.community-card__cta svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.community-feed-message {
  grid-column: 1 / -1;
  min-height: 310px;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 48px 24px;
  border-top: 1px solid rgba(29, 37, 37, .24);
  border-bottom: 1px solid rgba(29, 37, 37, .24);
  text-align: center;
}

.community-feed-message strong {
  font-family: var(--serif);
  font-size: clamp(29px, 4vw, 46px);
  font-style: italic;
  font-weight: 500;
}

.community-feed-message span {
  max-width: 520px;
  margin-top: 10px;
  color: var(--ink-soft);
  font-size: 14px;
}

.community-feed-retry { min-height: 44px; margin-top: 20px; padding: 10px 14px; border: 1px solid var(--deep); background: transparent; color: var(--deep); font: 700 var(--type-micro) / var(--leading-label) var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.community-feed-retry:hover, .community-feed-retry:focus-visible { border-color: var(--coral); color: var(--coral); }
.community-feed-retry:focus-visible { outline: 2px solid var(--coral); outline-offset: 3px; }

.community-viewer {
  width: min(1100px, calc(100vw - 40px));
  max-width: none;
  height: min(760px, calc(100dvh - 40px));
  max-height: none;
  overflow: hidden;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: var(--paper);
  box-shadow: 0 28px 80px color-mix(in srgb, var(--deep) 42%, transparent);
  color: var(--ink);
}

.community-viewer::backdrop {
  background: rgba(10, 18, 25, .78);
  backdrop-filter: blur(8px);
}

.community-viewer[open] {
  animation: community-viewer-in .36s cubic-bezier(.22, 1, .36, 1) both;
}

@keyframes community-viewer-in {
  from { transform: translateY(24px) scale(.975); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.community-viewer__layout {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(340px, .88fr);
}

.community-viewer__gallery {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background: var(--deep);
  touch-action: pan-y;
}

.community-viewer__track {
  height: 100%;
  display: flex;
  transition: transform .42s cubic-bezier(.22, 1, .36, 1);
}

.community-viewer__slide {
  min-width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
}

.community-viewer__slide img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.community-viewer__empty-media {
  max-width: 18ch;
  color: rgba(255, 255, 255, .72);
  font-family: var(--serif);
  font-size: 34px;
  font-style: italic;
  text-align: center;
}

.community-viewer__close,
.community-viewer__arrow {
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 0;
  background: color-mix(in srgb, var(--deep) 82%, transparent);
  color: var(--paper);
  cursor: pointer;
}

.community-viewer__close {
  top: 15px;
  right: 15px;
  width: 48px;
  height: 48px;
}

.community-viewer__close svg,
.community-viewer__arrow svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 2;
}

.community-viewer__arrow {
  top: 50%;
  width: 48px;
  height: 48px;
  transform: translateY(-50%);
}

.community-viewer__arrow--prev { left: 15px; }
.community-viewer__arrow--next { right: 15px; }
.community-viewer__arrow[hidden] { display: none; }

.community-viewer__close:hover,
.community-viewer__arrow:hover { background: var(--coral); color: var(--deep); }
.community-viewer__close:focus-visible,
.community-viewer__arrow:focus-visible { outline: 3px solid var(--coral); outline-offset: 3px; }

.community-viewer__dots {
  position: absolute;
  z-index: 2;
  right: 0;
  bottom: 18px;
  left: 0;
  display: flex;
  justify-content: center;
  gap: 2px;
}

.community-viewer__dots[hidden] {
  display: none;
}

.community-viewer__dot {
  position: relative;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.community-viewer__dot::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--paper) 48%, transparent);
  transform: translate(-50%, -50%);
}

.community-viewer__dot[aria-current="true"]::after { background: var(--paper); }
.community-viewer__dot:focus-visible { outline: 3px solid var(--coral); outline-offset: 0; }

.community-viewer__post {
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--paper);
}

.community-viewer__post .community-post__header {
  padding: 21px 22px 15px;
}

.community-viewer__text {
  padding: 0 22px 22px;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.58;
  white-space: pre-wrap;
}

.community-viewer__pending-note {
  margin: 0 22px 20px;
  padding: 12px 13px;
  background: color-mix(in srgb, var(--coral) 13%, var(--paper));
  color: var(--ink);
  font-size: 12px;
  line-height: 1.4;
}

.community-viewer__actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: auto 18px 0;
  padding: 5px 0 18px;
  border-top: 1px solid var(--community-rule);
}

.community-viewer__actions .community-post__action {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
}

.community-viewer__actions .community-post__action svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.community-viewer__source {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  margin: 0 22px 22px;
  background: var(--deep);
  color: var(--paper);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.community-viewer__source:hover { background: var(--coral); color: var(--deep); }
.community-viewer__source:focus-visible { outline: 3px solid var(--coral); outline-offset: 3px; }

@media (max-width: 980px) {
  .community-viewer__layout { grid-template-columns: minmax(0, 1fr) 340px; }
}

@media (max-width: 700px) {
  .community-voices__heading { gap: var(--heading-copy-gap, 16px); }
  .community-rail-controls { margin-top: 20px; }
  .community-post-grid,
  .x-feed-grid { grid-auto-columns: min(78vw, 340px); gap: 16px; }
  .community-viewer { width: 100vw; height: 100dvh; border-radius: 0; }
  .community-viewer__layout { grid-template-columns: 1fr; grid-template-rows: minmax(300px, 54dvh) minmax(0, 46dvh); }
  .community-viewer__post { min-height: 0; }
  .community-viewer__close { position: fixed; }
}

@media (prefers-reduced-motion: reduce) {
  .community-card__open,
  .community-post__media img,
  .community-viewer[open],
  .community-viewer__track { animation: none; transition: none; }
}
