/* ============================================
   YOLI STUDIO — OFFERS
   Cards fed by Yoli Studio's audience Offers feed. Self-contained `yso__*`
   namespace on top of the nt2 type system (nutritional-testing-v2.css).
   Colors come from the feed (buttonStyle / accentStyle) as CSS variables:
     --yso-btn-color / --yso-btn-text   (set on the root)
     --yso-accent / --yso-accent-text   (set on the root)
   ============================================ */

.yso__section {
  padding-top: var(--yso-pt, var(--space-xl));
  padding-bottom: var(--yso-pb, var(--space-3xl));
}

/* Reserve space so the page does not jump while the feed loads. */
.yso__stage { min-height: 240px; }
.yso[data-yso-state="ready"] .yso__stage,
.yso[data-yso-state="empty"] .yso__stage,
.yso[data-yso-state="error"] .yso__stage { min-height: 0; }

/* ---------- Header ---------- */
.yso__header { margin-bottom: var(--space-2xl); }
.yso__eyebrow {
  margin: 0 0 var(--space-sm);
  font-family: var(--font-body);
  font-size: var(--font-size-sm);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--clr-accent-1, #F86F38);
}
.yso__title { margin: 0; }
.yso__lede { margin: var(--space-md) auto 0; }
@media (min-width: 1024px) { .yso__header { margin-bottom: var(--space-3xl); } }

/* ---------- Grid ---------- */
.yso__grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-lg);
}
.yso__grid[hidden] { display: none; }
@media (min-width: 768px) {
  .yso__grid { grid-template-columns: repeat(2, 1fr); gap: var(--space-xl); }
}

/* ---------- Loading skeleton ---------- */
.yso__skeleton {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-lg);
}
.yso__skeleton[hidden] { display: none; }
.yso__skeleton-card {
  min-height: 220px;
  border-radius: var(--radius-lg);
  background: var(--clr-bg-card-primary);
  border: 1px solid var(--nt2-hairline-soft);
}
@media (min-width: 768px) {
  .yso__skeleton { grid-template-columns: repeat(2, 1fr); gap: var(--space-xl); }
}
@media (prefers-reduced-motion: no-preference) {
  .yso__skeleton-card { animation: yso-pulse 1.6s ease-in-out infinite; }
  @keyframes yso-pulse { 50% { opacity: 0.55; } }
}

/* ---------- Card ---------- */
.yso__card {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--clr-bg-card-primary);
  border: 1px solid var(--nt2-hairline-soft);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color 0.25s ease, transform 0.25s ease;
}
@media (min-width: 768px) {
  .yso__card { flex-direction: row; align-items: stretch; }
}
@media (min-width: 1024px) { .yso__card { border-radius: var(--radius-xl); } }
@media (prefers-reduced-motion: no-preference) {
  .yso__card:hover { border-color: var(--nt2-hairline); transform: translateY(-3px); }
}

.yso__media {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  order: -1;
}
@media (min-width: 768px) {
  .yso__media { order: 0; flex: 0 0 42%; aspect-ratio: auto; align-self: stretch; }
  .yso__media::before { content: ""; display: block; padding-top: 100%; }
  .yso__media .yso__image { position: absolute; inset: 0; }
}
.yso__image { width: 100%; height: 100%; object-fit: cover; display: block; }

.yso__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  flex: 1 1 auto;
  min-width: 0;
  padding: var(--space-lg);
}
@media (min-width: 1024px) { .yso__body { padding: var(--space-xl); } }

