/* ==========================================================================
   Tools — Friendly SaaS design system
   Token-driven: 8pt spacing grid, modular type scale, 60-30-10 color,
   soft tinted elevation, rounded corners. Dark mode is first-class.
   All motion respects prefers-reduced-motion. WCAG AA contrast.
   ========================================================================== */

/* --- Self-hosted house fonts (no third-party requests) ------------------- */
@font-face {
  font-family: "Baloo 2";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/baloo-2-latin-600-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Baloo 2";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/baloo-2-latin-700-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Baloo 2";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("/fonts/baloo-2-latin-800-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/nunito-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/nunito-latin-600-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/nunito-latin-700-normal.woff2") format("woff2");
}

:root {
  /* Fonts — self-hosted house pairing (display = rounded, body = warm sans) */
  --font-display: "Baloo 2", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-body: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* Spacing — 8pt grid (4px for fine-tuning) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --space-9: 48px;
  --space-10: 64px;
  --space-11: 80px;
  --space-12: 96px;

  /* Type scale — ~1.2 minor third, 16px base */
  --text-xs: 0.75rem;    /* 12px */
  --text-sm: 0.875rem;   /* 14px */
  --text-base: 1rem;     /* 16px */
  --text-lg: 1.2rem;     /* ~19px */
  --text-xl: 1.5rem;     /* 24px */
  --text-2xl: 1.95rem;   /* ~31px */
  --text-3xl: 2.45rem;   /* ~39px */
  --leading-tight: 1.15;
  --leading-snug: 1.3;
  --leading-normal: 1.6;
  --tracking-tight: -0.02em;
  --tracking-tighter: -0.03em;
  --tracking-wide: 0.04em;

  /* Radius — round / friendly. Children stay smaller than parents. */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --radius-pill: 9999px;

  /* Color — warm cream canvas + coral accent + teal pop (60-30-10) */
  --bg: #fbf7f1;
  --surface: #ffffff;
  --surface-2: #fbf6ee;
  --fg: #2b2422;
  --fg-body: #4b423c;
  --muted: #6b6258;
  --border: #ece3d6;
  --border-strong: #dbcfbf;

  --accent: #c2410c;        /* coral button / interactive fill (AA on white) */
  --accent-hover: #ad3a0b;
  --accent-press: #99330a;
  --accent-fg: #ffffff;
  --link: #b23a12;          /* coral used as text on the cream canvas */
  --accent-soft: #fbebe1;  /* warm peach tinted result surface */
  --accent-soft-border: #f4d6c5;
  --accent-2: #0e8c80;      /* teal pop, used sparingly */

  --warn-soft: #fdf3e3;
  --warn-text: #8a5300;
  --warn-border: #f4dcb0;

  /* Elevation — soft, faintly tinted */
  --shadow-xs: 0 1px 2px rgba(28, 27, 34, 0.05);
  --shadow-sm: 0 1px 3px rgba(28, 27, 34, 0.07), 0 1px 2px rgba(28, 27, 34, 0.04);
  --shadow-md: 0 8px 20px rgba(28, 27, 34, 0.08), 0 2px 6px rgba(28, 27, 34, 0.05);
  --shadow-lg: 0 18px 40px rgba(28, 27, 34, 0.11), 0 6px 14px rgba(28, 27, 34, 0.06);
  --shadow-accent: 0 8px 20px rgba(194, 65, 12, 0.28);

  /* Motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Layout */
  --container: 760px;
  --container-wide: 1080px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1513;
    --surface: #241e1b;
    --surface-2: #2b2421;
    --fg: #f6efe8;
    --fg-body: #dcd2c9;
    --muted: #a4998e;
    --border: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.18);

    --accent: #c2410c;
    --accent-hover: #d2541f;
    --accent-press: #b23a0f;
    --accent-fg: #ffffff;
    --link: #ff9166;
    --accent-soft: rgba(194, 65, 12, 0.20);
    --accent-soft-border: rgba(255, 145, 102, 0.30);
    --accent-2: #2dd4bf;

    --warn-soft: rgba(245, 176, 65, 0.12);
    --warn-text: #f1c27d;
    --warn-border: rgba(245, 176, 65, 0.28);

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.45);
    --shadow-md: 0 8px 22px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 20px 44px rgba(0, 0, 0, 0.55);
    --shadow-accent: 0 8px 22px rgba(194, 65, 12, 0.45);
  }
}

