/* ==========================================================================
   LeWeb Interactive Checklist — Post 971 only
   SEO-safe: all text content remains in HTML, JS only enhances interactivity
   v3: fixed mobile rendering, score bar labels, scroll-to-section
   ========================================================================== */

/* ---- Individual checkbox items (replace ☐) ---- */

.entry-content .lw-check-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 12px;
  margin: 2px 0;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s ease, opacity .2s ease;
  -webkit-tap-highlight-color: transparent;
}

.entry-content .lw-check-item:hover {
  background: rgba(34, 107, 82, 0.06);
}

.entry-content .lw-check-item:focus-within {
  outline: 2px solid rgba(34, 107, 82, 0.3);
  outline-offset: 2px;
}

.entry-content .lw-check-box {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  min-width: 20px;
  border: 2px solid #c5ccc3;
  border-radius: 5px;
  margin-top: 3px;
  position: relative;
  transition: background .2s ease, border-color .2s ease, transform .1s ease;
  background: #fff;
}

.entry-content .lw-check-item.checked .lw-check-box {
  background: #226b52;
  border-color: #226b52;
  transform: scale(1.05);
}

.entry-content .lw-check-item.checked .lw-check-box::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.entry-content .lw-check-text {
  flex: 1;
  line-height: 1.6;
  transition: opacity .2s ease, text-decoration .2s ease;
}

.entry-content .lw-check-item.checked .lw-check-text {
  text-decoration: line-through;
  opacity: 0.5;
}

/* ---- Per-item points badge (shown when weight !== 1) ---- */

.entry-content .lw-check-points {
  flex-shrink: 0;
  padding: 1px 7px;
  margin-left: 4px;
  border-radius: 10px;
  background: rgba(34, 107, 82, 0.06);
  color: #226b52;
  font-size: .68rem;
  font-weight: 700;
  white-space: nowrap;
  line-height: 1.5;
  align-self: center;
}

.entry-content .lw-check-item.checked .lw-check-points {
  background: rgba(34, 107, 82, 0.12);
}

/* ---- Section points badge (green, right-aligned) ---- */

.entry-content .lw-section-points {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  margin-left: 10px;
  border-radius: 20px;
  background: rgba(34, 107, 82, 0.08);
  color: #226b52;
  font-size: .78rem;
  font-weight: 700;
  white-space: nowrap;
  vertical-align: middle;
  transition: background .2s ease;
}

.entry-content .lw-section-points.lw-all-done {
  background: rgba(34, 107, 82, 0.15);
}

.entry-content .lw-section-points .lw-points-icon {
  font-size: .85rem;
  line-height: 1;
}

/* ---- Table adjustments for checklist cells ---- */

.entry-content .lw-comparison-table td.lw-has-checklist,
.entry-content .lw-comparison-table th.lw-has-checklist {
  padding: 10px 14px;
}

/* ---- Mobile: let theme's native card layout work, just fix checkboxes ---- */
/* The theme converts tables to card layout on mobile. Checkbox items inside */
/* the card cells render fine as flex elements. No table-structure override needed. */

@media (max-width: 700px) {
  /* Ensure checkbox items render well inside the theme's card layout */
  .entry-content .lw-check-item {
    padding: 8px 10px;
    margin: 4px 0;
  }

  .entry-content .lw-check-box {
    width: 18px;
    height: 18px;
    min-width: 18px;
  }

  /* Make sure the data-label ::before doesn't push checkboxes awkwardly */
  .entry-content .lw-has-checklist[data-label]::before {
    margin-bottom: 8px;
  }

  /* Points badge: full width on mobile, not inline */
  .entry-content .lw-section-points {
    display: inline-flex;
    margin-left: 0;
    margin-top: 6px;
    font-size: .72rem;
  }
}

/* ---- Sticky Score Bar (shared base) ---- */

.lw-score-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9998;
  background: #fff;
  border-top: 1px solid #dde4db;
  box-shadow: 0 -8px 30px rgba(17, 19, 18, 0.1);
  transition: transform .3s ease;
  font-family: inherit;
  overscroll-behavior: contain;
}

.lw-score-bar * {
  box-sizing: border-box;
}

.lw-score-bar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.lw-score-bar__title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .9rem;
  font-weight: 800;
  color: #1f2924;
  letter-spacing: .01em;
}

/* Score label — make it clear what the number means */
.lw-score-bar__score-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  flex-shrink: 0;
}

.lw-score-bar__score {
  display: flex;
  align-items: baseline;
  gap: 3px;
}

.lw-score-bar__score-num {
  font-size: 1.6rem;
  font-weight: 900;
  color: #226b52;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  transition: color .3s ease;
}

.lw-score-bar__score-total {
  font-size: .9rem;
  color: #6b7570;
  font-weight: 600;
}

.lw-score-bar__score-label {
  font-size: .68rem;
  font-weight: 700;
  color: #6b7570;
  text-transform: uppercase;
  letter-spacing: .04em;
  line-height: 1;
}

.lw-score-bar__progress-track {
  flex: 1;
  height: 6px;
  margin: 0 16px;
  border-radius: 3px;
  background: #e8ece6;
  overflow: hidden;
}

.lw-score-bar__progress-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #226b52, #2d8a68);
  width: 0%;
  transition: width .4s cubic-bezier(.4, 0, .2, 1);
}

