/* Craft Calculators — shared styles
   Look: "pattern envelope" on warm cream with coral buttons. Each craft has its own colour, shown as a soft tint with
   a darker ink of the same hue; catalog numbers and big figures use a tall condensed face.
   Layout: one centered column (max 1180px) with a 16px+ gutter; tool pages split
   into a form column and a sticky result panel on wide screens. */
:root {
  --bg: #fff7ee;
  --surface: #ffffff;
  --surface-2: #fcefe2;
  --line: #f1e0cd;
  --line-strong: #e6cdb3;
  --input-line: #a48b77; /* field outlines: 3:1 against white */
  --fg: #2a211c;
  --muted: #6a574a;
  --accent: #c2410c;
  --accent-hover: #9a330a;
  --accent-ink: #ffffff;
  --hero-bg: linear-gradient(120deg, #ffe3d3 0%, #ffd8e4 45%, #fff0c2 100%);
  --part-a: #e09a2a;
  --part-b: #2f8f8a;
  --cup: #d9c9b9;
  --warn-bg: #fff3dc;
  --warn-fg: #6b3d00;
  --warn-line: #e8b75c;
  --error: #b3261e;
  --live: #1f7a4d;

  /* craft colours: tint (band), ink (text on the tint), dot (small marker) */
  --resin-tint: #ffe4dd;  --resin-ink: #b33a24;  --resin-dot: #e2553c;
  --candle-tint: #fdf1c7; --candle-ink: #7d5a00; --candle-dot: #e9b52f;
  --quilt-tint: #e1e7ff;  --quilt-ink: #2a47b8;  --quilt-dot: #3a5bd6;
  --yarn-tint: #d8f1e6;   --yarn-ink: #18704f;   --yarn-dot: #2a9b72;
  --bake-tint: #efe4fb;   --bake-ink: #6a3a9e;   --bake-dot: #8a55c9;
  --sell-tint: #efe2d1;   --sell-ink: #6b4a2b;   --sell-dot: #a0774c; /* kraft paper, like a shipping box */
  --sew-tint: #d5f0f3;    --sew-ink: #0f6470;    --sew-dot: #1f9aab;
  --stitch-tint: #fde2ee; --stitch-ink: #a3245c; --stitch-dot: #d9488a;

  --font-display: "Big Shoulders Display", "Arial Narrow", "Helvetica Neue", sans-serif;
  --font-body: "Libre Franklin", "Helvetica Neue", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --step--1: 0.8125rem;
  --step-0: 1rem;
  --step-1: 1.1875rem;
  --step-2: 1.875rem;
  --step-3: clamp(2.5rem, 1.6rem + 3.6vw, 4.25rem);
  --radius: 14px;
  --radius-sm: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17130f;
    --surface: #211b16;
    --surface-2: #2c241d;
    --line: #3a3027;
    --line-strong: #4a3d31;
    --input-line: #7a6656;
    --fg: #f3ebe3;
    --muted: #bfae9f;
    --accent: #ff8a5c;
    --accent-hover: #ffa883;
    --accent-ink: #2a1206;
    --hero-bg: linear-gradient(120deg, #4a2a1c 0%, #45223a 45%, #453a18 100%);
    --part-a: #f0a53a;
    --part-b: #52b8bc;
    --cup: #54473c;
    --warn-bg: #2e2412;
    --warn-fg: #f5d39a;
    --warn-line: #8a6420;
    --error: #ff8a80;
    --live: #5fcf96;
    --resin-tint: #3b2420;  --resin-ink: #ffa592;
    --candle-tint: #3a3018; --candle-ink: #f3cf6b;
    --quilt-tint: #222c4f;  --quilt-ink: #a9bbff;
    --yarn-tint: #183528;   --yarn-ink: #7fd8b2;
    --bake-tint: #2f2442;   --bake-ink: #cfadf7;
    --sell-tint: #33271c;   --sell-ink: #e3c29a;
    --sew-tint: #12343a;    --sew-ink: #7fd6e2;
    --stitch-tint: #3d1d2c; --stitch-ink: #f6a6c8;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17130f;
  --surface: #211b16;
  --surface-2: #2c241d;
  --line: #3a3027;
  --line-strong: #4a3d31;
  --input-line: #7a6656;
  --fg: #f3ebe3;
  --muted: #bfae9f;
  --accent: #ff8a5c;
  --accent-hover: #ffa883;
  --accent-ink: #2a1206;
  --hero-bg: linear-gradient(120deg, #4a2a1c 0%, #45223a 45%, #453a18 100%);
  --part-a: #f0a53a;
  --part-b: #52b8bc;
  --cup: #54473c;
  --warn-bg: #2e2412;
  --warn-fg: #f5d39a;
  --warn-line: #8a6420;
  --error: #ff8a80;
  --live: #5fcf96;
  --resin-tint: #3b2420;  --resin-ink: #ffa592;
  --candle-tint: #3a3018; --candle-ink: #f3cf6b;
  --quilt-tint: #222c4f;  --quilt-ink: #a9bbff;
  --yarn-tint: #183528;   --yarn-ink: #7fd8b2;
  --bake-tint: #2f2442;   --bake-ink: #cfadf7;
  --sell-tint: #33271c;   --sell-ink: #e3c29a;
  --sew-tint: #12343a;    --sew-ink: #7fd6e2;
  --stitch-tint: #3d1d2c; --stitch-ink: #f6a6c8;
  color-scheme: dark;
}

/* Any element carrying data-craft picks up that craft's colours. */
[data-craft="resin"]  { --tint: var(--resin-tint);  --ink: var(--resin-ink);  --dot: var(--resin-dot); }
[data-craft="candle"] { --tint: var(--candle-tint); --ink: var(--candle-ink); --dot: var(--candle-dot); }
[data-craft="quilt"]  { --tint: var(--quilt-tint);  --ink: var(--quilt-ink);  --dot: var(--quilt-dot); }
[data-craft="yarn"]   { --tint: var(--yarn-tint);   --ink: var(--yarn-ink);   --dot: var(--yarn-dot); }
[data-craft="bake"]   { --tint: var(--bake-tint);   --ink: var(--bake-ink);   --dot: var(--bake-dot); }
[data-craft="sell"]   { --tint: var(--sell-tint);   --ink: var(--sell-ink);   --dot: var(--sell-dot); }
[data-craft="sew"]    { --tint: var(--sew-tint);    --ink: var(--sew-ink);    --dot: var(--sew-dot); }
[data-craft="stitch"] { --tint: var(--stitch-tint); --ink: var(--stitch-ink); --dot: var(--stitch-dot); }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { overflow-x: clip; } /* lets the color bands run edge to edge */
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.55;
}
img { max-width: 100%; }
a { color: var(--accent); text-underline-offset: 0.18em; }
a:hover { color: var(--accent-hover); text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.wrap {
  width: 100%;
  max-width: 1180px;
  margin-inline: auto;
  padding-inline: max(16px, 3vw);
}

/* ---------- site bar ---------- */
.site-bar { border-bottom: 1px solid var(--line); background: var(--surface); }
.site-bar .wrap {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  padding-block: 12px;
}
.wordmark { display: inline-flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--fg); }
.wordmark:hover { color: var(--fg); }
.wordmark-name {
  font-family: var(--font-display); font-weight: 900; font-size: 1.75rem; line-height: 1;
  letter-spacing: 0.03em; text-transform: uppercase;
}
.wordmark-strip { display: flex; gap: 3px; }
.wordmark-strip span { width: 22px; height: 5px; border-radius: 2px; }
.wordmark-strip span:nth-child(1) { background: var(--resin-dot); }
.wordmark-strip span:nth-child(2) { background: var(--candle-dot); }
.wordmark-strip span:nth-child(3) { background: var(--quilt-dot); }
.wordmark-strip span:nth-child(4) { background: var(--yarn-dot); }
.wordmark-strip span:nth-child(5) { background: var(--bake-dot); }
.wordmark-strip span:nth-child(6) { background: var(--sell-dot); }
.site-nav { align-items: center; display: flex; gap: 22px; font-size: 0.9375rem; }
.bar-end { display: flex; align-items: center; gap: 18px; }
.theme-toggle {
  display: inline-flex; align-items: center; gap: 7px; height: 40px; padding: 0 14px 0 11px;
  border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--fg);
  font: 600 0.875rem var(--font-body); cursor: pointer;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle svg { width: 19px; height: 19px; flex: none; }
.theme-toggle .i-sun, :root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
@media (max-width: 420px) { .theme-word { display: none; } .theme-toggle { padding: 0 10px; } }
.site-nav a { color: var(--fg); text-decoration: none; font-weight: 600; }
.site-nav a:hover { color: var(--accent); text-decoration: underline; }

/* ---------- type ---------- */
h1, h2 {
  font-family: var(--font-display);
  text-wrap: balance;
  margin: 0;
}
h1 { font-size: var(--step-3); font-weight: 800; line-height: 0.98; letter-spacing: 0.005em; }
h2 { font-size: var(--step-2); font-weight: 800; line-height: 1.05; }
h3 { font-family: var(--font-body); font-size: var(--step-1); font-weight: 700; line-height: 1.25; margin: 0; text-wrap: balance; }
.eyebrow {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}
.lede { font-size: var(--step-1); color: var(--muted); max-width: 60ch; margin: 0; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------- page intro ---------- */
.page-head { padding-block: 40px 28px; display: grid; gap: 14px; position: relative; }
.page-head::before {
  content: ""; position: absolute; z-index: -1; inset: 0 calc(50% - 50vw);
  background: linear-gradient(180deg, color-mix(in srgb, var(--tint, var(--surface-2)) 75%, var(--bg)) 0%, var(--bg) 100%);
}
.page-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.craft-tag {
  margin: 0; display: inline-flex; align-items: stretch;
  border-radius: 999px; overflow: hidden; background: var(--tint, var(--surface-2)); color: var(--ink, var(--muted));
  font-size: 0.8125rem; font-weight: 700;
}
.craft-tag a { color: inherit; text-decoration: none; }
.craft-tag a:hover { text-decoration: underline; }
.craft-tag > * { padding: 5px 12px; }
.craft-tag .craft-no {
  font-family: var(--font-display); font-weight: 900; font-size: 1rem; letter-spacing: 0.02em;
  border-left: 1px solid color-mix(in srgb, currentColor 25%, transparent);
}
.updated { margin: 0; font-size: var(--step--1); color: var(--muted); }

/* ---------- footer ---------- */
.site-foot {
  margin-top: 72px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: var(--step--1);
}
.site-foot .wrap {
  padding-block: 24px 40px;
  display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between;
}
.site-foot p { margin: 0; max-width: 60ch; }
.site-foot strong { color: var(--fg); }
.foot-main { display: grid; gap: 8px; }
.foot-links { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.foot-links a { color: var(--muted); font-weight: 600; text-decoration: none; }
.foot-links a:hover { color: var(--fg); text-decoration: underline; }

/* ---------- plain text pages (about, privacy) ---------- */
.prose { display: grid; gap: 28px; max-width: 70ch; padding-bottom: 8px; }
.prose section { display: grid; gap: 12px; }
.prose p { margin: 0; }
.prose ul { margin: 0; padding-left: 1.25em; display: grid; gap: 6px; }
.prose h2 { font-size: 1.625rem; }

/* ---------- tool cards (home page and "More calculators") ---------- */
.tool-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 16px;
}
.tool-grid > li { display: flex; min-width: 0; }
.tool-card {
  flex: 1 1 auto; min-width: 0;
  display: flex; flex-direction: column; text-decoration: none; color: var(--fg);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.tool-card:hover { color: var(--fg); border-color: var(--line-strong); box-shadow: 0 6px 18px rgb(70 45 25 / 0.08); transform: translateY(-1px); }
.tool-band {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  background: var(--tint); color: var(--ink); padding: 10px 14px;
}
.tool-craft { font-size: 0.8125rem; font-weight: 700; }
.tool-no { font-family: var(--font-display); font-weight: 900; font-size: 1.625rem; line-height: 1; }
.tool-body { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px 16px; flex: 1 1 auto; }
.tool-name { font-size: 1.0625rem; font-weight: 700; line-height: 1.25; }
.tool-sum { color: var(--muted); font-size: 0.9375rem; flex: 1 1 auto; }
.tool-open { margin-top: 6px; display: inline-flex; align-items: center; gap: 6px; font-size: 0.9375rem; font-weight: 700; color: var(--ink); }
.tool-open svg { width: 14px; height: 14px; }
.tool-card:hover .tool-open { text-decoration: underline; text-underline-offset: 0.18em; }

/* ---------- article content (shared by tool pages) ---------- */
.article { display: grid; gap: 44px; padding-top: 56px; }
.article section { display: grid; gap: 14px; max-width: 70ch; }
.article section.wide { max-width: none; }
.article p { margin: 0; }
.article ul:not(.tool-grid), .article ol { margin: 0; padding-left: 1.25em; display: grid; gap: 6px; }
.formula {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  overflow-x: auto;
  white-space: pre;
  font-size: 0.9375rem;
  line-height: 1.6;
}
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
table.data {
  border-collapse: collapse;
  width: 100%;
  font-variant-numeric: tabular-nums;
  font-size: 0.9375rem;
}
table.data th, table.data td { padding: 10px 14px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data thead th {
  font-weight: 700; font-size: 0.75rem;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
  background: var(--surface-2);
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td:first-child { font-weight: 700; }

.faq { display: grid; gap: 10px; }
.faq details {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 16px;
}
.faq summary {
  cursor: pointer;
  font-weight: 700;
  padding-block: 14px;
  list-style: none;
  display: flex; justify-content: space-between; gap: 16px; align-items: baseline;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-family: var(--font-display); font-weight: 800; font-size: 1.25rem; line-height: 1; color: var(--accent); flex: none; }
.faq details[open] summary::after { content: "−"; }
.faq details > p { margin: 0; padding-bottom: 16px; color: var(--fg); }

.not-found { padding-block: 64px; display: grid; gap: 14px; max-width: 60ch; }

/* ---------- calculator UI (shared by tool pages) ---------- */
.calc { display: grid; gap: 20px; align-items: start; }
@media (min-width: 880px) {
  .calc { grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr); }
  .results { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 16px); }
}
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; min-width: 0; box-shadow: 0 1px 2px rgb(70 45 25 / 0.04); }

/* inputs */
.inputs { display: grid; gap: 26px; }
.group { display: grid; gap: 10px; border: 0; margin: 0; padding: 0; min-width: 0; }
.group > legend {
  font-family: var(--font-body); font-weight: 700; font-size: 0.75rem; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted); padding: 0; margin: 0 0 10px;
}
.seg { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 12px; }
.seg label { flex: 1 1 0; min-width: max-content; position: relative; }
.seg input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.seg span {
  display: block; text-align: center; padding: 9px 12px; border-radius: 9px;
  font-weight: 600; font-size: 0.9375rem; color: var(--muted); white-space: nowrap;
}
.seg input:checked + span { background: var(--surface); color: var(--fg); font-weight: 700; box-shadow: 0 1px 3px rgb(70 45 25 / 0.12), inset 0 0 0 1px var(--input-line); }
.seg input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 1px; }
.seg label:hover span { color: var(--fg); }

.examples { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.examples .try { font-size: var(--step--1); color: var(--muted); margin-right: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font: 600 0.8125rem var(--font-body); padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--fg); cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }

.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: 14px; }
.field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.field > label, .field-label { font-weight: 700; font-size: 0.9375rem; }
.input-unit { display: flex; align-items: center; background: var(--surface); border: 1px solid var(--input-line); border-radius: var(--radius-sm); min-width: 0; }
.input-unit:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.input-unit.invalid { border-color: var(--error); box-shadow: 0 0 0 3px color-mix(in srgb, var(--error) 18%, transparent); }
.input-unit input, .input-unit select {
  flex: 1 1 auto; min-width: 0; width: 100%; border: 0; background: transparent; color: var(--fg);
  font: 600 1.0625rem var(--font-body); font-variant-numeric: tabular-nums; padding: 11px 12px;
}
.input-unit input:focus, .input-unit select:focus { outline: none; }
.input-unit select { flex: 0 0 auto; width: auto; border-left: 1px solid var(--line); font-size: 0.9375rem; cursor: pointer; }
.input-unit select:only-child { flex: 1 1 auto; width: 100%; min-width: 0; border-left: 0; }
/* The open dropdown list is drawn by the browser; give its options solid theme colors so the
   text never ends up light-on-white (Windows) or dark-on-dark. */
