/* ===== 1. tokens, reset, base type ===== */
:root {
  --bg: #fbf8f2;
  --surface: #ffffff;
  --text: #1f2a24;
  --muted: #6b7770;
  --primary: #0e4b3c;
  --primary-deep: #0a382d;
  --accent: #c2673a;
  --line: rgb(31 42 36 / .12);
  --line-strong: rgb(31 42 36 / .28);
  --radius: 8px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --fs-xs: 12px;
  --fs-sm: 14px;
  --fs-base: 17px;
  --fs-md: 20px;
  --fs-lg: 26px;
  --fs-xl: 34px;
  --fs-2xl: 44px;
  --shadow-1: 0 1px 2px rgb(31 42 36 / .06);
  --shadow-2: 0 8px 24px rgb(31 42 36 / .08);
  --font-title: "Fraunces", Georgia, serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

h1, h2, h3 {
  font-family: var(--font-title);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.015em;
  text-wrap: balance;
  margin: 0 0 var(--space-3);
}

h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); margin-top: var(--space-7); }
h3 { font-size: var(--fs-md); margin-top: var(--space-6); }

p { margin: 0 0 var(--space-4); text-wrap: pretty; }
ul, ol { margin: 0 0 var(--space-4); padding-left: var(--space-5); }
li { margin-bottom: var(--space-2); }

img { max-width: 100%; height: auto; display: block; }

a { color: var(--primary); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--primary-deep); }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 2px; }
::selection { background: rgb(14 75 60 / .14); }

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--primary); color: var(--surface);
  padding: var(--space-3) var(--space-4); z-index: 20;
}
.skip-link:focus { left: var(--space-4); top: var(--space-4); }

.wrap {
  width: 100%;
  max-width: 1120px;
  margin-inline: auto;
  padding-inline: var(--space-5);
}

.page { padding-block: var(--space-7) var(--space-8); }
.page-narrow { max-width: 780px; }


/* ===== 2. header, footer, hero ===== */
.site-head {
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.head-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  min-height: 68px;
  padding-block: var(--space-3);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  color: var(--text);
}
.brand-mark {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  background: var(--primary);
  color: var(--surface);
  border-radius: var(--radius);
  font-family: var(--font-title);
  font-size: var(--fs-sm);
  line-height: 1;
}
.brand-name {
  font-family: var(--font-title);
  font-size: var(--fs-md);
  letter-spacing: -0.01em;
}
.nav { display: flex; flex-wrap: wrap; gap: var(--space-4); }
.nav a {
  color: var(--text);
  opacity: 0.74;
  text-decoration: none;
  font-size: var(--fs-sm);
  font-weight: 500;
  transition: color 160ms ease, opacity 160ms ease;
}
.nav a:hover { color: var(--primary); opacity: 1; }
.calculator-menu { display: none; }

[data-page-path="/"] .nav a[href="/"],
[data-page-path="/paypal-fee-calculator"] .nav a[href="/paypal-fee-calculator"],
[data-page-path="/stripe-fee-calculator"] .nav a[href="/stripe-fee-calculator"],
[data-page-path="/etsy-fee-calculator"] .nav a[href="/etsy-fee-calculator"],
[data-page-path="/shopify-fee-calculator"] .nav a[href="/shopify-fee-calculator"] {
  color: var(--primary);
  opacity: 1;
  text-decoration: underline;
  text-underline-offset: 6px;
  text-decoration-thickness: 2px;
}

.hero { padding-block: var(--space-6) var(--space-5); max-width: 760px; }
.hero-plain { padding-bottom: var(--space-4); }
.eyebrow {
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--space-3);
}
.hero h1 { font-size: var(--fs-2xl); margin-bottom: var(--space-4); }
.lede { font-size: var(--fs-md); color: var(--muted); line-height: 1.5; margin-bottom: 0; }

.site-foot {
  border-top: 1px solid var(--line);
  margin-top: var(--space-8);
  padding-block: var(--space-7) var(--space-5);
  background: var(--surface);
}
.foot-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr;
  gap: var(--space-6);
}
.foot-brand {
  font-family: var(--font-title);
  font-size: var(--fs-md);
  margin-bottom: var(--space-2);
}
.foot-note { font-size: var(--fs-sm); color: var(--muted); max-width: 46ch; }
.foot-title {
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: var(--space-3);
}
.foot-list { list-style: none; padding: 0; margin: 0; }
.foot-list li { margin-bottom: var(--space-2); }
.foot-list a { color: var(--text); text-decoration: none; font-size: var(--fs-sm); }
.foot-list a:hover { color: var(--primary); text-decoration: underline; }
.foot-bottom {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--line);
  font-size: var(--fs-xs);
  color: var(--muted);
}


