:root {
  --eitca-gap: 18px;
  --eitca-card-pad: 16px;
  --eitca-shadow: 0 10px 28px rgba(0,0,0,0.14);
  --eitca-shadow-hover: 0 22px 48px rgba(0,0,0,0.22);
  --eitca-yellow: #FFC107;
  --eitca-gray: #616161;
  --flag-size: 16px;  /* tweak to 18px if you prefer a bigger badge */
  --text-color: #616161;
  --text-color-strong: #2a2a2a;

  /* Responsive columns (overridden inline on the grid) */
  --eitca-columns-desktop: 3;
  --eitca-columns-laptop: 3; /* <=1200px */
  --eitca-columns-tablet: 2; /* <=1100px */
  --eitca-columns-mobile: 1; /* <=640px */
  --eitca-columns: var(--eitca-columns-desktop);
}

/* Make the widget container-query aware so it adapts inside sidebars */
.eitca-wrap { width: 100%; container-type: inline-size; }

/* =========================================================
   Filters (flex by default so “Clear” stays on the same row)
   ========================================================= */
.eitca-filters {
  display: flex;
  flex-wrap: wrap;                  /* single row if room; wrap only if needed */
  gap: 12px;
  margin: 0 0 18px 0;               /* slightly larger bottom margin */
  padding-bottom: 8px;              /* symmetric with top spacing */
  align-items: end;
}
.eitca-filter { display: grid; gap: 6px; }
.eitca-filter__label { font-size: 12px; color: #444; }
.eitca-filter__select {
  height: 36px;
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 8px;               /* sleeker */
  background: #fff;
  outline: none;
  width: 100%;
}
.eitca-filter__select:focus {
  border-color: #c3c9d0;
  box-shadow: 0 0 0 2px rgba(17, 24, 39, 0.08);
}

/* “Default” width behaviour for each filter tile */
.eitca-filters > .eitca-filter {
  flex: 1 1 220px;                  /* can grow & shrink; prefers ~220px */
  min-width: 160px;
}

/* Firefox-safe fallback: compress 3rd+ tiles first (typically Min/Max/Sort) */
.eitca-filters > .eitca-filter:nth-child(n+3) {
  flex: 0 1 160px;
  min-width: 130px;
}

/* Progressive enhancement (browsers with :has) – compress specific tiles first */
.eitca-filter:has(#eitca-filter-score),
.eitca-filter:has(#eitca-filter-score-max),
.eitca-filter:has(#eitca-filter-sort) {
  flex-basis: 160px;
  min-width: 130px;
}

/* Shared button */
.eitca-btn {
  height: 36px;
  padding: 0 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fafafa;
  cursor: pointer;
}
.eitca-btn:hover { background: #f0f0f0; }

.eitca-filter__clear {
  align-self: end;
  position: relative;
  top: -2px;                        /* align with selects */
  flex: 0 0 auto;                   /* keep “Clear” inline when there’s room */
  white-space: nowrap;
}

/* =================
   Uniform grid
   ================= */
.eitca-grid {
  --eitca-columns: var(--eitca-columns-desktop);
  display: grid;
  grid-template-columns: repeat(var(--eitca-columns), minmax(0, 1fr));
  gap: var(--eitca-gap);
}
/* laptop step (<=1200) before tablet */
@media (max-width: 1200px) {
  .eitca-grid {
    --eitca-columns: var(--eitca-columns-laptop);
    grid-template-columns: repeat(var(--eitca-columns), minmax(0, 1fr));
  }
}
@media (max-width: 1100px) {
  .eitca-grid {
    --eitca-columns: var(--eitca-columns-tablet);
    grid-template-columns: repeat(var(--eitca-columns), minmax(0, 1fr));
  }
}
@media (max-width: 640px) {
  .eitca-grid {
    --eitca-columns: var(--eitca-columns-mobile);
    grid-template-columns: repeat(var(--eitca-columns), minmax(0, 1fr));
  }
}

/* ===============================
   Masonry (true variable height)
   =============================== */
.eitca-grid--masonry {
  display: block;
  column-gap: var(--eitca-gap);
  column-count: var(--eitca-columns);
}
@media (max-width: 1200px) {
  .eitca-grid--masonry { column-count: var(--eitca-columns); }
}
@media (max-width: 1100px) {
  .eitca-grid--masonry { column-count: var(--eitca-columns); }
}
@media (max-width: 640px) {
  .eitca-grid--masonry { column-count: var(--eitca-columns); }
}

.eitca-empty { color: var(--eitca-gray); }

/* ========
   Cards
   ======== */
.eitca-card {
  background: #fff;
  border: 1px solid #eee;
  border-radius: 0;
  box-shadow: var(--eitca-shadow);
  padding: var(--eitca-card-pad);

  display: flex;
  flex-direction: column;

  min-height: 380px;                /* lets footer pin to bottom in uniform */
  position: relative;               /* for ::after halo */
  transform: translateY(8px);       /* no scale */
  opacity: 0;
  transition: transform .28s cubic-bezier(.2,.7,.3,1),
              box-shadow .28s ease,
              opacity .5s ease;
  will-change: transform, box-shadow;
  backface-visibility: hidden;      /* helps text stability on some GPUs */
}
.eitca-grid--masonry .eitca-card {
  break-inside: avoid;
  margin: 0 0 var(--eitca-gap);
  min-height: 0 !important;         /* natural height */
}

.eitca-card.in-view { opacity: 1; transform: translateY(0); }

.eitca-card:hover {
  transform: translateY(-14px);
  box-shadow:
    0 22px 48px rgba(0,0,0,0.22),
    0 60px 120px rgba(0,0,0,0.14);
}

.eitca-card.is-hidden,
.eitca-card.is-hidden-by-filter,
.eitca-card.is-hidden-by-load { display: none !important; }

/* Header */
.eitca-card__top {
  display: flex; align-items: center; justify-content: space-between;
  margin: 0 0 6px 0;
}
.eitca-card__stars { display: inline-flex; gap: 2px; }
.eitca-card__stars .star { fill: #E0E0E0; width: 18px; height: 18px; display: block; }
.eitca-card__stars .star.filled { fill: var(--eitca-yellow); }

.eitca-card__tag {
  font-size: 12px; font-weight: 700; color: #111; background: #F7F7F7; border: 1px solid #EEE;
  padding: 2px 8px; text-transform: uppercase; letter-spacing: .3px;
  cursor: pointer;
}

/* Avatar + name + position */
.eitca-card__avatar { display: flex; justify-content: center; margin-top: 2px; }
.eitca-card__avatar img {
  width: 92px; height: 92px; object-fit: cover; border-radius: 999px; border: 2px solid #f1f1f1;
}
.eitca-card__name { font-weight: 700; color: #1f1f1f; font-size: 14px; text-align: center; margin-top: 6px; }
.eitca-card__position { margin-top: 2px; font-size: 12px; color: var(--eitca-gray); text-align: center; }

/* Body */
.eitca-card__body { display: block; }
.eitca-card__text {
  color: var(--text-color);
  line-height: 1.6;
  margin: 10px 2px 0;
  white-space: normal;
  overflow: visible;
  text-overflow: initial;
  transition: color .28s ease;
}
.eitca-card:hover .eitca-card__text { color: var(--text-color-strong); }

/* Footer: date (left), country (center), source (right) */
.eitca-card__footer {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 8px;
  margin-top: auto;                 /* push to bottom in uniform */
}
.eitca-grid--masonry .eitca-card__footer { margin-top: 12px !important; }

.eitca-card__date { color: #333; font-size: 12px; justify-self: start; }

/* Country button (keep flag glued to text when the name wraps) */
.eitca-card__country {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 6px;

  /* keep button sized to content; don't stretch with grid column */
  width: -moz-fit-content;
  width: fit-content;
  max-width: 100%;

  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  appearance: none;
}
.eitca-card__country:focus-visible { outline: 2px solid #cfd8dc; outline-offset: 2px; }
.eitca-card__country .country-name {
  font-size: 12px;
  font-weight: 600;
  color: #333;
  flex: 0 1 auto;
  min-width: 0;                     /* allow wrapping without pushing the flag away */
}
.eitca-card__country .country-flag,
.eitca-card__country .country-flag-svg {
  flex: 0 0 auto;                   /* keep the flag tight next to the text even if the name wraps */
}

/* Emoji flags size */
.eitca-card__country .country-flag {
  font-size: var(--flag-size);
  line-height: 1;
}

/* SVG flags as circular badges */
.eitca-card__country .country-flag-svg {
  width: var(--flag-size);
  height: var(--flag-size);
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  object-fit: cover;
  display: inline-block;
  background: #fff;
  border: 1px solid #e6e6e6;
  box-shadow: 0 1px 0 rgba(0,0,0,0.04);
  vertical-align: middle;
}

.eitca-card__source,
.eitca-card__source--placeholder {
  font-weight: 600; font-size: 12px; text-decoration: none; justify-self: end;
}
.eitca-card__source:hover { text-decoration: underline; }

/* Load more */
.eitca-loadmore { display: flex; justify-content: center; margin: 52px 0 36px; }
.eitca-loadmore__btn {
  border: 1px solid #ddd; background: #fff; padding: 10px 16px; cursor: pointer;
  border-radius: 8px;               /* match filter buttons */
}
.eitca-loadmore__btn:hover { background: #fafafa; }

/* Subtle accent + reduced motion */
.eitca-card::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity .28s ease;
  background:
    radial-gradient(120% 160% at 50% -20%,
      rgba(0,0,0,0) 62%,
      rgba(56, 128, 255, 0.18) 100%);
}
.eitca-card:hover::after { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .eitca-card,
  .eitca-card:hover,
  .eitca-card.in-view {
    transition: box-shadow .18s ease, opacity .3s ease;
    transform: none !important;
  }
}

/* -------------------------
   Container-query overrides
   ------------------------- */

/* Earlier break to 2 cols when the widget itself is in a narrow sidebar */
@container (max-width: 980px) {
  .eitca-grid {
    --eitca-columns: var(--eitca-columns-tablet);  /* 2 columns (or inline override) */
    grid-template-columns: repeat(var(--eitca-columns), minmax(0, 1fr));
  }
  .eitca-grid--masonry { column-count: var(--eitca-columns); }

  /* In narrow columns, compress filters a bit more, then wrap */
  .eitca-filters { row-gap: 12px; padding-bottom: 12px; }
  .eitca-filters > .eitca-filter       { flex: 1 1 200px; min-width: 150px; }
  .eitca-filters > .eitca-filter:nth-child(n+2) { flex: 0 1 150px; min-width: 120px; }
  /* :has enhancement applies too (already declared above) */
}

/* Down to 1 col sooner inside very narrow columns */
@container (max-width: 760px) {
  .eitca-grid {
    --eitca-columns: var(--eitca-columns-mobile);  /* 1 column */
    grid-template-columns: repeat(var(--eitca-columns), minmax(0, 1fr));
  }
  .eitca-grid--masonry { column-count: var(--eitca-columns); }

  /* Balanced spacing when the filter row wraps */
  .eitca-filters { row-gap: 14px; padding-bottom: 12px; }
}
