/*
 * PureBariatric — Directions Guide styles.
 * Uses the existing app design tokens (styles.css :root custom properties).
 * Fallback literals mirror the light theme so the guide still renders correctly
 * if loaded standalone (e.g. the offline www/ fallback) without the app stylesheet.
 */

.pb-guide-overlay {
  position: fixed;
  inset: 0;
  z-index: 2147483000; /* above app modals/nav */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  /* No backdrop blur here: a blurred ancestor can stop iPhone Safari from
     drawing <video> frames (audio plays, picture stays blank). */
  background: rgba(20, 34, 22, 0.72);
  opacity: 0;
  transition: opacity var(--transition, 180ms cubic-bezier(0.16, 1, 0.3, 1));
}
.pb-guide-overlay.is-open { opacity: 1; }
.pb-guide-overlay[hidden] { display: none; }

.pb-guide-card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  max-height: calc(100dvh - 32px);
  max-height: calc(100vh - 32px);
  overflow: hidden auto;
  background: var(--color-surface, #ffffff);
  color: var(--color-text, #1a2b1c);
  border-radius: var(--radius-lg, 1rem);
  box-shadow: var(--shadow-lg, 0 12px 40px rgba(30, 50, 30, 0.14));
  -webkit-overflow-scrolling: touch;
}

.pb-guide-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 8px;
}
.pb-guide-title {
  margin: 0;
  font-family: var(--font-display, 'Cabinet Grotesk', 'Helvetica Neue', sans-serif);
  font-size: var(--text-lg, 1.25rem);
  font-weight: 700;
  color: var(--color-text, #1a2b1c);
}
.pb-guide-close {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  color: var(--color-text-muted, #5a6e5c);
  background: var(--color-surface-offset, #e8ede9);
  border: none;
  border-radius: var(--radius-full, 9999px);
  cursor: pointer;
  transition: background var(--transition, 180ms);
}
.pb-guide-close:hover { background: var(--color-divider, #d8dfd9); }
.pb-guide-close:focus-visible {
  outline: 2px solid var(--color-primary, #1e7a5c);
  outline-offset: 2px;
}

.pb-guide-media {
  position: relative;
  margin: 4px 16px 0;
  background: #000;
  border-radius: var(--radius-md, 0.625rem);
  overflow: hidden;
}
.pb-guide-media video {
  display: block;
  width: 100%;
  height: auto;
  max-height: 62dvh;
  max-height: 62vh;
  background: #000;
  /* Own compositing layer so the rounded, scrollable card doesn't hide it on iOS. */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

/* Graceful fallback when media cannot load */
.pb-guide-fallback {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px 16px;
  margin: 4px 16px 0;
  text-align: center;
  color: var(--color-text-muted, #5a6e5c);
  background: var(--color-surface-offset, #e8ede9);
  border: 1px dashed var(--color-border, #ccd4cc);
  border-radius: var(--radius-md, 0.625rem);
}
.pb-guide-fallback strong { color: var(--color-text, #1a2b1c); }

.pb-guide-disclaimer {
  margin: 12px 16px 0;
  padding: 10px 12px;
  font-size: var(--text-xs, 0.8125rem);
  line-height: 1.45;
  color: var(--color-text-muted, #5a6e5c);
  background: var(--color-primary-light, #e0f0ea);
  border-radius: var(--radius-sm, 0.375rem);
}

.pb-guide-transcript {
  margin: 12px 16px 0;
  font-size: var(--text-sm, 0.9375rem);
}
.pb-guide-transcript > summary {
  cursor: pointer;
  padding: 8px 0;
  font-weight: 600;
  color: var(--color-primary, #1e7a5c);
  list-style: none;
}
.pb-guide-transcript > summary::-webkit-details-marker { display: none; }
.pb-guide-transcript > summary::before { content: '▸ '; }
.pb-guide-transcript[open] > summary::before { content: '▾ '; }
.pb-guide-transcript-body {
  max-height: 240px;
  overflow: auto;
  padding: 4px 0 8px;
  color: var(--color-text, #1a2b1c);
  white-space: pre-wrap;
  line-height: 1.5;
}

.pb-guide-actions {
  display: flex;
  gap: 10px;
  padding: 16px;
  margin-top: auto;
}
.pb-guide-btn {
  flex: 1 1 auto;
  min-height: 44px; /* touch target */
  padding: 10px 16px;
  font-family: var(--font-body, 'General Sans', 'Inter', sans-serif);
  font-size: var(--text-base, 1rem);
  font-weight: 600;
  border-radius: var(--radius-md, 0.625rem);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--transition, 180ms), color var(--transition, 180ms);
}
.pb-guide-btn-primary {
  color: var(--color-text-inverse, #f5f7f5);
  background: var(--color-primary, #1e7a5c);
}
.pb-guide-btn-primary:hover { background: var(--color-primary-hover, #165e46); }
.pb-guide-btn-secondary {
  color: var(--color-primary, #1e7a5c);
  background: transparent;
  border-color: var(--color-border, #ccd4cc);
}
.pb-guide-btn-secondary:hover { background: var(--color-surface-offset, #e8ede9); }
.pb-guide-btn:focus-visible {
  outline: 2px solid var(--color-primary, #1e7a5c);
  outline-offset: 2px;
}

/* Replay entry button injected into Me / Learn */
.pb-guide-entry {
  width: 100%;
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

@media (prefers-reduced-motion: reduce) {
  .pb-guide-overlay { transition: none; }
}

/* Caption tracks (EN/FR/ES): a little smaller so they cover less of the app screenshots. */
.pb-guide-media video::cue {
  font-size: 0.72em;
  line-height: 1.3;
  background: rgba(0, 0, 0, 0.72);
}
