/* ============================================================
   downloads.css — Downloads page (dl- prefix)
   ============================================================ */

/* ── Layout override ──────────────────── */

.downloads .td-page-body {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: var(--space-lg);
}

/* ── Page Hero ──────────────────── */

.dl-page-hero {
  position: relative;
  min-height: 80px;
  background-image: url('/assets/images/common/page_hero.webp');
  background-color: var(--color-bg-light);
  background-size: auto 100%;
  background-position: right center;
  background-repeat: no-repeat;
  border-bottom: 1px solid var(--color-border);
  /*display: flex;
  flex-direction: column;
  justify-content: flex-end;*/
}

/* ── Filter Panel (aside) ──────────────────── */

/* Override base.css align-self: stretch (lower specificity) */
.downloads .td-page-body aside {
  align-self: start;
  position: sticky;
  top: var(--space-md);
}

/* Mobile toggle button — hidden on PC */
.dl-filter-toggle {
  display: none;
}

/* Apply button — hidden on PC */
.dl-filter__apply-wrap {
  display: none;
}

.dl-filter {
  background: var(--color-bg-light);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-md);
}

.dl-filter__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-sm);
}

.dl-filter__title {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  color: var(--color-primary);
  font-size: var(--text-md);
  font-weight: var(--font-regular);
}

.dl-filter__title::before {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  background-color: var(--color-primary);
  mask: url('/assets/images/common/icon/icon_filter.svg') center / contain no-repeat;
  -webkit-mask: url('/assets/images/common/icon/icon_filter.svg') center / contain no-repeat;
}

.dl-filter__reset {
  font-size: var(--text-xs);
  color: var(--color-primary);
  text-decoration: underline;
  white-space: nowrap;
  transition: color var(--transition-fast);
}

.dl-filter__reset:hover {
  text-decoration: none;
  color: var(--color-text-dark);
}

/* "All" row */
.dl-filter__row {
  padding-block: var(--space-sm);
}

/* Category groups */
.dl-filter__group {
  border-top: 1px solid var(--color-border);
  padding-block: var(--space-sm);
}

.dl-filter__group-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-xs);
}

/* Checkbox + label wrap */
.dl-filter__checkbox-wrap {
  display: flex;
  align-items: flex-start;
  gap: var(--space-xs);
}

.dl-filter__checkbox-wrap--sub {
  padding-left: var(--space-md);
  margin-bottom: 2px;
}

/* Custom checkbox */
.dl-checkbox {
  width: 20px;
  height: 20px;
  min-width: 20px;
  appearance: none;
  -webkit-appearance: none;
  background: var(--color-bg-white);
  border: 1px solid var(--color-text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  margin-top: 2px;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.dl-checkbox:checked {
  background: linear-gradient(180deg, var(--color-primary) 0%, #007AB7 100%);
  border-color: var(--color-primary);
}

.dl-checkbox:checked::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 10.5px;
  transform: translate(-50%, -50%);
  background-color: #fff;
  mask: url('/assets/images/common/icon/icon_checkbox.svg') center / contain no-repeat;
  -webkit-mask: url('/assets/images/common/icon/icon_checkbox.svg') center / contain no-repeat;
}

.dl-filter__label {
  font-size: var(--text-body);
  color: var(--color-text-dark);
  cursor: pointer;
  line-height: 1.5;
}

/* Checked state: label turns primary */
.dl-checkbox:checked + .dl-filter__label {
  color: var(--color-primary);
}

/* Sub-category label (Universal / Flowable / etc.) */
.dl-filter__sub-label {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--color-text-sub);
  padding-left: var(--space-md);
  margin-top: var(--space-sm);
  margin-bottom: var(--space-xs);
  letter-spacing: var(--tracking-normal);
}

/* Toggle button (+/-) */
.dl-filter__toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  position: relative;
  color: var(--color-text-dark);
  transition: color var(--transition-fast);
}

.dl-filter__toggle::before,
.dl-filter__toggle::after {
  content: '';
  display: block;
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 2px;
  background-color: currentColor;
  border-radius: 1px;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.dl-filter__toggle::before {
  transform: translate(-50%, -50%);
}

.dl-filter__toggle::after {
  transform: translate(-50%, -50%) rotate(90deg);
}

.dl-filter__toggle[aria-expanded="true"]::after {
  transform: translate(-50%, -50%) rotate(0deg);
  opacity: 0;
}

.dl-filter__toggle:hover {
  color: var(--color-primary);
}

/* Accordion body */
.dl-filter__group-body {
  overflow: hidden;
  max-height: 800px;
  opacity: 1;
  transition: max-height 0.5s ease, opacity 0.4s ease-out;
  padding-top: var(--space-xs);
}

.dl-filter__group-body.is-collapsed {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
}

/* ── Content Panel ──────────────────── */

.dl-content {
  background: var(--color-bg-light);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-md) var(--space-lg) var(--space-xl);
  min-width: 0;
}

.dl-intro {
  color: var(--color-text-sub);
  font-size: var(--text-sm);
  margin-bottom: var(--space-lg);
  line-height: var(--leading-normal);
}

/* ── Status Bar ──────────────────── */

.dl-status-bar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
}