/* --------------------------------------------------------------- base ---- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Keep skip-link jumps and keyboard focus clear of the sticky header
     (WCAG 2.2 — 2.4.11 Focus Not Obscured). */
  scroll-padding-top: 5rem;
}

/* `main` is a programmatic focus target for the skip link (tabindex="-1");
   it should move focus but not show a control-style focus ring. */
main:focus {
  outline: none;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--fg-body);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--link);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

:where(a, button, input, select, textarea):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.skip-link {
  position: absolute;
  left: var(--space-3);
  top: -64px;
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: var(--radius-md);
  transition: top 150ms var(--ease-out);
}
.skip-link:focus {
  top: var(--space-3);
  text-decoration: none;
}

/* ------------------------------------------------------------ headings --- */

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--fg);
  line-height: var(--leading-snug);
  margin: 0 0 var(--space-4);
}
h1 {
  font-size: var(--text-3xl);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tighter);
}
h2 {
  font-size: var(--text-xl);
  letter-spacing: var(--tracking-tight);
  margin-top: var(--space-9);
}
h3 {
  font-size: var(--text-lg);
  margin-top: var(--space-7);
}

/* ------------------------------------------------------- layout / chrome - */

main {
  max-width: var(--container);
  margin: 0 auto;
  padding: var(--space-9) var(--space-5) var(--space-12);
  animation: fade-in-up 420ms var(--ease-out) both;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border-bottom: 1px solid var(--border);
}
.site-header .brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-xl);
  color: var(--fg);
  letter-spacing: 0;
}
.site-header .brand::before {
  content: "";
  width: 30px;
  height: 30px;
  border-radius: 10px;
  /* coral squircle with a 2x2 white dot grid — a calculator-keypad motif */
  background:
    radial-gradient(circle at 10px 10px, #fff 2.4px, transparent 2.9px),
    radial-gradient(circle at 20px 10px, #fff 2.4px, transparent 2.9px),
    radial-gradient(circle at 10px 20px, #fff 2.4px, transparent 2.9px),
    radial-gradient(circle at 20px 20px, #fff 2.4px, transparent 2.9px),
    linear-gradient(140deg, var(--accent-hover), var(--accent-press));
  box-shadow: var(--shadow-accent);
  transition: transform 220ms var(--ease-spring);
}
.site-header .brand:hover {
  text-decoration: none;
}
.site-header .brand:hover::before {
  transform: rotate(-6deg) scale(1.06);
}
.site-header nav {
  display: flex;
  gap: var(--space-2);
}
.site-header nav a {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-pill);
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 500;
  text-transform: capitalize;
}
.site-header nav a:hover {
  background: var(--surface);
  color: var(--fg);
  text-decoration: none;
}

.site-footer {
  max-width: var(--container);
  margin: var(--space-10) auto 0;
  padding: var(--space-6) var(--space-5);
  color: var(--muted);
  border-top: 1px solid var(--border);
  font-size: var(--text-sm);
}

/* --------------------------------------------------------- breadcrumb ---- */

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  margin-bottom: var(--space-5);
  font-size: var(--text-sm);
  color: var(--muted);
}
.breadcrumb a {
  color: var(--muted);
}
.breadcrumb a:hover {
  color: var(--fg);
}
.breadcrumb .sep {
  opacity: 0.5;
}
.breadcrumb [aria-current] {
  color: var(--fg);
  font-weight: 600;
}
.cap {
  text-transform: capitalize;
}

/* ----------------------------------------------------------- intro/lead -- */

.intro,
.lead {
  font-size: var(--text-lg);
  color: var(--fg-body);
  max-width: 60ch;
  margin: 0 0 var(--space-6);
}

/* ------------------------------------------------------------- callout --- */

.tool-disclaimer {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  margin: 0 0 var(--space-6);
  background: var(--warn-soft);
  border: 1px solid var(--warn-border);
  border-radius: var(--radius-md);
  color: var(--warn-text);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
}
.tool-disclaimer::before {
  content: "!";
  flex: none;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-pill);
  background: var(--warn-text);
  color: var(--warn-soft);
  font-weight: 700;
  font-size: var(--text-sm);
}
.tool-disclaimer strong {
  color: var(--warn-text);
}
.tool-disclaimer code {
  background: none;
  padding: 0;
  color: inherit;
  opacity: 0.8;
}

/* --------------------------------------------------------------- form ---- */

form.tool-form {
  display: grid;
  gap: var(--space-5);
  margin: 0 0 var(--space-7);
  padding: var(--space-6);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
form.tool-form .field {
  display: grid;
  gap: var(--space-2);
  margin: 0;
}
form.tool-form label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--fg);
}
form.tool-form input,
form.tool-form select {
  width: 100%;
  min-height: 44px;
  padding: 0 var(--space-4);
  font: inherit;
  color: var(--fg);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: inset 0 1px 2px rgba(28, 27, 34, 0.05);
  transition: border-color 120ms var(--ease-out),
    box-shadow 120ms var(--ease-out);
  appearance: none;
}
form.tool-form select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: var(--space-9);
}
form.tool-form input:hover,
form.tool-form select:hover {
  border-color: var(--accent);
}
form.tool-form input:focus,
form.tool-form select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0 var(--space-6);
  font: inherit;
  font-weight: 600;
  color: var(--accent-fg);
  background: linear-gradient(180deg, var(--accent-hover), var(--accent-press));
  border: 0;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-accent);
  cursor: pointer;
  transition: transform 220ms var(--ease-spring), box-shadow 160ms var(--ease-out),
    filter 120ms var(--ease-out);
}
button:hover,
.button:hover {
  transform: translateY(-2px) scale(1.02);
  filter: brightness(1.05);
  text-decoration: none;
}
button:active,
.button:active {
  transform: translateY(0) scale(0.97);
  filter: brightness(0.96);
}
form.tool-form button {
  justify-self: start;
}

