/* 
  FeeMini - Pure Vanilla CSS 
  Z-depth system, glass morphism, purple/cyan palette 
*/

:root {
  /* Dark Theme (Default) */
  --bg-color: #0f0f14;
  --surface-z0: #0f0f14;
  --surface-z1: #1a1a23;
  --surface-z2: #22222e;
  --surface-z3: #2a2a38;
  
  --text-primary: #f8f8fa;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --border-light: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(139, 92, 246, 0.5);
  
  --glass-bg: rgba(26, 26, 35, 0.7);
  
  --shadow-z1: 0 4px 24px rgba(0,0,0,0.3), 0 1px 4px rgba(0,0,0,0.2);
  --shadow-z2: 0 8px 40px rgba(0,0,0,0.4), 0 2px 8px rgba(0,0,0,0.25);
  --shadow-z3: 0 16px 64px rgba(139,92,246,0.15), 0 4px 16px rgba(0,0,0,0.35);
  --shadow-inset: inset 0 2px 8px rgba(0,0,0,0.3), 0 0 0 1px rgba(255,255,255,0.05);
  
  /* Brand Accents */
  --accent-purple: #8b5cf6;
  --accent-cyan: #22d3ee;
  --accent-green: #34d399;
  --accent-red: #f87171;
  --brand-gradient: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
}

html[data-theme="light"] {
  --bg-color: #f8f8fa;
  --surface-z0: #f8f8fa;
  --surface-z1: #ffffff;
  --surface-z2: #f0f0f3;
  --surface-z3: #e4e4e9;
  
  --text-primary: #0f0f14;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;
  
  --border-light: rgba(0, 0, 0, 0.08);
  --border-focus: rgba(139, 92, 246, 0.5);
  
  --glass-bg: rgba(255, 255, 255, 0.8);
  
  --shadow-z1: 0 4px 24px rgba(0,0,0,0.06), 0 1px 4px rgba(0,0,0,0.04);
  --shadow-z2: 0 8px 40px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.05);
  --shadow-z3: 0 16px 64px rgba(139,92,246,0.15), 0 4px 16px rgba(0,0,0,0.1);
  --shadow-inset: inset 0 2px 4px rgba(0,0,0,0.05), 0 0 0 1px rgba(0,0,0,0.1);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.page-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 80px 20px 40px; /* Top padding clears sticky header */
}

/* Glass Morphism Utility */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--border-light);
}

/* Depths */
.z-0 { box-shadow: none; }
.z-1 { box-shadow: var(--shadow-z1); }
.z-2 { box-shadow: var(--shadow-z2); }
.Z-3 { box-shadow: var(--shadow-z3); } /* dramatic */

/* Header */
header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  z-index: 100;
}
.header-container {
  max-width: 1200px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.25rem;
}
#theme-toggle {
  background: transparent;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
#theme-toggle:hover {
  background: rgba(139, 92, 246, 0.1);
}
html[data-theme="dark"] .icon-moon { display: none; }
html[data-theme="light"] .icon-sun { display: none; }

/* Savings Callout Z-3 */
.savings-callout {
  position: relative;
  border-radius: 24px;
  padding: 40px;
  text-align: center;
  margin: 40px 0;
  overflow: hidden;
  transform: translateY(-4px);
}
.savings-callout h1 {
  font-size: 2.5rem;
  line-height: 1.2;
  font-weight: 800;
}
.savings-callout .highlight-amount {
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: block;
  font-size: 3.5rem;
  margin-top: 8px;
}
.glow-ring {
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at center, rgba(139,92,246,0.1) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}
.callout-content {
  position: relative;
  z-index: 1;
}

/* Calculator Panel */
.calculator-panel {
  border-radius: 16px;
  padding: 32px;
  margin-bottom: 40px;
}
.calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}
.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.input-group label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.inset-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--surface-z0);
  border-radius: 12px;
  box-shadow: var(--shadow-inset);
  transition: box-shadow 0.2s ease;
}
.inset-input-wrapper:focus-within {
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.3), 0 0 0 2px var(--border-focus);
}
.inset-input-wrapper input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 1.25rem;
  font-weight: 600;
  padding: 16px 16px 16px 36px;
  outline: none;
  width: 100%;
}
.prefix {
  position: absolute;
  left: 16px;
  color: var(--text-muted);
  font-size: 1.125rem;
  pointer-events: none;
}
.suffix {
  position: absolute;
  right: 16px;
  color: var(--text-muted);
  font-size: 1.125rem;
  pointer-events: none;
}
.inset-input-wrapper input.mix-input {
  padding: 16px 36px 16px 16px; /* suffix padding */
}

/* Card Mix */
.card-mix-section {
  padding-top: 24px;
  border-top: 1px solid var(--border-light);
}
.mix-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.mix-header h3 {
  font-size: 1rem;
  color: var(--text-secondary);
}
.mix-badge {
  font-size: 0.75rem;
  background: var(--surface-z1);
  padding: 4px 8px;
  border-radius: 4px;
  font-weight: 700;
  color: var(--accent-green);
}
.mix-badge.error {
  color: var(--accent-red);
}
.mix-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.mix-error {
  display: none;
  color: var(--accent-red);
  font-size: 0.875rem;
  margin-top: 12px;
}
.mix-error.visible {
  display: block;
}

