/*
 * RBT Resources page: browse/download cards for the therapy PDF library.
 * Reuses base.css tokens (.wood-button, .leaf-badge, .kw-canvas-section)
 * and only adds the layout/card styles specific to this page.
 *
 * The .kw-icon system normally lives in css/app.css, which this
 * marketing-style page does not load (to stay as light as home.css) -
 * so the base rule and the specific glyphs used here are duplicated
 * from app.css rather than pulling in the whole library-page stylesheet.
 */

.kw-icon {
  display: inline-block;
  width: var(--icon-size, 1rem);
  height: var(--icon-size, 1rem);
  flex: 0 0 auto;
  background: currentColor;
  -webkit-mask: var(--kw-icon) center / contain no-repeat;
  mask: var(--kw-icon) center / contain no-repeat;
}

.kw-icon-search { --kw-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M10.5 4a6.5 6.5 0 0 1 5.1 10.5l4.4 4.4-1.4 1.4-4.4-4.4A6.5 6.5 0 1 1 10.5 4Zm0 2a4.5 4.5 0 1 0 0 9 4.5 4.5 0 0 0 0-9Z'/%3E%3C/svg%3E"); }
.kw-icon-lock { --kw-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M17 9V7A5 5 0 0 0 7 7v2H5v12h14V9h-2Zm-8 0V7a3 3 0 0 1 6 0v2H9Z'/%3E%3C/svg%3E"); }
.kw-icon-document { --kw-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 2h9l5 5v15H6V2Zm8 1.5V8h4.5L14 3.5ZM8 12h8v1.6H8V12Zm0 3.5h8V17H8v-1.5Zm0 3.5h5v1.6H8V19Z'/%3E%3C/svg%3E"); }
.kw-icon-download { --kw-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M11 3h2v10.2l3.6-3.6 1.4 1.4-6 6-6-6 1.4-1.4L11 13.2V3ZM5 19h14v2H5v-2Z'/%3E%3C/svg%3E"); }
.kw-icon-package { --kw-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2 3 6.5V17.5L12 22l9-4.5V6.5L12 2Zm0 2.2 5.9 2.95L12 10.1 6.1 7.15 12 4.2ZM5 8.6l6 3v7.7l-6-3V8.6Zm14 0v7.7l-6 3v-7.7l6-3Z'/%3E%3C/svg%3E"); }

/* --------------------------------------------------------
 * Override base .kw-canvas-section defaults for this page
 * to avoid 100svh minimum and fix the footer overlap
 * -------------------------------------------------------- */

.rbt-page {
  background: var(--kw-product-profile-canvas) center / cover no-repeat fixed #c2d8b0;
}

.rbt-page .kw-canvas-section {
  min-height: auto;
}

.rbt-page .forest-footer {
  margin-top: 0;
}

/* --------------------------------------------------------
 * Hero section
 * -------------------------------------------------------- */

.rbt-hero {
  padding-top: clamp(7.4rem, 11vw, 9.6rem);
  padding-bottom: 4.5rem;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.2rem;
  background: transparent;
}

/*
 * Every other kw-canvas-section page (admin, legal, auth, library) gives
 * its heading and body text an opaque parchment backing over its canvas
 * art. The RBT hero never got one, so text fell back to the faint
 * section-wide wash - unreadable dark-on-dark. Match the established
 * pattern instead of leaning on the shared wash alone.
 */
.rbt-hero .section-heading.is-centered {
  max-width: 46rem;
  padding: 1.6rem 2.2rem 1.4rem;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(255, 226, 154, 0.45), rgba(255, 226, 154, 0) 55%),
    linear-gradient(180deg, var(--surface-paper-strong), var(--surface-paper) 75%);
  border-radius: 1.2rem;
  box-shadow:
    var(--surface-shadow),
    0 0 0 0.06rem var(--surface-border);
  animation: rbt-fade-up 600ms ease both;
}

/* --------------------------------------------------------
 * Controls bar (search, filter chips, category dropdown)
 * -------------------------------------------------------- */

.rbt-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  width: min(64rem, 100%);
  animation: rbt-fade-up 600ms 150ms ease both;
}

.rbt-search-wrap {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex: 1 1 16rem;
  min-width: 14rem;
  padding: 0.6rem 1rem;
  background: var(--surface-paper-strong);
  border: 0.08rem solid var(--surface-border);
  border-radius: 999px;
  box-shadow:
    var(--surface-shadow-soft),
    inset 0 0.06rem 0 rgba(255, 255, 255, 0.55);
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

.rbt-search-wrap:focus-within {
  border-color: var(--moss-600);
  box-shadow:
    0 0.2rem 0.6rem rgba(37, 58, 31, 0.18),
    0 0 0 0.16rem rgba(63, 138, 75, 0.2),
    inset 0 0.06rem 0 rgba(255, 255, 255, 0.55);
}

.rbt-search-icon {
  --icon-size: 1.05rem;
  color: var(--bark-text);
  opacity: 0.7;
  flex: 0 0 auto;
  transition: opacity 200ms ease;
}

.rbt-search-wrap:focus-within .rbt-search-icon {
  opacity: 1;
  color: var(--moss-700);
}

.rbt-search-wrap input {
  flex: 1 1 auto;
  border: 0;
  background: transparent;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--forest-text);
  outline: none;
}

.rbt-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.rbt-filters .leaf-badge {
  cursor: pointer;
  transition: transform 180ms ease, filter 180ms ease, opacity 180ms ease, box-shadow 180ms ease;
  opacity: 0.78;
}

.rbt-filters .leaf-badge:hover {
  opacity: 0.95;
  transform: translateY(-0.12rem) scale(1.04);
  box-shadow: 0 0.3rem 0.5rem rgba(30, 61, 35, 0.15);
}

.rbt-filters .leaf-badge.is-active {
  opacity: 1;
  filter: saturate(1.15) drop-shadow(0 0.2rem 0.3rem rgba(30, 61, 35, 0.25));
  transform: translateY(-0.06rem);
  box-shadow: 0 0.25rem 0.5rem rgba(30, 61, 35, 0.2);
}

.rbt-category-select {
  padding: 0.6rem 1rem 0.6rem 0.85rem;
  border-radius: 999px;
  border: 0.08rem solid var(--surface-border);
  background: var(--surface-paper-strong);
  color: var(--forest-text);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: var(--surface-shadow-soft);
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

.rbt-category-select:focus {
  border-color: var(--moss-600);
  box-shadow:
    0 0.2rem 0.6rem rgba(37, 58, 31, 0.18),
    0 0 0 0.16rem rgba(63, 138, 75, 0.2);
}

/* --------------------------------------------------------
 * Sections (resource bundles + individual resources)
 * -------------------------------------------------------- */

.rbt-section {
  width: min(84rem, 100%);
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
  animation: rbt-fade-up 600ms 250ms ease both;
}

.rbt-section-head {
  width: fit-content;
  max-width: 100%;
  padding: 0.9rem 1.5rem;
  background:
    radial-gradient(ellipse at 50% 20%, rgba(255, 241, 201, 0.35), transparent 60%),
    var(--surface-paper-strong);
  border: 0.08rem solid var(--surface-border);
  border-radius: 0.85rem;
  box-shadow: var(--surface-shadow-soft);
}

.rbt-section-head h2 {
  margin: 0 0 0.2rem;
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 2vw, 1.6rem);
  color: var(--forest-ink);
  text-shadow: 0 0.06rem 0 rgba(255, 240, 180, 0.55);
}

.rbt-section-head p {
  margin: 0;
  color: var(--bark-text);
  font-size: 0.9rem;
  opacity: 0.85;
}

/* --------------------------------------------------------
 * Card grids
 * -------------------------------------------------------- */

.rbt-resource-grid,
.rbt-package-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
  gap: clamp(1.2rem, 2.2vw, 1.8rem);
}

/* --------------------------------------------------------
 * Resource cards
 * -------------------------------------------------------- */

.rbt-card,
.rbt-package-card {
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 250, 226, 0.5), transparent 60%),
    var(--surface-paper-strong);
  border: 0.08rem solid var(--surface-border);
  border-radius: 1rem;
  box-shadow: var(--surface-shadow);
  overflow: hidden;
  transition: transform 260ms cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 260ms ease;
  animation: rbt-card-enter 500ms ease both;
}

