/* Core styles for WPRR block; use theme brand variables when available */
.wprr-wrapper {
  margin: 12px 0;
  overflow-x: hidden
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px
}

.container,
.card,
.hero-image,
.sticky-nav>div {
  box-sizing: border-box
}

.hero {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: center
}

.meta-row {
  display: flex;
  gap: 8px;
  align-items: center
}

.btn-group {
  display: flex;
  gap: 8px;
  align-items: center
}

.btn-group .btn {
  min-width: 120px
}

.btn-group-below {
  margin-top: 8px;
  margin-bottom: 6px
}

.title {
  font-size: clamp(1.6rem, 2.8vw, 2.4rem);
  margin: 0;
  color: var(--color-text, #222)
}

.badge {
  background: #f6f6f6;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: .9rem;
  color: #666
}

.hero-image {
  width: 100%;
  /* Allow natural aspect ratio but max-height to prevent taking up too much space on desktop */
  max-height: 800px;
  overflow: hidden;
  border-radius: 10px;
  content-visibility: auto;
  background: var(--color-background, #faf9f0);
  display: flex;
  justify-content: center;
  align-items: center;
}

.hero-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block
}

.hero-image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px
}

.hero-image-grid img {
  width: 100%;
  height: 300px;
  object-fit: cover;
  border-radius: 8px;
  display: block
}

.fact-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 10px 0
}

.fact-row {
  row-gap: 12px
}

.pinterest-image {
  width: 100%;
  display: block;
  margin-top: 8px
}

.pinterest-image img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 10px
}

.fact {
  background: #fff;
  border: 1px solid #eee;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: .95rem
}

.sticky-nav {
  position: sticky;
  top: 0;
  background: linear-gradient(180deg, #fff, rgba(255, 255, 255, .95));
  z-index: 40;
  padding: 6px 0;
  border-bottom: 1px solid #f6f6f6
}

.grid-2 {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: stretch
}

.grid-2>* {
  width: 100%;
  max-width: 100%
}

.grid-2 {
  justify-items: center
}

.article {
  background: #fff;
  padding: 0;
  max-width: 100%
}

.card {
  background: #fff;
  padding: 8px;
  border-radius: 6px;
  margin-bottom: 12px;
  border: 1px solid #f1f1f1;
  contain: layout style paint
}

.ings {
  list-style: none;
  padding: 0;
  margin: 0
}

.ings li {
  padding: 6px 0;
  border-bottom: 1px dashed #fafafa;
  display: flex;
  align-items: flex-start;
  gap: 8px
}

.ings .checkbox {
  margin-right: 8px;
  flex: 0 0 auto
}

.ings li label {
  display: flex;
  gap: 8px;
  flex: 1
}

.ings li span {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: clamp(1rem, 3.5vw, 1.1rem);
  line-height: 1.6
}

.step {
  margin: 6px 0;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #fafafa
}

.small {
  font-size: .9rem;
  color: #666
}

.ad-slot {
  width: 100%;
  height: 90px;
  background: #f8f8f8;
  border: 1px solid #dcdcdc;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
  position: relative;
  /* For absolute positioning of ad-code */
}

/* Ad placeholder wrapper */
.ad-placeholder {
  position: relative;
  width: 100%;
  height: 100%;
}

/* Ad placement code label (A1, A2, etc.) */
.ad-code {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: monospace;
  z-index: 100;
  pointer-events: none;
  line-height: 1;
  letter-spacing: 0.5px;
}

#ad-hero {
  max-width: 728px;
  margin: 16px auto
}

.rating-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 6px 0
}

.star {
  font-size: 1.1rem;
  color: #f4c150
}

.star.empty {
  color: #ddd
}

.chip-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0
}

.chip {
  background: #eae8df;
  color: #2C2C2C;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: .9rem;
  border: 1px solid #ddd
}

.affiliate-carousel {
  display: flex;
  gap: 8px;
  overflow: auto;
  padding: 6px 0
}

.aff-card {
  min-width: 150px;
  border: 1px solid #eee;
  padding: 8px;
  border-radius: 8px;
  background: #fff;
  text-decoration: none;
  color: inherit
}

