/**
 * Just Word Content Library Styles
 * Loaded only on the Content Library page template
 *
 * @package JustWord Child
 */

/* ── VARIABLES ── */
:root {
  /* Just Word brand colors — hardcoded for consistency logged in and out */
  --jw-navy:        #0d2240;
  --jw-navy-mid:    #163352;
  --jw-navy-light:  #1e4a73;
  --jw-orange:      #e87722;
  --jw-orange-lt:   #f5922a;
  --jw-orange-pale: #fff3e8;
  --jw-white:       #ffffff;
  --jw-off-white:   #faf8f4;
  --jw-light:       #f2ede4;
  --jw-border:      #e0d9ce;
  --jw-text:        #1a1208;
  --jw-text-mid:    #3d3020;
  --jw-text-soft:   #6b5e4a;
  --jw-text-hint:   #9c8e7a;
  --jw-green:       #1e6e45;
  --jw-green-pale:  #e6f4ed;
}

/* ── RESET KADENCE DEFAULTS on library page ── */
.jw-library-wrap .entry-content,
.jw-library-wrap .entry-header {
  max-width: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
}

/* ── WRAP ── */
.jw-library-wrap {
  background: var(--jw-off-white);
  min-height: 100vh;
}

/* ══════════════════════════════
   HERO
══════════════════════════════ */
.jw-hero {
  background: #0d2240;
  padding: 72px 40px 60px;
  position: relative;
  overflow: hidden;
  text-align: center;
}

.jw-hero-glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 60% 50% at 50% 0%, rgba(232,119,34,.12) 0%, transparent 60%);
  pointer-events: none;
}

.jw-hero-inner {
  max-width: 760px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.jw-hero-eyebrow {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .18em;
  color: var(--jw-orange);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.jw-hero-eyebrow::before,
.jw-hero-eyebrow::after {
  content: '';
  display: block;
  width: 28px;
  height: 2px;
  background: var(--jw-orange);
}

.jw-hero-title {
  font-family: 'Merriweather', Georgia, serif;
  font-size: clamp(28px, 4vw, 48px);
  font-weight: 700;
  color: var(--jw-white);
  line-height: 1.2;
  margin: 0 0 16px;
}
.jw-hero-title em {
  font-style: italic;
  color: var(--jw-orange-lt);
}

.jw-hero-sub {
  font-size: 15px;
  color: rgba(255,255,255,.62);
  line-height: 1.8;
  margin: 0 auto 32px;
  max-width: 520px;
}

.jw-hero-stats {
  display: flex;
  justify-content: center;
  gap: 0;
}
.jw-hstat {
  padding: 14px 28px;
  border-right: 1px solid rgba(255,255,255,.1);
  text-align: center;
}
.jw-hstat:last-child { border-right: none; }
.jw-hstat-num {
  font-size: 26px;
  font-weight: 900;
  color: var(--jw-orange-lt);
  line-height: 1;
  margin-bottom: 4px;
}
.jw-hstat-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: rgba(255,255,255,.4);
}

/* ══════════════════════════════
   FILTER BAR
══════════════════════════════ */
.jw-filter-bar {
  background: var(--jw-white);
  border-bottom: 2px solid var(--jw-border);
  padding: 28px 40px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 24px rgba(0,0,0,.07);
}
.jw-filter-bar-inner {
  max-width: 1140px;
  margin: 0 auto;
}

.jw-filter-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.jw-filter-heading {
  font-size: 14px;
  font-weight: 700;
  color: var(--jw-navy);
}
.jw-filter-summary {
  font-size: 12px;
  font-weight: 500;
  color: var(--jw-text-hint);
  margin-left: 6px;
}
.jw-clear-btn {
  font-size: 11px;
  font-weight: 700;
  color: var(--jw-orange);
  background: none;
  border: 1.5px solid var(--jw-orange);
  border-radius: 20px;
  padding: 5px 16px;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
}
.jw-clear-btn:hover {
  background: var(--jw-orange);
  color: var(--jw-white);
}
/* When there are no active filters, dim the button and disable interactions */
.jw-clear-btn--inactive,
.jw-clear-btn[disabled] {
  color: var(--jw-text-hint);
  border-color: var(--jw-border);
  cursor: default;
  opacity: .7;
}
.jw-clear-btn--inactive:hover,
.jw-clear-btn[disabled]:hover {
  background: none;
  color: var(--jw-text-hint);
}

.jw-filter-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1.1fr;
  gap: 16px;
  align-items: end;
}
.jw-filter-label {
  display: block;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--jw-text-hint);
  margin-bottom: 7px;
}

