/* ============================================================
   components.css — Buttons · Inputs · Cards · Badges · Accordions
   MoneyMaths | Mobile-first
   ============================================================ */

/* ── 1. Buttons ──────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.625rem var(--space-5);
  border-radius: var(--radius-lg);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  line-height: 1;
  cursor: pointer;
  border: 2px solid transparent;
  text-decoration: none;
  white-space: nowrap;
  min-height: 44px;
  transition:
    background var(--transition-fast),
    color var(--transition-fast),
    border-color var(--transition-fast),
    box-shadow var(--transition-fast),
    transform var(--transition-fast);
  user-select: none;
}

.btn:active { transform: translateY(1px); }

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn--primary {
  background: var(--color-primary);
  color: var(--color-text-on-primary);
  border-color: var(--color-primary);
}
.btn--primary:hover {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
  box-shadow: var(--shadow-md);
}

.btn--secondary {
  background: var(--color-surface);
  color: var(--color-primary);
  border-color: var(--color-primary);
}
.btn--secondary:hover {
  background: var(--color-primary-50);
  box-shadow: var(--shadow-sm);
}

.btn--ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border-color: var(--color-border);
}
.btn--ghost:hover {
  background: var(--color-border-light);
  color: var(--color-text);
}

.btn--accent {
  background: var(--color-accent);
  color: var(--color-text);
  border-color: var(--color-accent);
  font-weight: var(--weight-bold);
}
.btn--accent:hover {
  background: var(--color-accent-dark);
  border-color: var(--color-accent-dark);
  box-shadow: var(--shadow-md);
}

.btn--danger {
  background: var(--color-error);
  color: #fff;
  border-color: var(--color-error);
}
.btn--danger:hover { background: #b91c1c; border-color: #b91c1c; }

.btn--sm  { padding: var(--space-2) var(--space-4); font-size: var(--text-xs); min-height: 36px; }
.btn--lg  { padding: var(--space-4) var(--space-8); font-size: var(--text-base); min-height: 52px; border-radius: var(--radius-xl); }
.btn--full { width: 100%; }

.btn--loading {
  position: relative;
  color: transparent;
  pointer-events: none;
}
.btn--loading::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  border: 2px solid white;
  border-top-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.6s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

/* ── 2. Form Inputs ──────────────────────────────────────── */

.form-group { display: flex; flex-direction: column; gap: var(--space-2); }

.form-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text);
  line-height: 1;
}
.form-label--required::after { content: ' *'; color: var(--color-error); }

.form-hint  { font-size: var(--text-xs); color: var(--color-text-muted); line-height: var(--leading-normal); }
.form-error { font-size: var(--text-xs); color: var(--color-error); display: flex; align-items: center; gap: var(--space-1); }
.form-error svg { width: 12px; height: 12px; flex-shrink: 0; }

.input, .select, .textarea {
  width: 100%;
  min-height: 44px;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  font-size: var(--text-base);
  font-family: var(--font-body);
  color: var(--color-text);
  line-height: var(--leading-normal);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  appearance: none;
  -webkit-appearance: none;
}

.input::placeholder, .textarea::placeholder { color: var(--color-text-muted); }

.input:hover, .select:hover, .textarea:hover { border-color: var(--color-primary-light); }

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgb(26 107 85 / 0.12);
}

.input--error, .select--error, .textarea--error { border-color: var(--color-error); }
.input--error:focus, .select--error:focus, .textarea--error:focus {
  box-shadow: 0 0 0 3px rgb(220 38 38 / 0.12);
}

.input-wrapper { position: relative; display: flex; align-items: center; }
.input-wrapper .input { padding-left: var(--space-10); }
.input-wrapper .input-prefix {
  position: absolute; left: var(--space-4);
  color: var(--color-text-muted); font-size: var(--text-base);
  font-weight: var(--weight-medium); pointer-events: none; user-select: none;
}
.input-wrapper .input-suffix {
  position: absolute; right: var(--space-4);
  color: var(--color-text-muted); font-size: var(--text-sm);
  pointer-events: none; user-select: none;
}

.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-4) center;
  padding-right: var(--space-10);
  cursor: pointer;
}

.textarea { min-height: 120px; resize: vertical; line-height: var(--leading-relaxed); }

.range-slider {
  width: 100%; height: 6px;
  border-radius: var(--radius-full);
  background: var(--color-border);
  outline: none; appearance: none; -webkit-appearance: none; cursor: pointer;
}
.range-slider::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--color-primary);
  border: 2px solid var(--color-surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}
