/* ==========================================================================
   PatientSavvy — patientsavvy.css
   Design system: dark forest green + mint, Cormorant Garamond + Montserrat
   All classes prefixed .ps- to avoid WordPress theme conflicts.
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS VARIABLES — defined on .ps-root so they inherit to all children
   but do not leak into the rest of the WordPress page.
   -------------------------------------------------------------------------- */

.ps-root {
  /* Palette */
  --ps-green-dark:    #1B3A2D;
  --ps-green-mid:     #2D5C45;
  --ps-green-accent:  #3A7A57;
  --ps-green-light:   #4A9E6E;
  --ps-mint-bg:       #EFF7F0;
  --ps-mint-card:     #F5FAF6;
  --ps-cream:         #FAFAF7;
  --ps-text-primary:  #011627;
  --ps-text-secondary:#3D5248;
  --ps-text-muted:    #7A9489;
  --ps-border:        rgba(27,58,45,0.12);
  --ps-border-strong: rgba(27,58,45,0.22);

  /* Outcome colours */
  --ps-good:    #2D7A45;
  --ps-bad:     #8B2E2E;
  --ps-unclear: #6B6040;

  /* Cancer type accents */
  --ps-breast:      #C0336A;
  --ps-lung:        #4A6070;
  --ps-colorectal:  #2D55AA;

  /* Shadows */
  --ps-shadow-xs: 0 1px 3px rgba(0,0,0,.06);
  --ps-shadow-sm: 0 2px 10px rgba(0,0,0,.09);
  --ps-shadow-md: 0 6px 24px rgba(0,0,0,.12);
  --ps-shadow-lg: 0 16px 48px rgba(0,0,0,.16);

  /* Typography — Montserrat matches the patientsavvy.org Astra theme */
  --ps-font-serif: 'Cormorant Garamond', Georgia, serif;
  --ps-font-sans:  'Montserrat', system-ui, -apple-system, sans-serif;

  /* Radii */
  --ps-r-sm:   8px;
  --ps-r-md:   16px;
  --ps-r-lg:   20px;
  --ps-r-pill: 100px;

  /* Applied base */
  font-family: var(--ps-font-sans);
  color: var(--ps-text-primary);
  box-sizing: border-box;
  position: relative;
  width: 100%;
}

.ps-root *,
.ps-root *::before,
.ps-root *::after {
  box-sizing: inherit;
}

/* --------------------------------------------------------------------------
   SCREEN-READER ONLY
   -------------------------------------------------------------------------- */

.ps-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------------------------
   SPINNER
   -------------------------------------------------------------------------- */

.ps-spinner {
  display: inline-block;
  width: 42px;
  height: 42px;
  border: 3px solid var(--ps-border-strong);
  border-top-color: var(--ps-green-accent);
  border-radius: 50%;
  animation: ps-spin 0.75s linear infinite;
}

.ps-spinner--inline {
  display: block;
  margin: 3rem auto;
}

@keyframes ps-spin {
  to { transform: rotate(360deg); }
}

/* --------------------------------------------------------------------------
   ADMIN DEMO NOTICE (visible only to logged-in admins via .logged-in body)
   -------------------------------------------------------------------------- */

.ps-demo-notice {
  font-family: var(--ps-font-sans);
  font-size: 0.78rem;
  background: rgba(107,96,64,.08);
  color: var(--ps-unclear);
  border: 1px dashed rgba(107,96,64,.35);
  border-radius: var(--ps-r-sm);
  padding: 0.5rem 0.875rem;
  margin-bottom: 1.25rem;
}

/* ==========================================================================
   SEARCH BAR
   ========================================================================== */

.ps-search-bar-wrap {
  margin-bottom: 1.25rem;
}

.ps-search-bar {
  display: flex;
  align-items: center;
  width: 100%;
  height: 60px;
  background: #fff;
  border: 1.5px solid var(--ps-border-strong);
  border-radius: var(--ps-r-pill);
  box-shadow: var(--ps-shadow-sm);
  padding: 0 0.5rem 0 1.5rem;
  gap: 0.5rem;
  transition: border-color 0.18s, box-shadow 0.18s;
}

