/* ============================================================
   FREELANCE RATE CALCULATOR — style.css
   Color scheme: Navy (#0f1e45) + White + Orange accent (#f97316)
   Font: Inter (Google Fonts)
   ============================================================ */

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

:root {
  --navy:       #0f1e45;
  --navy-mid:   #1a3068;
  --navy-light: #2a4a8e;
  --orange:     #f97316;
  --orange-dark:#ea6c0a;
  --white:      #ffffff;
  --off-white:  #f8fafc;
  --gray-100:   #f1f5f9;
  --gray-200:   #e2e8f0;
  --gray-400:   #94a3b8;
  --gray-600:   #475569;
  --gray-800:   #1e293b;
  --green:      #22c55e;
  --radius-sm:  6px;
  --radius-md:  12px;
  --radius-lg:  18px;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:  0 4px 16px rgba(0,0,0,.10), 0 2px 6px rgba(0,0,0,.06);
  --shadow-lg:  0 10px 40px rgba(0,0,0,.14);
  --transition: 0.2s ease;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--off-white);
  color: var(--gray-800);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Ad Banners ───────────────────────────────────────────── */
.ad-banner {
  background: var(--gray-100);
  border-bottom: 1px solid var(--gray-200);
  text-align: center;
  padding: 10px 16px;
  font-size: 0.8rem;
  color: var(--gray-400);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 60px;
}

#ad-banner-bottom {
  border-top: 1px solid var(--gray-200);
  border-bottom: none;
  margin-top: auto;
}

.ad-label {
  background: var(--gray-200);
  color: var(--gray-400);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 3px;
}

.ad-banner a {
  color: var(--navy-light);
  text-decoration: underline;
}

/* ── Site Header ──────────────────────────────────────────── */
.site-header {
  background: var(--navy);
  color: var(--white);
  padding: 20px 0;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.logo-icon {
  color: var(--orange);
  font-size: 1.5rem;
}

.logo-accent {
  color: var(--orange);
}

.tagline {
  font-size: 0.85rem;
  color: rgba(255,255,255,.6);
  font-style: italic;
}

/* ── Layout / Container ───────────────────────────────────── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

.main-content {
  flex: 1;
  padding: 40px 0 60px;
}

/* ── Hero ─────────────────────────────────────────────────── */
.hero {
  text-align: center;
  margin-bottom: 36px;
}

.hero h1 {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 800;
  color: var(--navy);
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.hero-sub {
  margin-top: 12px;
  font-size: 1.05rem;
  color: var(--gray-600);
  max-width: 620px;
  margin-left: auto;
  margin-right: auto;
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 32px;
  border: 1px solid var(--gray-200);
}

.card-header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--gray-100);
}

.card-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--navy);
}

.card-header p {
  font-size: 0.85rem;
  color: var(--gray-400);
  margin-top: 4px;
}

/* ── Calculator Grid ──────────────────────────────────────── */
.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

@media (max-width: 768px) {
  .calc-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Form Styles ──────────────────────────────────────────── */
fieldset {
  border: none;
  margin-bottom: 20px;
}

legend {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--orange);
  margin-bottom: 16px;
  padding: 0;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 6px;
}

.input-wrap {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
  background: var(--white);
}

.input-wrap:focus-within {
  border-color: var(--navy-light);
  box-shadow: 0 0 0 3px rgba(42,74,142,.15);
}

.input-prefix,
.input-suffix {
  padding: 10px 12px;
  background: var(--gray-100);
  color: var(--gray-600);
  font-size: 0.875rem;
  font-weight: 600;
  user-select: none;
  white-space: nowrap;
}

.input-wrap input {
  flex: 1;
  border: none;
  outline: none;
  padding: 10px 12px;
  font-size: 0.95rem;
  font-family: 'Inter', sans-serif;
  color: var(--gray-800);
  background: transparent;
  min-width: 0;
  -moz-appearance: textfield;
}

.input-wrap input::-webkit-outer-spin-button,
.input-wrap input::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

/* Tooltip */
.tooltip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--gray-200);
  color: var(--gray-600);
  font-size: 0.65rem;
  font-weight: 700;
  cursor: help;
  position: relative;
  flex-shrink: 0;
}

.tooltip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--gray-800);
  color: var(--white);
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1.4;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  width: 220px;
  white-space: normal;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition);
  z-index: 10;
  box-shadow: var(--shadow-md);
}

.tooltip:hover::after {
  opacity: 1;
}

/* ── Results ──────────────────────────────────────────────── */
.results-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.result-item {
  padding: 16px 18px;
  border-radius: var(--radius-md);
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  transition: background var(--transition);
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 12px;
  row-gap: 2px;
  align-items: center;
}

.result-label {
  grid-column: 1;
  grid-row: 1;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--gray-600);
}

.result-value {
  grid-column: 2;
  grid-row: 1 / 3;
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--navy);
  letter-spacing: -0.03em;
  align-self: center;
  transition: color var(--transition);
  white-space: nowrap;
}

