/**
 * PureChain Elements - COA Grid & Lightbox Viewer Styles
 * 1:1 Pixel-Perfect Replica of Onyx Research Test Results
 *
 * Strictly Enforced Design System Tokens:
 * - Surface: #101116 | Dark: #050505 | Light: #F5F7FA
 * - Border: 1px solid #292D35
 * - Accent Blue: #1677FF | Button Blue: #0057E7 | Hover Blue: #338CFF
 * - Text Primary: #FFFFFF | Text Muted: #BFC5D0 | Light Text: #050505
 * - STRICTLY 0px Border Radius Everywhere
 * - Fonts: Space Grotesk, Sora, Space Mono
 */

/* Hide default theme page header on COA page */
.page-id-42 .page-header,
.post-42 .page-header,
body.page-id-42 .entry-header,
body.page-id-42 h1.entry-title {
  display: none !important;
}

/* ========================================================
   1. GRID CONTAINER & SECTION WRAPPER (100% Section Fit)
   ======================================================== */
.purechain-coa-wrap {
  width: 100%;
  box-sizing: border-box;
  background: transparent;
  padding: 0;
  margin: 0;
}

.purechain-coa-container {
  width: 100%;
  max-width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  box-sizing: border-box;
}

/* Floating COA Search Bar (1:1 Onyx Research Match) */
.coa-floatsearch {
  position: fixed;
  left: 50%;
  bottom: 24px;
  width: min(540px, calc(100vw - 32px));
  z-index: 85;
  transform: translateX(-50%) translateY(0);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
  pointer-events: auto;
}

.coa-floatsearch.hidden {
  transform: translateX(-50%) translateY(180%);
  opacity: 0;
  pointer-events: none;
}

.coa-floatsearch-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(16, 17, 22, 0.92) !important;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid #292D35 !important;
  border-radius: 0px !important;
  -webkit-border-radius: 0px !important;
  padding: 0 18px;
  height: 52px;
  box-shadow: 0 20px 50px -15px rgba(0, 0, 0, 0.85);
  color: #BFC5D0;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.coa-floatsearch-inner:focus-within {
  border-color: #1677FF !important;
  box-shadow: 0 0 0 1px #1677FF, 0 20px 50px -15px rgba(0, 0, 0, 0.95);
}

.coa-floatsearch-inner svg {
  color: #BFC5D0;
  stroke: #BFC5D0;
  flex-shrink: 0;
  transition: stroke 0.2s ease;
}

.coa-floatsearch-inner:focus-within svg {
  stroke: #1677FF;
  color: #1677FF;
}

.coa-search-input {
  flex: 1;
  background: transparent !important;
  border: none !important;
  outline: none !important;
  color: #FFFFFF !important;
  font-family: 'Sora', sans-serif !important;
  font-size: 14px !important;
  line-height: 1.4 !important;
  padding: 0 !important;
  margin: 0 !important;
  box-shadow: none !important;
}

.coa-search-input::placeholder {
  color: #8E95A5 !important;
  font-family: 'Sora', sans-serif !important;
  font-size: 14px !important;
}

.coa-search-clear {
  background: transparent !important;
  border: none !important;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #8E95A5;
  transition: color 0.2s ease;
  line-height: 1;
}

.coa-search-clear:hover {
  color: #FFFFFF;
}

.coa-search-clear svg {
  stroke: currentColor;
  width: 14px;
  height: 14px;
}

/* Empty search result container */
.coa-empty {
  text-align: center;
  padding: 80px 20px;
  width: 100%;
  grid-column: 1 / -1;
}

.coa-empty p {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 18px;
  font-weight: 500;
  color: #FFFFFF;
  margin: 0 0 16px;
}

.coa-empty-reset {
  background: transparent !important;
  border: 1px solid #292D35 !important;
  color: #1677FF !important;
  font-family: 'Sora', sans-serif !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  padding: 8px 20px !important;
  border-radius: 0px !important;
  -webkit-border-radius: 0px !important;
  cursor: pointer;
  transition: all 0.2s ease;
}

.coa-empty-reset:hover {
  background: #1677FF !important;
  color: #FFFFFF !important;
  border-color: #1677FF !important;
}

@media (max-width: 640px) {
  .coa-floatsearch {
    bottom: 16px;
    width: calc(100vw - 24px);
  }
  .coa-floatsearch-inner {
    height: 48px;
    padding: 0 14px;
    gap: 10px;
  }
  .coa-search-input {
    font-size: 13px !important;
  }
  .coa-search-input::placeholder {
    font-size: 13px !important;
  }
}

