/* ================================================================
   What Should I Charge? — Dark Default Design System
   Palette: Indigo primary + Amber accent + Dark Slate neutrals
   Typography: Inter (Google Fonts) — 400/500/600/700/800/900
   Theme: Dark by default; [data-theme="light"] for light mode
   ================================================================ */

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Dark theme (default) */
  --primary: #6366f1;
  --primary-light: #818cf8;
  --primary-dark: #4f46e5;
  --primary-bg: #1e1b4b;
  --accent: #f59e0b;
  --accent-light: #fbbf24;
  --accent-bg: #451a03;

  /* Neutrals */
  --bg: #0f172a;
  --card-bg: #1e293b;
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: #334155;
  --border-light: #1e293b;

  /* Spacing & Shape */
  --radius: 10px;
  --radius-lg: 16px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow: 0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4), 0 2px 4px -2px rgba(0,0,0,0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.5), 0 4px 6px -4px rgba(0,0,0,0.3);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.5), 0 8px 10px -6px rgba(0,0,0,0.3);

  /* Success / Warning */
  --success: #34d399;
  --success-bg: #064e3b;
  --warning: #fbbf24;
  --error: #f87171;

  /* Ad */
  --ad-bg: #1e293b;

  /* Input disabled */
  --input-disabled-bg: #0f172a;

  /* Font */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', monospace;

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  color-scheme: dark;
}

/* Light theme override */
[data-theme="light"] {
  --primary: #4338ca;
  --primary-light: #6366f1;
  --primary-dark: #3730a3;
  --primary-bg: #eef2ff;
  --accent: #f59e0b;
  --accent-light: #fbbf24;
  --accent-bg: #fffbeb;

  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-light: #f1f5f9;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);

  --success: #059669;
  --success-bg: #ecfdf5;
  --warning: #d97706;
  --error: #dc2626;

  --ad-bg: #f1f5f9;
  --input-disabled-bg: #f8fafc;

  color-scheme: light;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  padding: 0 1rem 4rem;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== SELECTION ===== */
::selection {
  background: var(--primary);
  color: white;
}

[data-theme="light"] ::selection {
  background: var(--primary-bg);
  color: var(--primary-dark);
}

/* ===== THEME TOGGLE ===== */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.35rem 0.6rem;
  line-height: 1;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}

.theme-toggle:hover {
  border-color: var(--primary-light);
  background: var(--primary-bg);
}

/* ===== HEADER ===== */
header {
  text-align: center;
  padding: 3.5rem 0 2.5rem;
  position: relative;
}

header::after {
  content: '';
  display: block;
  width: 60px;
  height: 4px;
  background: linear-gradient(90deg, var(--primary-light), var(--accent));
  border-radius: 2px;
  margin: 1.5rem auto 0;
  opacity: 0.8;
}

.lang-switcher {
  margin-top: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.lang-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.lang-select {
  font-family: var(--font);
  font-size: 0.85rem;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  color: var(--text);
  cursor: pointer;
  appearance: auto;
  -webkit-appearance: auto;
}

.lang-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
}

header h1 {
  font-size: 2.6rem;
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--text);
}

header h1 span {
  color: var(--primary-light);
}

[data-theme="light"] header h1 span {
  color: var(--primary-dark);
}

.subtitle {
  color: var(--text-secondary);
  font-size: 1.15rem;
  font-weight: 400;
  margin-top: 0.5rem;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

/* ===== LAYOUT ===== */
main {
  max-width: 760px;
  margin: 0 auto;
}

section {
  margin-bottom: 2.5rem;
}

/* ===== CARD BASE (shared by intro, calculator, results, educational) ===== */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow);
  transition: box-shadow 0.3s var(--ease), border-color 0.3s var(--ease);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card h2 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  margin-bottom: 1rem;
  color: var(--text);
}

/* ===== INTRO ===== */
.intro {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow);
}

.intro h2 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  margin-bottom: 1rem;
}

.intro p {
  margin-bottom: 0.85rem;
  color: var(--text-secondary);
  font-size: 0.975rem;
  line-height: 1.75;
}

.intro p strong {
  color: var(--text);
  font-weight: 600;
}

.disclaimer {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-light);
  margin-top: 1rem;
  line-height: 1.6;
}

/* ===== FORM (Calculator) ===== */
.calculator {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow);
}

.calculator h2 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  margin-bottom: 1.5rem;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.4rem;
  color: var(--text);
  letter-spacing: -0.01em;
}

.form-group select {
  width: 100%;
  padding: 0.7rem 0.85rem;
  font-size: 0.95rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  cursor: pointer;
  font-family: var(--font);
  color: var(--text);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
  appearance: none;
  -webkit-appearance: none;
  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='%2364748b' stroke-width='2' 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 0.85rem center;
  padding-right: 2.5rem;
}

.form-group select:hover:not(:disabled) {
  border-color: var(--primary-light);
}

.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

.form-group select:disabled {
  background: var(--input-disabled-bg);
  color: var(--text-muted);
  cursor: not-allowed;
  border-color: var(--border-light);
}

