/* Shared appearance wins over legacy feature rules. Keep placement and width in features.
   Important declarations in this layer outrank unlayered legacy !important rules, so
   display stays unforced: features must still be able to hide a button. */
@layer sf-button-appearance {
/* One visual contract for action buttons. Feature classes may own placement,
   width and margins; the shared component owns appearance and interaction. */
:root {
  --sf-button-accent: #7159b8;
  --sf-button-accent-hover: #60489f;
  --sf-button-tint: #eee7f7;
  --sf-button-border: #b5a4d5;
}
.sf-button--danger { --sf-button-accent:#b42318; --sf-button-accent-hover:#912018; --sf-button-tint:#fff0ee; --sf-button-border:#d99590; }
/* Specificity keeps legacy feature selectors from restyling migrated buttons. */
:root :is(.sf-button, .primary-action, .creation-primary-action, .photo-review-secondary-action):is(.sf-button, .primary-action, .creation-primary-action, .photo-review-secondary-action) {
  box-sizing: border-box !important;
  display: inline-flex;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  min-height: 48px !important;
  padding: 12px 22px !important;
  border: 1px solid transparent !important;
  border-radius: 999px !important;
  background: var(--sf-button-accent) !important;
  color: #fff !important;
  font: 500 16px/1.4 var(--font, 'Silka', Arial, sans-serif) !important;
  text-align: center !important;
  text-decoration: none !important;
  overflow-wrap: anywhere !important;
  box-shadow: none !important;
  cursor: pointer !important;
  transform: none !important;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease !important;
}
:root :is(.sf-button--outlined, .photo-review-secondary-action):is(.sf-button, .photo-review-secondary-action) { background: transparent !important; color: var(--sf-button-accent) !important; border-color: var(--sf-button-border) !important; }
:root .sf-button.sf-button--ghost { background: transparent !important; color: var(--sf-button-accent) !important; }
:root :is(.sf-button--compact, .primary-action.compact):is(.sf-button, .primary-action) { min-height: 44px !important; padding: 10px 16px !important; font-size: 14px !important; }
:root .sf-button.sf-button--full { width: 100%; }
/* Matches the 12px corners of toolbar controls such as the reader's edit and menu buttons. */
:root .sf-button.sf-button--rounded { border-radius: 12px !important; }
/* Phone step bars share one row with other controls, so the pill steps down a size. */
@media (max-width: 430px) { :root .story-step-actions .sf-button:not(.sf-button--compact) { min-height: 44px !important; padding: 10px 14px !important; font-size: 14px !important; } }
/* Ghost actions align with surrounding text in every size, including phone step bars. */
:root .sf-button.sf-button--ghost.sf-button--ghost { padding-inline: 0 !important; }
:root :is(.sf-button, .primary-action, .creation-primary-action, .photo-review-secondary-action):is(.sf-button, .primary-action, .creation-primary-action, .photo-review-secondary-action) svg { width: 20px; height: 20px; flex: none; }
@media (hover: hover) {
  :root :is(.sf-button, .primary-action, .creation-primary-action, .photo-review-secondary-action):is(.sf-button, .primary-action, .creation-primary-action, .photo-review-secondary-action):hover:not(:disabled, [aria-disabled="true"]) { background: var(--sf-button-accent-hover) !important; color: #fff !important; text-decoration: none !important; box-shadow: none !important; transform: none !important; }
  :root :is(.sf-button--outlined, .photo-review-secondary-action):is(.sf-button, .photo-review-secondary-action):hover:not(:disabled, [aria-disabled="true"]) { background: var(--sf-button-tint) !important; color: var(--sf-button-accent) !important; }
  :root .sf-button.sf-button--ghost:hover:not(:disabled, [aria-disabled="true"]) { background: transparent !important; color: var(--sf-button-accent-hover) !important; }
}
:root :is(.sf-button, .primary-action, .creation-primary-action, .photo-review-secondary-action):is(.sf-button, .primary-action, .creation-primary-action, .photo-review-secondary-action):active:not(:disabled, [aria-disabled="true"]) { opacity: .8 !important; transform: none !important; }
:root :is(.sf-button, .primary-action, .creation-primary-action, .photo-review-secondary-action):is(.sf-button, .primary-action, .creation-primary-action, .photo-review-secondary-action):focus-visible { outline: 3px solid var(--sf-button-accent) !important; outline-offset: 3px !important; }
:root :is(.sf-button, .primary-action, .creation-primary-action, .photo-review-secondary-action):is(.sf-button, .primary-action, .creation-primary-action, .photo-review-secondary-action):is(:disabled, [aria-disabled="true"]):not([aria-busy="true"]) { opacity: .45 !important; cursor: not-allowed !important; }
:root :is(.sf-button, .primary-action, .creation-primary-action, .photo-review-secondary-action):is(.sf-button, .primary-action, .creation-primary-action, .photo-review-secondary-action)[aria-busy="true"] { cursor: progress !important; }
@media (prefers-reduced-motion: reduce) { :root :is(.sf-button, .primary-action, .creation-primary-action, .photo-review-secondary-action):is(.sf-button, .primary-action, .creation-primary-action, .photo-review-secondary-action) { transition: none !important; } }
@media (forced-colors: active) { :root :is(.sf-button, .primary-action, .creation-primary-action, .photo-review-secondary-action):is(.sf-button, .primary-action, .creation-primary-action, .photo-review-secondary-action) { border: 1px solid ButtonText !important; } }

/* Logical placement follows the document direction; icons are decorative. */
.sf-button-icon { display: inline-flex; align-items: center !important; justify-content: center !important; flex: 0 0 20px; width: 20px; height: 20px; }
:root .sf-button.sf-button--compact .sf-button-icon { flex-basis: 18px; width: 18px; height: 18px; }
:root .sf-button.sf-button--compact .sf-button-icon svg { width: 18px; height: 18px; }

}

/* CTA arrows grow from a chevron without changing the label or icon slot width. */
.sf-button .directional-arrow { display:inline-flex; align-items:center; justify-content:center; }
.sf-button .directional-arrow-shaft { opacity:0; transform:translateX(4px) scaleX(0); transform-origin:5px 12px; transition:transform 180ms ease, opacity 180ms ease; }
.sf-button .directional-arrow-head { transform:translateX(-4px); transition:transform 180ms ease; }
.sf-button:focus-visible:not(:disabled, [aria-disabled="true"], [aria-busy="true"]) .directional-arrow-shaft { opacity:1; transform:none; }
.sf-button:focus-visible:not(:disabled, [aria-disabled="true"], [aria-busy="true"]) .directional-arrow-head { transform:none; }
@media(hover:hover) {
  .sf-button:hover:not(:disabled, [aria-disabled="true"], [aria-busy="true"]) .directional-arrow-shaft { opacity:1; transform:none; }
  .sf-button:hover:not(:disabled, [aria-disabled="true"], [aria-busy="true"]) .directional-arrow-head { transform:none; }
}
@media(prefers-reduced-motion:reduce) {
  .sf-button .directional-arrow-shaft, .sf-button .directional-arrow-head { transition:none; }
}

/* Prominent marketing CTA, shared by React and static pages. */
@layer sf-button-appearance {
  :root .sf-button.sf-button--hero.sf-button--hero {
    --sf-button-hero-background: #ffd866;
    --sf-button-hero-hover: #ffe38d;
    --sf-button-hero-ink: #251c2f;
    min-height: 72px !important;
    padding: 18px 34px !important;
    gap: 32px !important;
    border-width: 1.5px !important;
    background: var(--sf-button-hero-background) !important;
    color: var(--sf-button-hero-ink) !important;
    font-size: 1.25rem !important;
    box-shadow: none !important;
    transition: background-color 150ms ease, color 150ms ease, transform 150ms ease !important;
  }
  @media (hover: hover) {
    :root .sf-button.sf-button--hero.sf-button--hero:hover:not(:disabled, [aria-disabled="true"], [aria-busy="true"]) {
      background: var(--sf-button-hero-hover) !important;
      color: var(--sf-button-hero-ink) !important;
      box-shadow: none !important;
      transform: translateY(-1px) !important;
    }
  }
  :root .sf-button.sf-button--hero.sf-button--hero[aria-busy="true"]:hover { background: var(--sf-button-hero-background) !important; color: var(--sf-button-hero-ink) !important; box-shadow: none !important; }
  /* Pages that place the CTA on a dark image set --sf-button-hero-focus (e.g. white). */
  :root .sf-button.sf-button--hero.sf-button--hero:focus-visible { outline: 3px solid var(--sf-button-hero-focus, var(--sf-button-accent)) !important; outline-offset: 5px !important; }
  :root .sf-button.sf-button--hero .sf-button-icon { flex-basis: 24px; width: 24px; height: 24px; }
  :root .sf-button.sf-button--hero .sf-button-icon svg { width: 24px; height: 24px; }
  @media (max-width: 680px) {
    :root .sf-button.sf-button--hero.sf-button--hero { min-height: 64px !important; padding: 16px 24px !important; font-size: 1.125rem !important; }
  }
  @media (prefers-reduced-motion: reduce) {
    :root .sf-button.sf-button--hero.sf-button--hero { transition: none !important; }
    :root .sf-button.sf-button--hero.sf-button--hero:hover:not(:disabled, [aria-disabled="true"]) { transform: none !important; }
  }
}
/* The prominent CTA keeps a complete arrow visible at rest. */
.sf-button--hero .directional-arrow-shaft { opacity: 1; transform: none; }
.sf-button--hero .directional-arrow-head { transform: none; }

/* Busy label and spinner, used by every button implementation. */
.button-progress {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  /* The empty spinner, placed first, would otherwise set the inline-flex
     baseline and push the label down; top alignment keeps idle and busy
     buttons the same height. */
  vertical-align: top;
}

.button-progress > .button-progress-spinner {
  display: inline-block;
  flex: 0 0 auto;
  width: 0.9em;
  height: 0.9em;
  box-sizing: border-box;
  border: 2px solid currentColor;
  border-inline-end-color: transparent;
  border-radius: 50%;
  color: inherit;
  animation: sf-button-spin 0.8s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  .button-progress > .button-progress-spinner { animation: none; }
}

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