.lw-score-bar__toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .8rem;
  color: #6b7570;
  font-weight: 600;
  flex-shrink: 0;
}

.lw-score-bar__toggle-icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  transition: transform .3s ease;
}

.lw-score-bar.expanded .lw-score-bar__toggle-icon {
  transform: rotate(180deg);
}

/* ---- Score bar detail panel ---- */

.lw-score-bar__detail {
  max-height: 0;
  overflow: hidden;
  transition: max-height .35s cubic-bezier(.4, 0, .2, 1);
}

.lw-score-bar.expanded .lw-score-bar__detail {
  max-height: 500px;
}

.lw-score-bar__detail-inner {
  padding: 0 20px 16px;
  max-height: 340px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -ms-overflow-style: none;
  scrollbar-width: thin;
}

/* Detail panel header */
.lw-score-detail__header {
  font-size: .78rem;
  font-weight: 800;
  color: #6b7570;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 4px 0 10px;
  border-bottom: 2px solid #f0f3ee;
  margin-bottom: 4px;
}

.lw-score-detail__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 6px;
  border-bottom: 1px solid #f0f3ee;
  font-size: .85rem;
  cursor: pointer;
  transition: background .15s ease;
  border-radius: 6px;
}

.lw-score-detail__row:hover {
  background: rgba(34, 107, 82, 0.04);
}

.lw-score-detail__row:last-child {
  border-bottom: 0;
}

.lw-score-detail__label {
  color: #1f2924;
  font-weight: 600;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 8px;
}

.lw-score-detail__value {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.lw-score-detail__bar {
  width: 60px;
  height: 4px;
  border-radius: 2px;
  background: #e8ece6;
  overflow: hidden;
}

.lw-score-detail__bar-fill {
  height: 100%;
  border-radius: 2px;
  background: #226b52;
  width: 0%;
  transition: width .3s ease;
}

.lw-score-detail__count {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #226b52;
  min-width: 36px;
  text-align: right;
}

.lw-score-detail__cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
  padding: 12px 18px;
  border-radius: 10px;
  background: #226b52;
  color: #fff;
  text-align: center;
  text-decoration: none;
  font-size: .88rem;
  font-weight: 700;
  transition: background .2s ease;
}

.lw-score-detail__cta:hover {
  background: #1d5944;
  color: #fff;
}

.lw-score-detail__cta strong {
  font-weight: 800;
}

.lw-score-detail__cta-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: .68rem;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
  flex-shrink: 0;
}

/* ---- Mobile score bar ---- */

@media (max-width: 768px) {
  .lw-score-bar__header {
    padding: 12px 16px;
  }

  .lw-score-bar__title {
    font-size: .82rem;
  }

  .lw-score-bar__score-num {
    font-size: 1.35rem;
  }

  .lw-score-bar__progress-track {
    margin: 0 10px;
  }

  .lw-score-bar__toggle-text {
    display: none;
  }

  .lw-score-bar__detail-inner {
    padding: 0 16px 14px;
    max-height: 260px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
  }

  .lw-score-detail__bar {
    width: 40px;
  }

  .lw-score-detail__label {
    font-size: .8rem;
  }
}

/* ---- Desktop: score bar as floating card, bottom-right ---- */

@media (min-width: 769px) {
  .lw-score-bar {
    left: auto;
    right: 24px;
    bottom: 24px;
    width: 400px;
    border-radius: 14px;
    border: 1px solid #dde4db;
    box-shadow: 0 12px 40px rgba(17, 19, 18, 0.12);
  }

  .lw-score-bar__header {
    padding: 16px 20px;
    border-radius: 14px;
  }

  .lw-score-bar:not(.expanded) .lw-score-bar__header {
    border-radius: 14px;
  }

  .lw-score-bar.expanded .lw-score-bar__detail {
    max-height: 500px;
  }

  .lw-score-bar__detail-inner {
    max-height: 380px;
  }
}

/* ---- Score bar status colors ---- */

.lw-score-bar[data-status="not-ready"] .lw-score-bar__score-num {
  color: #b85c3e;
}

.lw-score-bar[data-status="needs-work"] .lw-score-bar__score-num {
  color: #c6932e;
}

.lw-score-bar[data-status="citation-ready"] .lw-score-bar__score-num {
  color: #226b52;
}

.lw-score-bar[data-status="strong"] .lw-score-bar__score-num {
  color: #1a5238;
}

.lw-score-bar[data-status="not-ready"] .lw-score-bar__progress-fill {
  background: linear-gradient(90deg, #b85c3e, #d4744e);
}

.lw-score-bar[data-status="needs-work"] .lw-score-bar__progress-fill {
  background: linear-gradient(90deg, #c6932e, #d9a83e);
}

/* ---- Hide original ☐ character (JS replaces it) ---- */

.entry-content .lw-check-original {
  display: none;
}

/* ---- Reduced motion ---- */

@media (prefers-reduced-motion: reduce) {
  .lw-check-item,
  .lw-check-box,
  .lw-check-text,
  .lw-score-bar,
  .lw-score-bar__progress-fill,
  .lw-score-bar__toggle-icon,
  .lw-score-bar__detail,
  .lw-score-detail__bar-fill {
    transition: none !important;
  }
}
