/* YourHealthRx — peptide detail modal + clickable chip styles
   Restores the clickable peptide chips / summary panels that existed
   on the original single-page site. Uses the current design tokens so
   the look stays consistent with the approved multipage rebuild. */

/* ---------- protocol-card <li> as chip + inner peptide-chip button ----------
   Both the static <li> chip (e.g. "Labs optional") and the <li> wrapping a
   clickable .peptide-chip button must render with identical geometry so the
   row reads as one uniform pill strip. We give every chip the same box model
   (border-box, transparent 1px border, line-height 1, inherited font) and
   the button inherits those values directly from its parent <li>. */
.protocol-card li {
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
  min-height: 32px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  background: var(--color-surface-2);
  font-size: var(--text-xs);
  font-weight: 700;
  line-height: 1;
}

.protocol-card li:has(> .peptide-chip) {
  padding: 0;
  background: transparent;
  border-color: transparent;
}

.protocol-card li > .peptide-chip {
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
  min-height: 32px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  background: var(--color-surface-2);
  font-family: inherit;
  font-size: var(--text-xs);
  font-weight: 700;
  line-height: 1;
  margin: 0;
  cursor: pointer;
}

.protocol-card li > .peptide-chip:hover,
.protocol-card li > .peptide-chip:focus-visible {
  color: var(--color-primary);
  border-color: var(--color-primary);
  background: var(--color-surface-2);
}

/* ---------- Clickable chip (button) ---------- */
/* The base .chip styling lives in styles.css. We layer a button reset
   and interactive affordances on top when a chip is a real drug link so
   button.chip and span.chip render at identical size. */
button.chip,
.peptide-chip {
  box-sizing: border-box;
  font-family: inherit;
  font-size: var(--text-xs);
  font-weight: 700;
  line-height: 1;
  margin: 0;
  cursor: pointer;
  transition: color var(--transition-interactive),
              background var(--transition-interactive),
              border-color var(--transition-interactive),
              transform var(--transition-interactive);
  -webkit-appearance: none;
  appearance: none;
}

button.chip {
  min-height: 32px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-full);
}

.peptide-chip:hover,
.peptide-chip:focus-visible {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.peptide-chip:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.peptide-chip:active { transform: translateY(1px); }

.peptide-chip.is-selected,
.peptide-chip[aria-expanded="true"] {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-text-inverse);
}

/* ---------- Modal shell ---------- */
.peptide-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 14, 13, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  pointer-events: none;
  z-index: 1000;
  transition: opacity 0.2s ease;
}

.peptide-modal-backdrop[hidden] { display: none; }

.peptide-modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.peptide-modal {
  position: relative;
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: min(720px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.97);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.peptide-modal-backdrop.open .peptide-modal { transform: scale(1); }

.peptide-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  position: sticky;
  top: 0;
  z-index: 2;
  flex-shrink: 0;
}

.peptide-modal__eyebrow {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  font-family: var(--font-body);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
}

.peptide-modal__close {
  background: transparent;
  border: 1px solid transparent;
  color: var(--color-text-muted);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition-interactive),
              color var(--transition-interactive);
}

.peptide-modal__close:hover,
.peptide-modal__close:focus-visible {
  background: var(--color-surface-2);
  color: var(--color-text);
}

.peptide-modal__close:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.peptide-modal__content {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  outline: none;
}

.peptide-modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  flex-shrink: 0;
}

/* ---------- Modal body ---------- */
.peptide-hero {
  padding: var(--space-6) var(--space-6) var(--space-6);
  border-bottom: 1px solid var(--color-border);
}

.peptide-hero__eyebrow {
  font-size: var(--text-xs);
  color: var(--color-primary);
  font-family: var(--font-body);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: var(--space-2);
}

.peptide-hero__name {
  font-family: var(--font-display);
  font-size: clamp(2rem, 1.5rem + 1.5vw, 2.75rem);
  font-weight: 400;
  color: var(--color-text);
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0 0 var(--space-2);
}

.peptide-hero__tagline {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  font-family: var(--font-body);
  line-height: 1.6;
  margin: 0;
}

.peptide-hero__badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.peptide-badge {
  font-size: var(--text-xs);
  font-family: var(--font-body);
  font-weight: 500;
  color: var(--color-text-muted);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
}

.peptide-badge--warn {
  color: var(--color-gold);
  background: color-mix(in oklch, var(--color-gold) 10%, transparent);
  border-color: color-mix(in oklch, var(--color-gold) 35%, var(--color-border));
}

.peptide-body {
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.peptide-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-4);
  padding: var(--space-5);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.peptide-meta__label {
  font-size: 10px;
  color: var(--color-text-faint);
  font-family: var(--font-body);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: 4px;
}

.peptide-meta__value {
  font-size: var(--text-sm);
  color: var(--color-text);
  font-family: var(--font-body);
  font-weight: 500;
}

.peptide-section__label {
  font-size: 11px;
  color: var(--color-text-faint);
  font-family: var(--font-body);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: var(--space-2);
}

.peptide-section__body {
  font-size: var(--text-sm);
  color: var(--color-text);
  font-family: var(--font-body);
  line-height: 1.7;
}

.peptide-section__body p { margin: 0 0 var(--space-3); }
.peptide-section__body p:last-child { margin-bottom: 0; }

.peptide-section__body ul {
  margin: 0;
  padding-left: var(--space-5);
  color: var(--color-text-muted);
}

.peptide-section__body ul li { margin-bottom: var(--space-2); }

.peptide-disclaimer {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-family: var(--font-body);
  line-height: 1.6;
  padding: var(--space-4);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

/* ---------- Dark-theme panel override ----------
   On pages with section-dark wrapping, chips sit on the dark panel but
   the modal always uses the surface palette so body copy stays readable. */
[data-theme="dark"] .peptide-modal-backdrop {
  background: rgba(0, 0, 0, 0.75);
}

/* ---------- Mobile ---------- */
@media (max-width: 600px) {
  .peptide-modal {
    max-height: 95vh;
    border-radius: var(--radius-lg);
  }
  .peptide-hero,
  .peptide-body,
  .peptide-modal__header,
  .peptide-modal__footer {
    padding-left: var(--space-5);
    padding-right: var(--space-5);
  }
  .peptide-hero__name {
    font-size: 1.75rem;
  }
}