/* ===== 3. calculator shell, form, receipt ===== */
.calculator-page { padding-block-start: var(--space-6); }
.calculator-hero { padding: 0 0 var(--space-5); }
.calculator-hero h1 { margin-bottom: var(--space-2); }
.calculator-hero .lede { font-size: var(--fs-base); }

.calc-shell {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  padding: var(--space-5);
  margin-bottom: var(--space-7);
}

.calc [hidden] { display: none !important; }
.calc-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  grid-template-rows: max-content 1fr;
  grid-template-areas: "core result" "options result";
  column-gap: var(--space-6);
  row-gap: var(--space-3);
  align-items: start;
}
.calc-core { grid-area: core; }
.calc-result { grid-area: result; }
.calc-options { grid-area: options; }
.calc-order-options { grid-area: order-options; }
.calc-grid > * { min-width: 0; }
.calc-grid--shopify {
  grid-template-areas: "core result" "order-options result" "options result";
  grid-template-rows: max-content max-content 1fr;
}

@media (min-width: 1000px) {
  .calc-grid--three {
    grid-template-columns: minmax(0, .92fr) minmax(0, 1.13fr) minmax(0, 1fr);
    grid-template-areas: "core options result";
    grid-template-rows: auto;
    column-gap: var(--space-5);
  }
  .calc-grid--three > .calc-options {
    padding-inline-start: var(--space-5);
    border-inline-start: 1px solid var(--line);
    align-self: stretch;
  }
  .calc-grid--shopify {
    grid-template-areas: "core options result" "order-options options result";
    grid-template-rows: max-content 1fr;
  }
  .calc-grid--three .calc-extra[data-wide-open] { border-top: 0; }
  .calc-grid--three .calc-extra[data-wide-open] > summary {
    align-items: flex-start;
    padding-block: 0 var(--space-1);
  }
  .calc-grid--three .calc-extra[data-wide-open] > summary::before { margin-top: 8px; }
  .calc-grid--three .calc-extra[data-wide-open] > summary > span:first-child {
    font-family: var(--font-title);
    font-size: var(--fs-md);
    line-height: 1.2;
  }
  .calc-grid--three .calc-extra[data-wide-open] > .calc-disclosure-body { padding-block-start: 0; }
  .calc-grid--three .calc-extra[data-wide-open][open] > summary > .calc-options-summary { display: none; }
}