.rbt-card:hover,
.rbt-package-card:hover {
  transform: translateY(-0.3rem) scale(1.015);
  box-shadow:
    0 0.8rem 1.4rem rgba(37, 58, 31, 0.22),
    0 0 0 0.06rem rgba(63, 138, 75, 0.12);
}

.rbt-card-art {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 5.5rem;
  background:
    radial-gradient(ellipse at 50% 80%, rgba(255, 246, 192, 0.3), transparent 55%),
    linear-gradient(180deg, var(--moss-300), var(--meadow-100));
  border-bottom: 0.06rem solid rgba(67, 101, 52, 0.18);
  position: relative;
  overflow: hidden;
}

/* Subtle shimmer on the art strip */
.rbt-card-art::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    120deg,
    transparent 30%,
    rgba(255, 255, 255, 0.15) 50%,
    transparent 70%
  );
  opacity: 0;
  transition: opacity 300ms ease;
}

.rbt-card:hover .rbt-card-art::after,
.rbt-package-card:hover .rbt-card-art::after {
  opacity: 1;
}

.rbt-card-art .kw-icon {
  --icon-size: 2.4rem;
  color: var(--moss-700);
  transition: transform 300ms ease;
}

.rbt-card:hover .rbt-card-art .kw-icon,
.rbt-package-card:hover .rbt-card-art .kw-icon {
  transform: scale(1.12) translateY(-0.1rem);
}