/* Tag pill — look comes from the set's accentStyle */
.yso__tag {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  font-family: var(--font-body);
  font-size: var(--font-size-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: var(--radius-3xl);
  padding: var(--space-xs) var(--space-md);
  border: 1.5px solid var(--yso-accent, var(--clr-secondary));
  color: var(--yso-accent-text, var(--clr-text-primary));
  background: var(--yso-accent, var(--clr-secondary));
}
.yso[data-accent-style="outline"] .yso__tag { background: transparent; }

.yso__name { margin: 0; }

/* Rich text from the feed (p br ul ol li strong em u a span) */
.yso__rich {
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  line-height: 1.6;
  color: var(--clr-text-secondary);
  overflow-wrap: anywhere;
}
.yso__rich > :first-child { margin-top: 0; }
.yso__rich > :last-child { margin-bottom: 0; }
.yso__rich p { margin: 0; }
.yso__rich p + p,
.yso__rich ul + p,
.yso__rich ol + p,
.yso__rich p + ul,
.yso__rich p + ol { margin-top: var(--space-sm); }
.yso__rich ul,
.yso__rich ol { margin: 0; padding-left: 1.25em; }
.yso__rich ul { list-style: disc; }
.yso__rich ol { list-style: decimal; }
.yso__rich li + li { margin-top: var(--space-xs); }
.yso__rich strong { font-weight: 600; color: var(--clr-text-primary); }
.yso__rich u { text-decoration: underline; text-underline-offset: 3px; }
.yso__rich a {
  color: var(--clr-text-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.yso__rich a:hover { text-decoration-thickness: 2px; }
.yso__details { flex: 0 1 auto; }
.yso__bodycopy { font-size: var(--font-size-sm); }

/* ---------- Code chip + button: ONE row, wrapping only when too narrow ---------- */
.yso__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
  margin-top: auto;
  padding-top: var(--space-sm);
}
.yso__code-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: var(--space-xs);
}
.yso__code-label {
  font-family: var(--font-body);
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  white-space: nowrap;
  color: color-mix(in srgb, var(--clr-text-primary) 55%, transparent);
}
.yso__code {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  min-height: 44px;
  font-family: var(--font-body);
  font-size: var(--font-size-xs);
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--clr-text-primary);
  background: color-mix(in srgb, var(--yso-accent, var(--clr-secondary)) 7%, transparent);
  border: 1.5px dashed var(--yso-accent, var(--clr-secondary));
  border-radius: var(--radius-base);
  padding: var(--space-xs) var(--space-sm);
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.yso__code:hover { background: color-mix(in srgb, var(--yso-accent, var(--clr-secondary)) 14%, transparent); }
.yso__code:focus-visible { outline: 2px solid var(--clr-text-primary); outline-offset: 3px; }
.yso__code-icons { display: inline-flex; position: relative; width: 15px; height: 15px; }
.yso__code-svg { flex-shrink: 0; }
.yso__code-svg--check {
  position: absolute;
  inset: 0;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.yso__code.is-copied {
  color: var(--clr-white);
  background: var(--clr-text-primary);
  border-style: solid;
  border-color: var(--clr-text-primary);
}
.yso__code.is-copied .yso__code-svg--copy { opacity: 0; }
.yso__code.is-copied .yso__code-svg--check { opacity: 1; transform: scale(1); }

.yso__code--auto {
  cursor: default;
  min-height: 44px;
  color: var(--clr-primary);
  background: color-mix(in srgb, var(--clr-primary) 6%, transparent);
  border: 1px solid var(--nt2-hairline-soft);
  border-radius: var(--radius-3xl);
  letter-spacing: 0.02em;
  text-transform: none;
  font-weight: 500;
  padding: var(--space-xs) var(--space-md);
}
.yso__code--auto:hover { background: color-mix(in srgb, var(--clr-primary) 6%, transparent); }
.yso__code--auto .yso__code-svg { color: var(--yso-accent, var(--clr-secondary)); }

/* ---------- Buttons — look comes from the set's buttonStyle ---------- */
.yso__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin: 0;
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-body);
  font-size: var(--font-size-xs);
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  border-radius: 999px;
  border: 1.5px solid var(--yso-btn-color, var(--clr-btn-primary));
  color: var(--yso-btn-text, var(--clr-btn-primary));
  background: transparent;
  cursor: pointer;
  transition: opacity 0.2s ease, background-color 0.2s ease;
}
.yso[data-btn-style="filled"] .yso__btn { background: var(--yso-btn-color, var(--clr-btn-primary)); }
.yso__btn:hover { opacity: 0.85; }
.yso[data-btn-style="outline"] .yso__btn:hover {
  opacity: 1;
  background: color-mix(in srgb, var(--yso-btn-color, var(--clr-btn-primary)) 8%, transparent);
}
.yso__btn:focus-visible { outline: 2px solid var(--clr-text-primary); outline-offset: 3px; }
@media (max-width: 767px) {
  .yso__actions .yso__btn { flex: 1 1 auto; }
}