/* ------------------------------------------------------------- result ---- */

.tool-result {
  margin: 0 0 var(--space-7);
  padding: var(--space-6);
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft-border);
  border-radius: var(--radius-lg);
}
.tool-result h2 {
  margin: 0 0 var(--space-4);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--link);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}
/* Hero number for single-value tools */
.tool-result strong {
  display: block;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-3xl);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tighter);
  color: var(--accent);
}
.result-range {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-4);
  margin: 0;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--accent-soft-border);
}
.result-range:last-of-type {
  border-bottom: 0;
}
.result-label {
  color: var(--muted);
  font-size: var(--text-sm);
}
.result-value {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--fg);
  letter-spacing: var(--tracking-tight);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.result-list {
  margin: 0;
}
.result-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-4);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--accent-soft-border);
}
.result-row:last-child {
  border-bottom: 0;
}
.result-row dt {
  color: var(--muted);
  font-size: var(--text-sm);
}
.result-row dd {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}
.result-unreachable {
  margin: 0;
  font-size: var(--text-base);
  color: var(--fg);
}
.result-note {
  margin: var(--space-4) 0 0;
  font-size: var(--text-sm);
  color: var(--warn-text);
}
.result-fineprint {
  margin: var(--space-4) 0 0;
  font-size: var(--text-xs);
  color: var(--muted);
}

