/**
 * 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;
  overflow-x: hidden;
  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;
}

/* Section 10.5 Fix: Above-the-Fold High-Contrast FTC Disclosure Bar */
.ftc-top-bar {
  background: #ecfdf5;
  border-bottom: 1px solid var(--primary-border);
  color: #065f46;
  font-size: 0.85rem; /* 13.6px (>= 10.2pt, exceeds 8pt requirement) */
  line-height: 1.45;
  padding: 9px 20px;
  text-align: center;
}

.ftc-top-bar-inner {
  max-width: 1120px;
  margin: 0 auto;
}

.ftc-top-bar strong {
  font-weight: 800;
  color: #065f46;
}

.ftc-top-bar a {
  color: #065f46;
  font-weight: 700;
  text-decoration: underline;
  margin-left: 6px;
}

.ftc-top-bar a:hover {
  color: var(--slate);
}

/* Rakuten-Style Inline Advertising Disclosure Trigger & Modal */
.disclosure-trigger-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  padding: 2px 4px;
  margin-left: 4px;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
  cursor: pointer;
  border-radius: 4px;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.disclosure-trigger-link:hover {
  color: var(--primary-hover);
  background-color: var(--primary-light);
  text-decoration-style: solid;
}

.disclosure-trigger-icon {
  font-style: normal;
  font-weight: 700;
  font-size: 0.88rem;
  line-height: 1;
}

.header-inner,
.nav-container {
  max-width: 1200px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding: 14px 24px;
  box-sizing: border-box;
  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: 36px;
  height: 36px;
  flex-shrink: 0;
  display: block;
}

.brand-wordmark {
  display: inline-flex;
  align-items: center;
  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: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px 56px;
  box-sizing: border-box;
}

.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;
  height: 100%;
  cursor: pointer;
  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(--primary);
}

.store-card:hover .store-name {
  color: var(--primary-hover);
}

.store-card-body {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.card-top,
.store-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  min-height: 54px;
}

.brand-favicon-box {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  color: #0f172a;
  font-family: "Inter", system-ui, sans-serif;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  box-sizing: border-box;
}

.brand-favicon-box.has-cj-logo {
  width: 136px;
  height: 46px;
  border-radius: 10px;
  padding: 4px 10px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
}

.brand-favicon-box img {
  max-width: 120px;
  max-height: 36px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.brand-favicon-monogram {
  font-family: "Inter", system-ui, sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1;
  user-select: none;
}

.badge-group {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.cashback-rate-badge {
  white-space: nowrap;
  font-size: 0.8rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
  line-height: 1.2;
}

.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);
  white-space: nowrap;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  line-height: 1.2;
}

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

.store-desc {
  flex-grow: 1;
  line-height: 1.5;
  color: #475569;
  font-size: 0.92rem;
  margin: 0 0 16px 0;
}

.card-footer-area {
  margin-top: auto;
}

.rate-status-line,
.cashback-status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.82rem;
  font-weight: 600;
  color: #334155;
  padding: 10px 0 12px 0;
  border-top: 1px solid #f1f5f9;
  margin-bottom: 0;
}

.rate-status-line.paused,
.cashback-status-line.paused {
  color: #92400e;
  font-weight: 700;
}

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

.rate-status-dot.paused {
  background: #d97706;
}

/* Proactive Amber Warning Bar when Tracking is Opted Out */
.tracking-paused-bar {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-left: 5px solid #d97706;
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  color: #78350f;
  font-size: 0.92rem;
  line-height: 1.5;
}

.tracking-paused-bar-text {
  flex: 1;
  min-width: 240px;
}

.tracking-paused-bar .btn-enable-tracking {
  background: var(--primary);
  color: #ffffff;
  border: none;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s;
}

.tracking-paused-bar .btn-enable-tracking:hover {
  background: var(--primary-hover);
}

/* Pre-Redirect Opt-Out Confirmation Modal */
.optout-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.62);
  backdrop-filter: blur(2px);
  z-index: 9800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: modalFadeIn 0.15s ease-out;
}

.optout-modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: 0 20px 38px -6px rgba(17, 24, 39, 0.28);
  max-width: 500px;
  width: 100%;
  overflow: hidden;
}