/* ---------- Terms trigger (card bottom; opens the shared terms dialog, card never grows) ---------- */
.yso__terms-toggle {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: var(--space-xs);
  min-height: 32px;
  margin: var(--space-sm) 0 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: var(--font-size-xs);
  line-height: 1.5;
  font-weight: 600;
  text-align: left;
  color: var(--clr-text-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.yso__terms-toggle::after {
  content: "";
  flex-shrink: 0;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.18s ease;
}
@media (prefers-reduced-motion: no-preference) {
  .yso__terms-toggle:hover::after { transform: translateX(2px) rotate(-45deg); }
}
.yso__terms-toggle:focus-visible { outline: 2px solid var(--clr-text-primary); outline-offset: 3px; }

/* ---------- Terms dialog (centered modal ≥768px, bottom sheet below) ---------- */
html.yso-scroll-lock { overflow: hidden; }
.yso__terms-dialog {
  margin: auto;
  padding: 0;
  width: min(760px, calc(100% - 48px));
  max-width: none;
  max-height: 85dvh;
  overflow: hidden;
  border: 1px solid var(--clr-border-light);
  border-radius: var(--radius-xl);
  background: var(--clr-bg-card-primary);
  color: var(--clr-text-primary);
  font-family: var(--font-body);
}
.yso__terms-dialog[open] { display: flex; }
.yso__terms-dialog::backdrop { background: rgb(0 0 0 / 45%); }
.yso__terms-panel {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
}
.yso__terms-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-md);
  flex: 0 0 auto;
  padding: var(--space-lg) var(--space-lg) var(--space-md) var(--space-xl);
  border-bottom: 1px solid var(--nt2-hairline-soft);
  background: var(--clr-bg-card-primary);
}
.yso__terms-heading { min-width: 0; }
.yso__terms-eyebrow {
  margin: 0 0 var(--space-xs);
  font-size: var(--font-size-xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--clr-text-secondary);
}
.yso__terms-title { margin: 0; font-family: var(--font-primary); }
.yso__terms-sub { margin: var(--space-xs) 0 0; font-size: var(--font-size-sm); color: var(--clr-text-secondary); }
.yso__terms-eyebrow[hidden], .yso__terms-sub[hidden] { display: none; }
.yso__terms-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  margin: -6px -6px 0 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--clr-text-primary);
  cursor: pointer;
  transition: background-color 0.2s ease;
}
.yso__terms-close:hover { background: color-mix(in srgb, var(--clr-text-primary) 7%, transparent); }
.yso__terms-close:focus-visible { outline: 2px solid var(--clr-text-primary); outline-offset: 2px; }
.yso__terms-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-lg) var(--space-xl) var(--space-xl);
}
.yso__terms-scroll:focus-visible { outline: 2px solid var(--clr-text-primary); outline-offset: -4px; }