/* ----------------------------------------------------- prose (MDX body) -- */

.prose {
  max-width: 65ch;
}
.prose p,
.prose li {
  color: var(--fg-body);
}
.prose p {
  margin: 0 0 var(--space-4);
}
.prose ul,
.prose ol {
  margin: 0 0 var(--space-4);
  padding-left: var(--space-6);
}
.prose li {
  margin: var(--space-2) 0;
}
.prose a {
  text-decoration: underline;
  text-underline-offset: 2px;
}
.prose code {
  font-size: 0.9em;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
}
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-4) 0;
  font-size: var(--text-sm);
}
.prose th,
.prose td {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}
.prose th {
  color: var(--fg);
  font-weight: 600;
}
.prose tr:hover td {
  background: var(--surface);
}

/* -------------------------------------------------------- related tools -- */

.related-tools {
  margin-top: var(--space-10);
  padding: var(--space-6);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.related-tools h2 {
  margin: 0 0 var(--space-4);
  font-size: var(--text-lg);
}
.related-tools ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-2);
}
.related-tools a {
  display: block;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--fg);
  font-weight: 500;
  transition: border-color 120ms var(--ease-out),
    transform 120ms var(--ease-out);
}
.related-tools a:hover {
  border-color: var(--accent);
  transform: translateX(2px);
  text-decoration: none;
}

/* ------------------------------------------------------------- home ------ */

.hero {
  padding: var(--space-8) 0 var(--space-7);
}
.hero h1 {
  max-width: 18ch;
}
.hero .lead {
  font-size: var(--text-xl);
}
.section-title {
  font-size: var(--text-lg);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  margin: var(--space-9) 0 var(--space-4);
}

.category-grid {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--space-7);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.category-grid a {
  display: inline-block;
  padding: var(--space-2) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--fg);
  font-size: var(--text-sm);
  font-weight: 500;
  text-transform: capitalize;
  transition: border-color 120ms var(--ease-out),
    transform 120ms var(--ease-out);
}
.category-grid a:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  text-decoration: none;
}

.tool-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: var(--space-3);
}
.tool-list li {
  padding: 0;
}
.tool-list a {
  display: block;
  padding: var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  color: var(--fg);
  font-weight: 600;
  transition: transform 160ms var(--ease-out),
    box-shadow 160ms var(--ease-out), border-color 160ms var(--ease-out);
}
.tool-list a:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
  text-decoration: none;
}
.tool-list a small {
  display: block;
  margin-top: var(--space-1);
  font-weight: 400;
  font-size: var(--text-sm);
  color: var(--muted);
}

/* ----------------------------------------------------------- sitemap ----- */

.sitemap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-5);
  margin-top: var(--space-7);
}
.sitemap-category {
  padding: var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}
.sitemap-category h2 {
  margin: 0 0 var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-lg);
  text-transform: capitalize;
  letter-spacing: var(--tracking-tight);
}
.sitemap-category h2 a {
  color: var(--fg);
}
.sitemap-category h2 small {
  font-weight: 400;
  font-size: var(--text-sm);
  color: var(--muted);
  text-transform: none;
}
.sitemap-category ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-1);
}
.sitemap-category li a {
  display: block;
  padding: var(--space-2) 0;
  font-size: var(--text-sm);
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-5);
}
.footer-nav a {
  color: var(--muted);
}
.footer-nav a:hover {
  color: var(--fg);
}

/* --------------------------------------------------------- responsive ---- */

@media (max-width: 640px) {
  :root {
    --text-3xl: 2rem;
    --text-2xl: 1.6rem;
  }
  main {
    padding: var(--space-7) var(--space-4) var(--space-10);
  }
  form.tool-form button {
    justify-self: stretch;
    width: 100%;
  }
  .result-range,
  .result-row {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-1);
  }
}

/* --------------------------------------------------------------- motion -- */

@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
