/* =========================================
   Community Story Statistics Modal
   ========================================= */

#community-story-statistics-modal .community-story-statistics-modal__close {
  position: absolute !important;

  top: 1rem !important;
  right: 1rem !important;
  left: auto !important;

  z-index: 20;

  display: flex;
  align-items: center;
  justify-content: center;

  width: 32px;
  height: 32px;

  margin: 0;
  padding: 0;

  border: none;
  border-radius: 50%;

  background: rgb(0 0 0 / 7%);

  color: var(--text-color-of-background);

  font-size: 1.25rem;
  font-weight: 400;
  line-height: 1;

  cursor: pointer;

  appearance: none;

  transition:
    background-color 0.2s ease,
    transform 0.2s ease;
}

#community-story-statistics-modal
  .community-story-statistics-modal__close:hover {
  background: rgb(0 0 0 / 12%);
  transform: scale(1.05);
}

#community-story-statistics-modal
  .community-story-statistics-modal__close:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.community-story-statistics__delete-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 40px;
  padding: 0.65rem 1rem;
  border: 1px solid rgb(220 38 38 / 20%);
  border-radius: 8px;
  background: transparent;
  color: var(--error-color);
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease,
    transform 0.2s ease;
}

.community-story-statistics__delete-button:hover {
  border-color: var(--error-color);
  background: rgb(220 38 38 / 8%);
}

.community-story-statistics__delete-button:active {
  transform: scale(0.98);
}

.community-story-statistics__delete-button:focus-visible {
  outline: 2px solid var(--error-color);
  outline-offset: 2px;
}

.community-story-statistics__delete-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.community-story-statistics__delete-status {
  min-height: 1.25rem;
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  line-height: 1.4;
  text-align: right;
}

.community-story-statistics__delete-status--error {
  color: var(--error-color);
}

/* -----------------------------------------
   Modal
----------------------------------------- */

.community-story-statistics-modal {
  position: relative;

  display: flex;
  flex-direction: column;

  width: min(760px, calc(100% - 2rem));
  height: min(820px, calc(100vh - 2rem));
  max-height: calc(100vh - 2rem);

  min-height: 0;

  overflow: hidden;

  border-radius: 20px;

  background: var(--background-color);

  box-shadow: 0 24px 60px rgb(0 0 0 / 25%);
}

/* -----------------------------------------
   Close Button
----------------------------------------- */

#community-story-statistics-modal .community-story-statistics-modal__close {
  position: absolute;
  top: 1rem;
  right: 1rem;

  z-index: 20;

  display: flex;
  align-items: center;
  justify-content: center;

  width: 32px;
  height: 32px;

  padding: 0;

  border: 0;
  border-radius: 50%;

  background: rgb(0 0 0 / 8%);

  color: var(--text-color-of-background);

  font-size: 1.25rem;
  line-height: 1;

  cursor: pointer;

  transition:
    background-color 0.2s ease,
    transform 0.2s ease;
}

#community-story-statistics-modal
  .community-story-statistics-modal__close:hover {
  background: rgb(0 0 0 / 14%);

  transform: scale(1.05);
}

/* -----------------------------------------
   Header
----------------------------------------- */

.community-story-statistics-modal .modal__header {
  flex-shrink: 0;

  padding: 2rem 2rem 1.25rem;

  border-bottom: 1px solid rgb(0 0 0 / 8%);
}

.community-story-statistics-modal .modal__header h2 {
  margin: 0 0 0.35rem;

  color: var(--text-color-of-background);

  font-size: 1.5rem;
}

.community-story-statistics-modal .modal__header p {
  margin: 0;

  color: var(--text-color-of-background);

  opacity: 0.65;
}

/* -----------------------------------------
   Scrollable Content
----------------------------------------- */

.community-story-statistics {
  display: flex;
  flex: 1;
  flex-direction: column;

  gap: 1rem;

  min-height: 0;

  padding: 1.5rem 2rem 2rem;

  overflow-x: hidden;
  overflow-y: auto;

  scrollbar-width: thin;
}

/* -----------------------------------------
   Story
----------------------------------------- */

.community-story-statistics__story {
  flex-shrink: 0;

  overflow: hidden;

  border: 1px solid rgb(0 0 0 / 8%);
  border-radius: 14px;

  background: var(--background-color);
}

/* -----------------------------------------
   Story Visual
----------------------------------------- */

.community-story-statistics__story-visual {
  position: relative;

  width: 100%;
  height: 320px;

  overflow: hidden;

  background: var(--secondary-background-color);
}

.community-story-statistics__story-image {
  position: absolute;
  inset: 0;

  display: block;

  width: 100%;
  height: 100%;

  object-fit: cover;
}

/* Dark gradient over image */

.community-story-statistics__story-overlay {
  position: absolute;
  inset: 0;

  z-index: 1;

  background: linear-gradient(
    180deg,
    rgb(0 0 0 / 5%) 0%,
    rgb(0 0 0 / 10%) 35%,
    rgb(0 0 0 / 35%) 65%,
    rgb(0 0 0 / 80%) 100%
  );
}

/* -----------------------------------------
   Story Title + Text on Image
----------------------------------------- */

.community-story-statistics__story-info {
  position: absolute;

  right: 0;
  bottom: 0;
  left: 0;

  z-index: 2;

  padding: 2rem 1.5rem 1.5rem;
}

.community-story-statistics__story-visual
  .community-story-statistics__story-title {
  margin: 0 0 0.5rem;

  color: #fff;

  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.25;
}