.btn {
  background: var(--color-accent, #c55a11);
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  text-decoration: none;
  display: inline-block;
  min-height: 48px
}

.video-embed iframe,
.video-embed video {
  border-radius: 8px
}

.step-media img {
  content-visibility: auto;
  contain-intrinsic-size: 400px 300px;
}

/* HB Agency Ad Styling */
.ad-slot[data-ad-type="hb-agency"] {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border: 2px dashed #dee2e6;
}

.ad-slot[data-ad-type="hb-agency"] .ad-loading {
  font-size: 14px;
  color: #6c757d;
  font-weight: 500;
  text-align: center;
  padding: 20px;
}

.ad-slot[data-ad-type="hb-agency"].ad-loaded {
  background: #ffffff;
  border: 1px solid #e9ecef;
}

/* Ad placeholder animations */
.ad-lazy .ad-placeholder {
  animation: adPulse 1.5s ease-in-out infinite;
  transition: all 0.3s ease;
}

.ad-lazy.ad-loaded .ad-placeholder {
  animation: none;
}

@keyframes adPulse {

  0%,
  100% {
    opacity: .5
  }

  50% {
    opacity: 1
  }
}

@media(max-width:900px) {
  .grid-2 {
    align-items: center
  }
}

@media(max-width:600px) {
  .container {
    padding: 8px
  }

  .card {
    padding: 6px;
    margin-bottom: 10px
  }

  .fact-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px
  }

  .btn-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px
  }

  .btn {
    width: 100%;
    padding: 10px
  }

  .title {
    text-align: center
  }

  /* Print Styles - Robust Clone Strategy (Nuclear Option) */
  @media print {

    /* 
       Strategy: Make the body invisible, but the print container visible.
       This bypasses 'display: none' specificity wars with themes.
    */
    body.wprr-printing-active {
      visibility: hidden !important;
      overflow: visible !important;
      /* Allow print container to flow */
      height: auto !important;
      background: white !important;
    }

    /* Hide all direct children to collapse layout space */
    body.wprr-printing-active>*:not(#wprr-print-container) {
      display: none !important;
    }

    /* Position the print container at the absolute top-left */
    body.wprr-printing-active #wprr-print-container {
      visibility: visible !important;
      display: block !important;
      position: absolute !important;
      top: 0 !important;
      left: 0 !important;
      width: 100% !important;
      height: auto !important;
      z-index: 2147483647 !important;
      /* Max z-index */
      background: white !important;
      margin: 0 !important;
      padding: 0 !important;
    }

    /* Ensure all children of the print container are visible */
    body.wprr-printing-active #wprr-print-container * {
      visibility: visible !important;
    }

    /* Restore flex/grid for specific elements inside the clone */
    #wprr-print-container .grid-2 {
      display: block !important;
    }

    #wprr-print-container .meta-row,
    #wprr-print-container .fact-row,
    #wprr-print-container .ings li,
    #wprr-print-container .wprr-branding-header {
      display: flex !important;
    }

    /* Hide unwanted elements inside the clone */
    #wprr-print-container .ad-slot,
    #wprr-print-container .btn-group,
    #wprr-print-container .sticky-nav,
    #wprr-print-container aside {
      display: none !important;
    }

    /* Branding Styles */
    .wprr-print-branding {
      margin-bottom: 20px;
      border-bottom: 2px solid #000;
      padding-bottom: 15px;
    }

    .wprr-branding-header {
      display: flex;
      align-items: center;
      gap: 20px;
    }

    .wprr-print-logo {
      max-height: 60px;
      width: auto;
    }

    .wprr-branding-text h1 {
      margin: 0;
      font-size: 24px;
      line-height: 1.2;
    }

    .wprr-branding-text p {
      margin: 5px 0 0;
      font-size: 12px;
      color: #666;
    }

    .wprr-return-link {
      color: #666;
      text-decoration: none;
    }

    /* Image Optimization */
    #wprr-print-container .hero-image {
      max-height: 300px;
      width: auto;
      margin: 0 auto 20px auto;
      aspect-ratio: auto !important;
    }

    /* Typography */
    #wprr-print-container {
      font-size: 12pt;
      line-height: 1.5;
      color: #000;
    }

    #wprr-print-container h1,
    #wprr-print-container h2,
    #wprr-print-container h3 {
      page-break-after: avoid;
      color: #000;
    }

    #wprr-print-container li,
    #wprr-print-container p {
      page-break-inside: avoid;
    }
  }

  .meta-row {
    justify-content: center
  }

  .rating-row {
    justify-content: center
  }

  .chip-row {
    justify-content: center
  }

  .sticky-nav>div {
    display: flex;
    justify-content: center
  }

  .card {
    margin-left: auto;
    margin-right: auto
  }

  .grid-2 {
    grid-template-columns: 1fr;
    justify-items: center;
    align-items: start;
    gap: 12px
  }

  .grid-2>* {
    width: 100%
  }

  aside {
    width: 100%;
    justify-self: center
  }

  .ings li span {
    font-size: 1rem;
    line-height: 1.6
  }
}

