/* Tractor Plan Builder: "home workshop magazine" look. See ../../BRAND.md.
   Newsprint paper, one red spot colour plus mustard, condensed headlines, typewriter callouts.
   System fonts only: fast, private, no outside requests. Controls on the left, the plan on the
   right; on a phone they stack. */
:root {
  --paper: #f2e8d2; --paper-2: #fbf5e6; --ink: #1f1a14; --ink-2: #5a4e40;
  --red: #b3261e; --red-ink: #fff8ec; --mustard: #e9b949; --rule: #b9a98a;
  --display: Impact, Haettenschweiler, "Arial Narrow Bold", "Arial Narrow", "Liberation Sans Narrow", "Nimbus Sans Narrow", sans-serif;
  --serif: Rockwell, "Roboto Slab", "Zilla Slab", Georgia, "Times New Roman", serif;
  --type: "Courier Prime", "Courier New", Courier, ui-monospace, monospace;
  color-scheme: light;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .12 0 0 0 0 .1 0 0 0 0 .08 0 0 0 .14 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --mottle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='520' height='520'%3E%3Cfilter id='m'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.012' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .32 0 0 0 0 .15 0 0 0 .16 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23m)'/%3E%3C/svg%3E");
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  color: var(--ink); font-family: var(--serif); font-size: 17px; line-height: 1.5;
  background-color: var(--paper);
  /* newsprint: fine paper grain, soft mottling, and a faint halftone. All drawn here, nothing downloaded. */
  background-image: var(--grain), var(--mottle), radial-gradient(rgba(31, 26, 20, .07) 1px, transparent 1.3px);
  background-size: 180px 180px, 520px 520px, 6px 6px;
}
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px 48px; }

/* ---- Masthead ---------------------------------------------------------------------------- */
.masthead { position: relative; margin: 0 -16px 22px; padding: 14px 16px 18px; background: var(--grain) var(--paper-2); background-size: 180px 180px; border-bottom: 6px double var(--ink); }
.kicker {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 16px; margin: 0 0 6px;
  font-family: var(--type); font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  border-bottom: 2px solid var(--ink); padding-bottom: 4px;
}
/* Title: ink on paper with a mustard offset, over a heavy red halftone bar. Deliberately not
   light lettering on a solid red block, which is a real magazine's trademark look. */
h1 {
  margin: 0; padding: 4px 0 12px; color: var(--ink); text-wrap: balance;
  font-family: var(--display); font-weight: 900; font-stretch: condensed; text-transform: uppercase;
  font-size: clamp(38px, 8vw, 76px); line-height: .95; letter-spacing: .01em;
  text-shadow: 3px 3px 0 var(--mustard);
}
h1::after {
  content: ""; display: block; height: 14px; margin-top: 10px;
  background-color: var(--red);
  background-image: radial-gradient(rgba(0, 0, 0, .25) 1.2px, transparent 1.6px);
  background-size: 6px 6px;
}
.mast-body { display: grid; grid-template-columns: 1fr minmax(280px, 44%); gap: 8px 20px; align-items: center; }
.mast-hero { display: block; width: 100%; height: auto; }
.mast-hen { display: none; }
@media (max-width: 820px) {
  .mast-body { grid-template-columns: 1fr 84px; }
  .mast-hero { display: none; }
  .mast-hen { display: block; width: 84px; height: auto; }
}
.spot { width: 54px; height: auto; margin: -8px 0 -6px 4px; }
.colophon img { width: 110px; height: auto; margin-bottom: 4px; }
.deck { margin: 10px 0 0; max-width: 62ch; font-size: 18px; font-style: italic; }

