/* ==============================
   Hot Wheels Communities (hwcomm.html + hwcommadmin.html)
   Uses the theme variables from style.css (--card, --text, --border...)
   so light/dark mode works the same as the rest of the site.
============================== */

:root {
  /* Height of ONE collapsed community row (line 1 + the description button).
     The scroll box is 5 rows tall, so change this one number to resize both. */
  --hwc-row-h: 76px;
  --hwc-visible-rows: 5; /* overridden by displayCommSize from hwcommadmin.json */
  /* Size of the community icon: the real picture AND the fallback type logo use this one value */
  --hwc-icon-size: 1.6rem;
}

.hwcomm-sub {
  color: var(--secondary);
}

.hwcomm-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

/* ---------- page layout: list on the left, form on the right ----------
   CSS grid instead of Bootstrap's .row/.col: style.css overrides the
   padding of `.row > *`, which breaks the gutter maths and causes a
   small sideways scroll on phones. minmax(0, ..) lets long text shrink. */
.hwcomm-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
}

@media (min-width: 992px) {
  .hwcomm-layout {
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    align-items: start;
  }
}

/* Phones/tablets (single column): show the submit form BEFORE the list.
   The HTML order stays list-then-form; `order` only changes how it is drawn. */
@media (max-width: 991.98px) {
  .hwcomm-layout > aside {
    order: -1;
  }
}

/* ---------- one group = one community Type ---------- */
.hwcomm-group {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 16px;
  overflow: hidden;
}

.hwcomm-group-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.hwcomm-group-head h5 {
  margin: 0;
  font-size: 1.05rem;
}

.hwcomm-group-head .hwcomm-count {
  margin-left: auto;
  font-size: 12px;
  color: var(--secondary);
}

.hwcomm-group-head i {
  font-size: 1.25rem;
}

/* brand colours for the icons */
.hwcomm-ic-whatsapp {
  color: #25d366;
}
.hwcomm-ic-facebook {
  color: #1877f2;
}
.hwcomm-ic-reddit {
  color: #ff4500;
}
.hwcomm-ic-instagram {
  color: #e1306c;
}
.hwcomm-ic-telegram {
  color: #26a5e4;
}
.hwcomm-ic-discord {
  color: #5865f2;
}
.hwcomm-ic-other {
  color: var(--secondary);
}

/* ---------- the scroll box: shows max 5 rows, scrolls for the rest ---------- */
.hwcomm-scroll {
  max-height: calc(var(--hwc-row-h) * var(--hwc-visible-rows));
  overflow-y: auto;
  overscroll-behavior: contain; /* scrolling inside doesn't scroll the page */
}

.hwcomm-row {
  min-height: var(--hwc-row-h); /* grows when the description is opened */
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
}