.result-value--md {
  font-size: 1.35rem;
}

.result-note {
  grid-column: 1;
  grid-row: 2;
  font-size: 0.75rem;
  color: var(--gray-400);
}

/* Highlight = minimum rate */
.result-highlight {
  background: #fff7ed;
  border-color: #fed7aa;
}

.result-highlight .result-value {
  color: var(--orange-dark);
}

/* Primary = recommended rate */
.result-primary {
  background: var(--navy);
  border-color: var(--navy-mid);
}

.result-primary .result-label {
  color: rgba(255,255,255,.7);
}

.result-primary .result-value {
  color: var(--orange);
  font-size: 2.1rem;
}

.result-primary .result-note {
  color: rgba(255,255,255,.45);
}

/* ── Calculation Breakdown ────────────────────────────────── */
.breakdown {
  margin-top: 20px;
  border-top: 1px solid var(--gray-200);
  padding-top: 16px;
}

.breakdown-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--navy-light);
  padding: 4px 0;
  gap: 8px;
}

.breakdown-toggle:hover {
  color: var(--navy);
}

.breakdown-icon {
  font-size: 0.7rem;
  transition: transform var(--transition);
}

.breakdown-toggle[aria-expanded="true"] .breakdown-icon {
  transform: rotate(180deg);
}

.breakdown-body {
  margin-top: 14px;
}

.breakdown-body[hidden] {
  display: none;
}

.breakdown-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.825rem;
}

.breakdown-table tr {
  border-bottom: 1px solid var(--gray-100);
}

.breakdown-table tr:last-child {
  border-bottom: none;
}

.breakdown-table td {
  padding: 7px 4px;
  vertical-align: top;
}

.breakdown-table td:first-child {
  color: var(--gray-600);
  width: 65%;
}

.breakdown-table td:last-child {
  text-align: right;
  font-weight: 600;
  color: var(--gray-800);
  font-variant-numeric: tabular-nums;
}

.breakdown-table tr.bd-separator td {
  padding-top: 12px;
  color: var(--orange);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.breakdown-table tr.bd-total td {
  font-weight: 800;
  color: var(--navy);
  border-top: 2px solid var(--navy);
  padding-top: 10px;
}

/* ── How It Works ─────────────────────────────────────────── */
.how-it-works {
  margin-bottom: 24px;
}

.how-it-works h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 16px;
}

.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  list-style: none;
  counter-reset: steps;
}

.steps li {
  counter-increment: steps;
  background: var(--gray-100);
  border-radius: var(--radius-md);
  padding: 16px;
  position: relative;
  border: 1px solid var(--gray-200);
  font-size: 0.875rem;
  color: var(--gray-600);
  padding-left: 48px;
}

.steps li::before {
  content: counter(steps);
  position: absolute;
  left: 14px;
  top: 16px;
  width: 22px;
  height: 22px;
  background: var(--orange);
  color: var(--white);
  font-weight: 800;
  font-size: 0.75rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.steps li strong {
  display: block;
  color: var(--gray-800);
  font-weight: 700;
  margin-bottom: 4px;
}

.steps li code {
  background: var(--gray-200);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.8rem;
}

/* ── Tools / Affiliate Section ────────────────────────────── */
.tools-section {
  margin-bottom: 8px;
}

.tools-section h2 {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--navy);
  margin-bottom: 6px;
}

.tools-sub {
  color: var(--gray-600);
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}

.tool-card {
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-decoration: none;
  color: inherit;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
  box-shadow: var(--shadow-sm);
}

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

.tool-icon {
  font-size: 2rem;
  flex-shrink: 0;
  line-height: 1;
}

.tool-body h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 6px;
}

.tool-body p {
  font-size: 0.83rem;
  color: var(--gray-600);
  line-height: 1.5;
  margin-bottom: 10px;
}

.tool-cta {
  font-size: 0.83rem;
  font-weight: 700;
  color: var(--orange);
  display: inline-block;
}

/* ── Footer ───────────────────────────────────────────────── */
.site-footer {
  background: var(--navy);
  color: rgba(255,255,255,.6);
  padding: 24px 0;
  text-align: center;
  font-size: 0.82rem;
  line-height: 1.8;
}

.footer-note {
  font-size: 0.75rem;
  color: rgba(255,255,255,.35);
}

/* ── Result Update Flash Animation ───────────────────────── */
@keyframes flash {
  0%   { opacity: .55; }
  100% { opacity: 1; }
}

.result-value.updating {
  animation: flash 0.25s ease-out;
}

/* ── Responsive tweaks ────────────────────────────────────── */
@media (max-width: 520px) {
  .card {
    padding: 20px 16px;
  }

  .header-inner {
    flex-direction: column;
    align-items: flex-start;
  }

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

  .result-primary .result-value {
    font-size: 1.7rem;
  }
}