/* ========================================================
   2. COA GRID LAYOUT (2 cols mobile/tablet, 4 cols desktop)
   ======================================================== */
.coa-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 0 0 32px 0;
}

@media (min-width: 1025px) {
  .coa-cards {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
  }
}

/* ========================================================
   3. CARD BASE & HOVER STATE
   ======================================================== */
.coa-card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  text-align: left;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 0px !important;
  -webkit-border-radius: 0px !important;
  box-sizing: border-box;
  outline: none;
  text-decoration: none;
  -webkit-appearance: none;
  appearance: none;
}

.coa-card__inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  background-color: #101116;
  border: 1px solid #292D35;
  border-radius: 0px !important;
  -webkit-border-radius: 0px !important;
  padding: 0;
  overflow: hidden;
  box-sizing: border-box;
  transition: border-color 0.2s ease;
}

/* Card Hover -> Border becomes Electric Blue #1677FF */
.coa-card:hover .coa-card__inner,
.coa-card.group:hover .coa-card__inner,
.coa-card:focus-visible .coa-card__inner {
  border-color: #1677FF !important;
}

/* ========================================================
   4. TOP IMAGE AREA (Aspect 5:4, #F5F7FA, PDF Badge)
   ======================================================== */
.coa-card__media {
  position: relative;
  width: 100%;
  aspect-ratio: 5 / 4;
  background-color: #F5F7FA;
  padding: 16px;
  overflow: hidden;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
}

.coa-card__media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  transition: transform 500ms ease;
  transform-origin: center center;
}

/* On Card Hover -> Image Zoom 5% */
.coa-card:hover .coa-card__media img,
.coa-card.group:hover .coa-card__media img {
  transform: scale(1.05);
}

/* Top-Right "PDF" Text Badge */
.coa-card__pdf-badge {
  position: absolute;
  top: 16px;
  right: 16px;
  font-family: 'Space Mono', monospace;
  font-size: 0.6rem; /* ~9.6px */
  line-height: 1;
  color: #050505;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  pointer-events: none;
  user-select: none;
  background: transparent;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 0px !important;
}

/* ========================================================
   5. CARD CONTENT & TYPOGRAPHY
   ======================================================== */
.coa-card__body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  padding: 16px;
  box-sizing: border-box;
}

/* Category Eyebrow */
.coa-card__eyebrow {
  display: block;
  font-family: 'Space Mono', monospace;
  font-size: 0.58rem; /* ~9.3px */
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #BFC5D0;
  line-height: 1.2;
  margin: 0;
  padding: 0;
}

/* Product Title */
.coa-card__title {
  display: block;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.375; /* leading-snug */
  min-height: 48px;
  margin-top: 12px;
  margin-bottom: 0;
  color: #FFFFFF;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* LOT Divider */
.coa-card__lot-divider {
  display: block;
  margin-top: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid #292D35;
  box-sizing: border-box;
}

.coa-card__lot {
  display: block;
  font-family: 'Space Mono', monospace;
  font-size: 0.6rem; /* 9.6px */
  line-height: 1.2;
  color: #BFC5D0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0;
  padding: 0;
}

/* Action Bar ("Purity" + Arrow Box) */
.coa-card__action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 16px;
  box-sizing: border-box;
}

/* "Purity" Label */
.coa-card__purity-label {
  font-family: 'Sora', sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: #FFFFFF;
  line-height: 1;
}

/* Arrow Button Box */
.coa-card__arrow-box {
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid #292D35;
  background-color: transparent;
  border-radius: 0px !important;
  -webkit-border-radius: 0px !important;
  color: #FFFFFF;
  transition: background-color 0.2s ease, border-color 0.2s ease;
  box-sizing: border-box;
}

.coa-card__arrow-box svg {
  width: 16px;
  height: 16px;
  stroke: #FFFFFF;
  color: #FFFFFF;
  stroke-width: 2;
  display: block;
}

/* Card Hover -> Arrow Box becomes Button Blue #0057E7 with white arrow */
.coa-card:hover .coa-card__arrow-box,
.coa-card.group:hover .coa-card__arrow-box {
  background-color: #0057E7 !important;
  border-color: #0057E7 !important;
}