/* Custom select */
.jw-custom-select { position: relative; }
.jw-custom-select select {
  width: 100%;
  padding: 12px 40px 12px 16px;
  border: 2px solid var(--jw-border);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  font-family: 'Montserrat', sans-serif;
  color: var(--jw-text);
  background: var(--jw-off-white);
  appearance: none;
  cursor: pointer;
  outline: none;
  transition: border-color .15s, background .15s;
}
.jw-custom-select select:hover,
.jw-custom-select select:focus {
  border-color: var(--jw-navy);
  background: var(--jw-white);
}
.jw-custom-select select.jw-has-value {
  border-color: var(--jw-navy);
  background: var(--jw-white);
  color: var(--jw-navy);
  font-weight: 600;
}
.jw-select-arrow {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--jw-text-hint);
  font-size: 10px;
}

/* Search */
.jw-search-wrap {
  position: relative;
}
.jw-search-wrap input {
  width: 100%;
  padding: 12px 16px 12px 40px;
  border: 2px solid var(--jw-border);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: var(--jw-text);
  background: var(--jw-off-white);
  outline: none;
  transition: border-color .15s;
}
.jw-search-wrap input:focus {
  border-color: var(--jw-orange);
  background: var(--jw-white);
}
.jw-search-wrap input::placeholder { color: var(--jw-text-hint); }
.jw-search-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--jw-text-hint);
  display: flex;
  align-items: center;
}

/* Active pills */
.jw-active-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 16px;
  min-height: 0;
}
.jw-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px 4px 12px;
  border-radius: 20px;
  background: var(--jw-navy);
  color: var(--jw-white);
}
.jw-pill-x {
  cursor: pointer;
  opacity: .65;
  font-size: 15px;
  line-height: 1;
  transition: opacity .15s;
}
.jw-pill-x:hover { opacity: 1; }

/* ══════════════════════════════
   MAIN
══════════════════════════════ */
.jw-main {
  max-width: 1140px;
  margin: 0 auto;
  padding: 36px 40px 72px;
}

/* Limited-library notice — sits above the results */
.jw-library-notice {
  display: flex;
  align-items: center;
  gap: 13px;
  background: var(--jw-orange-pale);
  border: 1px solid rgba(232, 119, 34, .30);
  border-radius: 12px;
  padding: 13px 20px;
  margin-bottom: 24px;
}
.jw-library-notice-ic {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--jw-orange);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.jw-library-notice-ic svg { width: 18px; height: 18px; }
.jw-library-notice-text {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.55;
  font-weight: 500;
  color: var(--jw-text-mid);
}
.jw-library-notice-text a {
  color: var(--jw-orange);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.jw-library-notice-text a:hover { color: #c4611a; }

.jw-results-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}
.jw-results-count {
  font-size: 13px;
  color: var(--jw-text-soft);
}
.jw-results-count strong {
  font-size: 16px;
  font-weight: 700;
  color: var(--jw-text);
}
.jw-sort-select {
  font-size: 12px;
  font-family: inherit;
  padding: 8px 14px;
  border: 1.5px solid var(--jw-border);
  border-radius: 8px;
  background: var(--jw-white);
  color: var(--jw-text);
  outline: none;
  cursor: pointer;
}

/* ══════════════════════════════
   GRID
══════════════════════════════ */
.jw-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
  min-height: 300px;
}

/* Grid wrap — positions the overlay relative to the grid */
.jw-grid-wrap {
  position: relative;
  /* Ensure overlay only covers the card grid, not hero or filter bar */
  isolation: isolate;
}

/* Filter loading overlay — shown during AJAX filter calls */
.jw-grid-loading-overlay {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(250, 248, 244, 0.88);
  z-index: 10;
  border-radius: 14px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  min-height: 200px;
  /* Never go above the grid wrap */
  max-height: 100%;
}
.jw-grid-loading-overlay.active {
  display: flex;
  align-items: center;      /* horizontal center */
  justify-content: flex-start; /* push to top */
  padding-top: 36px;
}
.jw-grid-loading-overlay .jw-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--jw-border);
  border-top-color: var(--jw-orange);
  border-radius: 50%;
  animation: jw-spin .6s linear infinite;
}
.jw-grid-loading-overlay p {
  font-size: 13px;
  font-weight: 600;
  color: var(--jw-text-soft);
  margin: 0;
}

/* Initial loading state inside grid */
.jw-loading {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 72px 20px;
  color: var(--jw-text-hint);
  font-size: 13px;
  gap: 16px;
}
.jw-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--jw-border);
  border-top-color: var(--jw-orange);
  border-radius: 50%;
  animation: jw-spin .6s linear infinite;
}
@keyframes jw-spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════
   CARD