/* ---- Layout ------------------------------------------------------------------------------- */
.grid { display: grid; grid-template-columns: 310px 1fr; gap: 22px; align-items: start; }
@media (max-width: 820px) { .grid { grid-template-columns: 1fr; } }
.panel { background: var(--grain) var(--paper-2); background-size: 180px 180px; border: 2px solid var(--ink); padding: 16px; box-shadow: 4px 4px 0 var(--ink); }
.controls { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 12px; }
@media (max-width: 820px) { .controls { position: static; } }
.form-title { margin: -16px -16px 0; padding: 8px 16px; border-bottom: 0; display: block; background: var(--ink); color: var(--paper-2); font-family: var(--display); font-weight: 900; font-stretch: condensed; text-transform: uppercase; font-size: 22px; letter-spacing: .03em; }
#tpl-inputs { display: flex; flex-direction: column; gap: 14px; }
#tpl-inputs:empty { display: none; }
.sheet { display: flex; flex-direction: column; gap: 22px; min-width: 0; }

/* ---- Headings ----------------------------------------------------------------------------- */
h2 {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; margin: 0 0 12px; padding-bottom: 6px;
  border-bottom: 4px double var(--ink);
  font-family: var(--display); font-weight: 900; font-stretch: condensed; text-transform: uppercase;
  font-size: 26px; line-height: 1; letter-spacing: .02em; text-wrap: balance;
}
.fig { font-family: var(--type); font-size: 13px; font-weight: 700; color: var(--red-ink); background: var(--red); padding: 3px 6px; letter-spacing: .06em; }
h3 { margin: 18px 0 6px; font-family: var(--type); font-size: 14px; text-transform: uppercase; letter-spacing: .08em; }
h3:first-child { margin-top: 0; }

/* ---- Form: an order blank ------------------------------------------------------------------- */
label, legend { display: block; margin: 0 0 4px; padding: 0; font-family: var(--type); font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
fieldset { border: 0; margin: 0; padding: 0; }
select, input[type=number] {
  width: 100%; min-height: 44px; padding: 9px 8px; font: inherit; font-size: 16px; font-weight: 700;
  color: var(--ink); background: #fff; border: 2px solid var(--ink); border-radius: 0;
}
select:focus-visible, input:focus-visible, .btn:focus-visible, .link:focus-visible {
  outline: 3px solid var(--red); outline-offset: 2px;
}
/* Segmented buttons share borders, so their focus ring sits just inside the button. It only shows
   for keyboard focus (not after a click), and turns mustard on the dark selected button so it
   still stands out. */
.seg label:has(input:focus-visible) { outline: 3px solid var(--red); outline-offset: -6px; }
.seg label:has(input:checked:focus-visible) { outline-color: var(--mustard); }
.seg { display: flex; border: 2px solid var(--ink); }
.kind-art { display: block; width: 100%; max-width: 120px; height: auto; margin: 0 auto 4px; }
.seg label {
  flex: 1; display: flex; align-items: center; justify-content: center; margin: 0; padding: 8px 4px; min-height: 44px;
  text-align: center; cursor: pointer; background: #fff; line-height: 1.15;
}
.seg label + label { border-left: 2px solid var(--ink); }
.seg label.kind { flex-direction: column; padding: 6px 4px 8px; }
.seg label.kind:has(input:checked) .kind-art { background: var(--paper-2); outline: 2px solid var(--mustard); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--ink); color: var(--mustard); }
.btn {
  width: 100%; min-height: 48px; padding: 10px; cursor: pointer;
  font-family: var(--display); font-weight: 900; font-stretch: condensed; text-transform: uppercase; font-size: 20px; letter-spacing: .04em;
  color: var(--red-ink); background: var(--red); border: 2px solid var(--ink); box-shadow: 3px 3px 0 var(--ink);
}
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.link { font: inherit; color: var(--red); background: none; border: 0; padding: 0; text-decoration: underline; font-weight: 700; cursor: pointer; }
.hint { margin: 6px 0 0; font-size: 14px; color: var(--ink-2); }

