/**
 * Scoped stylesheet for Fan Platform Commerce.
 * Class prefix: .fan-commerce-
 * Provides high-contrast, responsive mobile/desktop layout,
 * accessible focus outlines, button loading states, and error banners.
 */

:root {
  --fc-brand: #1c5257;
  --fc-brand-strong: #103b3f;
  --fc-focus: #8b4f00;
  --fc-ink: #17243a;
  --fc-muted: #59677b;
  --fc-surface: #ffffff;
  --fc-paper: #f8f7f4;
  --fc-line: #dce2e7;
  --fc-accent: #caa56a;

  --fc-error-border: #f5c2c7;
  --fc-error-bg: #fdf2f2;
  --fc-error-text: #842029;

  --fc-warning-border: #fedfc8;
  --fc-warning-bg: #fef7e0;
  --fc-warning-text: #664d03;

  --fc-success-border: #a8dab5;
  --fc-success-bg: #e6f4ea;
  --fc-success-text: #0f5132;

  --fc-info-border: #b6d4fe;
  --fc-info-bg: #cfe2ff;
  --fc-info-text: #084298;
}

.fan-commerce {
  display: block;
  width: 100%;
  color: var(--fc-ink);
  font-family: inherit;
  line-height: 1.5;
  box-sizing: border-box;
}

.fan-commerce *,
.fan-commerce *::before,
.fan-commerce *::after {
  box-sizing: inherit;
}

/* Accessible focus outlines */
.fan-commerce a:focus-visible,
.fan-commerce button:focus-visible,
.fan-commerce input:focus-visible,
.fan-commerce select:focus-visible {
  outline: 3px solid var(--fc-focus);
  outline-offset: 3px;
  border-radius: 4px;
}

/* Breadcrumbs & Navigation */
.fan-commerce-breadcrumbs {
  margin: 0.5rem 0 1.25rem;
}

.fan-commerce-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--fc-brand-strong);
  font-weight: 700;
  text-decoration: none;
}

.fan-commerce-link:hover {
  text-decoration: underline;
  color: #0a3034;
}

/* Notice / Alert Banners */
.fan-commerce-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.2rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--fc-line);
  border-radius: 0.6rem;
  font-size: 0.95rem;
  line-height: 1.4;
}

.fan-commerce-notice--error {
  background: var(--fc-error-bg);
  border-color: var(--fc-error-border);
  color: var(--fc-error-text);
}

.fan-commerce-notice--warning {
  background: var(--fc-warning-bg);
  border-color: var(--fc-warning-border);
  color: var(--fc-warning-text);
}

.fan-commerce-notice--success {
  background: var(--fc-success-bg);
  border-color: var(--fc-success-border);
  color: var(--fc-success-text);
}

.fan-commerce-notice--info {
  background: var(--fc-info-bg);
  border-color: var(--fc-info-border);
  color: var(--fc-info-text);
}

.fan-commerce-notice__close {
  background: transparent;
  border: 0;
  font-size: 1.3rem;
  cursor: pointer;
  color: inherit;
  line-height: 1;
  padding: 0.2rem 0.4rem;
  align-self: flex-start;
}

.fan-commerce-notice__content {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.fan-commerce-notice__text {
  font-weight: 600;
}

.fan-commerce-notice__op-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  margin-top: 0.2rem;
}

.fan-commerce-notice__op-label {
  font-weight: 700;
}

.fan-commerce-notice__op-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: rgba(0, 0, 0, 0.07);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.82rem;
}

.fan-commerce-notice__recoverable {
  margin: 0.25rem 0 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--fc-brand-strong);
}

.fan-commerce-op-id {
  margin: 0.75rem 0;
  font-size: 0.88rem;
  color: var(--fc-muted);
}

.fan-commerce-op-id code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--fc-paper);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  border: 1px solid var(--fc-line);
}

.fan-commerce-alert {
  padding: 0.75rem 1rem;
  margin: 0.75rem 0;
  border-radius: 0.5rem;
  font-size: 0.9rem;
}