══════════════════════════════ */
@keyframes jw-card-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.jw-card {
  background: var(--jw-white);
  border: 1px solid var(--jw-border);
  border-radius: 14px;
  overflow: hidden;
  transition: box-shadow .22s, transform .18s, border-color .18s;
  animation: jw-card-in .35s ease both;
}
.jw-card:hover {
  box-shadow: 0 12px 40px rgba(13,34,64,.11);
  transform: translateY(-4px);
  border-color: rgba(13,34,64,.15);
}
.jw-card-link {
  display: flex;
  flex-direction: column;
  height: 100%;
  text-decoration: none;
  color: inherit;
}

/* Card image */
.jw-card-img-wrap {
  position: relative;
  height: 160px;
  overflow: hidden;
  flex-shrink: 0;
}
.jw-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .4s ease;
}
.jw-card:hover .jw-card-img { transform: scale(1.04); }

/* Fallback when no featured image */
.jw-card-img-fallback {
  width: 100%;
  height: 100%;
}
.jw-fi-navy   { background: linear-gradient(135deg, var(--jw-navy) 0%, var(--jw-navy-mid) 100%); }
.jw-fi-blue   { background: linear-gradient(135deg, #0f2d5e 0%, #1e4a73 100%); }
.jw-fi-purple { background: linear-gradient(135deg, #2d1b6b 0%, #5e35b1 100%); }
.jw-fi-teal   { background: linear-gradient(135deg, #053d36 0%, #0f6e5e 100%); }
.jw-fi-green  { background: linear-gradient(135deg, #0a3d22 0%, #1e6e45 100%); }
.jw-fi-orange { background: linear-gradient(135deg, #c4611a 0%, var(--jw-orange) 100%); }

/* Badge on image */
.jw-card-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .1em;
  padding: 4px 10px;
  border-radius: 20px;
  color: var(--jw-white);
  /* All badges use brand orange */
  background: rgba(232, 119, 34, 0.92);
}
/* Individual overrides intentionally removed — all badges are orange */
.jw-badge-post,
.jw-badge-video,
.jw-badge-qa,
.jw-badge-plan,
.jw-badge-worksheet,
.jw-badge-product { background: rgba(232, 119, 34, 0.92); }

/* Download tag */
.jw-card-dl-tag {
  position: absolute;
  bottom: 10px;
  right: 10px;
  font-size: 9px;
  font-weight: 800;
  background: rgba(30,110,69,.9);
  color: var(--jw-white);
  padding: 3px 9px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* Academy preview: navy badge + "Academy" tag (links out to the Academy) */
.jw-badge-academy { background: rgba(13,34,64,.95); }
.jw-card-academy-tag {
  position: absolute;
  bottom: 10px;
  right: 10px;
  font-size: 9px;
  font-weight: 800;
  background: rgba(13,34,64,.92);
  color: var(--jw-white);
  padding: 3px 9px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* Card body */
.jw-card-body {
  padding: 18px;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.jw-card-subject {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--jw-orange);
  margin-bottom: 6px;
}
.jw-card-title {
  font-family: 'Merriweather', Georgia, serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--jw-navy);
  line-height: 1.4;
  margin: 0 0 8px;
  flex: 1;
}
.jw-card-excerpt {
  font-size: 12px;
  color: var(--jw-text-soft);
  line-height: 1.65;
  margin-bottom: 14px;
}
.jw-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--jw-border);
}
.jw-card-meta {
  font-size: 10px;
  color: var(--jw-text-hint);
  font-weight: 500;
}
.jw-card-cta {
  font-size: 10px;
  font-weight: 700;
  color: var(--jw-orange);
  text-transform: uppercase;
  letter-spacing: .06em;
  transition: letter-spacing .15s;
}
.jw-card--download .jw-card-cta { color: var(--jw-green); }
.jw-card:hover .jw-card-cta { letter-spacing: .1em; }

/* ══════════════════════════════
   PRODUCT CARDS (overrides)
   Transparent product mockups: show whole image, no crop, no zoom.
   Outside-anchor footer: price + Shop Now link.
══════════════════════════════ */
/* Use CSS Grid: row 1 = link (fills remaining height), row 2 = foot (auto height).
   This is more reliable than flex because the link's natural intrinsic size
   is preserved while the foot stays pinned to the bottom on equal-height cards. */
.jw-card.jw-card--product {
  display: grid;
  grid-template-rows: 1fr auto;
}
.jw-card--product .jw-card-img-wrap {
  background: var(--jw-off-white);
  display: flex;
  align-items: center;
  justify-content: center;
}
.jw-card--product .jw-card-img {
  object-fit: contain;
  padding: 14px;
  height: 100%;
  width: 100%;
}
/* No zoom on contained images — looks awkward when there's whitespace around */
.jw-card--product:hover .jw-card-img { transform: none; }

.jw-product-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-top: 1px solid var(--jw-border);
  background: var(--jw-off-white);
}
.jw-product-price {
  font-family: 'Merriweather', Georgia, serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--jw-navy);
  line-height: 1.2;
}
/* WooCommerce sale price markup: <del>$X</del> <ins>$Y</ins> */
.jw-product-price del {
  color: var(--jw-text-hint);
  font-weight: 500;
  font-size: 13px;
  margin-right: 5px;
  text-decoration: line-through;
}
.jw-product-price ins {
  text-decoration: none;
  color: var(--jw-orange);
}
.jw-product-price .woocommerce-Price-amount { font-family: inherit; }

.jw-product-cart-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  background: var(--jw-orange);
  color: var(--jw-white);
  font-family: 'Montserrat', system-ui, sans-serif;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  border: none;
  border-radius: 100px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s ease, transform .15s ease, box-shadow .15s ease;
}
.jw-product-cart-btn:hover,
.jw-product-cart-btn:focus-visible {
  background: var(--jw-navy);
  color: var(--jw-white);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(13, 34, 64, .2);
  outline: none;
}

/* ══════════════════════════════
   EMPTY STATE
══════════════════════════════ */
.jw-empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 72px 20px;
}
.jw-empty-icon  { font-size: 52px; margin-bottom: 16px; }
.jw-empty-title {
  font-family: 'Merriweather', Georgia, serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--jw-navy);
  margin-bottom: 8px;
}
.jw-empty-sub {
  font-size: 14px;
  color: var(--jw-text-soft);
  max-width: 360px;
  margin: 0 auto;
}

/* ══════════════════════════════
   PAGINATION
══════════════════════════════ */
.jw-pagination { margin-top: 48px; }
.jw-page-btns {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.jw-page-btn {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  border: 1.5px solid var(--jw-border);
  background: var(--jw-white);
  font-size: 13px;
  font-weight: 600;
  color: var(--jw-text-mid);
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
}
.jw-page-btn:hover {
  border-color: var(--jw-navy);
  color: var(--jw-navy);
}
.jw-page-btn--active {
  background: var(--jw-navy);
  border-color: var(--jw-navy);
  color: var(--jw-white);
}

/* Loading bar removed — spinner inside grid handles loading state */

/* ══════════════════════════════
   PRODUCT CATEGORY FILTER
══════════════════════════════ */
.jw-product-cat-row {
  display: none;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--jw-border);
  align-items: center;
}
.jw-product-cat-row.active {
  display: grid;
}
.jw-product-cat-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--jw-orange);
  align-self: center;
  white-space: nowrap;
}
.jw-cat-btns {
  grid-column: 2 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.jw-cat-btn {
  font-size: 11px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--jw-border);
  background: var(--jw-off-white);
  color: var(--jw-text-soft);
  cursor: pointer;
  transition: all .15s;
  font-family: 'Montserrat', sans-serif;
}
.jw-cat-btn:hover {
  border-color: var(--jw-orange);
  color: var(--jw-orange);
}
.jw-cat-btn.active {
  background: var(--jw-orange);
  border-color: var(--jw-orange);
  color: #fff;
}

/* ══════════════════════════════
   RESPONSIVE
══════════════════════════════ */
@media (max-width: 1024px) {
  .jw-grid { grid-template-columns: repeat(2, 1fr); }
  .jw-filter-row { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 680px) {
  .jw-hero { padding: 48px 20px 40px; }
  .jw-filter-bar { padding: 16px; }
  .jw-main { padding: 20px 16px 48px; }
  .jw-grid { grid-template-columns: 1fr; }
  /* 2-column filter grid on mobile */
  .jw-filter-row { grid-template-columns: 1fr 1fr; gap: 10px; }
  /* Search spans full width on mobile */
  .jw-filter-group.jw-search-group { grid-column: 1 / -1; }
  /* Product category row spans full width */
  .jw-product-cat-row { grid-template-columns: 1fr !important; }
  .jw-hero-stats { flex-wrap: wrap; }
  .jw-hstat { border-right: none; padding: 10px 16px; }
  .jw-filter-top { flex-direction: column; align-items: flex-start; gap: 8px; }
}
/* ══════════════════════════════
   OVERLAY — locked to results section, top-center
══════════════════════════════ */
.jw-library-wrap #jw-grid-wrap,
.jw-library-wrap .jw-grid-wrap {
  position: relative !important;
  isolation: isolate;
}

.jw-library-wrap #jw-grid-overlay,
.jw-library-wrap .jw-grid-loading-overlay {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  z-index: 10 !important;
}

.jw-library-wrap #jw-grid-overlay.active,
.jw-library-wrap .jw-grid-loading-overlay.active {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;       /* horizontal center */
  justify-content: flex-start !important; /* anchor to top */
  padding-top: 36px !important;
}

/* Belt-and-suspenders: make sure no ancestor accidentally
   becomes the positioning context */
.jw-library-wrap .jw-main {
  position: static !important;
}