.dl-status-bar[hidden] {
  display: none;
}

.dl-status-bar__count {
  font-size: var(--text-lg);
  font-weight: var(--font-medium);
  color: var(--color-text-dark);
}

.dl-status-bar__remove {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-text-dark);
  border: 1px solid var(--color-text-dark);
  border-radius: var(--radius-sm);
  padding: 0.1em 1em;
  background: transparent;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.dl-status-bar__remove:hover {
  background: var(--color-text-dark);
  color: var(--color-bg-white);
}

/* ── Category & Product blocks ──────────────────── */

/* Override h2 default margin within the content panel */
.dl-content h2.wp-block-heading {
  margin-top: var(--space-xl);
  padding-bottom: var(--space-sm);
}

.dl-content .dl-category-block:first-child h2.wp-block-heading {
  margin-top: 0;
  color: var(--color-text-dark);
  font-size: var(--text-xl);  
}

.dl-category-block {
  margin-bottom: var(--space-xl);
}

.dl-category-block:last-child {
  margin-bottom: 0;
}

/* Product name */
.dl-product-name {
  font-size: clamp(1.125rem, 2vw, 1.5rem);
  font-weight: var(--font-regular);
  color: var(--color-primary);
  margin-top: var(--space-lg);
  margin-bottom: var(--space-sm);
  line-height: var(--leading-tight);
}

.dl-product:first-of-type .dl-product-name {
  margin-top: var(--space-md);
}

/* ── Download Document Grid ──────────────────── */

.dl-docs-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

/* Base button */
.dl-doc-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-sm);
  min-height: 60px;
  background: linear-gradient(180deg, var(--color-bg-white) 0%, var(--color-bg-light) 100%);
  border: 1px solid var(--color-text-muted);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--color-text-dark);
  gap: var(--space-xs);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), color var(--transition-fast);
}

.dl-doc-btn:hover {
  border-color: var(--color-border-ruminous);
  box-shadow: 0 0 12px rgba(27, 143, 203, 0.5);
  color: var(--color-primary);
  text-decoration: none;
}

.dl-doc-btn__label {
  flex: 1;
  line-height: var(--leading-tight);
  font-size: var(--text-body);
}

.dl-doc-btn__icon {
  width: 20px;
  height: 24px;
  flex-shrink: 0;
  object-fit: contain;
}

.dl-doc-btn__icon--blank {
  width: 14px;
  height: 14px;
}

/* ── Mixitup — hide/show product blocks ──────────────────── */

.dl-product {
  margin-bottom: var(--space-md);
}


/* ── Responsive ──────────────────── */

@media (max-width: 1100px) {
  .dl-docs-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 767px) {
  .downloads .td-page-body {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .downloads .td-page-body aside {
    display: block;
    position: sticky;
    top: 0;
    align-self: auto;
    z-index: 190;
  }

  /* Mobile toggle button */
  .dl-filter-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 55px;
    padding: 0 var(--space-md);
    background: var(--color-text);
    color: #fff;
    font-size: var(--text-md);
    font-weight: var(--font-medium);
    border: none;
    cursor: pointer;
    text-align: left;
  }

  .dl-filter-toggle span {
    flex: 1;
  }

  .dl-filter-toggle__chevron {
    transition: transform var(--transition-fast);
    flex-shrink: 0;
    width: 16px;
  }

  .dl-filter-toggle[aria-expanded="true"] .dl-filter-toggle__chevron {
    transform: rotate(180deg);
  }

  /* Filter panel: collapsed by default on mobile */
  .dl-filter-panel {
    max-height: 0;
    overflow: hidden;
    transition: 0.35s ease;
    background: var(--color-text);
    padding: 0 var(--space-md);
  }

  .dl-filter-panel.is-open {
    max-height: calc(100dvh - 55px);
    overflow-y: auto;
    padding: var(--space-md);
    padding-top: 0;
    padding-bottom: var(--space-xl);
  }

  /* Filter box inside panel */
  .dl-filter-panel .dl-filter {
    background: var(--color-bg-light);
    border-color: transparent;
    box-shadow: 0 0 6px rgba(27, 143, 203, 0.3);
    margin-top: var(--space-md);
  }

  .downloads .td-layout-two__content {
    width: min(var(--container-max), 100% - var(--container-pad) * 2);
    margin-inline: auto;
  }

  .dl-docs-grid {
    grid-template-columns: 1fr;
  }

  .dl-content {
    padding: var(--space-md);
  }

  /*.dl-page-hero {
    background-size: 60% auto;
    background-position: right bottom;
  }*/

  .dl-filter__apply-wrap {
    display: block;
    padding-top: var(--space-md);
    text-align: center;
  }

  .dl-filter__apply-btn {
    display: inline-block;
    width: 100%;
    max-width: 260px;
    min-height: 48px;
    margin: 0 auto;
    padding: 0 var(--space-md);
    background: transparent;
    border: 1px solid #fff;
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: var(--text-body);
    font-family: var(--font-base);
    cursor: pointer;
    text-align: center;
    line-height: 48px;
    transition: background var(--transition-fast);
  }

  .dl-filter__apply-btn:hover {
    background: rgba(255, 255, 255, 0.15);
  }
}
