/* ── eDelivery Purchase Flow — Shared Stylesheet ── */
/* Mobile-first, dark theme, no external frameworks  */

:root {
  --bg:          #0f172a;
  --bg-card:     #1e293b;
  --bg-input:    #334155;
  --text:        #e2e8f0;
  --text-muted:  #94a3b8;
  --text-dim:    #64748b;
  --amber:       #f59e0b;
  --amber-hover: #d97706;
  --amber-dim:   #92400e;
  --green:       #22c55e;
  --red:         #ef4444;
  --red-dim:     #7f1d1d;
  --border:      #334155;
  --radius:      0.75rem;
  --radius-sm:   0.5rem;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ── */
.page {
  max-width: 440px;
  margin: 0 auto;
  padding: 0 1rem 2rem;
}

/* ── Header ── */
.header {
  text-align: center;
  padding: 1.25rem 0 0.75rem;
}

.header__venue {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--amber);
  letter-spacing: 0.02em;
}

/* ── Preview card ── */
.preview {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-card);
  aspect-ratio: 9 / 16;
  max-height: 360px;
  margin: 0 auto 1rem;
  width: 100%;
}

.preview img,
.preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.preview__overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.75rem;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.preview__code {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
}

.preview__time {
  font-size: 0.8125rem;
  color: rgba(255, 255, 255, 0.7);
}

/* ── Price hero ── */
.price-hero {
  text-align: center;
  padding: 0.75rem 0;
}

.price-hero__amount {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
}

.price-hero__subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* ── Tier cards ── */
.tiers {
  margin: 1rem 0;
}

.tiers__heading {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.tier-row {
  display: flex;
  gap: 0.5rem;
}

.tier-card {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.tier-card:hover {
  border-color: var(--amber);
}

.tier-card--active {
  border-color: var(--amber);
  background: var(--amber-dim);
}

.tier-card__count {
  font-size: 1.25rem;
  font-weight: 700;
}

.tier-card__price {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--amber);
}

.tier-card__unit {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ── Add-more section ── */
.add-more {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0;
}

.add-more__btn {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.625rem 0.5rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s;
  text-align: center;
}

.add-more__btn:hover {
  border-color: var(--amber);
}

/* ── Code entry ── */
.code-entry {
  display: none;
  margin: 0.5rem 0 1rem;
}

.code-entry--visible {
  display: flex;
  gap: 0.5rem;
}

.code-entry__input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.625rem 0.75rem;
  font-size: 1rem;
  color: var(--text);
  outline: none;
  font-family: inherit;
}

.code-entry__input::placeholder {
  color: var(--text-dim);
}

.code-entry__input:focus {
  border-color: var(--amber);
}

.code-entry__submit {
  background: var(--amber);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
}

.code-entry__submit:hover {
  background: var(--amber-hover);
}

/* ── Cart ── */
.cart {
  display: none;
  margin: 1rem 0;
}

.cart--visible {
  display: block;
}

.cart__heading {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.cart__item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.375rem;
}

.cart__thumb {
  width: 40px;
  height: 56px;
  border-radius: 4px;
  object-fit: cover;
  background: var(--bg-input);
  flex-shrink: 0;
}

.cart__meta {
  flex: 1;
  min-width: 0;
}

.cart__code {
  font-weight: 700;
  font-size: 0.875rem;
}

.cart__detail {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cart__remove {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
}

.cart__remove:hover {
  color: var(--red);
}

.cart__savings {
  text-align: center;
  padding: 0.5rem;
  font-size: 0.875rem;
  color: var(--green);
  font-weight: 600;
}

.cart__savings s {
  color: var(--text-dim);
  font-weight: 400;
}

/* ── Buy button ── */
.buy-btn {
  display: block;
  width: 100%;
  background: var(--amber);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  padding: 1rem;
  font-size: 1.125rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 0.75rem;
}

.buy-btn:hover {
  background: var(--amber-hover);
}

.buy-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Token entry ── */
.token-section {
  text-align: center;
  margin-top: 1rem;
}

.token-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.8125rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  font-family: inherit;
}

.token-toggle:hover {
  color: var(--text);
}

.token-form {
  display: none;
  margin-top: 0.75rem;
}

.token-form--visible {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.token-form__input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: var(--text);
  outline: none;
  width: 160px;
  font-family: inherit;
}

.token-form__input:focus {
  border-color: var(--amber);
}

.token-form__submit {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}

.token-form__submit:hover {
  border-color: var(--amber);
}

/* ── Turnstile widget ── */
.turnstile-wrap {
  display: flex;
  justify-content: center;
  margin: 0.75rem 0 0;
}

/* ── Error / status banners ── */
.banner {
  border-radius: var(--radius-sm);
  padding: 0.625rem 0.75rem;
  font-size: 0.8125rem;
  margin-bottom: 0.75rem;
  display: none;
}

.banner--visible { display: block; }

.banner--error {
  background: var(--red-dim);
  color: #fca5a5;
  border: 1px solid #991b1b;
}

.banner--info {
  background: #1e3a5f;
  color: #93c5fd;
  border: 1px solid #1e40af;
}

/* ── Skeleton / loading ── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-input) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton--preview {
  aspect-ratio: 9 / 16;
  max-height: 360px;
  width: 100%;
  margin-bottom: 1rem;
}

.skeleton--price {
  height: 3.5rem;
  width: 120px;
  margin: 0.75rem auto;
}

/* ── Download page ── */
.dl-title {
  text-align: center;
  margin-bottom: 1.25rem;
}

.dl-title h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.dl-title p {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.125rem;
}

.download-all {
  margin-bottom: 1.25rem;
}

.download-all__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  background: var(--amber);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
}

