/* Hay barn: red board-and-batten siding with white trim, the feed-room chalk slate, the loft stacked with bales. */
@font-face { font-family: "Cabin Sketch"; src: url(fonts/cabin-sketch-700.woff2) format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Vollkorn"; src: url(fonts/vollkorn-var.woff2) format("woff2"); font-weight: 400 900; font-display: swap; }

:root {
  --barn: #2e2219;     /* barn-board brown, text */
  --paper: #f4ecd8;    /* loft oat, paper */
  --straw: #7d5200;    /* bale gold for text and rules */
  --pasture: #2f5d34;  /* pasture green, buttons */
  --twine: #a12a1a;    /* barn red siding, warnings */
  --slate: #263130;    /* feed-room chalkboard */
  --chalk: #f3f0e6;    /* chalk and white trim */
  --pine: #c99a5b;
  --hay: #dcaa45;
  --chalkfont: "Cabin Sketch", "Vollkorn", Georgia, serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; color: var(--barn); background: var(--paper); font: 400 18px/1.55 "Vollkorn", Georgia, "Times New Roman", serif; }
a { color: var(--pasture); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:focus-visible, select:focus-visible, input:focus-visible, button:focus-visible, summary:focus-visible { outline: 3px solid var(--hay); outline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2 { font-family: var(--chalkfont); font-weight: 700; letter-spacing: .01em; }
h2 { margin: 0 0 14px; font-size: clamp(1.6rem, 5vw, 2.1rem); line-height: 1.1; }

/* ---------- masthead: red board-and-batten siding ---------- */
.masthead {
  color: var(--chalk);
  background:
    repeating-linear-gradient(90deg, transparent 0 52px, rgba(0,0,0,.22) 52px 54px, #b5341f 54px 58px, rgba(0,0,0,.25) 58px 60px),
    linear-gradient(180deg, #a12a1a, #8e2416);
  border-top: 12px solid var(--chalk);
  border-bottom: 12px solid var(--chalk);
  box-shadow: inset 0 -6px 0 #6e1b10;
}
.mast-in { max-width: 1240px; margin: 0 auto; padding: 28px 20px 30px; display: grid; gap: 22px; align-items: center; }
.kicker { display: inline-block; margin: 0 0 12px; padding: 4px 12px; font: 700 .85rem/1.3 "Vollkorn", serif; letter-spacing: .18em; text-transform: uppercase; color: var(--barn); background: var(--chalk); }
h1 { margin: 0 0 14px; font-size: clamp(2.6rem, 11vw, 5.4rem); line-height: .95; color: var(--chalk); text-shadow: 0 3px 0 #6e1b10; }
.intro { margin: 0; max-width: 34em; font-size: 1.12rem; color: var(--chalk); }
.intro a { color: var(--chalk); font-weight: 600; }
.mast-art { border: 8px solid var(--chalk); background: #efe2c2; box-shadow: 0 6px 0 rgba(0,0,0,.25); }
.barn-art { display: block; width: 100%; height: auto; }

/* ---------- barn floor: slate and loft ---------- */
.barnfloor {
  display: grid; gap: 22px; padding: 26px 14px 34px;
  background: repeating-linear-gradient(180deg, #3a2b20 0 30px, #2e2219 30px 32px), #3a2b20;
}
.barnfloor > section { min-width: 0; }

#form {
  position: relative; color: var(--chalk);
  background:
    radial-gradient(ellipse at 30% 20%, rgba(255,255,255,.06), transparent 55%),
    radial-gradient(ellipse at 80% 80%, rgba(255,255,255,.04), transparent 50%), var(--slate);
  border: 14px solid var(--pine);
  border-image: repeating-linear-gradient(90deg, #c99a5b 0 18px, #b98a4e 18px 30px, #d1a466 30px 44px) 14;
  padding: 22px 18px 18px;
  box-shadow: 0 8px 0 rgba(0,0,0,.35);
}
#form h2, #form label { color: var(--chalk); }
.num { display: inline-grid; place-items: center; width: 1.7em; height: 1.7em; margin-right: .45em; border: 2px solid var(--chalk); border-radius: 50%; font: 700 .8em/1 var(--chalkfont); vertical-align: .08em; }
#form h2 .num { font-size: .6em; vertical-align: .3em; }
label { display: block; font: 700 1rem/1.3 "Vollkorn", serif; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; align-items: end; margin-bottom: 14px; }
input, select, button { width: 100%; font: 600 1.08rem/1.2 "Vollkorn", serif; padding: 10px 12px; margin-top: 6px; min-height: 48px; border-radius: 0; }
#form input, #form select {
  color: var(--chalk); background: rgba(0,0,0,.18);
  border: 0; border-bottom: 3px solid var(--chalk); box-shadow: inset 0 0 0 1px rgba(243,240,230,.35);
}
#form select option { color: var(--barn); background: var(--paper); }
#form input::placeholder { color: #c9c3b4; font-style: italic; }
#bale { border-bottom-color: var(--hay); }
button { cursor: pointer; background: var(--pasture); color: #fff; border: 2px solid var(--pasture); margin-top: 0; }
button.secondary { background: transparent; color: var(--chalk); border: 2px dashed var(--chalk); }
#add { width: auto; padding: 10px 18px; }
#rows { margin-bottom: 4px; }
.animal-row { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) auto; gap: 10px; padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px dashed rgba(243,240,230,.4); }
.a-x button { min-width: 48px; padding: 10px 12px; }
.hint { font-size: .95rem; margin: 4px 0 8px; color: #dcd7c8; font-style: italic; }
.err { margin: 10px 0 0; padding: 10px 12px; color: var(--chalk); background: var(--twine); font-weight: 700; }

/* the loft */
.loft { display: flex; flex-direction: column; padding: 40px 0 14px; background: #efe2c2; border: 6px solid #6b4a2b; box-shadow: 0 8px 0 rgba(0,0,0,.35); }
#answer { display: contents; }
.loft > .slate, #answer > .slate { order: 1; width: calc(100% - 28px); }
.stack { order: 2; }
.facts { order: 3; } #detail { order: 4; } .warn { order: 5; }
#answer:not([hidden]) ~ .waiting { display: none; }
.waiting .w-h { margin: 0; font: 700 1.4rem/1.1 var(--chalkfont); }
.waiting .w-n { margin: 6px 0 0; font-style: italic; color: #dcd7c8; }
.slate {
  position: relative; max-width: 460px; margin: 0 auto 16px; padding: 14px 18px 16px; text-align: center; color: var(--chalk);
  background: var(--slate); border: 10px solid var(--pine); box-shadow: 0 6px 0 rgba(0,0,0,.25);
}
.slate::before, .slate::after { content: ""; position: absolute; top: -48px; width: 2px; height: 38px; background: var(--straw); }
.slate::before { left: 22%; transform: rotate(8deg); } .slate::after { right: 22%; transform: rotate(-8deg); }
.slate h2 { margin: 0; font-size: 1.4rem; color: var(--chalk); }
.big { margin: 4px 0 0; font: 700 clamp(2.4rem, 9vw, 3.9rem)/1.05 var(--chalkfont); color: var(--chalk); }
.facts { margin: 14px 18px 10px; display: grid; gap: 8px; }
.facts div { padding: 10px 12px; background: var(--paper); border-left: 5px solid var(--straw); }
dt { font: 700 .8rem/1.3 "Vollkorn", serif; text-transform: uppercase; letter-spacing: .12em; color: var(--straw); }
dd { margin: 2px 0 0; font-size: 1.05rem; }
#total { font-weight: 700; font-size: 1.25rem; }
#detail { margin: 0 18px 10px; padding: 0; list-style: none; }
#detail li { padding: 4px 0 4px 24px; position: relative; border-bottom: 1px dotted var(--straw); }
#detail li::before { content: ""; position: absolute; left: 2px; top: .8em; width: 14px; height: 8px; background: var(--hay); border: 1px solid var(--straw); }
.warn { margin: 4px 18px 0; padding: 10px 12px; color: var(--chalk); background: var(--twine); font-weight: 700; border-left: 8px solid var(--chalk); }
.stack { margin: 0; }
#stack { display: block; width: 100%; height: auto; }
#stack-cap { padding: 8px 14px 0; font-style: italic; font-size: .95rem; }
#stack-key { list-style: none; margin: 8px 0 0; padding: 0 14px; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: .95rem; }
#stack-key li { display: flex; align-items: center; gap: 6px; }
.beast { width: 44px; height: 34px; }
.tw { width: 18px; height: 4px; }
.sw { width: 26px; height: 12px; border: 1px solid var(--straw); border-radius: 2px; }
.sw-buf { background: repeating-linear-gradient(45deg, var(--twine) 0 2px, var(--hay) 2px 5px); }
.sw-extra { border: 1.5px dashed var(--straw); }
.bale.new { animation: settle .35s ease-out both; }
@keyframes settle { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .bale.new { animation: none; } }

/* ---------- feed room: pine boards ---------- */
.feedroom {
  display: grid; gap: 22px; padding: 34px 14px;
  background: repeating-linear-gradient(90deg, #dcc08c 0 118px, #b8945c 118px 120px, #d6b781 120px 238px, #b8945c 238px 240px);
}
.feedroom > section { min-width: 0; position: relative; padding: 24px 20px 18px; box-shadow: 0 5px 0 rgba(46,34,25,.25); }
#example { background: var(--paper); border-top: 10px solid var(--twine); }
#example::before { content: "Tally"; position: absolute; top: -10px; right: 16px; padding: 4px 10px 6px; font: 700 .95rem/1 var(--chalkfont); color: var(--chalk); background: var(--twine); }
#example p, #how p { margin: 0 0 12px; }
#how { background: #fbf7ec; border-top: 10px solid var(--straw); }

/* ---------- questions ---------- */
#faq { padding: 34px 14px; max-width: 1240px; margin: 0 auto; }
#faq h2 { padding-bottom: 8px; border-bottom: 4px double var(--straw); }
details { padding: 12px 0; border-bottom: 1px solid #cdb88a; }
summary { cursor: pointer; font-weight: 700; font-size: 1.08rem; list-style: none; position: relative; padding-left: 32px; min-height: 28px; }
summary::-webkit-details-marker { display: none; }
summary::before { content: ""; position: absolute; left: 0; top: .3em; width: 20px; height: 11px; background: var(--hay); border: 1px solid var(--straw); border-radius: 2px; }
summary::after { content: ""; position: absolute; left: 5px; top: .3em; width: 10px; height: 13px; border-left: 2px solid var(--twine); border-right: 2px solid var(--twine); box-sizing: border-box; }
details p { margin: 6px 0 0 32px; }

/* ---------- shop: X-braced barn door ---------- */
.shop-guide {
  position: relative; margin: 0 14px 34px; padding: 26px 16px 20px; color: var(--chalk);
  background: repeating-linear-gradient(90deg, #a12a1a 0 46px, #8e2416 46px 48px);
  border: 10px solid var(--chalk);
}
.shop-guide > * { position: relative; background: var(--paper); color: var(--barn); padding: 12px 16px; margin: 0; }
.shop-guide h2 { display: inline-block; background: var(--chalk); margin-bottom: 0; }
.shop-guide p + p { border-top: 1px dashed var(--straw); }
.shop-guide .disc { font-size: .95rem; }

footer {
  color: var(--chalk); font-size: .95rem;
  background: repeating-linear-gradient(90deg, #8e2416 0 52px, #6e1b10 52px 54px);
  border-top: 12px solid var(--chalk);
}
footer p { max-width: 1240px; margin: 0 auto; padding: 22px 20px 28px; }
footer a { color: var(--chalk); font-weight: 600; }

/* ---------- wider screens ---------- */
@media (min-width: 900px) {
  .mast-in { grid-template-columns: 7fr 5fr; padding: 36px 28px 38px; }
  .barnfloor, .feedroom { grid-template-columns: 5fr 7fr; align-items: start; padding-left: max(28px, calc((100% - 1240px) / 2)); padding-right: max(28px, calc((100% - 1240px) / 2)); }
  #results { position: sticky; top: 14px; }
  #how { column-count: 2; column-gap: 28px; }
  #how h2 { column-span: all; }
  #faq { padding-left: 28px; padding-right: 28px; }
  #faq details { display: inline-block; width: calc(50% - 16px); vertical-align: top; margin-right: 28px; }
  #faq details:nth-of-type(2n) { margin-right: 0; }
  .shop-guide { max-width: 1184px; margin: 0 auto 40px; padding: 34px 34px 28px; }
  .shop-guide::before { content: ""; position: absolute; inset: 0; background:
      linear-gradient(to top right, transparent calc(50% - 4px), var(--chalk) calc(50% - 4px) calc(50% + 4px), transparent calc(50% + 4px)),
      linear-gradient(to bottom right, transparent calc(50% - 4px), var(--chalk) calc(50% - 4px) calc(50% + 4px), transparent calc(50% + 4px)); }
  .shop-guide > * { max-width: 760px; margin-left: auto; margin-right: auto; }
  .shop-guide h2 { display: block; }
}
@media (max-width: 420px) {
  .animal-row { grid-template-columns: minmax(0, 1fr) 96px; }
  .a-x { grid-column: 1 / -1; }
}