.range-slider::-webkit-slider-thumb:hover {
  box-shadow: 0 0 0 4px rgb(26 107 85 / 0.15);
  transform: scale(1.1);
}
.range-slider::-moz-range-thumb {
  width: 20px; height: 20px;
  border-radius: 50%; background: var(--color-primary);
  border: 2px solid var(--color-surface); box-shadow: var(--shadow-sm);
}

.check-group { display: flex; align-items: center; gap: var(--space-3); cursor: pointer; }
.check-group input[type="checkbox"],
.check-group input[type="radio"] {
  width: 18px; height: 18px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  appearance: none; -webkit-appearance: none;
  cursor: pointer; flex-shrink: 0;
  transition: background var(--transition-fast), border-color var(--transition-fast);
  position: relative;
}
.check-group input[type="radio"] { border-radius: 50%; }
.check-group input[type="checkbox"]:checked,
.check-group input[type="radio"]:checked {
  background: var(--color-primary); border-color: var(--color-primary);
}
.check-group input[type="checkbox"]:checked::after {
  content: ''; position: absolute;
  left: 4px; top: 1px; width: 6px; height: 10px;
  border: 2px solid white; border-top: none; border-left: none;
  transform: rotate(45deg);
}
.check-group input[type="radio"]:checked::after {
  content: ''; position: absolute; inset: 3px;
  background: white; border-radius: 50%;
}
.check-group__label { font-size: var(--text-sm); color: var(--color-text); line-height: var(--leading-normal); }

/* ── 3. Cards ─────────────────────────────────────────────── */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-xs);
}
.card--raised  { box-shadow: var(--shadow-md); border-color: transparent; }
.card--primary { background: var(--color-primary); border-color: transparent; color: var(--color-text-on-primary); }
.card--accent  { background: linear-gradient(135deg, var(--color-primary-50), var(--color-accent-50)); border-color: var(--color-primary-100); }

.card--interactive {
  cursor: pointer;
  transition: box-shadow var(--transition-base), border-color var(--transition-base), transform var(--transition-base);
}
.card--interactive:hover {
  box-shadow: var(--shadow-lg); border-color: var(--color-primary-100); transform: translateY(-2px);
}

.card__header  { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-4); }
.card__title   { font-size: var(--text-lg); font-weight: var(--weight-semibold); color: var(--color-text); line-height: var(--leading-snug); }
.card__subtitle{ font-size: var(--text-sm); color: var(--color-text-muted); margin-top: var(--space-1); }
.card__body    { font-size: var(--text-sm); color: var(--color-text-secondary); line-height: var(--leading-relaxed); }
.card__footer  {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  margin-top: var(--space-5); padding-top: var(--space-5); border-top: 1px solid var(--color-border);
}

/* Tool Card */
.tool-card {
  display: flex; flex-direction: column;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  text-decoration: none; color: inherit;
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--transition-base), border-color var(--transition-base), transform var(--transition-base);
}
.tool-card:hover { box-shadow: var(--shadow-lg); border-color: var(--color-primary-100); transform: translateY(-3px); }
.tool-card__icon {
  width: 44px; height: 44px;
  background: var(--color-primary-50); border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: var(--space-4); color: var(--color-primary);
}
.tool-card__icon svg { width: 22px; height: 22px; }
.tool-card__name { font-size: var(--text-base); font-weight: var(--weight-semibold); color: var(--color-text); margin-bottom: var(--space-2); line-height: var(--leading-snug); }
.tool-card__desc { font-size: var(--text-sm); color: var(--color-text-muted); line-height: var(--leading-relaxed); flex: 1; }
.tool-card__arrow {
  display: flex; align-items: center; gap: var(--space-1);
  margin-top: var(--space-4); font-size: var(--text-sm);
  font-weight: var(--weight-medium); color: var(--color-primary);
}
.tool-card__arrow svg { width: 14px; height: 14px; transition: transform var(--transition-fast); }
.tool-card:hover .tool-card__arrow svg { transform: translateX(3px); }

/* ── 4. Badges ───────────────────────────────────────────── */

.badge {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: 0.2rem var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs); font-weight: var(--weight-semibold);
  line-height: 1.5; white-space: nowrap;
}
.badge svg { width: 12px; height: 12px; flex-shrink: 0; }
.badge--primary { background: var(--color-primary-50); color: var(--color-primary-dark); }
.badge--success { background: var(--color-success-bg); color: var(--color-success); }
.badge--warning { background: var(--color-warning-bg); color: var(--color-warning); }
.badge--error   { background: var(--color-error-bg);   color: var(--color-error); }
.badge--neutral { background: var(--color-border-light); color: var(--color-text-secondary); }
.badge--accent  { background: var(--color-accent-50);  color: var(--color-accent-dark); }