.ps-search-bar:focus-within {
  border-color: var(--ps-green-accent);
  box-shadow: 0 0 0 4px rgba(58,122,87,.14), var(--ps-shadow-sm);
}

/* Nuke all browser/theme input overrides — must be !important to beat theme stylesheets */
.ps-root input[type="search"].ps-search-bar__input,
.ps-root input[type="text"].ps-search-bar__input,
.ps-root .ps-search-bar__input {
  flex: 1 !important;
  border: none !important;
  background: transparent !important;
  font-family: var(--ps-font-sans) !important;
  font-size: 1rem !important;
  font-weight: 400 !important;
  color: var(--ps-text-primary) !important;
  outline: none !important;
  outline-width: 0 !important;
  outline-offset: 0 !important;
  box-shadow: none !important;
  -webkit-appearance: textfield !important; /* textfield not none — avoids Safari quirks */
  appearance: textfield !important;
  -webkit-tap-highlight-color: transparent !important;
  min-width: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  width: 100% !important;
}

.ps-root .ps-search-bar__input:focus,
.ps-root .ps-search-bar__input:focus-visible,
.ps-root .ps-search-bar__input:focus-within,
.ps-root .ps-search-bar__input:active {
  outline: none !important;
  outline-width: 0 !important;
  box-shadow: none !important;
  border: none !important;
}

.ps-root .ps-search-bar__input::placeholder {
  color: var(--ps-text-muted);
  opacity: 1;
}

/* Kill ALL browser search field chrome */
.ps-root .ps-search-bar__input::-webkit-search-cancel-button,
.ps-root .ps-search-bar__input::-webkit-search-decoration,
.ps-root .ps-search-bar__input::-webkit-search-results-button,
.ps-root .ps-search-bar__input::-webkit-search-results-decoration,
.ps-root .ps-search-bar__input::-webkit-inner-spin-button,
.ps-root .ps-search-bar__input::-webkit-outer-spin-button { display: none !important; -webkit-appearance: none !important; }

.ps-search-bar__btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: flex !important;
  align-items: center;
  justify-content: center;
  background: var(--ps-green-dark) !important;
  color: #fff !important;
  border: none !important;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  line-height: 0;
  padding: 0;
  overflow: visible;
}

/* Force SVG to be visible — some themes set svg { display:none } or max-width:0 */
.ps-search-bar__btn svg {
  display: block !important;
  visibility: visible !important;
  width: 20px !important;
  height: 20px !important;
  min-width: 20px !important;
  min-height: 20px !important;
  flex-shrink: 0 !important;
  overflow: visible !important;
  fill: none !important;
  pointer-events: none;
}

.ps-search-bar__btn svg *,
.ps-search-bar__btn svg circle,
.ps-search-bar__btn svg path,
.ps-search-bar__btn svg line {
  stroke: #fff !important;
  fill: none !important;
  vector-effect: non-scaling-stroke;
}

.ps-search-bar__btn:hover {
  background: var(--ps-green-accent);
  transform: scale(1.05);
}

.ps-search-bar__btn:active {
  transform: scale(0.97);
}

/* Large variant for hero bars */
.ps-bar--large .ps-search-bar {
  height: 80px;
  padding: 0 0.625rem 0 2rem;
}

.ps-bar--large .ps-search-bar__input {
  font-size: 1.15rem;
}

.ps-bar--large .ps-search-bar__btn {
  width: 58px;
  height: 58px;
}

.ps-bar--large .ps-search-bar__btn svg {
  width: 24px;
  height: 24px;
}

/* ==========================================================================
   INTENT PILLS & AUTO-CHIPS
   ========================================================================== */

.ps-intent-row,
.ps-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.875rem;
  align-items: center;
}

.ps-intent-row[hidden],
.ps-chips-row[hidden] {
  display: none;
}

.ps-intent-label {
  font-family: var(--ps-font-sans);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ps-text-muted);
}

.ps-intent-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.22rem 0.72rem;
  background: rgba(58,122,87,.10);
  border: 1px solid rgba(58,122,87,.22);
  border-radius: var(--ps-r-pill);
  font-family: var(--ps-font-sans);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ps-green-mid);
}