/* Section backgrounds using brand palette */
#ingredients.card {
  background: var(--color-background, #faf9f0);
  width: 100%;
  max-width: 100%;
  padding: 8px;
  box-sizing: border-box;
  margin: 0 auto;
  overflow-x: hidden
}

#ingredients.card>* {
  max-width: 100%;
  width: 100%;
  display: block;
  min-width: 0;
  margin-left: auto;
  margin-right: auto
}

#nutrition.card {
  background: color-mix(in oklab, var(--color-background, #faf9f0) 80%, white)
}

#notes.card {
  background: color-mix(in oklab, var(--color-background, #faf9f0) 92%, white)
}

/* Stronger separators for ingredients */
.ings li {
  border-bottom: 1px solid #e3e3e3
}

.ings li:last-child {
  border-bottom: 0
}

.ings li span {
  line-height: 1.5
}

/* Nutrition list formatting */
.nutrition-list {
  list-style: none;
  padding: 0;
  margin: 0
}

.nutrition-list li {
  padding: 6px 0;
  border-bottom: 1px solid #e3e3e3;
  display: flex;
  justify-content: space-between;
  align-items: center
}

.nutrition-list li:last-child {
  border-bottom: 0
}

.nut-label {
  color: #666
}

.nut-value {
  font-weight: 600
}

/* Removed duplicate print styles */

/* Print card styles */
#wprr-print-card {
  padding: 24pt;
  font-family: sans-serif;
  color: #333;
  display: none;
}

#wprr-print-card h1 {
  font-size: 18pt;
  margin: 0 0 8pt;
}

#wprr-print-card h2 {
  font-size: 14pt;
  margin: 12pt 0 6pt;
  border-bottom: 1px solid #eee;
  padding-bottom: 4pt;
}

#wprr-print-card p,
#wprr-print-card li,
#wprr-print-card span {
  font-size: 11pt;
  line-height: 1.45;
}

#wprr-print-card .print-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12pt;
}

#wprr-print-card .print-logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

#wprr-print-card .print-hero {
  max-height: 220px;
  overflow: hidden;
  border-radius: 8px;
  margin-bottom: 12pt;
}

#wprr-print-card .print-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#wprr-print-card .print-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 6pt;
  margin: 8pt 0;
}

#wprr-print-card .print-fact {
  border: 1pt solid #ddd;
  padding: 6pt 8pt;
  border-radius: 6pt;
  background: #f9f9f9;
}

#wprr-print-card ul {
  list-style-position: inside;
  padding-left: 0;
}

#wprr-print-card .print-steps img {
  max-height: 140px;
  width: 100%;
  object-fit: cover;
  border-radius: 6px;
  margin: 6pt 0;
}

#wprr-print-card .print-footer {
  margin-top: 12pt;
  text-align: center;
  font-size: 9pt;
  color: #777;
}

#wprr-print-card a {
  color: #0066cc;
  text-decoration: none;
}

/* Ad Slot Styles */
.ad-slot {
  display: block;
  margin: 20px auto;
  text-align: center;
  clear: both;
  min-height: 90px;
  /* Prevent CLS */
  max-width: 100%;
}

.ad-slot.ad-sticky-top {
  position: sticky;
  top: 10px;
  z-index: 100;
}