.download-all__btn:hover {
  background: var(--amber-hover);
}

.download-all__btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.download-all__btn svg {
  flex-shrink: 0;
}

.dl-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
}

.dl-card__info {
  flex: 1;
  min-width: 0;
}

.dl-card__title {
  font-weight: 700;
  font-size: 0.9375rem;
  color: var(--text);
}

.dl-card__meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.125rem;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.dl-card__actions {
  flex-shrink: 0;
}

.dl-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background: var(--amber);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.875rem;
  font-size: 0.8125rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
  font-family: inherit;
}

.dl-btn:hover {
  background: var(--amber-hover);
  text-decoration: none;
}

.dl-btn svg {
  flex-shrink: 0;
}

.format-badge {
  display: inline-block;
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.0625rem 0.375rem;
  border-radius: 9999px;
}

.format-badge--av1 {
  background: rgba(245, 158, 11, 0.15);
  color: var(--amber);
}

.format-badge--h265 {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
}

.dl-notice {
  font-size: 0.8125rem;
  color: var(--text-dim);
  text-align: center;
  margin-top: 1.5rem;
  line-height: 1.5;
}

.dl-notice + .dl-notice {
  margin-top: 0.75rem;
}

.dl-notice a {
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.dl-notice a:hover {
  color: var(--text);
}

/* ── State screens (loading, error, expired, preparing) ── */
.state {
  text-align: center;
  padding: 4rem 1rem 2rem;
}

.state h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.state p {
  font-size: 0.9375rem;
  color: var(--text-muted);
  max-width: 280px;
  margin: 0 auto;
  line-height: 1.5;
}

.spinner {
  width: 2.5rem;
  height: 2.5rem;
  border: 3px solid var(--bg-input);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 1.5rem auto 0;
}

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

/* ── Utilities ── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

.hidden { display: none !important; }

/* ── Responsive ── */
@media (min-width: 480px) {
  .page { padding: 0 1.5rem 2rem; }
  .preview { max-height: 420px; }
  .dl-title h1 { font-size: 1.75rem; }
}