.ps-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.28rem 0.85rem;
  background: #fff;
  border: 1.5px solid var(--ps-border-strong);
  border-radius: var(--ps-r-pill);
  font-family: var(--ps-font-sans);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ps-text-secondary);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.ps-chip:hover,
.ps-chip--active {
  background: var(--ps-green-dark);
  border-color: var(--ps-green-dark);
  color: #fff;
}

/* ==========================================================================
   THEME TAB BAR
   ========================================================================== */

.ps-theme-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 1rem 0 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--ps-border);
}

.ps-theme-tab {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.9rem;
  background: transparent;
  border: 1.5px solid var(--ps-border-strong);
  border-radius: var(--ps-r-pill);
  font-family: var(--ps-font-sans);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ps-text-secondary);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.ps-theme-tab:hover {
  background: rgba(27,58,45,.06);
  border-color: var(--ps-green-mid);
  color: var(--ps-green-mid);
}

.ps-theme-tab--active {
  background: var(--ps-green-dark);
  border-color: var(--ps-green-dark);
  color: #fff;
}

/* ==========================================================================
   THEMED SECTIONS  (section-mode "All stories")
   ========================================================================== */

.ps-section {
  margin-bottom: 2.5rem;
}

.ps-section__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 2px solid var(--ps-border);
}

.ps-section__title {
  font-family: var(--ps-font-sans);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ps-text-primary);
  margin: 0;
  letter-spacing: -0.01em;
}

.ps-section__see-all {
  background: none;
  border: none;
  padding: 0;
  font-family: var(--ps-font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ps-green-mid);
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.ps-section__see-all:hover { opacity: 0.7; }

/* Carousel wrapper — positions the arrows relative to the track */
.ps-section__carousel-wrap {
  position: relative;
}

/* Edge fade hints that more cards are available */
.ps-section__carousel-wrap::after {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 56px;
  background: linear-gradient(to left, #fff 20%, transparent);
  pointer-events: none;
  z-index: 2;
}

/* The scrollable track (reuses ps-story-grid--row layout) */
.ps-section__track {
  /* hide the thin scrollbar — swipe/arrows are the affordance */
  scrollbar-width: none;
}
.ps-section__track::-webkit-scrollbar { display: none; }

/* Prev / Next arrow buttons */
.ps-section__arrow {
  display: none; /* hidden on mobile — touch swipe suffices */
  position: absolute;
  top: 50%;
  transform: translateY(-70%);
  z-index: 3;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: #fff;
  border: 1.5px solid rgba(27,58,45,.14);
  box-shadow: 0 2px 10px rgba(0,0,0,.10);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #0F1F18;
  transition: background .18s, color .18s, border-color .18s;
  padding: 0;
}
.ps-section__arrow:hover {
  background: #1B3A2D;
  color: #fff;
  border-color: #1B3A2D;
}
.ps-section__arrow svg { display: block; }
.ps-section__arrow--left  { left: -18px; }
.ps-section__arrow--right { right: -18px; }

/* Show arrows on devices with a pointer (desktop/tablet with mouse) */
@media (pointer: fine) {
  .ps-section__arrow { display: flex; }
}

.ps-section--loading .ps-story-grid { opacity: 0.5; }

/* ==========================================================================
   RESULTS META
   ========================================================================== */

.ps-results-meta {
  font-family: var(--ps-font-sans);
  font-size: 0.85rem;
  color: var(--ps-text-muted);
  margin-bottom: 1.25rem;
  min-height: 1.4em;
}

/* ==========================================================================
   STORY GRID
   ========================================================================== */

.ps-story-grid--grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

/* Horizontal scroll row for shelves */
.ps-story-grid--row {
  display: flex;
  gap: 1.25rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.5rem;
}

.ps-story-grid--row::-webkit-scrollbar {
  height: 4px;
}

.ps-story-grid--row::-webkit-scrollbar-track {
  background: var(--ps-border);
  border-radius: 2px;
}

.ps-story-grid--row::-webkit-scrollbar-thumb {
  background: var(--ps-green-light);
  border-radius: 2px;
}

.ps-story-grid--row .ps-story-card {
  flex: 0 0 280px;
  scroll-snap-align: start;
}

/* ==========================================================================
   STORY CARD
   ========================================================================== */

.ps-story-card {
  position: relative;
  background: #fff;
  border: 1px solid var(--ps-border);
  border-radius: var(--ps-r-lg);
  box-shadow: var(--ps-shadow-xs);
  overflow: hidden;
  cursor: pointer !important;
  pointer-events: auto !important;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  outline: none;
}

.ps-story-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--ps-shadow-md);
}