/* Results Grid */
.results-header-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.results-header-actions h2 {
  font-size: 1.5rem;
}
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
  margin-bottom: 60px;
}
.processor-card {
  background: var(--surface-z1);
  border-radius: 16px;
  padding: 24px;
  border: 1px solid var(--border-light);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  display: flex;
  flex-direction: column;
}
@media (hover: hover) {
  .processor-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-z2);
    border-color: var(--border-focus);
  }
}
.processor-card.best-value {
  border-color: var(--accent-purple);
  position: relative;
}
.best-badge {
  position: absolute;
  top: -12px;
  left: 24px;
  background: var(--brand-gradient);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(139,92,246,0.3);
}
.proc-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-light);
}
.proc-name {
  font-size: 1.25rem;
  font-weight: 700;
}
.proc-type {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.proc-costs {
  margin-bottom: 24px;
  flex-grow: 1;
}
.cost-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.875rem;
}
.cost-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--border-light);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
}
.effective-rate {
  font-size: 0.875rem;
  color: var(--accent-cyan);
  font-weight: 600;
}
.proc-details {
  background: var(--surface-z0);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 24px;
}
.detail-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.detail-item:last-child { margin-bottom: 0; }

/* Buttons */
.btn-primary {
  display: block;
  width: 100%;
  padding: 14px;
  background: var(--brand-gradient);
  color: #fff;
  text-align: center;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.btn-primary:hover {
  transform: translateY(-2px);
  opacity: 0.9;
}
.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--surface-z2);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-secondary:hover {
  background: var(--surface-z3);
}

/* FAQ Accordion */
.faq-section {
  margin-top: 60px;
}
.faq-section h2 {
  margin-bottom: 24px;
}
.faq-item {
  background: var(--surface-z1);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  margin-bottom: 12px;
  overflow: hidden;
  transition: all 0.3s ease;
}
.faq-item.active {
  box-shadow: var(--shadow-z3);
  transform: translateY(-2px);
  border-color: var(--border-focus);
}
.faq-question {
  width: 100%;
  padding: 20px;
  background: transparent;
  border: none;
  text-align: left;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.faq-icon {
  width: 12px;
  height: 12px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.3s ease;
}
.faq-item.active .faq-icon {
  transform: rotate(-135deg);
  color: var(--accent-purple);
}
.faq-answer-wrapper {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.3s cubic-bezier(0, 1, 0, 1), opacity 0.3s ease;
}
.faq-item.active .faq-answer-wrapper {
  max-height: 1000px; /* rAF logic in js handles exact height, this is fallback */
  opacity: 1;
  transition: max-height 0.3s ease-in-out, opacity 0.3s ease 0.1s;
}
.faq-answer {
  padding: 0 20px 20px;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* AdSense Placeholder */
.adsense-placeholder {
  width: 100%;
  height: 90px;
  border: 2px dashed var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  margin: 40px 0;
  border-radius: 8px;
}

/* Footer / Cookie */
.site-footer {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 0.875rem;
  border-top: 1px solid var(--border-light);
}
#cookie-banner {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  border-radius: 12px;
  z-index: 1000;
  display: none; /* toggled by JS */
}
#cookie-banner.visible {
  display: flex;
}
#cookie-banner button {
  width: auto;
  padding: 8px 24px;
}

/* --- Hero Polish Pass --- */
.hero-chips {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: -16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.hero-chips .chip {
  background: var(--surface-z1);
  border: 1px solid var(--border-light);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  box-shadow: var(--shadow-z1);
  transition: transform 0.2s;
}
.hero-chips .chip:hover {
  transform: translateY(-2px);
}
.pulse-anim {
  animation: pulse-glow 1s ease-out;
}
@keyframes pulse-glow {
  0% { box-shadow: var(--shadow-z3), 0 0 0 0 rgba(139, 92, 246, 0.4); }
  70% { box-shadow: var(--shadow-z3), 0 0 0 20px rgba(139, 92, 246, 0); }
  100% { box-shadow: var(--shadow-z3), 0 0 0 0 rgba(139, 92, 246, 0); }
}

/* Background Atmosphere */
body::before {
  content: "";
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background: radial-gradient(circle at 50% 20%, rgba(139, 92, 246, 0.05) 0%, transparent 60%);
  pointer-events: none;
  z-index: -1;
}

/* Processor Card Polish */
.processor-card {
  position: relative;
  background: linear-gradient(180deg, var(--surface-z2) 0%, var(--surface-z1) 20%);
}
.processor-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(180deg, rgba(255,255,255,0.1), transparent);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
  transition: opacity 0.3s;
}
@media (hover: hover) {
  .processor-card:hover::before {
    background: var(--brand-gradient);
    opacity: 0.5;
  }
}

/* Responsive Breakpoints */
@media (max-width: 768px) {
  .savings-callout {
    padding: 24px;
  }
  .savings-callout h1 {
    font-size: 1.75rem;
  }
  .savings-callout .highlight-amount {
    font-size: 2.5rem;
  }
  .mix-grid {
    grid-template-columns: 1fr;
  }
  .results-header-actions {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
  #cookie-banner {
    flex-direction: column;
    width:calc(100% - 40px);
    text-align: center;
  }
  #cookie-banner button {
    width: 100%;
  }
}

/* Print Styles */
@media print {
  header, #theme-toggle, .card-mix-section, .btn-primary, #export-btn, .faq-section, .adsense-placeholder, #cookie-banner {
    display: none !important;
  }
  body, .page-wrapper { margin: 0; padding: 0; background: #fff; color: #000; }
  .savings-callout { border: 1px solid #000; box-shadow: none; color: #000; }
  .savings-callout .highlight-amount { background: none; -webkit-text-fill-color: #000; color: #000; }
  .processor-card { break-inside: avoid; border: 1px solid #ccc; box-shadow: none; }
  .results-grid { grid-template-columns: repeat(2, 1fr); }
  .best-badge { border: 1px solid #000; color:#000; background: none;}
}