@font-face {
  font-family: "Instrument Sans";
  src: url("../fonts/InstrumentSans-Regular.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Sans";
  src: url("../fonts/InstrumentSans-Italic.woff") format("woff");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Sans";
  src: url("../fonts/InstrumentSans-SemiBold.woff") format("woff");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Serif";
  src: url("../fonts/InstrumentSerif-Regular.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Serif";
  src: url("../fonts/InstrumentSerif-Italic.woff") format("woff");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

:root {
  --bg: #f4f1ea;
  --ink: #1a1c16;
  --muted: #4a5046;
  --line: #d2ccbe;
  --card: #fffdf8;
  --accent: #2a3a30;
  --accent-soft: #e7efe8;
  --warn: #7a2e1f;
  --warn-bg: #f8ebe6;
  --ok: #2a3a30;
  --ok-bg: #e7efe8;
  --gold: #6b5226;
  --font: "Instrument Sans", "Segoe UI", system-ui, sans-serif;
  --serif: "Instrument Serif", Georgia, "Times New Roman", serif;
  --wrap: 1120px;
  --pad: clamp(1.25rem, 4vw, 2rem);
  --radius: 14px;
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; height: auto; }
a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -3.5rem;
  z-index: 20;
  background: var(--ink);
  color: #fffdf8;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  text-decoration: none;
}
.skip-link:focus { top: 0.75rem; }

.wrap {
  width: min(var(--wrap), 100% - var(--pad) * 2);
  margin-inline: auto;
}

.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4.25rem;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: inherit;
  font-family: var(--serif);
  font-size: 1.2rem;
}

.logo-mark { flex: none; }

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.92rem;
}
.nav-links a {
  color: var(--muted);
  text-decoration: none;
}
.nav-links a:hover,
.nav-links a[aria-current="page"] {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.hero { padding: clamp(2.75rem, 7vw, 5rem) 0 2rem; }

.eyebrow {
  margin: 0 0 0.85rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin: 0 0 0.85rem;
}

h1 { font-size: clamp(2.15rem, 5.4vw, 3.75rem); max-width: 18ch; }
h2 { font-size: clamp(1.7rem, 3vw, 2.15rem); }
h3 { font-size: 1.35rem; }

.lead {
  margin: 0;
  color: var(--muted);
  max-width: 42em;
  font-size: 1.125rem;
}

.section { padding: 1.5rem 0 3rem; }

.cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16.5rem, 1fr));
  gap: 1.15rem;
}

