/* PinchMath — shared styles. Mobile-first, no external fonts (fast = better SEO). */
:root {
  --bg: #fbf8f3;
  --surface: #ffffff;
  --ink: #1f2a24;
  --muted: #5d6b63;
  --line: #e7e1d6;
  --accent: #2f6b4f;
  --accent-ink: #ffffff;
  --accent-soft: #e6f0ea;
  --warm: #c8553d;
  --warm-soft: #fbeae5;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(31, 42, 36, .06), 0 6px 24px rgba(31, 42, 36, .06);
  --max: 1080px;
  --font: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-head: ui-serif, Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
}
img { max-width: 100%; height: auto; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: #224f3a; }
h1, h2, h3 { font-family: var(--font-head); line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.9rem, 4.5vw, 2.7rem); margin: 0 0 .4em; }
h2 { font-size: 1.5rem; margin: 2em 0 .6em; }
h3 { font-size: 1.15rem; margin: 1.6em 0 .4em; }
p { margin: 0 0 1em; }

.wrap { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 20px; }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 700; font-size: 1.15rem; }
.logo-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: #fff; display: grid; place-items: center; font-family: var(--font-head); font-size: 1.1rem; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
@media (max-width: 619px) {
  .site-header .wrap { padding-top: 10px; gap: 6px; }
  .nav { flex-wrap: nowrap; overflow-x: auto; width: calc(100% + 40px); margin: 0 -20px; padding: 0 16px 8px; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { white-space: nowrap; }
}
.nav a { text-decoration: none; color: var(--muted); font-size: .92rem; padding: 6px 10px; border-radius: 8px; }
.nav a:hover, .nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }

/* Hero */
.hero { padding: 48px 0 24px; }
.hero p.lead { font-size: 1.15rem; color: var(--muted); max-width: 640px; }
.crumbs { font-size: .85rem; color: var(--muted); margin: 20px 0 0; }
.crumbs a { color: var(--muted); }

/* Tool grid (home) */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin: 24px 0 40px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; text-decoration: none; color: var(--ink); box-shadow: var(--shadow); transition: transform .15s ease, border-color .15s ease; display: flex; flex-direction: column; gap: 6px; }
.card:hover { transform: translateY(-2px); border-color: var(--accent); color: var(--ink); }
.card .icon { font-size: 1.6rem; }
.card h2 { font-size: 1.15rem; margin: 4px 0 0; }
.card p { color: var(--muted); font-size: .95rem; margin: 0; }
.badge { display: inline-block; align-self: flex-start; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--warm); background: var(--warm-soft); padding: 2px 8px; border-radius: 999px; }

/* Layout with sidebar ad slot on desktop */
.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 32px; padding-bottom: 48px; }
@media (min-width: 960px) { .layout { grid-template-columns: minmax(0, 1fr) 300px; } }
.sidebar { display: none; }
@media (min-width: 960px) { .sidebar { display: block; } .sidebar .ad-slot { position: sticky; top: 20px; min-height: 600px; } }

/* Tool box */
.tool { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.row { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 620px) { .row.cols-2 { grid-template-columns: 1fr 1fr; } .row.cols-3 { grid-template-columns: 1fr 1fr 1fr; } }
label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 6px; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink);
  background: #fff; border: 1.5px solid var(--line); border-radius: 10px; padding: 11px 12px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { min-height: 180px; resize: vertical; line-height: 1.5; }
.row > div { min-width: 0; }
.seg { display: inline-flex; flex-wrap: wrap; max-width: 100%; background: var(--bg); border: 1.5px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { font: inherit; font-size: .92rem; border: 0; background: transparent; padding: 8px 14px; border-radius: 8px; cursor: pointer; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.btn { font: inherit; font-weight: 600; border: 0; background: var(--accent); color: var(--accent-ink); padding: 11px 18px; border-radius: 10px; cursor: pointer; }
.btn:hover { background: #224f3a; }
.btn.ghost { background: transparent; color: var(--accent); border: 1.5px solid var(--line); }
.btn.ghost:hover { border-color: var(--accent); background: var(--accent-soft); }
.btn.small { padding: 6px 12px; font-size: .88rem; }

.result { margin-top: 18px; background: var(--accent-soft); border-radius: 12px; padding: 18px; }
.result .big { font-family: var(--font-head); font-size: clamp(1.7rem, 5vw, 2.3rem); font-weight: 700; color: var(--accent); line-height: 1.15; }
.result .sub { color: var(--muted); font-size: .95rem; margin-top: 4px; }
.result.warn { background: var(--warm-soft); }
.result.warn .big { color: var(--warm); }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 12px; }
@media (min-width: 620px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: #fff; border-radius: 10px; padding: 12px; text-align: center; }
.stat b { display: block; font-size: 1.35rem; color: var(--ink); }
.stat span { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

.note { font-size: .88rem; color: var(--muted); margin-top: 12px; }
.hint { font-size: .85rem; color: var(--muted); margin-top: 6px; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 12px 0 20px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); }
th { background: var(--bg); font-weight: 700; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Macro calculator ingredient rows */
.ing-row { display: grid; grid-template-columns: minmax(0, 1fr) 96px 40px; gap: 8px; align-items: center; margin-bottom: 8px; }
.ing-row .x { border: 0; background: transparent; font-size: 1.3rem; color: var(--muted); cursor: pointer; border-radius: 8px; height: 44px; }
.ing-row .x:hover { background: var(--warm-soft); color: var(--warm); }

/* Scaled output */
.out-list { list-style: none; margin: 0; padding: 0; }
.out-list li { padding: 8px 0; border-bottom: 1px dashed var(--line); }
.out-list li:last-child { border-bottom: 0; }
.out-list .q { font-weight: 700; color: var(--accent); }

/* Content */
.content { max-width: 720px; }
.content ul, .content ol { padding-left: 1.3em; }
.content li { margin-bottom: .35em; }
.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; }
.faq summary { font-weight: 700; cursor: pointer; }
.faq details p { margin: 10px 0 0; color: var(--muted); }
.related { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 0; }
.related a { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; text-decoration: none; font-size: .92rem; }
.related a:hover { border-color: var(--accent); }

/* Ad slots — placeholders until AdSense is approved. Reserve space to avoid layout shift (CLS). */
.ad-slot { display: flex; align-items: center; justify-content: center; min-height: 120px; margin: 28px 0; border: 1.5px dashed var(--line); border-radius: 12px; color: #b3aa9b; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; }
body:not(.ads) .ad-slot { display: none !important; }
.ad-slot:empty::before { content: "Advertisement"; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding: 28px 0; font-size: .9rem; color: var(--muted); }
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; }
.site-footer nav a { color: var(--muted); margin-right: 14px; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