select option, select optgroup, .input-unit select option {
  background-color: var(--surface);
  color: var(--fg);
  font-family: var(--font-body);
  font-weight: 400;
}
.input-unit .unit { padding-right: 12px; color: var(--muted); font-size: 0.875rem; font-weight: 500; white-space: nowrap; }
.hint { margin: 0; font-size: var(--step--1); color: var(--muted); }

.range-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.range-head output { font-weight: 700; font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; accent-color: var(--accent); margin: 0; }
.advanced summary { cursor: pointer; color: var(--accent); font-size: var(--step--1); font-weight: 700; width: max-content; }
.advanced[open] summary { margin-bottom: 10px; }

/* results */
.results { display: grid; gap: 18px; }
.total { display: grid; gap: 4px; }
.total-main {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(2.5rem, 2rem + 2vw, 3.25rem); line-height: 1; font-variant-numeric: tabular-nums; margin: 4px 0 0;
}
.total-alt { color: var(--muted); font-size: 0.9375rem; font-variant-numeric: tabular-nums; margin: 0; }
.extra-note { font-size: var(--step--1); color: var(--muted); margin: 0; }
.calc-error { color: var(--error); font-weight: 700; margin: 0; }

.rows { display: grid; gap: 12px; margin: 0; }
.row { display: grid; grid-template-columns: 12px minmax(0, 1fr); gap: 1px 10px; }
.row dt { grid-column: 2; font-size: var(--step--1); color: var(--muted); font-weight: 700; }
.row dd { grid-column: 2; margin: 0; font-weight: 700; font-size: 1.0625rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.row .sub { display: block; font-weight: 400; font-size: 0.8125rem; color: var(--muted); }
.swatch { grid-column: 1; grid-row: 1 / span 2; width: 12px; height: 12px; border-radius: 3px; margin-top: 3px; }
.swatch.a { background: var(--part-a); }
.swatch.b { background: var(--part-b); }
.swatch.none { visibility: hidden; }

.notice { border: 1px solid var(--warn-line); background: var(--warn-bg); color: var(--warn-fg); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 0.9375rem; margin: 0; }
.tip { font-size: 0.9375rem; color: var(--muted); margin: 0; }
.tip strong { color: var(--fg); }
.actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-block-start: 16px; }
.btn {
  font: 700 0.9375rem var(--font-body);
  background: var(--surface); color: var(--fg); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 10px 16px; cursor: pointer;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.copy-status { font-size: var(--step--1); color: var(--live); font-weight: 700; }
.copy-fallback { width: 100%; min-height: 120px; font: 0.8125rem var(--font-mono); color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px; }

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