/* ---- Spec tiles --------------------------------------------------------------------------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 0; border: 2px solid var(--ink); background: var(--paper-2); }
.tile { padding: 10px 12px; border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.tile b { display: block; font-family: var(--display); font-weight: 900; font-stretch: condensed; font-size: 30px; line-height: 1.05; font-variant-numeric: tabular-nums; }
.tile span { font-family: var(--type); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }
.sizing { margin: 0; padding: 10px 14px; font-size: 17px; background: var(--paper-2); border-left: 6px solid var(--red); }
.sizing::before { content: ""; float: left; width: 58px; height: 29px; margin: -3px 10px 0 0; background: url("../img/pointing-hand.svg") center / contain no-repeat; }
.sizing::after { content: ""; display: block; clear: both; }
.sizing b { font-family: var(--type); text-transform: uppercase; font-size: 14px; letter-spacing: .06em; color: var(--red); }
.sizing:empty { display: none; }

/* ---- Shop notes and cautions ---------------------------------------------------------------- */
.note { position: relative; padding: 22px 14px 10px; background: var(--mustard); border: 2px solid var(--ink); font-size: 16px; }
.note::before { content: "Shop note"; position: absolute; top: -2px; left: -2px; padding: 1px 8px; background: var(--ink); color: var(--mustard); font-family: var(--type); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.note + .note { margin-top: 10px; }
.untested { position: relative; padding: 22px 14px 10px; background: var(--paper-2); border: 3px solid var(--red); font-size: 15px; }
.untested::before { content: "Caution"; position: absolute; top: -3px; left: -3px; padding: 1px 8px; background: var(--red); color: var(--red-ink); font-family: var(--type); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.untested b { font-family: var(--type); text-transform: uppercase; font-size: 13px; letter-spacing: .04em; }

/* ---- Tables ------------------------------------------------------------------------------- */
.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 16px; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px dotted var(--ink-2); vertical-align: top; }
th { font-family: var(--type); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; border-bottom: 2px solid var(--ink); white-space: nowrap; }
td.n, th.n { text-align: right; font-family: var(--type); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cut { display: block; margin-top: 3px; font-family: var(--type); font-size: 14px; font-weight: 700; color: var(--red); }
.angles { margin: 0 0 14px; padding: 8px 12px; background: var(--paper); border: 2px solid var(--red); font-size: 15px; }
.angles b { font-family: var(--type); text-transform: uppercase; font-size: 13px; letter-spacing: .04em; color: var(--red); }
.buy-links { display: block; margin-top: 3px; font-family: var(--type); font-size: 13px; }
.buy-links a { color: var(--red); font-weight: 700; }
.my-price { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; white-space: nowrap; margin: 6px 0 0; font-family: var(--type); font-size: 13px; text-transform: none; letter-spacing: 0; }
.my-price input { width: 7em; min-height: 40px; padding: 6px; font-family: var(--type); font-weight: 700; border: 2px solid var(--ink); background: #fff; }
.estimate { margin-top: 12px; }
.price-help { margin: 0 0 10px; padding: 8px 12px; background: var(--mustard); border: 2px solid var(--ink); font-size: 15px; }
#est-missing { font-size: 15px; }
.est-total { margin: 0; font-size: 18px; }
.est-total b { font-family: var(--type); text-transform: uppercase; font-size: 14px; letter-spacing: .06em; color: var(--red); }
#est-total { font-family: var(--display); font-weight: 900; font-stretch: condensed; font-size: 26px; }
.price-tools { margin: 8px 0 0; }
.sub { display: block; margin-top: 2px; font-size: 14px; font-style: italic; color: var(--ink-2); }

/* ---- Drawing: ink line work on paper --------------------------------------------------------- */
svg { display: block; width: 100%; height: auto; color: var(--ink); background: #fffdf6; border: 1px solid var(--rule); }
.d-frame { fill: none; stroke: var(--ink); stroke-width: .9; }
.d-solid { fill: var(--mustard); fill-opacity: .75; stroke: var(--ink); stroke-width: .7; }
.d-wire { fill: url(#wire); stroke: var(--ink-2); stroke-width: .4; }
.d-open { fill: #fffdf6; fill-opacity: .85; stroke: var(--red); stroke-width: 1; stroke-dasharray: 2 1.5; }
.d-lid { fill: none; stroke: var(--red); stroke-width: .8; stroke-dasharray: 2 1.5; }
.d-hinge { stroke: var(--red); stroke-width: 1.6; }
.d-ground { stroke: var(--ink-2); stroke-width: .6; stroke-dasharray: 3 2; }
.d-text { fill: var(--ink); font-family: var(--type); font-weight: 700; }
.d-cap { fill: var(--ink-2); font-family: var(--type); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; font-family: var(--type); font-size: 13px; color: var(--ink-2); }
.sw { display: inline-block; width: 14px; height: 14px; vertical-align: -2px; margin-right: 5px; border: 1px solid var(--ink); }
.sw.s { background: var(--mustard); }
.sw.w { background: repeating-linear-gradient(45deg, var(--ink-2) 0 1px, transparent 1px 4px); }
.sw.o { border: 1px dashed var(--red); }

/* ---- Free / full plan stamps and clip-out coupons ------------------------------------------- */
.pill { margin-left: auto; padding: 2px 8px; font-family: var(--type); font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; border: 2px solid currentColor; }
.pill.free { color: var(--ink); }
.pill.paid { color: var(--red); transform: rotate(-3deg); }
.locked { position: relative; padding: 18px 16px 14px; background: var(--paper-2); border: 2px dashed var(--ink); font-size: 16px; }
.locked::before { content: ""; position: absolute; top: -15px; left: 12px; width: 52px; height: 26px; background: url("../img/scissors.svg") center / contain no-repeat; }
.locked b { font-family: var(--type); text-transform: uppercase; font-size: 14px; letter-spacing: .04em; color: var(--red); }

/* ---- Cutting layout ----------------------------------------------------------------------- */
.boards { display: flex; flex-direction: column; gap: 6px; }
.board { display: flex; align-items: center; gap: 8px; font-family: var(--type); font-size: 12px; font-weight: 700; }
.board .lbl { width: 78px; flex: none; color: var(--ink-2); }
.bar { flex: 1; display: flex; height: 26px; min-width: 0; overflow: hidden; background: #fffdf6; border: 2px solid var(--ink); }
.bar i.ang { background: var(--red); color: var(--red-ink); clip-path: polygon(7px 0, 100% 0, calc(100% - 7px) 100%, 0 100%); padding-left: 9px; }
.bar i.spl { background-image: repeating-linear-gradient(135deg, rgba(31, 26, 20, .18) 0 3px, transparent 3px 7px); }
.splice { display: block; margin-top: 3px; font-family: var(--type); font-size: 14px; font-weight: 700; color: var(--ink); }
.bar i { display: block; overflow: hidden; white-space: nowrap; padding: 4px 4px; font-style: normal; font-size: 11px; color: var(--ink); background: var(--mustard); border-right: 2px solid var(--ink); }

/* ---- Gear --------------------------------------------------------------------------------- */
.gear { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.gear div { padding: 10px 12px; background: #fff; border: 2px solid var(--ink); }
.gear b { display: block; font-family: var(--display); font-weight: 900; font-stretch: condensed; text-transform: uppercase; font-size: 19px; letter-spacing: .02em; }
.gear span { font-size: 15px; color: var(--ink-2); }

/* ---- Fine print ----------------------------------------------------------------------------- */
.disclaimer { margin: 0; padding-top: 12px; font-size: 14px; font-style: italic; color: var(--ink-2); border-top: 4px double var(--ink); }
.colophon { margin-top: 28px; padding-top: 10px; border-top: 2px solid var(--ink); font-family: var(--type); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); text-align: center; }
[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) { .btn:active { transform: none; } }
@media print {
  .controls, #tier-box, .colophon { display: none; }
  .grid { grid-template-columns: 1fr; }
  body { background: #fff; }
  .panel { box-shadow: none; }
}