.card {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 1px 0 rgba(26, 28, 22, 0.04);
}
a.card:hover { border-color: #b9b3a4; }

.card img { width: 100%; aspect-ratio: 1200 / 630; object-fit: cover; background: #e8e3d8; }

.card-body { padding: 1.15rem 1.2rem 1.3rem; flex: 1; display: flex; flex-direction: column; }
.card-kicker {
  margin: 0 0 0.3rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
}
.card-body p { margin: 0 0 0.85rem; color: var(--muted); flex: 1; }
.card-link {
  font-weight: 600;
  color: var(--accent);
  font-size: 0.95rem;
}

.note {
  margin-top: 2rem;
  padding: 1rem 1.15rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  max-width: 46em;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(18rem, 0.85fr);
  gap: clamp(1.25rem, 3vw, 2.5rem);
  align-items: start;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.2rem 1.2rem 1.35rem;
}

.panel h2 { font-size: 1.55rem; }

.calc-form { display: grid; gap: 0.9rem; }

.field, .check, .field-row {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }

label, .legend {
  font-weight: 600;
  font-size: 0.92rem;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

input[type="text"],
input[type="number"],
select {
  font: inherit;
  color: inherit;
  background: #fff;
  border: 1px solid #c5bfb2;
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  width: 100%;
  min-height: 2.6rem;
}

input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--accent);
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 10px;
  margin: 0;
  padding: 0.85rem 0.9rem 1rem;
  display: grid;
  gap: 0.65rem;
}

legend { padding: 0 0.25rem; font-weight: 600; }

.cat-row, .ing-row {
  display: grid;
  gap: 0.5rem 0.65rem;
  align-items: end;
  padding: 0.45rem 0;
  border-top: 1px solid var(--line);
}
.cat-row { grid-template-columns: auto 1fr 6.5rem; }
.ing-row { grid-template-columns: 1.4fr 5.5rem 6.2rem 5.8rem 5.5rem 6.2rem auto; }
.ing-row .ing-name { grid-column: 1 / -2; }

.cat-row:first-of-type, .ing-row:first-of-type { border-top: 0; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.3rem;
}

button, .btn {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border-radius: 999px;
  padding: 0.55rem 1rem;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fffdf8;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.6rem;
}

button.secondary, a.btn.secondary {
  background: transparent;
  color: var(--ink);
}

button:hover, .btn:hover { opacity: 0.92; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.results { position: sticky; top: 1rem; }
.results h2 { margin-bottom: 0.35rem; }

.result-list, .result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
.result-table th, .result-table td {
  text-align: left;
  padding: 0.45rem 0.3rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.result-table th:nth-child(n+2),
.result-table td:nth-child(n+2),
.result-table td.num, .num { text-align: right; font-variant-numeric: tabular-nums; }
.result-table tfoot td { font-weight: 600; border-bottom: 0; }

.totals {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}
.totals li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
  padding: 0.35rem 0;
}
.totals .value { font-variant-numeric: tabular-nums; font-weight: 600; }

.flag {
  margin: 0 0 0.85rem;
  padding: 0.7rem 0.8rem;
  border-radius: 10px;
  background: var(--ok-bg);
  color: var(--ok);
}
.flag.warn { background: var(--warn-bg); color: var(--warn); }
.flag[hidden] { display: none; }

.error {
  color: var(--warn);
  margin: 0;
  font-size: 0.92rem;
}

.bar {
  height: 0.55rem;
  background: #ece7dc;
  border-radius: 999px;
  overflow: hidden;
  display: flex;
}
.bar > span { display: block; height: 100%; }
.bar .needs { background: #2a3a30; }
.bar .wants { background: #6b5226; }
.bar .savings { background: #5b7a68; }

.article, .faq, .cta, .related {
  padding: 0.5rem 0 2.25rem;
}

.article {
  max-width: 42.5rem;
}
.article p, .article li { color: var(--ink); }
.article p { margin: 0 0 1rem; }
.article ul, .article ol { margin: 0 0 1rem; padding-left: 1.2rem; }
.article li { margin: 0 0 0.4rem; }

.faq { max-width: 46rem; }
.faq h2 { margin-bottom: 1rem; }
details {
  border-top: 1px solid var(--line);
  padding: 0.7rem 0;
}
details:last-of-type { border-bottom: 1px solid var(--line); }
summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.15rem 0;
}
details p { margin: 0.5rem 0 0.25rem; color: var(--muted); }

.cta-box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.3rem 1.35rem;
  max-width: 46rem;
}
.cta-box p:last-child { margin-bottom: 0; }
.cta-box .btn { margin: 0.4rem 0 0.8rem; }

.related .cards { grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }

.site-footer {
  border-top: 1px solid var(--line);
  padding: 1.75rem 0 2.5rem;
  color: var(--muted);
  font-size: 0.92rem;
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  justify-content: space-between;
}
.footer-links { display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem; }
.footer-links a { color: var(--muted); }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .results { position: static; }
  .header-inner { flex-wrap: wrap; padding: 0.6rem 0; }
  .ing-row {
    grid-template-columns: 1fr 1fr;
  }
  .ing-row .ing-name { grid-column: 1 / -1; }
}

@media (max-width: 560px) {
  .field-row, .cat-row { grid-template-columns: 1fr; }
  .cat-row { grid-template-columns: auto 1fr; }
  .cat-row .pct { grid-column: 2; }
  h1 { max-width: none; }
}

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

@media print {
  .site-header, .site-footer, .cta, .related, .skip-link, .actions button.secondary {
    display: none;
  }
  body { background: #fff; }
  .panel, .cta-box, .card { box-shadow: none; }
  .results { position: static; }
}
