/* Layout redesign for the templates gallery.
   Reference: Figma "Design Explore All Templates Page" at 1903px
   (node 1302:1725, dropdown state 1302:1909).

   The base stylesheet and the card markup both come from sites.cubewp.com,
   so this file overrides rather than replaces them. Anything the remote
   scripts read stays in the DOM — see .cwp-offscreen. */

/* Hidden from view but still readable/clickable by the gallery scripts.
   The category and main-category filter handlers are delegated from these
   nodes, and the dropdown proxies clicks to them. */
.cwp-offscreen {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ===============================================================
   Page width — the design runs edge to edge with a 16px gutter,
   but the base stylesheet caps .container-fluid at 1424px. Scoped
   to the gallery's own sections so nothing else is affected.
   =============================================================== */

.cwp-hero-wrapper > .container-fluid,
.cwp-templates-explore-container > .container-fluid {
    width: 100% !important;
    padding-left: 0 !important;
padding: 0 !important;
    padding-right: 0 !important;
    max-width: 1871px !important;
    margin: auto !important;
}

/* ===============================================================
   Hero — title and copy left, status pills right-aligned on the
   copy's line.
   =============================================================== */

.cwp-hero-wrapper .cwp-hero-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    'title title'
    'copy  meta';
  align-items: end;
  column-gap: 24px;
     row-gap: 2px;
}

.cwp-hero-wrapper .cwp-hero-title {
  grid-area: title;
  margin: 0;
}

.cwp-hero-wrapper .cwp-hero-description {
  grid-area: copy;
  max-width: 720px;
  margin: 0;
}

.cwp-hero-wrapper .cwp-hero-top {
  grid-area: meta;
  justify-self: end;
  margin: 0;
}

.cwp-hero-wrapper .cwp-hero-top-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

@media (max-width: 900px) {
  .cwp-hero-wrapper .cwp-hero-card {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      'title'
      'copy'
      'meta';
    row-gap: 12px;
  }

  .cwp-hero-wrapper .cwp-hero-top {
    justify-self: start;
  }

  .cwp-hero-wrapper .cwp-hero-top-left {
    justify-content: flex-start;
  }
}

/* ===============================================================
   Shell — no sidebar; toolbar, grid and pagination share one white
   card.
   =============================================================== */

.cwp-templates-explore-sidebar {
  display: none !important;
}

.cwp-templates-explore-wrapper {
  display: block !important;
}

.cwp-templates-explore-main {
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: visible !important;
  background: #ffffff;
  border-radius: 20px;
}

/* ===============================================================
   Toolbar — search, category dropdown, result count, sort tabs.
   =============================================================== */

.cwp-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
}

.cwp-toolbar .cwp-templates-explore-search-box {
  position: relative;
  flex: 1 1 420px;
  max-width: 690px;
  margin: 0;
}

.cwp-toolbar .cwp-templates-explore-search-box input {
  width: 100%;
  height: 40px;
  margin: 0;
  padding: 0px 17px 0 33px;
  border: 1px solid #ededf2;
  border-radius: 9999px;
  background: #f7f7fa;
  color: #1a1a1a;
  font-family: 'Inter Tight', sans-serif;
  font-size: 14px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.18s ease, background-color 0.18s ease;
  letter-spacing: -0.3px;
}

.cwp-toolbar .cwp-templates-explore-search-box input::placeholder {
  color: #9a9aae;
}

.cwp-toolbar .cwp-templates-explore-search-box input:focus {
  border-color: #5641f3;
  background: #ffffff;
}

.cwp-toolbar .cwp-templates-explore-search-box .cwp-search-icon {
  position: absolute;
  top: 50%;
  left: 12px;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  pointer-events: none;
}

/* Plain text in the design — no chip. */
.cwp-toolbar .cwp-results-count {
  margin: 0;
  padding: 0;
  background: none;
  border-radius: 0;
  color: #9a9aae;
  font-family: 'Inter Tight', sans-serif;
  font-size: 13px;
  font-weight: 400;
  line-height: 1;
  white-space: nowrap;
}

.cwp-toolbar .cwp-templates-type-filters {
  display: flex;
  gap: 0px;
  margin: 0 0 0 auto;
  padding: 4px;
  list-style: none;
  background: #f4f4f8;
  border-radius: 10px;
  height: auto !important;
}