.calc-group-title, .calc-section-title {
  font-family: var(--font-title);
  font-size: var(--fs-md);
  font-weight: 600;
  line-height: 1.2;
  margin: 0 0 var(--space-4);
}
.calc-note, .receipt-foot {
  font-size: var(--fs-xs);
  color: var(--muted);
  margin: var(--space-2) 0 0;
}
.receipt-foot:empty { display: none; }
.field { margin-bottom: var(--space-3); min-width: 0; }
.field:last-child { margin-bottom: 0; }
.field label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: var(--space-2);
}
.field .hint, .calc-check .hint { color: var(--muted); font-weight: 400; font-size: var(--fs-xs); }
.calc-error { color: #8e3d22; font-size: var(--fs-sm); line-height: 1.4; margin: var(--space-2) 0 0; }
.input-wrap:has([aria-invalid="true"]) { border-color: #8e3d22; }
.calc-field-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.calc-field-pair > .field { margin: 0; }
.calc-field-pair:last-child { margin-bottom: 0; }

.input-wrap {
  display: flex;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.input-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgb(14 75 60 / .12);
}
.input-affix {
  display: inline-flex;
  align-items: center;
  align-self: stretch;
  padding-inline: var(--space-2);
  color: var(--muted);
  font-size: var(--fs-sm);
}
.input-wrap input, .input-wrap select {
  flex: 1;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: max(16px, var(--fs-base));
  font-variant-numeric: tabular-nums;
  color: var(--text);
  padding: var(--space-2) var(--space-2) var(--space-2) 0;
  outline: none;
}
.input-wrap > select, .input-wrap > input:first-child { padding-inline-start: var(--space-3); }
.input-wrap > select { text-overflow: ellipsis; }

.calc-disclosure { border-top: 1px solid var(--line); }
.calc-disclosure > summary, .calculator-menu > summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: var(--space-2);
  min-height: 44px;
  padding-block: var(--space-2);
  cursor: pointer;
  list-style: none;
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.35;
}
.calc-disclosure > summary::-webkit-details-marker,
.calculator-menu > summary::-webkit-details-marker { display: none; }
.calc-disclosure > summary::before, .calculator-menu > summary::after {
  content: "";
  flex: none;
  width: 7px;
  height: 7px;
  border: solid var(--primary);
  border-width: 0 1.5px 1.5px 0;
  transform: translateY(-2px) rotate(45deg);
}
.calc-disclosure[open] > summary::before, .calculator-menu[open] > summary::after {
  transform: translateY(2px) rotate(225deg);
}
.calc-disclosure > summary .calc-section-title { margin: 0; }
.calc-options-summary {
  flex-basis: 100%;
  padding-inline-start: 15px;
  color: var(--muted);
  font: 400 var(--fs-xs) / 1.45 var(--font-body);
  overflow-wrap: anywhere;
}
.calc-options-summary:empty { display: none; }
.calc-disclosure-body { padding-block: var(--space-2) var(--space-1); }
.calc-check {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-size: var(--fs-sm);
  line-height: 1.35;
  cursor: pointer;
}
.calc-check:focus-within { border-color: var(--primary); }
.calc-check input { width: 17px; height: 17px; margin: 0; accent-color: var(--primary); }
.calc-check .hint { white-space: nowrap; }

.receipt {
  background: var(--bg);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: var(--space-5);
}
.receipt-head {
  font-family: var(--font-title);
  font-size: var(--fs-md);
  font-weight: 600;
  line-height: 1.2;
  margin: 0 0 var(--space-2);
}
.receipt-amount {
  font-family: var(--font-title);
  font-size: clamp(2.35rem, 5vw, 3.4rem);
  font-weight: 700;
  line-height: 1;
  color: var(--primary);
  margin: 0 0 var(--space-4);
  overflow-wrap: anywhere;
}
.receipt-lines, .receipt-summary, .receipt-fees { margin: 0; }
.receipt-summary, .receipt-fees { border-top: 1px dashed var(--line-strong); }
.rline {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-3);
  padding-block: var(--space-2);
  border-bottom: 1px dotted var(--line-strong);
  font-size: var(--fs-sm);
  line-height: 1.35;
}
.rline:last-child { border-bottom: 0; }
.rline dt { color: var(--muted); margin: 0; }
.rline dd { margin: 0; font-weight: 600; text-align: right; }
.rline.is-deduct dd, .receipt-fee dd { color: var(--accent); }
.receipt-profit dt, .receipt-profit dd { color: var(--primary); font-weight: 600; }
.receipt-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-3);
  border-top: 1px solid var(--line-strong);
  margin-top: var(--space-2);
  padding-top: var(--space-2);
  font-size: var(--fs-sm);
}
.receipt-total strong { color: var(--primary); font-family: var(--font-title); font-size: var(--fs-md); }
.receipt-detail { margin-top: var(--space-3); }
.receipt-detail > summary { color: var(--primary); }
.calc-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  font: 600 var(--fs-sm) var(--font-body);
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.calc-link + .receipt-detail { margin-top: 0; }

@media (min-width: 761px) and (min-height: 600px) {
  .calc-result:not(:has(.receipt-detail[open])) {
    position: sticky;
    top: 84px;
  }
}