.ad-placeholder {
  background: #f6f7f8;
  background-image: linear-gradient(to right, #f6f7f8 0%, #edeef1 20%, #f6f7f8 40%, #f6f7f8 100%);
  background-repeat: no-repeat;
  background-size: 800px 100%;
  display: block;
  min-height: inherit;
  width: 100%;
  height: 100%;
  animation-duration: 1s;
  animation-fill-mode: forwards;
  animation-iteration-count: infinite;
  animation-name: placeholderShimmer;
  animation-timing-function: linear;
  border: none;
  /* Remove dashed border */
}

@keyframes placeholderShimmer {
  0% {
    background-position: -468px 0;
  }

  100% {
    background-position: 468px 0;
  }
}

.ad-loading {
  display: none;
  /* Hide text */
}

.ad-refreshing {
  opacity: 0.5;
  transition: opacity 0.3s ease;
}

/* Google Shopping Footer Popup */
.wprr-footer-popup {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-top: 1px solid #e0e0e0;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
  z-index: 9999;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: none;
}

.wprr-footer-popup.visible {
  transform: translateY(0);
}

.wprr-popup-container {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px;
  position: relative;
}

.wprr-popup-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  font-size: 24px;
  color: #5f6368;
  cursor: pointer;
  padding: 5px 10px;
  line-height: 1;
  transition: color 0.2s;
}

.wprr-popup-close:hover {
  color: #202124;
}

.wprr-popup-title {
  font-size: 18px;
  font-weight: 500;
  color: #202124;
  margin: 0 0 12px 0;
  text-align: center;
}

.wprr-search-box {
  display: flex;
  gap: 8px;
}

.wprr-search-box input {
  flex: 1;
  padding: 10px 15px;
  border: 1px solid #dfe1e5;
  border-radius: 24px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.wprr-search-box input:focus {
  border-color: #1a73e8;
  box-shadow: 0 1px 6px rgba(32, 33, 36, 0.28);
}

.wprr-search-box button {
  background: #1a73e8;
  color: white;
  border: none;
  padding: 0 20px;
  border-radius: 24px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.wprr-search-box button:hover {
  background: #1557b0;
}

.wprr-popup-footer {
  text-align: center;
  font-size: 10px;
  color: #5f6368;
  margin-top: 8px;
}

/* ======================================== */
/* ENHANCED SMART SCROLL - PROGRESS INDICATOR */
/* ======================================== */

/* Progress Indicator Container */
.wprr-scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: rgba(0, 0, 0, 0.05);
  z-index: 99999;
  opacity: 0;
  transform: translateY(-100%);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.wprr-scroll-progress.visible {
  opacity: 1;
  transform: translateY(0);
}

.wprr-scroll-progress.hidden {
  opacity: 0;
  transform: translateY(-100%);
}

/* Progress Bar */
.wprr-scroll-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #2b5a3e 0%, #3d7a54 50%, #2b5a3e 100%);
  background-size: 200% 100%;
  animation: progressShimmer 1.5s ease-in-out infinite;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 10px rgba(43, 90, 62, 0.5);
}

@keyframes progressShimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Progress Message */
.wprr-scroll-progress-message {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(43, 90, 62, 0.95);
  color: white;
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(10px);
  animation: messagePulse 2s ease-in-out infinite;
}

@keyframes messagePulse {
  0%, 100% {
    transform: translateX(-50%) scale(1);
  }
  50% {
    transform: translateX(-50%) scale(1.02);
  }
}

/* Target Element Highlight */
.wprr-highlight-target {
  animation: targetHighlight 2s ease-out;
  scroll-margin-top: 20px;
}

@keyframes targetHighlight {
  0% {
    box-shadow: 0 0 0 0 rgba(43, 90, 62, 0.7);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(43, 90, 62, 0.3);
  }
  100% {
    box-shadow: 0 0 0 20px rgba(43, 90, 62, 0);
  }
}

/* Ad Viewing Highlight (Optional) */
.ad-slot.ad-viewing {
  outline: 2px solid rgba(43, 90, 62, 0.3);
  outline-offset: 4px;
  transition: outline 0.3s ease;
}

/* Mobile Responsive */
@media (max-width: 600px) {
  .wprr-scroll-progress {
    height: 3px;
  }

  .wprr-scroll-progress-message {
    font-size: 12px;
    padding: 6px 16px;
    top: 10px;
  }
}