.cwp-toolbar .cwp-templates-type-filters li {
  margin: 0;
  padding: 0;
  list-style: none;
}

.cwp-toolbar .cwp-templates-type-filter {
  padding: 10px 8px;
  border: none;
  border-radius: 7px;
  background: none;
  box-shadow: none;
  color: #717182;
  font-family: 'Inter Tight', sans-serif;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.18s ease, color 0.18s ease;
}

.cwp-toolbar .cwp-templates-type-filter:hover {
  color: #1a1a1a;
}

.cwp-toolbar .cwp-templates-type-filter.active {
  background: #ffffff;
  color: #111118;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(17, 17, 40, 0.1);
}

/* ---- Category dropdown ---- */

.cwp-category-select {
  position: relative;
  flex: 0 0 auto;
}

.cwp-category-select-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 44px;
  padding: 0 12px;
  border: 1px solid #e4e4ec;
  border-radius: 9999px;
  background: #ffffff !important;
  color: #1a1a1a;
  font-family: 'Inter Tight', sans-serif;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.18s ease, color 0.18s ease;
  letter-spacing: -0.3px;
}

.cwp-category-select-toggle:hover {
  border-color: #c8c3f5;
}

.cwp-category-select.is-open .cwp-category-select-toggle,
.cwp-category-select.has-selection .cwp-category-select-toggle {
  border-color: #5641f3;
  color: #5641f3;
}

.cwp-category-select-chevron {
  flex-shrink: 0;
  transition: transform 0.18s ease;
}

.cwp-category-select.is-open .cwp-category-select-chevron {
  transform: rotate(180deg);
}

.cwp-category-select-panel {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  z-index: 60;
  display: none;
  width: 268px;
  padding: 8px 0 0;
  border: 1px solid #efeff3;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 20px 44px rgba(17, 17, 40, 0.16);
}

.cwp-category-select.is-open .cwp-category-select-panel {
  display: block;
}

.cwp-cat-list {
  max-height: 340px;
  overflow-y: auto;
  padding: 0 8px;
}

.cwp-cat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  background: none;
  color: #1a1a1a;
  font-family: 'Inter Tight', sans-serif;
  font-size: 14.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.cwp-cat-row:hover {
  background: #f6f5ff;
}

.cwp-cat-row.is-active {
  background: #f3f0ff;
  color: #5641f3;
}

.cwp-cat-row--parent.is-expanded {
  color: #5641f3;
}

.cwp-cat-row--child {
  padding-left: 34px;
  color: #4a4a5a;
  font-weight: 400;
}

.cwp-cat-row-end {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.cwp-cat-count {
  min-width: 26px;
  padding: 3px 9px;
  border-radius: 9999px;
  background: #f0f0f5;
  color: #717182;
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
  text-align: center;
}

.cwp-cat-row--parent.is-expanded .cwp-cat-count,
.cwp-cat-row.is-active .cwp-cat-count {
  background: #ede9fe;
  color: #5641f3;
}

.cwp-cat-chevron {
  flex-shrink: 0;
  color: #9a9aae;
  transition: transform 0.18s ease;
}

.cwp-cat-row--parent.is-expanded .cwp-cat-chevron {
  color: #5641f3;
  transform: rotate(180deg);
}

.cwp-cat-children {
  display: none;
}

.cwp-cat-group.is-open .cwp-cat-children {
  display: block;
}

.cwp-cat-footer {
  margin-top: 8px;
  padding: 12px 20px;
  border-top: 1px solid #efeff3;
}

.cwp-cat-clear {
    padding: 0;
    border: none;
    background: none;
    color: #9999A8;
    font-family: 'Inter Tight', sans-serif;
    font-size: 13px;
    font-weight: 500;
    text-decoration: underline;
    cursor: pointer;
}

/* ===============================================================
   Grid + cards
   =============================================================== */

.cwp-templates-explore-content {
  padding: 29px 29px 32px 35px;
}

.cwp-templates-explore-grid {
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  gap: 26px !important;
  margin: 0 !important;
}

@media (max-width: 1280px) {
  .cwp-templates-explore-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 940px) {
  .cwp-templates-explore-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 600px) {
  .cwp-templates-explore-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .cwp-templates-explore-content {
    padding: 20px;
  }

  .cwp-toolbar {
    padding: 16px 20px;
  }
}

/* The browser-chrome dots, category chip and device icons all belong to the
   previous card design. The preview modal reads the category chip's text, so
   these are hidden rather than removed. */
.cwp-templates-explore-card .cwp-templates-explore-card-header,
.cwp-templates-explore-card .cwp-card-tags,
.cwp-templates-explore-card .cwp-card-device-icons {
  display: none !important;
}

.cwp-templates-explore-card {
  overflow: hidden;
  border: 1px solid #ececf1;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.cwp-templates-explore-card:hover {
  border-color: #dcd7fb;
  box-shadow: 0 14px 30px rgba(17, 17, 40, 0.1);
  transform: translateY(-2px);
}

.cwp-templates-explore-card .cwp-templates-explore-card-media {
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
}

.cwp-templates-explore-card .cwp-templates-explore-card-image-wrapper {
  position: relative;
  display: block;
  /* The base stylesheet pins this to a fixed pixel width, which breaks the
     fluid 4-up grid — force it back to the card's width. */
  width: 100% !important;
  height: 337px !important;
  overflow: hidden;
  margin: 0;
  border-radius: 0;
}

.cwp-templates-explore-card .cwp-template-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

/* ---- Hover overlay: Preview + Create ---- */

.cwp-templates-explore-card .cwp-templates-explore-hover-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  opacity: 0;
  background: rgba(26, 18, 66, 0.55);
  transition: opacity 0.2s ease;
}