.community-story-statistics__story-visual
  .community-story-statistics__story-text {
  display: -webkit-box;

  margin: 0;

  overflow: hidden;

  color: #fff;

  font-size: 0.95rem;
  line-height: 1.5;

  opacity: 0.92;

  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

/* -----------------------------------------
   Story without image
----------------------------------------- */

.community-story-statistics__story-no-image {
  position: relative;

  min-height: 220px;

  padding: 1.5rem;

  display: flex;
  flex-direction: column;
  justify-content: flex-end;

  background: linear-gradient(
    135deg,
    var(--secondary-background-color),
    var(--background-color)
  );
}

.community-story-statistics__story-no-image
  .community-story-statistics__story-title {
  margin: 0 0 0.5rem;

  color: var(--text-color-of-background);

  font-size: 1.25rem;
}

.community-story-statistics__story-no-image
  .community-story-statistics__story-text {
  margin: 0;

  color: var(--text-color-of-background);

  line-height: 1.5;

  opacity: 0.75;
}

/* -----------------------------------------
   Story Meta
----------------------------------------- */

.community-story-statistics__story-content {
  padding: 0 1.25rem 1.25rem;
}

.community-story-statistics__story-date {
  padding: 0.75rem 0 0.25rem;

  color: var(--text-color-of-background);

  font-size: 0.78rem;

  opacity: 0.5;
}

/* -----------------------------------------
   Sections
----------------------------------------- */

.community-story-statistics__section {
  padding-top: 1rem;

  border-top: 1px solid rgb(0 0 0 / 7%);
}

.community-story-statistics__section + .community-story-statistics__section {
  margin-top: 1rem;
}

.community-story-statistics__section-title {
  display: flex;
  align-items: center;

  gap: 0.5rem;

  margin: 0 0 0.65rem;

  color: var(--text-color-of-background);

  font-size: 0.9rem;
  font-weight: 600;
}

/* -----------------------------------------
   Viewed By
----------------------------------------- */

.community-story-statistics__people {
  display: flex;
  flex-direction: column;

  gap: 0.25rem;
}

.community-story-statistics__person {
  display: flex;
  align-items: center;

  gap: 0.75rem;

  padding: 0.55rem 0;
}

.community-story-statistics__person-avatar {
  display: flex;
  align-items: center;
  justify-content: center;

  flex-shrink: 0;

  width: 36px;
  height: 36px;

  border-radius: 50%;

  background: var(--secondary-background-color);

  font-size: 1.1rem;
}

.community-story-statistics__person-info {
  display: flex;
  flex: 1;
  flex-direction: column;

  min-width: 0;
}

.community-story-statistics__person-name {
  overflow: hidden;

  color: var(--text-color-of-background);

  font-size: 0.88rem;
  font-weight: 500;

  text-overflow: ellipsis;
  white-space: nowrap;
}

.community-story-statistics__person-date {
  margin-top: 0.1rem;

  color: var(--text-color-of-background);

  font-size: 0.75rem;

  opacity: 0.5;
}

/* -----------------------------------------
   Messages
----------------------------------------- */

.community-story-statistics__messages {
  display: flex;
  flex-direction: column;

  gap: 0.75rem;
}

.community-story-statistics__message {
  display: flex;
  align-items: flex-start;

  gap: 0.7rem;
}

.community-story-statistics__message-content {
  flex: 1;

  min-width: 0;
}

.community-story-statistics__message-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;

  gap: 0.75rem;

  margin-bottom: 0.3rem;
}

.community-story-statistics__message-text {
  margin: 0;

  padding: 0.65rem 0.8rem;

  border-radius: 0 10px 10px 10px;

  background: var(--secondary-background-color);

  color: var(--text-color-of-background);

  font-size: 0.86rem;
  line-height: 1.5;
}

/* -----------------------------------------
   Empty / Loading / Error
----------------------------------------- */

.community-story-statistics__loading,
.community-story-statistics__empty,
.community-story-statistics__error {
  padding: 2.5rem 1rem;

  text-align: center;

  color: var(--text-color-of-background);
}

.community-story-statistics__empty-icon {
  margin-bottom: 0.75rem;

  font-size: 2rem;
}

.community-story-statistics__empty h3,
.community-story-statistics__error h3 {
  margin: 0 0 0.5rem;

  color: var(--text-color-of-background);
}

.community-story-statistics__empty p,
.community-story-statistics__error p {
  margin: 0;

  opacity: 0.65;
}

.community-story-statistics__no-data {
  margin: 0;

  color: var(--text-color-of-background);

  font-size: 0.85rem;

  opacity: 0.55;
}

/* -----------------------------------------
   Mobile
----------------------------------------- */

@media (max-width: 600px) {
  .community-story-statistics-modal {
    width: calc(100% - 1rem);
    height: auto;
    max-height: calc(100dvh - 2rem);

    border-radius: 16px;
  }

  .community-story-statistics-modal .modal__header {
    padding: 1.25rem 1rem 0.75rem;
  }

  #community-story-statistics-modal .modal__content {
    width: calc(100% - 2rem);
    max-width: 420px;
    max-height: calc(100dvh - 2rem);
    padding: 1rem;
    border-radius: 16px;
    overflow-y: auto;
  }

  .community-story-statistics {
    padding: 0.75rem 1rem 1.25rem;
  }

  .community-story-statistics__story-visual {
    height: 240px;
  }

  .community-story-statistics__story-info {
    padding: 1.25rem 0.75rem 0.75rem;
  }

  .community-story-statistics__story-visual
    .community-story-statistics__story-title {
    font-size: 1.1rem;
  }

  .community-story-statistics__story-visual
    .community-story-statistics__story-text {
    font-size: 0.85rem;
  }

  .community-story-statistics__story-content {
    padding: 0 0.75rem 1rem;
  }

  .community-story-statistics__message-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.1rem;
  }
}