.fan-commerce-alert--info {
  background: var(--fc-info-bg);
  border: 1px solid var(--fc-info-border);
  color: var(--fc-info-text);
}

/* Creator Header */
.fan-commerce-header {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding-bottom: 1.5rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--fc-line);
}

.fan-commerce-avatar {
  display: block;
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--fc-line);
  background: #e8efed;
  flex-shrink: 0;
}

.fan-commerce-avatar--fallback {
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--fc-brand-strong);
}

.fan-commerce-header__info {
  min-width: 0;
}

.fan-commerce-eyebrow {
  margin: 0 0 0.2rem;
  color: var(--fc-brand);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.fan-commerce-title {
  margin: 0 0 0.3rem;
  font-size: clamp(1.5rem, 3.5vw, 2.2rem);
  font-weight: 800;
  line-height: 1.15;
}

.fan-commerce-title-link {
  color: inherit;
  text-decoration: none;
}

.fan-commerce-title-link:hover {
  text-decoration: underline;
}

.fan-commerce-bio {
  margin: 0;
  color: var(--fc-muted);
  font-size: 0.95rem;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

/* Grid Layout */
.fan-commerce-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

/* Cards */
.fan-commerce-card {
  padding: 1.5rem;
  border: 1px solid var(--fc-line);
  border-radius: 0.85rem;
  background: var(--fc-surface);
  box-shadow: 0 4px 16px rgba(23, 36, 58, 0.04);
}

.fan-commerce-card--featured {
  border-color: #bcd0cc;
  box-shadow: 0 6px 20px rgba(28, 82, 87, 0.08);
}

.fan-commerce-card--warning {
  border-color: var(--fc-warning-border);
  background: #fffdf9;
}

.fan-commerce-card--centered {
  max-width: 580px;
  margin: 2rem auto;
  text-align: center;
}

.fan-commerce-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.fan-commerce-card__title {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.fan-commerce-card__desc {
  margin: 0 0 1.25rem;
  color: var(--fc-muted);
  font-size: 0.95rem;
}

.fan-commerce-card__actions {
  margin-top: 1.5rem;
}

/* Pricing Row */
.fan-commerce-pricing-row {
  display: flex;
  align-items: baseline;
  gap: 2rem;
  margin: 1.25rem 0;
  padding: 1rem;
  background: var(--fc-paper);
  border-radius: 0.6rem;
}

.fan-commerce-price-block,
.fan-commerce-duration-block {
  display: flex;
  flex-direction: column;
}

.fan-commerce-price-label,
.fan-commerce-duration-label {
  font-size: 0.78rem;
  color: var(--fc-muted);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.fan-commerce-price-value {
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--fc-ink);
}

.fan-commerce-price-value--unknown {
  color: var(--fc-muted);
  font-weight: 600;
}

.fan-commerce-duration-value {
  font-size: 1.3rem;
  font-weight: 750;
  color: var(--fc-brand-strong);
}

.fan-commerce-duration-value--unknown {
  color: var(--fc-muted);
  font-weight: 600;
}

/* Distinct AI Funding Callout */
.fan-commerce-funding-callout {
  padding: 0.85rem 1rem;
  margin: 1.25rem 0;
  background: #f1f6f5;
  border-left: 4px solid var(--fc-brand);
  border-radius: 0 0.5rem 0.5rem 0;
}

.fan-commerce-funding-callout__text {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.45;
  color: #1a4245;
  font-weight: 500;
}

/* Status Pills & Badges */
.fan-commerce-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 750;
}

.fan-commerce-status-pill--active {
  background: var(--fc-success-bg);
  color: var(--fc-success-text);
}

.fan-commerce-status-pill--expired {
  background: var(--fc-error-bg);
  color: var(--fc-error-text);
}

.fan-commerce-status-pill--none {
  background: #eef2f5;
  color: var(--fc-muted);
}

.fan-commerce-indicator {
  font-size: 0.8rem;
}

.fan-commerce-balance-pill {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}

.fan-commerce-balance-label {
  font-size: 0.82rem;
  color: var(--fc-muted);
}

.fan-commerce-balance-amount {
  font-size: 1.15rem;
  color: var(--fc-ink);
}

.fan-commerce-balance-amount--unknown {
  color: var(--fc-muted);
  font-weight: 600;
}

.fan-commerce-badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 700;
}

.fan-commerce-badge--settled {
  background: var(--fc-success-bg);
  color: var(--fc-success-text);
}

.fan-commerce-badge--held {
  background: var(--fc-warning-bg);
  color: var(--fc-warning-text);
}

.fan-commerce-badge--refunded {
  background: var(--fc-error-bg);
  color: var(--fc-error-text);
}

/* Forms and Inputs */
.fan-commerce-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.fan-commerce-form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.fan-commerce-form-group--checkbox {
  flex-direction: row;
  align-items: flex-start;
  margin: 0.25rem 0;
}

.fan-commerce-label {
  font-weight: 700;
  font-size: 0.9rem;
}

.fan-commerce-input {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid #8794a3;
  border-radius: 0.5rem;
  font: inherit;
  color: var(--fc-ink);
  background: #fff;
}

.fan-commerce-checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
}