.rbt-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 1.1rem 1.2rem 1.2rem;
  flex: 1 1 auto;
}

.rbt-card-body h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--forest-ink);
  line-height: 1.2;
}

.rbt-card-category {
  align-self: flex-start;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--wood-700);
  background:
    linear-gradient(180deg, var(--paper-100), var(--paper-200));
  padding: 0.18rem 0.6rem;
  border-radius: 999px;
  border: 0.06rem solid rgba(113, 64, 22, 0.15);
}

.rbt-card-body p {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--forest-text);
  opacity: 0.88;
}

.rbt-card-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
  padding-top: 0.75rem;
  border-top: 0.06rem dashed rgba(91, 50, 24, 0.15);
}

/* --------------------------------------------------------
 * Badges (free / paid)
 * -------------------------------------------------------- */

.rbt-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.24rem 0.7rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  font-family: var(--font-display);
  letter-spacing: 0.02em;
}

.rbt-badge.is-free {
  background:
    linear-gradient(180deg, var(--meadow-100), #d7e9b8);
  color: var(--moss-700);
  border: 0.06rem solid rgba(63, 138, 75, 0.3);
  box-shadow: inset 0 0.05rem 0 rgba(255, 255, 255, 0.5);
}

.rbt-badge.is-paid {
  background:
    linear-gradient(180deg, #ffe8a0, var(--honey-300));
  color: #6a4a10;
  border: 0.06rem solid rgba(224, 173, 67, 0.45);
  box-shadow: inset 0 0.05rem 0 rgba(255, 255, 255, 0.45);
}

/* --------------------------------------------------------
 * Action buttons (download / sign-in / locked)
 * -------------------------------------------------------- */

.rbt-action {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  padding: 0.45rem 0.9rem;
}

.rbt-action .kw-icon {
  --icon-size: 0.9rem;
  transition: transform 200ms ease;
}

.rbt-action:hover .kw-icon {
  transform: translateY(0.1rem);
}

.rbt-locked-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--bark-text);
  opacity: 0.7;
}