/* line 1: icon | name | users | Join */
.hwcomm-row-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.hwcomm-icon-box {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hwcomm-icon {
  width: var(--hwc-icon-size);
  height: var(--hwc-icon-size);
  border-radius: 50%; /* circle, like the type logos */
  object-fit: cover;
}

.hwcomm-icon-fallback {
  font-size: var(--hwc-icon-size);
}

/* user count: keeps its width even when empty so the Join buttons line up */
.hwcomm-users {
  flex: 0 0 auto;
  min-width: 52px;
  text-align: right;
  font-size: 12px;
  color: var(--secondary);
  white-space: nowrap;
}

/* star rating: grey stars underneath, yellow stars on top clipped to the rating */
.hwcomm-rating {
  flex: 0 0 auto;
  min-width: 4.6em; /* keeps the space when there is no rating */
  text-align: right;
  font-size: 14px;
  line-height: 1;
  white-space: nowrap;
}

.hwcomm-stars {
  position: relative;
  display: inline-block;
}

.hwcomm-stars-base {
  color: rgba(128, 128, 128, 0.35);
}

.hwcomm-stars-fill {
  position: absolute;
  top: 0;
  left: 0;
  overflow: hidden;
  white-space: nowrap;
  color: #ffc107; /* yellow */
}

/* narrow phones: squeeze the columns so the name keeps some room */
@media (max-width: 575.98px) {
  .hwcomm-row-main {
    gap: 8px;
  }

  .hwcomm-users {
    min-width: 44px;
  }

  .hwcomm-rating {
    font-size: 12px;
  }
}

/* line 2: small foldable description */
.hwcomm-desc-toggle {
  align-self: flex-start;
  margin-left: 48px; /* lines up under the name (36px icon + 12px gap) */
  padding: 0;
  background: none;
  border: 0;
  font-size: 11px;
  color: var(--secondary);
  cursor: pointer;
}

.hwcomm-desc-toggle:hover {
  color: var(--text);
}

.hwcomm-desc-toggle i {
  font-size: 9px;
  transition: transform 0.2s;
}

.hwcomm-desc-toggle.is-open i {
  transform: rotate(180deg);
}

.hwcomm-desc {
  margin: 2px 0 2px 48px;
  font-size: 12px;
  color: var(--secondary);
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.hwcomm-row:last-child {
  border-bottom: 0;
}

.hwcomm-row-text {
  flex: 1 1 auto;
  min-width: 0; /* lets the ellipsis work inside flex */
}

.hwcomm-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hwcomm-link {
  display: block;
  font-size: 12px;
  color: var(--secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hwcomm-link:hover {
  color: var(--text);
}

/* community name used as the link on the public page */
.hwcomm-name-link {
  display: block;
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.hwcomm-name-link:hover {
  color: var(--text);
  text-decoration-thickness: 2px;
}

/* form card stays invisible (but keeps its space) until the on/off setting is known */
.hwcomm-pending {
  visibility: hidden;
}

/* ---------- form ---------- */
.hwcomm-form-card {
  position: sticky;
  top: calc(var(--navbar-height) + 16px);
}

@media (max-width: 991.98px) {
  .hwcomm-form-card {
    position: static;
  }
}

.hwcomm-card .form-control,
.hwcomm-card .form-select {
  background: var(--input);
  color: var(--text);
  border-color: var(--input-border);
}

/* honeypot: off-screen, not display:none (some bots skip display:none) */
.hwcomm-hp {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ---------- popup ---------- */
.hwcomm-modal {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.hwcomm-modal-icon {
  font-size: 2.2rem;
  color: #ffc107;
  margin-bottom: 8px;
}

/* ---------- admin page ---------- */
.hwcomm-table-wrap {
  max-height: 60vh;
  overflow: auto;
}

.hwcomm-table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--text);
  --bs-table-border-color: var(--border);
  margin-bottom: 0;
  font-size: 13px;
}

.hwcomm-table thead th {
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 1;
  white-space: nowrap;
}

.hwcomm-table td {
  vertical-align: middle;
}

.hwcomm-cell-link {
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-block;
  vertical-align: middle;
}

.hwcomm-pending-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.hwcomm-pending-item:last-child {
  border-bottom: 0;
}

.hwcomm-pending-info {
  flex: 1 1 260px;
  min-width: 0;
}

.hwcomm-pending-actions {
  display: flex;
  gap: 8px;
}

/* Preview Comm popup (admin): image choice cards */
.hwcomm-img-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 6px;
  height: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
}

.hwcomm-img-choice:has(input:checked) {
  border-color: #0d6efd;
  box-shadow: 0 0 0 1px #0d6efd;
}

.hwcomm-img-choice:has(input:disabled) {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Preview Comm popup (admin): icon box */
.hwcomm-prev-icon {
  flex: 0 0 64px;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 50%; /* circle, same look as the public page */
  overflow: hidden;
}

.hwcomm-prev-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hwcomm-prev-icon i {
  font-size: 2rem;
}

/* Compact submit form: small text, controls all the same height,
   type dropdown and Submit button the same width */
#hwcommFormCard h5 {
  font-size: 0.9rem;
}

#hwcommIntro,
#hwcommClosed {
  font-size: 11px;
  line-height: 1.35;
  margin-bottom: 0.5rem !important;
}

.hwcomm-form-compact .form-control,
.hwcomm-form-compact .form-select,
.hwcomm-form-compact .btn {
  font-size: 12px;
  line-height: 1.2;
  height: 28px;
  padding-top: 0;
  padding-bottom: 0;
}

.hwcomm-form-compact .form-control {
  margin-bottom: 0.4rem !important;
}

.hwcomm-form-row > * {
  flex: 1 1 0; /* equal width */
  min-width: 0;
}

/* Sort By dropdown in each section header (sits just before the "N communities" count) */
.hwcomm-sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0 0 0 auto;
  font-size: 12px;
  color: var(--secondary);
  white-space: nowrap;
}

.hwcomm-sort-select {
  width: auto;
  height: 26px;
  padding-top: 0;
  padding-bottom: 0;
  font-size: 12px;
}

.hwcomm-sort + .hwcomm-count {
  margin-left: 0;
}

/* narrow phones: let the header wrap instead of overflowing */
@media (max-width: 575.98px) {
  .hwcomm-group-head {
    flex-wrap: wrap;
    row-gap: 6px;
  }
}