.privacy-badge {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: var(--color-success-bg);
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-full);
  font-size: var(--text-xs); font-weight: var(--weight-medium); color: var(--color-success);
}
.privacy-badge svg { width: 14px; height: 14px; flex-shrink: 0; }

/* ── 5. Accordion / FAQ ──────────────────────────────────── */

.accordion { border: 1px solid var(--color-border); border-radius: var(--radius-xl); overflow: hidden; }
.accordion__item { border-bottom: 1px solid var(--color-border); }
.accordion__item:last-child { border-bottom: none; }

.accordion__trigger {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: var(--space-5) var(--space-6);
  background: none; border: none; cursor: pointer; text-align: left;
  gap: var(--space-4);
  transition: background var(--transition-fast);
}
.accordion__trigger:hover { background: var(--color-border-light); }
.accordion__trigger[aria-expanded="true"] { background: var(--color-primary-50); }
.accordion__question { font-size: var(--text-base); font-weight: var(--weight-medium); color: var(--color-text); line-height: var(--leading-snug); }
.accordion__trigger[aria-expanded="true"] .accordion__question { color: var(--color-primary-dark); }
.accordion__icon { width: 20px; height: 20px; flex-shrink: 0; color: var(--color-text-muted); transition: transform var(--transition-base); }
.accordion__trigger[aria-expanded="true"] .accordion__icon { transform: rotate(180deg); color: var(--color-primary); }
.accordion__panel { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 280ms ease; background: var(--color-surface); }
.accordion__panel[aria-hidden="false"] { grid-template-rows: 1fr; }
.accordion__answer { overflow: hidden; padding: 0 var(--space-6) var(--space-5); font-size: var(--text-sm); color: var(--color-text-secondary); line-height: var(--leading-relaxed); padding-top: var(--space-2); }
.accordion__answer p + p { margin-top: var(--space-3); }

/* ── 6. Tabs ─────────────────────────────────────────────── */

.tabs { display: flex; flex-direction: column; gap: var(--space-6); }
.tabs__list {
  display: flex; gap: var(--space-1);
  border-bottom: 2px solid var(--color-border);
  overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.tabs__list::-webkit-scrollbar { display: none; }
.tabs__tab {
  padding: var(--space-3) var(--space-5); border: none; background: none; cursor: pointer;
  font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--color-text-muted);
  white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}
.tabs__tab:hover { color: var(--color-text); }
.tabs__tab[aria-selected="true"] { color: var(--color-primary); border-bottom-color: var(--color-primary); }
.tabs__panel { display: none; }
.tabs__panel[aria-hidden="false"] { display: block; }

/* ── 7. Alerts ───────────────────────────────────────────── */

