/**
 * Dollarback — Unified Fintech Design System & WCAG 2.1 AA Stylesheet
 *
 * Palette & Contrast Ratios (WCAG 2.1 AA >= 4.5:1):
 * - Emerald Primary (#047857) on White (#ffffff): 5.48:1 (PASS AA)
 * - Emerald Dark (#065f46) on White (#ffffff): 7.68:1 (PASS AAA)
 * - Rich Slate (#111827) on White (#ffffff): 17.74:1 (PASS AAA)
 * - Slate Muted (#374151) on White (#ffffff): 10.31:1 / on #f9fafb: 9.91:1 (PASS AAA)
 * - Preview Badge (#78350f on #fef3c7): 8.43:1 (PASS AAA)
 * - Live Badge (#065f46 on #d1fae5): 6.91:1 (PASS AA)
 */

:root {
  --primary: #047857;
  --primary-hover: #065f46;
  --primary-light: #ecfdf5;
  --primary-border: #a7f3d0;
  --slate: #111827;
  --slate-hover: #1f2937;
  --text: #111827;
  --gray: #374151;
  --muted: #4b5563;
  --light: #f9fafb;
  --surface: #ffffff;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --danger: #b91c1c;
  --danger-hover: #991b1b;
  --focus-ring: #047857;
  --radius-lg: 12px;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow-xs: 0 1px 2px rgba(17, 24, 39, 0.04);
  --shadow-sm: 0 2px 8px rgba(17, 24, 39, 0.05);
  --shadow-md: 0 8px 24px rgba(17, 24, 39, 0.08);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  padding: 0;
  color: var(--text);
  background-color: var(--light);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Accessibility: Skip to Main Content Link */
.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  background: var(--slate);
  color: #ffffff;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  text-decoration: none;
  z-index: 10000;
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: 12px;
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

/* Accessibility: Keyboard Focus Visible Outlines */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

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

/* Unified Sticky Header & Brand Wordmark */
.site-header {
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 900;
}

.header-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--primary);
}

.brand-logo:hover .brand-wordmark {
  color: var(--primary-hover);
}

.brand-coin {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: block;
}

.brand-wordmark {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.6px;
  line-height: 1;
}

.brand-tld {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--primary-hover);
  background: var(--primary-light);
  border: 1px solid var(--primary-border);
  padding: 2px 6px;
  border-radius: 6px;
  letter-spacing: 0;
  margin-left: 2px;
  vertical-align: middle;
}

.site-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.nav-link {
  color: var(--gray);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.94rem;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  transition: background-color 0.15s, color 0.15s;
}

.nav-link:hover {
  background: var(--light);
  color: var(--slate);
}

.nav-link[aria-current="page"] {
  color: var(--primary-hover);
  background: var(--primary-light);
  font-weight: 700;
}

.nav-user-chip {
  font-size: 0.85rem;
  color: var(--gray);
  font-weight: 600;
  padding: 4px 10px;
  background: var(--light);
  border: 1px solid var(--border);
  border-radius: 999px;
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.balance-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #d1fae5;
  color: #065f46;
  border: 1px solid var(--primary-border);
  padding: 6px 13px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.88rem;
  text-decoration: none;
  transition: background-color 0.15s, transform 0.1s;
}

.balance-badge:hover {
  background: #a7f3d0;
}

/* Cohesive Emerald & Slate Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: var(--shadow-xs);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-slate {
  background: var(--slate);
  color: #ffffff;
}

.btn-slate:hover:not(:disabled) {
  background: var(--slate-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--slate);
  border: 1px solid var(--border-strong);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--light);
  border-color: var(--slate);
}

.btn-outline-danger {
  background: transparent;
  color: var(--danger);
  border-color: #fecaca;
  padding: 6px 12px;
  font-size: 0.86rem;
}

.btn-outline-danger:hover {
  background: #fef2f2;
  color: var(--danger-hover);
}

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

/* Main Content Containers */
main {
  flex: 1;
  width: 100%;
}

.page-container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 24px 56px;
}

.page-container-narrow {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 24px 56px;
}

/* Shared Retailer Cards (Used on stores.html and index.html) */
.store-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.store-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-xs);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.store-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.brand-favicon-box {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: #ffffff;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.brand-favicon-box img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  display: block;
}

.badge-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
}

.badge {
  background: #fef3c7;
  color: #78350f;
  font-size: 0.74rem;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 700;
  border: 1px solid #fde68a;
}

.badge.live {
  background: #d1fae5;
  color: #065f46;
  border-color: #a7f3d0;
}

.category-tag {
  background: var(--light);
  color: var(--gray);
  font-size: 0.74rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.store-name {
  font-size: 1.2rem;
  font-weight: 800;
  margin: 0 0 6px 0;
  color: var(--slate);
  letter-spacing: -0.2px;
}

.store-desc {
  font-size: 0.9rem;
  color: var(--gray);
  margin: 0 0 16px 0;
  line-height: 1.45;
}

.card-footer-area {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: auto;
}

.rate-status-line {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--gray);
  margin-bottom: 12px;
}

.rate-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
}

.shop-btn {
  background: var(--primary);
  color: #ffffff;
  border: none;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 700;
  width: 100%;
  transition: background-color 0.15s;
  font-size: 0.94rem;
}

.shop-btn:hover:not(:disabled) {
  background: var(--primary-hover);
}

.shop-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

/* Toast Notification System */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9500;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
  width: calc(100% - 48px);
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: var(--slate);
  color: #ffffff;
  padding: 14px 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  border-left: 5px solid var(--primary);
  font-size: 0.92rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  animation: toastSlideIn 0.2s ease-out;
}

.toast.toast-success {
  border-left-color: #10b981;
}

.toast.toast-error {
  border-left-color: #ef4444;
}

.toast-close {
  background: transparent;
  border: none;
  color: #d1d5db;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.toast-close:hover {
  color: #ffffff;
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Unified Footer */
.site-footer {
  background: var(--slate);
  color: #e5e7eb;
  padding: 44px 24px;
  margin-top: auto;
  border-top: 1px solid #1f2937;
  font-size: 0.9rem;
}

.footer-inner {
  max-width: 1080px;
  margin: 0 auto;
  text-align: center;
}

.footer-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px 22px;
  margin-bottom: 18px;
}

.footer-links a {
  color: #ffffff;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 600;
}

.footer-links a:hover {
  color: #a7f3d0;
}

.footer-disclosure {
  max-width: 820px;
  margin: 0 auto 14px;
  color: #d1d5db;
  font-size: 0.84rem;
  line-height: 1.55;
}

.footer-copy {
  color: #9ca3af;
  font-size: 0.82rem;
  margin: 0;
}

/* Responsive Adjustments */
@media (max-width: 680px) {
  .header-inner {
    padding: 12px 16px;
  }
  .site-nav {
    width: 100%;
    justify-content: flex-start;
    gap: 6px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
  }
  .nav-user-chip {
    display: none;
  }
  .page-container,
  .page-container-narrow {
    padding: 20px 16px 40px;
  }
}