.cwp-templates-explore-card:hover .cwp-templates-explore-hover-overlay,
.cwp-templates-explore-card:focus-within .cwp-templates-explore-hover-overlay {
  opacity: 1;
}

.cwp-templates-explore-card .cwp-templates-explore-preview-btn,
.cwp-templates-explore-card .cwp-templates-explore-create-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  margin: 0;
  padding: 0 22px;
  border: none;
  border-radius: 9999px;
  font-family: 'Inter Tight', sans-serif;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.15s ease;
}

.cwp-templates-explore-card .cwp-templates-explore-preview-btn {
  background: #5641f3;
  color: #ffffff;
}

.cwp-templates-explore-card .cwp-templates-explore-preview-btn:hover {
  background: #4835e0;
  transform: translateY(-1px);
}

/* White pill, purple label — not the dark text the old design used. */
.cwp-templates-explore-card .cwp-templates-explore-create-btn {
  background: #ffffff;
  color: #5641f3;
}

.cwp-templates-explore-card .cwp-templates-explore-create-btn:hover {
  background: #f4f2ff;
  transform: translateY(-1px);
}

/* ---- Card footer: title + New badge, then the subtitle ---- */

.cwp-templates-explore-card .cwp-templates-explore-card-info {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 1px 10px;
  padding: 10px 13px 8px 12px;
}

.cwp-templates-explore-card .cwp-card-title {
  grid-column: 1;
  grid-row: 1;
  margin: 0;
  overflow: hidden;
  color: #1a1a1a;
  font-family: 'Inter Tight', sans-serif;
  font-size: 15px;
  font-weight: 500;
  line-height: 22px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cwp-card-new-pill {
  grid-column: 2;
  grid-row: 1;
  padding: 3px 7px;
  border-radius: 9999px;
  background: #5641f3;
  color: #ffffff;
  font-family: 'Inter Tight', sans-serif;
  font-size: 11px;
  font-weight: 600;
  line-height: 16px;
  white-space: nowrap;
}

.cwp-templates-explore-card .cwp-card-demo {
  grid-column: 1 / -1;
  grid-row: 2;
  margin: 0;
  overflow: hidden;
  color: #717182;
  font-family: 'Inter Tight', sans-serif;
  font-size: 13px;
  font-weight: 400;
  line-height: 20px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .cwp-templates-explore-card,
  .cwp-templates-explore-card .cwp-templates-explore-hover-overlay,
  .cwp-templates-explore-card .cwp-templates-explore-preview-btn,
  .cwp-templates-explore-card .cwp-templates-explore-create-btn,
  .cwp-cat-chevron,
  .cwp-category-select-chevron {
    transition: none;
  }

  .cwp-templates-explore-card:hover {
    transform: none;
  }
}