/* ===== 4. prose, tables, faq, cross links, mobile ===== */
.prose { max-width: 72ch; }
.prose h2 { padding-top: var(--space-5); margin-top: var(--space-8); }
.prose h2:first-child { margin-top: var(--space-5); }
.prose strong { font-weight: 600; }
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 var(--space-5);
  font-size: var(--fs-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
.prose thead th {
  text-align: left;
  font-weight: 600;
  font-size: var(--fs-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
  padding: var(--space-3);
  background: var(--bg);
  border-bottom: 1px solid var(--line-strong);
}
.prose tbody td {
  padding: var(--space-3);
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.prose tbody tr:last-child td { border-bottom: 0; }
.prose td:last-child, .prose th:last-child { text-align: right; }

.prose details {
  border-bottom: 1px solid var(--line);
  padding-block: var(--space-4);
}
.prose details:first-of-type { border-top: 1px solid var(--line); }
.prose summary {
  cursor: pointer;
  font-weight: 600;
  font-size: var(--fs-base);
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
}
.prose summary::-webkit-details-marker { display: none; }
.prose summary::after {
  content: "+";
  color: var(--accent);
  font-family: var(--font-body);
  font-weight: 400;
  font-size: var(--fs-md);
  line-height: 1;
}
.prose details[open] summary::after { content: "\2212"; }
.prose details p { margin: var(--space-3) 0 0; color: var(--muted); }

.prose .formula {
  background: var(--surface);
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: var(--space-4) var(--space-5);
  margin: 0 0 var(--space-5);
  font-size: var(--fs-sm);
}

.cross-links {
  margin-top: var(--space-7);
  padding-top: var(--space-5);
  border-top: 1px solid var(--line);
}
.cross-title {
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: var(--space-3);
}
.cross-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-5);
}
.cross-list a { font-size: var(--fs-sm); }

@media (max-width: 860px) {
  .foot-grid { grid-template-columns: 1fr 1fr; }
  .foot-about { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  .calc-grid, .calc-grid--shopify {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    grid-template-areas: "core" "result" "options";
    row-gap: var(--space-4);
  }
  .calc-grid--shopify { grid-template-areas: "core" "result" "options" "order-options"; }
}

@media (max-width: 640px) {
  :root { --fs-2xl: 30px; --fs-xl: 27px; --fs-lg: 22px; }
  .wrap { padding-inline: var(--space-4); }
  .head-inner { min-height: 58px; padding-block: var(--space-1); gap: var(--space-2); }
  .brand { gap: var(--space-2); min-width: 0; }
  .brand-mark { flex: none; width: 26px; height: 26px; }
  .brand-name { font-size: 16px; line-height: 1.15; }
  .head-inner > .nav { display: none; }
  .calculator-menu { display: block; position: relative; flex: none; }
  .calculator-menu > summary { padding-inline: var(--space-2); }
  .calculator-menu nav {
    display: grid;
    position: absolute;
    right: 0;
    min-width: 138px;
    padding: var(--space-1);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-2);
  }
  .calculator-menu a {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding-inline: var(--space-3);
    color: var(--text);
    font-size: var(--fs-sm);
  }
  .page { padding-block: var(--space-5) var(--space-7); }
  .calculator-page { padding-block-start: var(--space-4); }
  .hero { padding-block: var(--space-4) var(--space-4); }
  .calculator-hero { padding-block: 0 var(--space-4); }
  .hero h1 { font-size: 26px; margin-bottom: var(--space-3); }
  .calculator-hero h1 { margin-bottom: var(--space-1); }
  .lede { font-size: var(--fs-base); line-height: 1.45; }
  .calculator-hero .lede { font-size: var(--fs-sm); }
  .calc-shell { margin-bottom: var(--space-5); padding: var(--space-4); }
  .receipt { padding: var(--space-4); }
  .receipt-amount { margin-bottom: var(--space-3); }
  .site-head { position: relative; }
  .prose table { display: block; overflow-x: auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}


.rate-comparison {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
  align-items: start;
}

@media (max-width: 720px) {
  .rate-comparison { grid-template-columns: minmax(0, 1fr); }
}

/* Long-form tables on small screens: scroll instead of clipping */
@media (max-width: 720px) {
  .prose table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .prose table th,
  .prose table td {
    min-width: 7rem;
  }

  body[data-page-path="/payment-fee-calculator"] .prose table:first-of-type td:last-child,
  body[data-page-path="/payment-fee-calculator"] .prose table:nth-of-type(2) td:nth-child(2) {
    min-width: 13rem;
  }

  .calc-grid--three {
    display: flex;
    flex-direction: column;
    gap: 20px;
  }
}


/* Long-form table rhythm and mobile calculator spacing */
.prose table {
  width: 100%;
}

.prose table th,
.prose table td {
  padding: 10px 14px;
}

@media (max-width: 720px) {
  .calc-result {
    margin-top: 28px;
  }

  .calculator-hero h1 {
    font-size: 28px;
    line-height: 1.2;
  }

  .prose table th:first-child,
  .prose table td:first-child {
    position: sticky;
    left: 0;
    background: #fff;
  }
}