.ps-story-card:focus-visible {
  outline: 2px solid var(--ps-green-accent);
  outline-offset: 3px;
}

/* Photo / placeholder — 4:3 aspect ratio */
.ps-story-card__photo-wrap {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--ps-mint-bg);
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
}

.ps-story-card__photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
}

/* Placeholder shown when no portrait exists.
   Background colour applied via .ps-placeholder--{type} class AND inline style.
   Two approaches so at least one beats the theme. */
.ps-story-card__photo-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: linear-gradient(160deg, #1B3A2D 0%, #2D5C45 100%); /* fallback */
  position: relative;
  overflow: hidden;
}

/* Cancer-type gradient variants — applied via JS class name */
.ps-placeholder--breast     { background: linear-gradient(160deg, #7A1840 0%, #B02D60 100%) !important; }
.ps-placeholder--lung       { background: linear-gradient(160deg, #2A3C48 0%, #3D5868 100%) !important; }
.ps-placeholder--colorectal { background: linear-gradient(160deg, #1A2E6A 0%, #2D4A9A 100%) !important; }
.ps-placeholder--default    { background: linear-gradient(160deg, #1B3A2D 0%, #2D5C45 100%) !important; }

/* Subtle large circle watermark for depth */
.ps-story-card__photo-placeholder::before {
  content: '';
  position: absolute;
  width: 120%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(255,255,255,.04);
  top: -20%;
  right: -20%;
  pointer-events: none;
}

.ps-story-card__photo-placeholder-inner {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(255,255,255,.15);
  border: 1.5px solid rgba(255,255,255,.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--ps-font-serif);
  font-size: 1.5rem;
  font-weight: 600;
  color: rgba(255,255,255,.85);
}

/* Card body */
.ps-story-card__body {
  padding: 1rem 1.1rem 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
}

/* Cancer type tag */
/* Cancer type badge — overlaid on photo, top-right */
.ps-story-card__cancer-badge {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  font-family: var(--ps-font-sans);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  padding: 0.2rem 0.55rem;
  border-radius: var(--ps-r-pill);
  background: rgba(255,255,255,.82);
  color: var(--ps-green-dark);
  border: 1px solid rgba(255,255,255,.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  pointer-events: none;
}

.ps-story-card__cancer-badge.ps-story-card__cancer-tag--breast     { color: var(--ps-breast); }
.ps-story-card__cancer-badge.ps-story-card__cancer-tag--lung       { color: var(--ps-lung); }
.ps-story-card__cancer-badge.ps-story-card__cancer-tag--colorectal { color: var(--ps-colorectal); }

.ps-story-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.ps-story-card__theme-tag {
  display: inline-block;
  font-family: var(--ps-font-sans);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 0.18rem 0.6rem;
  border-radius: var(--ps-r-pill);
  white-space: nowrap;
  /* default fallback */
  background: #eef6f0;
  color: #2D5C45;
  border: 1px solid #b8d8c0;
}

/* dark green → yellow spectrum per theme */
.ps-story-card__theme-tag--beyond_prognosis {
  background: #c8e6d0;
  color: #0d2b1a;
  border-color: #6db88a;
}
.ps-story-card__theme-tag--what_worked {
  background: #e8f3de;
  color: #3a6020;
  border-color: #a8cc80;
}
.ps-story-card__theme-tag--how_it_feels {
  background: #f4f8e4;
  color: #4a6020;
  border-color: #c8d88a;
}
.ps-story-card__theme-tag--expert_education {
  background: #faf5e0;
  color: #7a6010;
  border-color: #dcc96a;
}
.ps-story-card__theme-tag--community_voices {
  background: #fef6d8;
  color: #8a6400;
  border-color: #e8c83a;
}

/* Patient name */
.ps-story-card__name {
  font-family: var(--ps-font-serif);
  font-size: 1.3rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--ps-text-primary);
  margin: 0;
}

/* Sub-line: age, sex, stage */
.ps-story-card__subline {
  font-family: var(--ps-font-sans);
  font-size: 0.78rem;
  color: var(--ps-text-muted);
  margin: 0;
}

.ps-story-card__subline-outcome {
  color: var(--ps-green-accent);
  font-weight: 600;
}

/* Teaser text */
.ps-story-card__teaser {
  font-family: var(--ps-font-sans);
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--ps-text-secondary);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

/* Bottom row: stage left, outcome pill right */
.ps-story-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.625rem;
  padding-top: 0.625rem;
  border-top: 1px solid var(--ps-border);
  gap: 0.5rem;
}

.ps-story-card__source {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--ps-font-sans);
  font-size: 0.73rem;
  font-weight: 500;
  color: var(--ps-text-muted);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ps-source-logo {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  border-radius: 2px;
  object-fit: contain;
}

/* ==========================================================================
   OUTCOME PILLS
   ========================================================================== */

.ps-outcome-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.65rem;
  border-radius: var(--ps-r-pill);
  font-family: var(--ps-font-sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: .03em;
  border: 1px solid transparent;
  white-space: nowrap;
  flex-shrink: 0;
}

.ps-outcome-pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.ps-outcome-pill--good {
  background: rgba(45,122,69,.1);
  color: var(--ps-good);
  border-color: rgba(45,122,69,.2);
}
.ps-outcome-pill--good::before { background: var(--ps-good); }

.ps-outcome-pill--bad {
  background: rgba(139,46,46,.09);
  color: var(--ps-bad);
  border-color: rgba(139,46,46,.2);
}
.ps-outcome-pill--bad::before { background: var(--ps-bad); }

.ps-outcome-pill--unclear {
  background: rgba(107,96,64,.09);
  color: var(--ps-unclear);
  border-color: rgba(107,96,64,.2);
}
.ps-outcome-pill--unclear::before { background: var(--ps-unclear); }

.ps-outcome-pill--survival {
  background: rgba(27,58,45,.08);
  color: #1B3A2D;
  border-color: rgba(27,58,45,.2);
  font-weight: 700;
  letter-spacing: .02em;
}
.ps-outcome-pill--survival::before { background: #3A7A57; }

/* ==========================================================================
   SKELETON CARDS (loading state)
   ========================================================================== */

.ps-skeleton {
  background: #fff;
  border: 1px solid var(--ps-border);
  border-radius: var(--ps-r-lg);
  overflow: hidden;
  pointer-events: none;
}

.ps-skeleton__photo {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: linear-gradient(90deg, var(--ps-mint-bg) 25%, var(--ps-mint-card) 50%, var(--ps-mint-bg) 75%);
  background-size: 200% 100%;
  animation: ps-shimmer 1.4s ease infinite;
}

.ps-skeleton__body {
  padding: 1rem 1.1rem 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.ps-skeleton__line {
  height: 0.75rem;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--ps-mint-bg) 25%, var(--ps-mint-card) 50%, var(--ps-mint-bg) 75%);
  background-size: 200% 100%;
  animation: ps-shimmer 1.4s ease infinite;
}

.ps-skeleton__line--wide  { width: 80%; }
.ps-skeleton__line--med   { width: 55%; }
.ps-skeleton__line--short { width: 40%; }
.ps-skeleton__line--tall  { height: 1.2rem; width: 65%; }

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

/* ==========================================================================
   LOAD MORE
   ========================================================================== */

.ps-load-more-wrap {
  display: flex;
  justify-content: center;
  margin-top: 2rem;
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */

.ps-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-family: var(--ps-font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.6rem 1.4rem;
  border-radius: var(--ps-r-pill);
  border: 2px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.15s;
  white-space: nowrap;
  line-height: 1;
}

.ps-btn--primary {
  background: #1B3A2D !important;
  color: #fff !important;
  border-color: #1B3A2D !important;
  box-shadow: 0 2px 8px rgba(27,58,45,.25) !important;
  text-decoration: none !important;
  width: auto !important;
  align-self: flex-start !important;
}

.ps-btn--primary:hover {
  background: #3A7A57 !important;
  border-color: #3A7A57 !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 14px rgba(27,58,45,.3) !important;
  color: #fff !important;
  text-decoration: none !important;
}

.ps-btn--outline {
  background: #fff;
  color: var(--ps-green-dark);
  border-color: var(--ps-border-strong);
}

.ps-btn--outline:hover {
  border-color: var(--ps-green-accent);
  color: var(--ps-green-accent);
  transform: translateY(-1px);
  text-decoration: none;
}

/* ==========================================================================
   SHELF TITLE
   ========================================================================== */

.ps-shelf-title {
  font-family: var(--ps-font-serif);
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--ps-text-primary);
  margin: 0 0 1.25rem;
  line-height: 1.2;
}

/* ==========================================================================
   STORY MODAL
   ========================================================================== */

.ps-story-modal {
  position: fixed;
  inset: 0;
  z-index: 99990;
  display: flex;
  align-items: flex-end;  /* panel slides up from bottom */
  justify-content: center;
}

.ps-story-modal[hidden] {
  display: none !important;
}

.ps-story-modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(15,31,24,.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  cursor: pointer;
}

.ps-story-modal__panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 780px;
  max-height: 92vh;
  background: #FAFAF7 !important;
  border-radius: 16px 16px 0 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transform: translateY(0) !important;
  box-shadow: 0 -8px 40px rgba(0,0,0,.2);
  animation: none !important;
}

.ps-story-modal--closing .ps-story-modal__panel {
  transform: translateY(100%) !important;
  transition: transform 0.22s ease-in !important;
}

.ps-story-modal__close {
  position: sticky !important;
  top: 0 !important;
  float: right !important;
  margin: 1rem 1rem -2.5rem 0 !important;
  width: 36px !important;
  height: 36px !important;
  min-width: 36px !important;
  min-height: 36px !important;
  border-radius: 50% !important;
  background: rgba(255,255,255,.95) !important;
  border: 1px solid rgba(27,58,45,.15) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  z-index: 2 !important;
  color: #1B3A2D !important;
  transition: background 0.15s, color 0.15s !important;
  backdrop-filter: blur(4px) !important;
  box-shadow: 0 2px 8px rgba(0,0,0,.12) !important;
  padding: 0 !important;
  font-size: 0 !important;
  line-height: 0 !important;
}

.ps-story-modal__close svg {
  display: block !important;
  width: 16px !important;
  height: 16px !important;
  flex-shrink: 0 !important;
}

.ps-story-modal__close:hover {
  background: #1B3A2D !important;
  color: #fff !important;
  border-color: #1B3A2D !important;
}

.ps-story-modal__content {
  padding: 0 2rem 2.5rem;
  clear: both;
}

/* --------------------------------------------------------------------------
   Modal — story header (portrait + name + meta)
   -------------------------------------------------------------------------- */

.ps-modal-header {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin: 0 -2rem 1.75rem;
  min-height: 210px;
  border-radius: var(--ps-r-lg) var(--ps-r-lg) 0 0;
  overflow: hidden;
}

.ps-modal-header__portrait-wrap {
  width: 240px;
  flex-shrink: 0;
  background: var(--ps-mint-bg);
  overflow: hidden;
}

.ps-modal-header__portrait {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
}

.ps-modal-header__portrait-placeholder {
  width: 100%;
  height: 100%;
  min-height: 210px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ps-mint-bg);
  overflow: hidden;
}

.ps-modal-header__portrait-placeholder span {
  font-family: var(--ps-font-serif);
  font-size: 3rem;
  font-weight: 600;
}

.ps-modal-header__info {
  flex: 1;
  padding: 1.5rem 1.75rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0.5rem;
}

.ps-modal-header__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.ps-modal-header__cancer-tag,
.ps-modal-header__theme-tag {
  display: inline-flex;
  font-family: var(--ps-font-sans);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 0.22rem 0.7rem;
  border-radius: var(--ps-r-pill);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.ps-modal-header__cancer-tag {
  background: rgba(255,255,255,.88);
  color: var(--ps-text-primary);
  border: 1px solid rgba(255,255,255,.6);
}

.ps-modal-header__theme-tag {
  background: rgba(255,255,255,.55);
  color: var(--ps-text-primary);
  border: 1px solid rgba(255,255,255,.35);
}

/* modal theme tag — tinted glass per theme */
.ps-modal-header__theme-tag[data-theme="beyond_prognosis"]   { background: rgba(27,58,45,.72);  color: #d4ece0; border-color: rgba(159,201,170,.4); }
.ps-modal-header__theme-tag[data-theme="what_worked"]        { background: rgba(45,92,69,.68);  color: #d8eedd; border-color: rgba(178,214,186,.4); }
.ps-modal-header__theme-tag[data-theme="how_it_feels"]       { background: rgba(74,96,32,.68);  color: #e8f0c8; border-color: rgba(200,216,138,.4); }
.ps-modal-header__theme-tag[data-theme="expert_education"]   { background: rgba(122,96,16,.68); color: #f5ecc8; border-color: rgba(220,201,106,.4); }
.ps-modal-header__theme-tag[data-theme="community_voices"]   { background: rgba(138,100,0,.68); color: #fdf0c0; border-color: rgba(232,200,58,.4);  }

.ps-modal-header__name {
  font-family: var(--ps-font-serif);
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: 600;
  font-style: italic;
  color: #1B3A2D;
  margin: 0;
  line-height: 1.15;
}

.ps-modal-header__subline {
  font-family: var(--ps-font-sans);
  font-size: 0.85rem;
  color: #3a5a4a;
  margin: 0;
}

.ps-modal-header__pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.25rem;
}

/* --------------------------------------------------------------------------
   Modal — facts grid (2 columns)
   -------------------------------------------------------------------------- */

.ps-modal-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1.5rem;
  background: var(--ps-mint-bg);
  border: 1px solid var(--ps-border);
  border-radius: var(--ps-r-md);
  padding: 1.1rem 1.25rem;
  margin-bottom: 1.75rem;
}

.ps-modal-facts__col {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.ps-modal-facts__col + .ps-modal-facts__col {
  border-left: 1px solid var(--ps-border);
  padding-left: 1.5rem;
}

.ps-modal-fact__label {
  font-family: var(--ps-font-sans);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ps-text-muted);
  margin: 0 0 0.2rem;
}

.ps-modal-fact__value {
  font-family: var(--ps-font-sans);
  font-size: 0.88rem;
  color: var(--ps-text-primary);
  font-weight: 500;
  margin: 0;
}

.ps-modal-fact__value--sub {
  font-size: 0.88rem;
  color: var(--ps-text-muted);
  font-weight: 400;
  margin-top: 0.15rem;
}

.ps-modal-fact__treat-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.ps-modal-fact__treat-list li {
  font-family: var(--ps-font-sans);
  font-size: 0.86rem;
  color: var(--ps-text-primary);
  font-weight: 500;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.ps-modal-fact__treat-list li::before {
  content: counter(li-counter);
  counter-increment: li-counter;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--ps-text-muted);
  background: var(--ps-border);
  border-radius: 50%;
  min-width: 1.25rem;
  height: 1.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ps-modal-fact__treat-list {
  counter-reset: li-counter;
}

/* --------------------------------------------------------------------------
   Modal — narrative text
   -------------------------------------------------------------------------- */

.ps-modal-section-title {
  font-family: var(--ps-font-sans);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--ps-text-muted);
  margin: 0 0 0.875rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--ps-border);
}

.ps-modal-patient-voice {
  display: block;
  font-style: italic;
  font-size: 0.72rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: #2d8a55;
  margin-top: 0.3rem;
}

.ps-modal-narrative {
  font-family: var(--ps-font-serif);
  font-size: 1.1rem;
  font-weight: 400;
  line-height: 1.85;
  color: var(--ps-text-primary);
  margin-bottom: 1.75rem;
}

.ps-modal-narrative p {
  margin: 0 0 1em;
}

.ps-modal-narrative p:last-child {
  margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   Modal — treatment timeline
   -------------------------------------------------------------------------- */

.ps-modal-timeline {
  list-style: none;
  padding: 0;
  margin: 0 0 1.75rem;
  position: relative;
}

.ps-modal-timeline::before {
  content: '';
  position: absolute;
  left: 0.9rem;
  top: 0.6rem;
  bottom: 0.6rem;
  width: 2px;
  background: linear-gradient(to bottom, var(--ps-green-accent), var(--ps-border));
  border-radius: 1px;
}

.ps-modal-timeline__step {
  position: relative;
  padding: 0 0 1rem 2.5rem;
}

.ps-modal-timeline__step::before {
  content: '';
  position: absolute;
  left: 0.525rem;
  top: 0.35rem;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  background: var(--ps-green-accent);
  border: 2px solid var(--ps-cream);
  box-shadow: 0 0 0 2px var(--ps-green-accent);
}

.ps-modal-timeline__label {
  display: block;
  font-family: var(--ps-font-sans);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ps-green-accent);
  margin-bottom: 0.2rem;
}

.ps-modal-timeline__text {
  font-family: var(--ps-font-sans);
  font-size: 0.9rem;
  color: var(--ps-text-primary);
  line-height: 1.55;
  margin: 0;
}

/* --------------------------------------------------------------------------
   Modal — source + disclaimer
   -------------------------------------------------------------------------- */

.ps-modal-source {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--ps-border);
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.ps-modal-disclaimer {
  font-family: var(--ps-font-sans);
  font-size: 0.75rem;
  color: #B03030;
  line-height: 1.5;
  margin: 0;
}

.ps-modal-credit {
  font-family: var(--ps-font-sans);
  font-size: 0.78rem;
  color: var(--ps-text-muted);
  margin: 0;
}

/* ==========================================================================
   INLINE SINGLE STORY ([patientsavvy_story])
   ========================================================================== */

.ps-inline-story-root {
  background: var(--ps-cream);
  border: 1px solid var(--ps-border);
  border-radius: var(--ps-r-lg);
  overflow: hidden;
}

.ps-inline-story-content {
  padding: 0 0 2rem;
}

/* Reuse modal header styles but flush to container */
.ps-inline-story-content .ps-modal-header {
  margin: 0 0 1.75rem;
  border-radius: var(--ps-r-lg) var(--ps-r-lg) 0 0;
}

.ps-inline-story-content .ps-modal-section-title,
.ps-inline-story-content .ps-modal-narrative,
.ps-inline-story-content .ps-modal-facts,
.ps-inline-story-content .ps-modal-source {
  margin-left: 2rem;
  margin-right: 2rem;
}

/* ==========================================================================
   ERROR STATE
   ========================================================================== */

.ps-error-msg {
  font-family: var(--ps-font-sans);
  font-size: 0.95rem;
  color: var(--ps-bad);
  text-align: center;
  padding: 2.5rem 1.5rem;
  margin: 0;
}

.ps-empty-msg {
  font-family: var(--ps-font-sans);
  font-size: 0.95rem;
  color: var(--ps-text-muted);
  text-align: center;
  padding: 3rem 1.5rem;
  margin: 0;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 900px) {
  .ps-story-grid--grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .ps-story-grid--grid {
    grid-template-columns: 1fr;
  }

  .ps-story-grid--row .ps-story-card {
    flex: 0 0 260px;
  }

  .ps-modal-header {
    flex-direction: column;
    margin: 0 -1rem 1.5rem;
  }

  .ps-modal-header__portrait-wrap {
    width: 100%;
    height: 220px;
  }

  .ps-story-modal__content {
    padding: 0 1rem 2rem;
  }

  .ps-inline-story-content .ps-modal-section-title,
  .ps-inline-story-content .ps-modal-narrative,
  .ps-inline-story-content .ps-modal-facts,
  .ps-inline-story-content .ps-modal-source {
    margin-left: 1rem;
    margin-right: 1rem;
  }

  .ps-modal-facts {
    grid-template-columns: 1fr;
  }

  .ps-modal-header__name {
    font-size: 1.5rem;
  }

  .ps-bar--large .ps-search-bar {
    height: 64px;
    padding: 0 0.5rem 0 1.25rem;
  }

  .ps-bar--large .ps-search-bar__btn {
    width: 48px;
    height: 48px;
  }
}