.help-text {
  font-size: 0.825rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
  line-height: 1.5;
}

/* Cost of living toggle */
.cost-of-living-toggle {
  background: var(--primary-bg);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  margin-bottom: 0;
}

.cost-of-living-toggle .help-text {
  color: var(--primary-light);
  opacity: 0.8;
  margin-top: 0.5rem;
}

[data-theme="light"] .cost-of-living-toggle {
  border-color: #c7d2fe;
}

[data-theme="light"] .cost-of-living-toggle .help-text {
  color: var(--primary-dark);
}

.toggle-label {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--text);
}

.toggle-label input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  margin-top: 0.15rem;
  accent-color: var(--primary);
  flex-shrink: 0;
}

/* ===== RESULTS ===== */
.results {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow);
  animation: fadeSlideIn 0.5s var(--ease-spring);
}

.results h2 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  margin-bottom: 1.25rem;
}

/* Hero result card */
.result-card {
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  text-align: center;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.result-card.result-hero {
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 50%, var(--primary-dark) 100%);
  color: white;
  border: none;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(99, 102, 241, 0.3);
  position: relative;
  overflow: hidden;
}

.result-hero::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 30% 50%, rgba(255,255,255,0.08) 0%, transparent 60%);
  pointer-events: none;
}

.result-hero .result-label {
  color: rgba(255,255,255,0.8);
  position: relative;
  z-index: 1;
}

.result-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.result-value {
  font-size: 3rem;
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -0.03em;
  position: relative;
  z-index: 1;
  animation: countUp 0.8s var(--ease-spring);
}

.result-sub {
  font-size: 0.85rem;
  margin-top: 0.3rem;
  color: rgba(255,255,255,0.7);
  position: relative;
  z-index: 1;
}

/* Project result card */
#result-project {
  background: var(--primary-bg);
  border-color: rgba(99, 102, 241, 0.25);
}

#result-project .result-label {
  color: var(--primary-light);
}

#result-project .result-value {
  color: var(--primary);
}

[data-theme="light"] #result-project {
  border-color: #c7d2fe;
}

[data-theme="light"] #result-project .result-label {
  color: var(--primary-dark);
}

/* ===== PERCENTILE CHART ===== */
.percentile-chart {
  margin: 1.75rem 0 1rem;
}

.percentile-chart h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.85rem;
  color: var(--text);
}

.percentile-bar {
  display: flex;
  height: 2.5rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 0.5rem;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.15);
}

.percentile-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: white;
  transition: flex 0.5s var(--ease-spring);
  letter-spacing: 0.03em;
}

.segment-10th { background: #6366f1; }
.segment-25th { background: #4f46e5; }
.segment-50th { background: #4338ca; }
.segment-75th { background: #3730a3; }
.segment-90th { background: #312e81; }

.percentile-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.rate-range {
  margin-top: 1.25rem;
  padding: 0.85rem 1rem;
  background: var(--primary-bg);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: var(--radius);
  font-size: 0.9rem;
  color: var(--primary-light);
  line-height: 1.6;
  text-align: center;
}

[data-theme="light"] .rate-range {
  border-color: #c7d2fe;
  color: var(--primary-dark);
}

.rate-range strong {
  color: var(--text);
}

/* ===== AD SPACE ===== */
.ad-space {
  padding: 1.25rem;
  background: var(--ad-bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
}

.ad-placeholder {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ===== EDUCATIONAL CONTENT ===== */
.educational {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow);
}

.educational h2 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  margin-bottom: 1.5rem;
}

.educational article {
  margin-bottom: 1.75rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--border-light);
}

.educational article:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.educational h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.6rem;
  color: var(--primary-light);
  letter-spacing: -0.01em;
}

[data-theme="light"] .educational h3 {
  color: var(--primary);
}

.educational p {
  margin-bottom: 0.6rem;
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.75;
}

.educational p:last-child {
  margin-bottom: 0;
}

.educational strong {
  color: var(--text);
  font-weight: 600;
}

.educational em {
  color: var(--text-secondary);
}

/* ===== FOOTER ===== */
footer {
  text-align: center;
  font-size: 0.825rem;
  color: var(--text-muted);
  margin-top: 3rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border);
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
}

footer p {
  margin-bottom: 0.3rem;
}

footer a {
  color: var(--primary-light);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s var(--ease);
}

footer a:hover {
  color: var(--primary);
  text-decoration: underline;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes countUp {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ===== MOBILE ===== */
@media (max-width: 640px) {
  body {
    padding: 0 0.75rem 2.5rem;
  }

  header {
    padding: 2rem 0 1.5rem;
  }

  header h1 {
    font-size: 2rem;
  }

  .subtitle {
    font-size: 1rem;
  }

  .intro,
  .calculator,
  .results,
  .educational {
    padding: 1.25rem;
  }

  .result-value {
    font-size: 2.25rem;
  }

  .percentile-segment {
    font-size: 0.6rem;
  }

  section {
    margin-bottom: 1.75rem;
  }
}

@media (max-width: 400px) {
  header h1 {
    font-size: 1.7rem;
  }

  .result-value {
    font-size: 1.85rem;
  }
}