.optout-modal-header {
  background: #fffbeb;
  border-bottom: 1px solid #fde68a;
  padding: 18px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.optout-modal-header.emerald-header {
  background: var(--primary-light);
  border-bottom: 1px solid var(--primary-border);
}

.optout-modal-title {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 800;
  color: #78350f;
  display: flex;
  align-items: center;
  gap: 8px;
}

.optout-modal-title.emerald-title {
  color: var(--primary-hover);
}

.optout-modal-close {
  background: transparent;
  border: none;
  color: #78350f;
  font-size: 1.4rem;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.optout-modal-close.emerald-close {
  color: var(--primary-hover);
}

.optout-modal-close:hover {
  background: #fef3c7;
}

.optout-modal-close.emerald-close:hover {
  background: #d1fae5;
}

.age-gate-box {
  background: var(--primary-light);
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 0 0 14px;
  text-align: left;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--text);
}

.age-gate-box label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-weight: 600;
}

.age-gate-box input[type="checkbox"] {
  margin-top: 3px;
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  flex-shrink: 0;
}

.age-gate-error {
  display: none;
  color: var(--danger);
  font-size: 0.84rem;
  font-weight: 700;
  margin: 6px 0 0;
}

.session-badge-box {
  background: var(--light);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 0.85rem;
  color: var(--gray);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.session-badge-box code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  background: #ffffff;
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 5px;
  color: var(--slate);
  font-size: 0.8rem;
}

.session-protection-list {
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.session-protection-list li {
  background: var(--light);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--text);
}

.optout-modal-body {
  padding: 22px 24px 18px;
  color: var(--text);
  font-size: 0.96rem;
  line-height: 1.6;
}

.optout-modal-body p {
  margin: 0 0 18px;
}

.optout-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 24px 24px;
}

.optout-modal-primary-btn {
  width: 100%;
  background: var(--primary);
  color: #ffffff;
  border: none;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.15s;
  text-align: center;
}

.optout-modal-primary-btn:hover {
  background: var(--primary-hover);
}

.optout-modal-secondary-btn {
  width: 100%;
  background: var(--surface);
  color: var(--slate);
  border: 1px solid var(--border-strong);
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
  text-align: center;
}

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

@keyframes modalFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.shop-btn,
.btn-shop {
  background: var(--primary);
  color: #ffffff;
  border: none;
  white-space: nowrap;
  width: 100%;
  padding: 12px 16px;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: background-color 0.15s;
}

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

.shop-btn:disabled,
.btn-shop: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);
  }
}

/* Cookie & Tracking Consent Banner (Sections 5.2(v) & 6.4) */
.cookie-consent-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--slate);
  color: #f9fafb;
  border-top: 2px solid var(--primary);
  padding: 14px 24px;
  z-index: 9400;
  box-shadow: 0 -4px 16px rgba(17, 24, 39, 0.2);
}

.cookie-consent-inner {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 0.88rem;
  line-height: 1.5;
}

.cookie-consent-text {
  flex: 1;
  min-width: 260px;
  color: #e5e7eb;
}

.cookie-consent-text a {
  color: #a7f3d0;
  font-weight: 700;
  text-decoration: underline;
}

.cookie-consent-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

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

.footer-inner,
.footer-container {
  max-width: 1200px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding-left: 24px;
  padding-right: 24px;
  box-sizing: border-box;
  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 (Mobile Viewport Above-the-Fold Optimization) */
@media (max-width: 680px) {
  .header-inner {
    padding: 8px 12px;
    gap: 6px;
  }
  .brand-coin {
    width: 26px;
    height: 26px;
  }
  .brand-wordmark {
    font-size: 1.2rem;
  }
  .site-nav {
    width: 100%;
    justify-content: space-between;
    gap: 4px;
    padding-top: 6px;
    border-top: 1px solid var(--border);
  }
  .nav-link {
    font-size: 0.82rem;
    padding: 4px 8px;
  }
  .site-nav .btn {
    padding: 5px 10px;
    font-size: 0.82rem;
  }
  .nav-user-chip {
    display: none;
  }
  .ftc-top-bar {
    font-size: 0.78rem; /* 12.48px = 9.36pt (>= 8pt Impact Sec 10.5 requirement) */
    line-height: 1.35;
    padding: 6px 12px;
  }
  .page-container,
  .page-container-narrow {
    padding: 12px 12px 36px;
  }
  .cookie-consent-bar {
    padding: 10px 14px;
  }
  .cookie-consent-inner {
    gap: 8px;
    font-size: 0.78rem;
    line-height: 1.38;
  }
  .cookie-consent-actions {
    width: 100%;
    justify-content: stretch;
    gap: 8px;
  }
  .cookie-consent-actions .btn {
    flex: 1;
    padding: 7px 10px !important;
    font-size: 0.8rem !important;
  }
}