.coa-card:hover .coa-card__arrow-box svg,
.coa-card.group:hover .coa-card__arrow-box svg {
  stroke: #FFFFFF !important;
  color: #FFFFFF !important;
}

/* ========================================================
   6. LIGHTBOX MODAL & VIEWER (Brutalist Strict 0px)
   ======================================================== */
.cl-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  box-sizing: border-box;
  padding: 24px;
}

.cl-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.cl-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 5, 5, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.cl-panel {
  position: relative;
  z-index: 2;
  width: min(1000px, calc(100vw - 36px));
  max-height: 88vh;
  background: #101116;
  border: 1px solid #292D35;
  border-radius: 0px !important;
  -webkit-border-radius: 0px !important;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr 340px;
  box-shadow: 0 40px 100px -20px rgba(0, 0, 0, 0.95);
  transform: scale(0.97);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

.cl-overlay.open .cl-panel {
  transform: scale(1);
}

/* Modal Close Button (Clean brutalist, sharp white cross) */
.cl-close,
button.cl-close,
#purechain-cl-close,
#cl-close {
  position: absolute !important;
  top: 16px !important;
  right: 16px !important;
  z-index: 99 !important;
  width: 36px !important;
  height: 36px !important;
  min-width: 36px !important;
  min-height: 36px !important;
  max-width: 36px !important;
  max-height: 36px !important;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: 0px !important;
  -webkit-border-radius: 0px !important;
  border: 1px solid #292D35 !important;
  background: #050505 !important;
  background-color: #050505 !important;
  color: #FFFFFF !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease !important;
  outline: none !important;
  box-shadow: none !important;
  line-height: 1 !important;
}

.cl-close svg,
button.cl-close svg,
#purechain-cl-close svg,
#cl-close svg {
  width: 18px !important;
  height: 18px !important;
  min-width: 18px !important;
  min-height: 18px !important;
  stroke: #FFFFFF !important;
  color: #FFFFFF !important;
  fill: none !important;
  display: block !important;
  transition: stroke 0.2s ease !important;
}

.cl-close:hover,
button.cl-close:hover,
#purechain-cl-close:hover,
#cl-close:hover {
  border-color: #1677FF !important;
  background: #17191E !important;
  background-color: #17191E !important;
  color: #1677FF !important;
}

.cl-close:hover svg,
button.cl-close:hover svg,
#purechain-cl-close:hover svg,
#cl-close:hover svg {
  stroke: #1677FF !important;
  color: #1677FF !important;
}

/* Left Main Document Stage */
.cl-main {
  padding: 32px;
  overflow-y: auto;
  max-height: 88vh;
  color: #FFFFFF;
  box-sizing: border-box;
  background: #101116;
}

.cl-doc-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.cl-doc-eyebrow {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #BFC5D0;
  margin-bottom: 6px;
}

.cl-doc-name {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: #FFFFFF;
}

.cl-lot {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  color: #BFC5D0;
  background: #050505;
  padding: 6px 12px;
  border-radius: 0px !important;
  -webkit-border-radius: 0px !important;
  border: 1px solid #292D35;
  white-space: nowrap;
}

/* Compact summary bar above PDF */
.cl-result-mini {
  background: #050505;
  border: 1px solid #292D35;
  border-radius: 0px !important;
  -webkit-border-radius: 0px !important;
  padding: 16px 20px;
  margin-bottom: 16px;
  box-sizing: border-box;
}

/* Full HPLC Result Box (Fallback when no PDF is attached) */
.cl-result-box {
  background: #050505;
  border: 1px solid #292D35;
  border-radius: 0px !important;
  -webkit-border-radius: 0px !important;
  padding: 24px;
  margin-bottom: 20px;
  box-sizing: border-box;
}

.cl-result-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}

.cl-result-purity {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 32px;
  font-weight: 600;
  color: #FFFFFF;
  letter-spacing: -0.02em;
}

.cl-pass-badge {
  background: #0057E7;
  color: #FFFFFF;
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  border-radius: 0px !important;
  -webkit-border-radius: 0px !important;
}

.cl-method-text {
  font-family: 'Space Mono', monospace;
  font-size: 11.5px;
  color: #BFC5D0;
  letter-spacing: 0.02em;
  line-height: 1.5;
}

.cl-chrom {
  position: relative;
  height: 90px;
  background: #101116;
  border: 1px solid #292D35;
  border-radius: 0px !important;
  -webkit-border-radius: 0px !important;
  overflow: hidden;
  margin: 14px 0 10px;
}