@media (max-width: 767px) {
  .yso__terms-dialog {
    margin: auto 0 0;
    width: 100%;
    max-height: 92dvh;
    border-bottom: 0;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  }
  .yso__terms-head { padding: var(--space-md) var(--space-sm) var(--space-sm) var(--space-lg); }
  .yso__terms-scroll { padding: var(--space-md) var(--space-lg) calc(var(--space-xl) + env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 767px) and (prefers-reduced-motion: no-preference) {
  .yso__terms-dialog[open] { animation: yso-sheet-up 0.28s cubic-bezier(0.2, 0.8, 0.2, 1); }
  .yso__terms-dialog[open]::backdrop { animation: yso-fade-in 0.28s ease; }
  @keyframes yso-sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
  @keyframes yso-fade-in { from { opacity: 0; } to { opacity: 1; } }
}

/* ---------- Legal typography (terms dialog body) ---------- */
.yso__rich.yso__legal,
.yso__rich.yso__legal p,
.yso__rich.yso__legal li {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  color: var(--clr-text-secondary);
}
.yso__rich.yso__legal > * { max-width: 68ch; }
.yso__rich.yso__legal p { margin: 0; }
.yso__rich.yso__legal > * + * { margin-top: var(--space-sm); }
.yso__rich.yso__legal ul,
.yso__rich.yso__legal ol { margin: var(--space-xs) 0 var(--space-sm); padding-left: 1.25em; }
.yso__rich.yso__legal ul { list-style: disc; }
.yso__rich.yso__legal li + li { margin-top: 4px; }
.yso__rich.yso__legal a { text-decoration: underline; text-underline-offset: 3px; overflow-wrap: anywhere; }
.yso__rich.yso__legal .yso__legal-sub {
  margin-top: var(--space-lg);
  margin-bottom: var(--space-xs);
  font-weight: 600;
  color: var(--clr-text-primary);
}
.yso__rich.yso__legal .yso__legal-sub + * { margin-top: 0; }
.yso__rich.yso__legal .yso__legal-label {
  margin-top: var(--space-xl);
  padding-top: var(--space-md);
  border-top: 1px solid var(--nt2-hairline-soft);
  font-size: var(--font-size-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--yso-accent, var(--clr-secondary));
}
.yso__rich.yso__legal .yso__legal-label strong,
.yso__rich.yso__legal .yso__legal-label u { color: inherit; font-weight: 600; text-decoration: none; }
.yso__rich.yso__legal .yso__legal-label + .yso__legal-sub { margin-top: var(--space-sm); }
.yso__rich.yso__legal > :first-child { margin-top: 0; }
@media (max-width: 767px) {
  .yso__rich.yso__legal,
  .yso__rich.yso__legal p,
  .yso__rich.yso__legal li { font-size: 14px; }
}

/* ---------- Empty / fallback CTA ---------- */
.yso__empty { display: flex; justify-content: center; margin-top: var(--space-lg); }
.yso__empty[hidden] { display: none; }
.yso__empty .yso__btn { padding: var(--space-sm) var(--space-xl); font-size: var(--font-size-sm); }

/* ---------- Disclaimer ---------- */
.yso__disclaimer {
  margin-top: var(--space-xl);
  font-family: var(--font-body);
  font-size: var(--font-size-xs);
  line-height: 1.5;
  color: var(--clr-text-muted, #6c6c6c);
}
.yso__disclaimer[hidden] { display: none; }
.yso__disclaimer-title { margin: 0 0 var(--space-xs); font: inherit; font-size: var(--font-size-sm); font-weight: 600; color: var(--clr-text-primary); }
.yso__disclaimer .yso__rich { font-size: inherit; line-height: inherit; color: inherit; }
/* Disclaimer body is sub-text under its title: keep it smaller than the title even when global p/li rules set a size. */
.yso__disclaimer .yso__rich,
.yso__disclaimer .yso__rich p,
.yso__disclaimer .yso__rich li,
.yso__disclaimer .yso__rich span { font-size: var(--font-size-xs); line-height: 1.5; }
.yso__disclaimer .yso__rich a { color: inherit; }

/* ---------- Copy-code dialog ---------- */
.yso__dialog {
  margin: auto;
  width: min(440px, calc(100% - 32px));
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  padding: var(--space-xl);
  border: 1px solid var(--clr-border-light);
  border-radius: var(--radius-lg);
  background: var(--clr-bg-card-primary);
  color: var(--clr-text-primary);
  font-family: var(--font-body);
}
.yso__dialog::backdrop { background: rgb(0 0 0 / 45%); }
.yso__dialog h2 {
  font-family: var(--font-primary);
  font-size: var(--font-size-2xl);
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0 0 var(--space-sm);
}
.yso__dialog-message {
  font-size: var(--font-size-sm);
  line-height: 1.6;
  color: var(--clr-text-secondary);
  margin: 0 0 var(--space-lg);
  user-select: text;
}
.yso__dialog-actions { display: flex; flex-wrap: wrap; gap: var(--space-sm); }
.yso__dialog .yso__btn { text-transform: none; }
.yso__dialog .yso__continue {
  background: var(--clr-text-primary);
  border-color: var(--clr-text-primary);
  color: var(--clr-white);
}
.yso__dialog .yso__dismiss { color: var(--clr-text-secondary); border-color: var(--clr-border-dark); background: transparent; }

/* ---------- Editor-only status ---------- */
.yso__editor-note {
  margin: var(--space-lg) 0 0;
  padding: var(--space-sm) var(--space-md);
  border: 1px dashed var(--clr-border-dark, #bbb);
  border-radius: var(--radius-base);
  font-family: var(--font-body);
  font-size: var(--font-size-xs);
  color: var(--clr-text-secondary);
}

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