.alert {
  display: flex; gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg); border: 1px solid;
  font-size: var(--text-sm); line-height: var(--leading-relaxed);
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert__body { flex: 1; color: inherit; }
.alert__title { font-weight: var(--weight-semibold); margin-bottom: var(--space-1); }
.alert--info    { background: var(--color-info-bg);    border-color: #bae6fd; color: var(--color-info); }
.alert--success { background: var(--color-success-bg); border-color: #bbf7d0; color: var(--color-success); }
.alert--warning { background: var(--color-warning-bg); border-color: #fde68a; color: var(--color-warning); }
.alert--error   { background: var(--color-error-bg);   border-color: #fecaca; color: var(--color-error); }

/* ── 8. Stat / KPI Display ───────────────────────────────── */

.stat-group { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--space-4); }
.stat { display: flex; flex-direction: column; gap: var(--space-1); }
.stat__label {
  font-size: var(--text-xs); font-weight: var(--weight-medium);
  text-transform: uppercase; letter-spacing: var(--tracking-wider); color: var(--color-text-muted);
}
.stat__value {
  font-family: var(--font-display); font-size: var(--text-3xl);
  font-weight: var(--weight-extrabold); color: var(--color-text);
  line-height: 1; letter-spacing: var(--tracking-tight);
}
.stat__value--primary { color: var(--color-primary); }
.stat__value--accent  { color: var(--color-accent-dark); }
.stat__value--success { color: var(--color-success); }
.stat__sub { font-size: var(--text-xs); color: var(--color-text-muted); }

/* ── 9. Divider ──────────────────────────────────────────── */

.divider { height: 1px; background: var(--color-border); border: none; margin-block: var(--space-8); }

/* ── 10. Skeleton Loaders ────────────────────────────────── */

.skeleton {
  background: linear-gradient(90deg, var(--color-border-light) 25%, var(--color-border) 50%, var(--color-border-light) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}
@keyframes skeleton-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton--text  { height: 1em; margin-block: 0.25em; }
.skeleton--title { height: 1.5em; width: 60%; }
.skeleton--card  { height: 120px; border-radius: var(--radius-xl); }

/* ── 11. Empty State ─────────────────────────────────────── */

.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: var(--space-16) var(--space-8); gap: var(--space-4); }
.empty-state__icon { width: 64px; height: 64px; background: var(--color-border-light); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--color-text-muted); }
.empty-state__icon svg { width: 32px; height: 32px; }
.empty-state__title { font-size: var(--text-lg); font-weight: var(--weight-semibold); color: var(--color-text); }
.empty-state__desc  { font-size: var(--text-sm); color: var(--color-text-muted); max-width: 320px; }

/* ── Content Sections (How-to, Formula, Editorial) ───────── */

.content-section {
  margin-top: var(--space-10, 2.5rem);
  padding: var(--space-8, 2rem) 0;
  border-top: 1px solid var(--color-border, #e2e8f0);
}

.content-section__header {
  margin-bottom: var(--space-6, 1.5rem);
}

.content-section__eyebrow {
  display: inline-block;
  font-size: var(--text-xs, 0.75rem);
  font-weight: var(--weight-semibold, 600);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-primary, #1a6b55);
  margin-bottom: var(--space-2, 0.5rem);
}

.content-section__title {
  font-size: var(--text-xl, 1.25rem);
  font-weight: var(--weight-bold, 700);
  color: var(--color-text-primary, #0f172a);
  line-height: 1.3;
}

.content-section__body {
  font-size: var(--text-base, 1rem);
  line-height: 1.7;
  color: var(--color-text-secondary, #475569);
}

.content-section__body p {
  margin-bottom: var(--space-4, 1rem);
}

.content-section__body h3 {
  font-size: var(--text-lg, 1.125rem);
  font-weight: var(--weight-semibold, 600);
  color: var(--color-text-primary, #0f172a);
  margin-top: var(--space-6, 1.5rem);
  margin-bottom: var(--space-3, 0.75rem);
}

.content-section__body a {
  color: var(--color-primary, #1a6b55);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.content-section__body a:hover {
  color: var(--color-primary-dark, #145544);
}

/* ── How-to Steps ────────────────────────────────────────── */

.how-to-steps {
  display: flex;
  flex-direction: column;
  gap: var(--space-5, 1.25rem);
  margin-top: var(--space-5, 1.25rem);
}

.how-to-step {
  display: flex;
  gap: var(--space-4, 1rem);
  align-items: flex-start;
}

.how-to-step__number {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--color-primary-50, #edf7f4);
  color: var(--color-primary, #1a6b55);
  font-weight: var(--weight-bold, 700);
  font-size: var(--text-sm, 0.875rem);
}

.how-to-step__content h3 {
  font-size: var(--text-base, 1rem);
  font-weight: var(--weight-semibold, 600);
  color: var(--color-text-primary, #0f172a);
  margin: 0 0 var(--space-1, 0.25rem);
}

.how-to-step__content p {
  font-size: var(--text-sm, 0.875rem);
  color: var(--color-text-secondary, #475569);
  line-height: 1.6;
  margin: 0;
}

/* ── Formula Card ────────────────────────────────────────── */

.formula-card {
  background: var(--color-surface-alt, #f8fafc);
  border: 1px solid var(--color-border, #e2e8f0);
  border-radius: var(--radius-lg, 0.75rem);
  padding: var(--space-6, 1.5rem);
  margin: var(--space-5, 1.25rem) 0;
}

.formula-card__expression {
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: var(--text-lg, 1.125rem);
  font-weight: 600;
  color: var(--color-text-primary, #0f172a);
  text-align: center;
  padding: var(--space-4, 1rem) 0;
  letter-spacing: 0.02em;
  line-height: 1.8;
}

.formula-card__legend {
  border-top: 1px solid var(--color-border, #e2e8f0);
  padding-top: var(--space-4, 1rem);
  margin-top: var(--space-2, 0.5rem);
}

.formula-card__legend p {
  font-size: var(--text-sm, 0.875rem);
  color: var(--color-text-secondary, #475569);
  margin-bottom: var(--space-2, 0.5rem);
  line-height: 1.5;
}

.formula-card__legend p strong {
  color: var(--color-text-primary, #0f172a);
  font-weight: var(--weight-semibold, 600);
  margin-right: 0.25rem;
}

/* ── Ad Slot ─────────────────────────────────────────────── */

.ad-slot {
  margin: var(--space-8, 2rem) 0;
  min-height: 90px;
  text-align: center;
}

.ad-slot--in-content {
  padding: var(--space-4, 1rem) 0;
}