.cl-chrom-svg {
  width: 100%;
  height: 100%;
}

.cl-note {
  font-family: 'Sora', sans-serif;
  font-size: 12px;
  color: #BFC5D0;
  margin: 0;
  line-height: 1.5;
}

/* PDF Embedded Viewer Container */
.cl-pdfwrap {
  margin-top: 14px;
  height: min(52vh, 480px);
  border: 1px solid #292D35;
  border-radius: 0px !important;
  -webkit-border-radius: 0px !important;
  overflow: hidden;
  background: #050505;
  box-sizing: border-box;
}

.cl-pdfwrap iframe.cl-pdf {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.cl-pdfwrap.cl-imgwrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}

.cl-doc-img-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  cursor: zoom-in;
  text-decoration: none;
}

.cl-doc-img-link:hover .cl-doc-img {
  opacity: 0.92;
  filter: brightness(1.04);
  transition: opacity 0.2s ease, filter 0.2s ease;
}

.cl-doc-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.cl-doc-actions {
  margin-top: 14px;
}

.cl-pdf-open {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #1677FF !important;
  font-family: 'Sora', sans-serif;
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  transition: color 0.2s ease;
}

.cl-pdf-open:hover {
  color: #338CFF !important;
}

.cl-pdf-open * {
  color: inherit !important;
}

/* Right Aside Product Card */
.cl-aside {
  background: #050505;
  border-left: 1px solid #292D35;
  padding: 28px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-sizing: border-box;
}

.cl-vial {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 0px !important;
  -webkit-border-radius: 0px !important;
  background: #F5F7FA;
  border: 1px solid #292D35;
  overflow: hidden;
  margin-bottom: 18px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.cl-vial img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.cl-aside-cat {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  color: #BFC5D0;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}

.cl-aside-name {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 20px;
  font-weight: 600;
  color: #FFFFFF;
  margin-bottom: 6px;
  line-height: 1.25;
}

.cl-aside-price {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 20px;
  font-weight: 600;
  color: #FFFFFF;
  margin-bottom: 20px;
}

/* Action Button ("View Product Page" / "Select Options") */
.cl-action-btn,
a.cl-action-btn,
button.cl-action-btn,
#cl-action-select,
#cl-action {
  width: 100% !important;
  height: 48px !important;
  min-height: 48px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: #0057E7 !important;
  background-color: #0057E7 !important;
  border: 1px solid #0057E7 !important;
  border-color: #0057E7 !important;
  color: #FFFFFF !important;
  font-family: 'Sora', sans-serif !important;
  font-weight: 600 !important;
  font-size: 14px !important;
  line-height: 20px !important;
  border-radius: 0px !important;
  -webkit-border-radius: 0px !important;
  cursor: pointer !important;
  text-align: center !important;
  text-decoration: none !important;
  box-sizing: border-box !important;
  box-shadow: none !important;
  outline: none !important;
  transition: background-color 0.2s ease, border-color 0.2s ease !important;
}

.cl-action-btn span,
.cl-action-btn *,
a.cl-action-btn,
a.cl-action-btn:visited,
a.cl-action-btn:hover,
a.cl-action-btn:active,
button.cl-action-btn {
  color: #FFFFFF !important;
  -webkit-text-fill-color: #FFFFFF !important;
}

.cl-action-btn:hover,
a.cl-action-btn:hover,
button.cl-action-btn:hover,
#cl-action-select:hover,
#cl-action:hover {
  background: #338CFF !important;
  background-color: #338CFF !important;
  border-color: #338CFF !important;
  color: #FFFFFF !important;
  -webkit-text-fill-color: #FFFFFF !important;
}

.cl-aside-note {
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  color: #BFC5D0;
  text-align: center;
  margin-top: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ========================================================
   7. RESPONSIVE QUERIES
   ======================================================== */
@media (max-width: 900px) {
  .cl-panel {
    grid-template-columns: 1fr;
    max-height: 90vh;
    overflow-y: auto;
  }
  .cl-aside {
    border-left: 0;
    border-top: 1px solid #292D35;
  }
  .cl-main {
    padding: 20px;
  }
}

@media (max-width: 640px) {
  .coa-cards {
    gap: 12px !important;
  }
  .coa-card__body {
    padding: 12px;
  }
  .coa-card__title {
    font-size: 15px;
    min-height: 40px;
  }
}