.rbt-locked-pill .kw-icon {
  --icon-size: 0.85rem;
}

/* --------------------------------------------------------
 * Package bundle cards
 * -------------------------------------------------------- */

.rbt-bundle-count {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--bark-text);
  opacity: 0.8;
}

.rbt-bundle-list {
  list-style: none;
  margin: 0.2rem 0 0;
  padding: 0.7rem 0 0;
  border-top: 0.06rem dashed var(--surface-border);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.rbt-bundle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--forest-text);
}

.rbt-bundle-item .rbt-action {
  padding: 0.3rem 0.65rem;
  font-size: 0.78rem;
}

/* --------------------------------------------------------
 * Empty state
 * -------------------------------------------------------- */

.rbt-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--bark-text);
  background:
    radial-gradient(ellipse at 50% 50%, rgba(255, 246, 210, 0.5), transparent 60%),
    var(--surface-paper);
  border: 0.08rem dashed var(--surface-border);
  border-radius: 1rem;
  animation: rbt-fade-up 600ms 300ms ease both;
}

.rbt-empty strong {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--forest-ink);
}

.rbt-empty span {
  font-size: 0.92rem;
  max-width: 28rem;
  line-height: 1.5;
}

/* --------------------------------------------------------
 * Entrance & micro-animations
 * -------------------------------------------------------- */

@keyframes rbt-fade-up {
  from {
    opacity: 0;
    transform: translateY(1.2rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes rbt-card-enter {
  from {
    opacity: 0;
    transform: translateY(1.5rem) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Stagger cards: the JS renders them in order so nth-child works */
.rbt-resource-grid > :nth-child(1),
.rbt-package-grid > :nth-child(1) { animation-delay: 80ms; }
.rbt-resource-grid > :nth-child(2),
.rbt-package-grid > :nth-child(2) { animation-delay: 160ms; }
.rbt-resource-grid > :nth-child(3),
.rbt-package-grid > :nth-child(3) { animation-delay: 240ms; }
.rbt-resource-grid > :nth-child(4),
.rbt-package-grid > :nth-child(4) { animation-delay: 320ms; }
.rbt-resource-grid > :nth-child(5),
.rbt-package-grid > :nth-child(5) { animation-delay: 400ms; }
.rbt-resource-grid > :nth-child(6),
.rbt-package-grid > :nth-child(6) { animation-delay: 480ms; }
.rbt-resource-grid > :nth-child(n+7),
.rbt-package-grid > :nth-child(n+7) { animation-delay: 540ms; }

/* --------------------------------------------------------
 * Responsive adjustments
 * -------------------------------------------------------- */

@media (max-width: 640px) {
  .rbt-hero {
    padding-top: 6.2rem;
    padding-bottom: 2.5rem;
    gap: 1.6rem;
  }

  .rbt-hero .section-heading.is-centered {
    padding: 1.2rem 1.2rem 1rem;
  }

  .rbt-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 0.7rem;
  }

  .rbt-category-select {
    width: 100%;
  }

  .rbt-resource-grid,
  .rbt-package-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .rbt-section-head {
    padding: 0.7rem 1rem;
  }

  .rbt-section-head h2 {
    font-size: 1.2rem;
  }

  .rbt-card-body {
    padding: 0.9rem 1rem 1rem;
  }
}

@media (max-width: 430px) {
  .rbt-hero .section-heading.is-centered {
    padding: 1rem;
    border-radius: 0.85rem;
  }
}

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

@media (prefers-reduced-motion: reduce) {
  .rbt-card,
  .rbt-package-card,
  .rbt-section,
  .rbt-hero .section-heading.is-centered,
  .rbt-controls,
  .rbt-empty {
    animation: none !important;
  }
}