.fan-commerce-checkbox {
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--fc-brand);
  cursor: pointer;
  flex-shrink: 0;
}

.fan-commerce-hint {
  margin: 0.2rem 0 0;
  font-size: 0.82rem;
  color: var(--fc-muted);
}

.fan-commerce-section-subtitle {
  margin: 1.25rem 0 0.75rem;
  font-size: 1.05rem;
  font-weight: 750;
  border-top: 1px solid var(--fc-line);
  padding-top: 1rem;
}

.fan-commerce-unavailable-block {
  margin: 0.5rem 0;
}

.fan-commerce-price-row {
  margin: 0.5rem 0;
}

/* Buttons */
.fan-commerce-button {
  display: inline-flex;
  min-height: 2.85rem;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1.4rem;
  border: 1px solid var(--fc-brand);
  border-radius: 999px;
  background: var(--fc-brand);
  color: #fff;
  font: inherit;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.fan-commerce-button:hover:not(:disabled) {
  background: var(--fc-brand-strong);
}

.fan-commerce-button--quiet {
  background: transparent;
  color: var(--fc-brand-strong);
}

.fan-commerce-button--quiet:hover:not(:disabled) {
  background: #e8efed;
}

.fan-commerce-button--danger {
  background: #b3261e;
  border-color: #b3261e;
  color: #fff;
}

.fan-commerce-button--danger:hover:not(:disabled) {
  background: #8c1d18;
}

.fan-commerce-button:disabled,
.fan-commerce-button--disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.fan-commerce-button--loading {
  position: relative;
  color: transparent !important;
}

.fan-commerce-button--loading::after {
  content: "";
  position: absolute;
  width: 1.2rem;
  height: 1.2rem;
  top: calc(50% - 0.6rem);
  left: calc(50% - 0.6rem);
  border: 2px solid #fff;
  border-top-color: transparent;
  border-radius: 50%;
  animation: fan-commerce-spin 0.6s linear infinite;
}

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

/* Receipts Table */
.fan-commerce-table-wrapper {
  overflow-x: auto;
}

.fan-commerce-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  text-align: left;
}

.fan-commerce-th {
  padding: 0.75rem 0.6rem;
  border-bottom: 2px solid var(--fc-line);
  color: var(--fc-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  font-weight: 750;
}

.fan-commerce-td {
  padding: 0.85rem 0.6rem;
  border-bottom: 1px solid var(--fc-line);
}

.fan-commerce-td--mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
}

.fan-commerce-empty {
  color: var(--fc-muted);
  font-style: italic;
  margin: 1rem 0;
}

/* Responsive adjustments */
@media (max-width: 680px) {
  .fan-commerce-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  .fan-commerce-grid {
    grid-template-columns: 1fr;
  }
  .fan-commerce-pricing-row {
    flex-direction: column;
    gap: 0.75rem;
  }
}

.fan-commerce-terms { max-height: 18rem; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }

.fan-commerce-direct-pass-section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--fc-line);
}

