/* LIVESTOCK. Palette, type and frames read off the farm-guide reference:
   olive ground, cream paper, dusty blue-grey data field, umber wood, flat light. */
:root {
  --ink:        #3a2a1c;
  --ink-soft:   #6b573f;
  --paper:      #efe6cd;
  --paper-2:    #ddcfab;
  --field:      #9aa7bd;
  --field-2:    #7b8aa4;
  --wood:       #7a5430;
  --wood-dark:  #3c2716;
  --wood-light: #b78a52;
  --brass:      #a89143;

  --pixel: "Silkscreen", "Courier New", monospace;
  --body:  "Pixelify Sans", "Trebuchet MS", sans-serif;

  --gutter: 16px;
  --bevel: 4px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--body);
  font-synthesis: none;
  font-size: 18px;
  line-height: 1.5;
  color: var(--ink);
  background-color: #7f8047;
  background-image: url("art/ground.png");
  background-size: 128px 128px;
  image-rendering: pixelated;
  padding-bottom: 48px;
}
img { image-rendering: pixelated; }
h2, h3 { margin: 0; font-family: var(--pixel); font-weight: 700; letter-spacing: .06em; }

main { max-width: 1600px; margin: 0 auto; padding: 0 var(--gutter); }

/* ---------- the gate: the sign and the tag ---------- */
.gate {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 0 0 24px;
}
.gate__board {
  width: min(520px, 100%);
  height: auto;
  margin-top: -12px; /* the chains run off the top edge */
}
.gate__line {
  max-width: 40ch;
  margin: 0;
  padding: 12px 18px;
  text-align: center;
  font-size: clamp(18px, 2vw, 22px);
  line-height: 1.35;
  color: #2a1f13;
  background: var(--paper);
  border: 3px solid var(--wood-dark);
  box-shadow: inset 0 0 0 3px var(--paper-2), 0 5px 0 rgba(30, 20, 10, .3);
}

/* the stamped brass tag: it carries the brand, the contract and the links */
.tag {
  width: min(540px, 100%);
  padding: 18px 18px 16px;
  color: #2b2410;
  background: var(--brass);
  border: var(--bevel) solid var(--wood-dark);
  box-shadow:
    inset 0 0 0 var(--bevel) #c9b25c,
    inset 0 0 0 calc(var(--bevel) * 2) #8e7833,
    0 6px 0 rgba(30, 20, 10, .35);
  display: grid;
  gap: 8px;
  justify-items: center;
  text-align: center;
}
.tag__ticker { margin: 0; font-family: var(--pixel); font-weight: 700; font-size: 26px; letter-spacing: .08em; }
.tag__label { margin: 0; font-family: var(--pixel); font-size: 16px; color: #5d4d1c; letter-spacing: .12em; }
.tag__ca {
  margin: 0;
  width: 100%;
  padding: 10px;
  font-family: var(--pixel);
  font-size: 16px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  user-select: all;
  background: #efe0a4;
  border: 3px solid #6d5a22;
}
.tag__ca.is-empty { color: #6d5a22; user-select: none; }
.tag__brand { display: flex; gap: 8px; width: 100%; align-items: stretch; }
.tag__brand .tag__ca { flex: 1 1 auto; }
.tag__acts { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: stretch; width: 100%; }
.tag__note { margin: 2px 0 0; font-size: 16px; color: #5d4d1c; }

/* ---------- buttons ---------- */
.btn {
  min-height: 48px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: var(--pixel);
  font-size: 16px;
  letter-spacing: .04em;
  text-decoration: none;
  color: var(--paper);
  background: var(--wood);
  border: 3px solid var(--wood-dark);
  box-shadow: inset 0 3px 0 var(--wood-light), 0 4px 0 var(--wood-dark);
  cursor: pointer;
}
.btn:active { transform: translateY(4px); box-shadow: inset 0 3px 0 var(--wood-light), 0 0 0 var(--wood-dark); }
.btn:focus-visible { outline: 4px solid #2a1f13; outline-offset: 3px; }
.btn[disabled], .btn[aria-disabled="true"] {
  background: #8d8060; color: #e3dcc6; cursor: not-allowed;
  box-shadow: inset 0 3px 0 #a79a79, 0 4px 0 #5b5140;
}
.btn[disabled]:active, .btn[aria-disabled="true"]:active { transform: none; }
.btn--buy { flex: 1 1 240px; padding: 0 12px; }
/* official marks stay untouched, so each sits on its own chip to survive the wood */
.btn--buy img, .btn--mark img {
  width: 26px; height: 26px; flex: 0 0 auto;
  background: var(--paper);
  border: 2px solid var(--wood-dark);
}
.btn--mark { width: 52px; padding: 0; }
.btn--mark svg { width: 22px; height: 22px; }
.btn--copy { flex: 0 0 auto; padding: 0 12px; }
.btn--small { min-height: 44px; font-size: 16px; }

/* ---------- the pen ---------- */
.pen {
  background: var(--paper);
  border: var(--bevel) solid var(--wood-dark);
  box-shadow: inset 0 0 0 var(--bevel) var(--paper-2), 0 6px 0 rgba(30, 20, 10, .35);
  padding: 18px;
}
.pen__head {
  display: grid;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 18px;
  background: var(--field);
  border: 3px solid var(--wood-dark);
  box-shadow: inset 0 0 0 3px var(--field-2);
}
.pen__head h2 { font-size: 24px; color: #1f2733; }
.pen__state { margin: 0; font-size: 17px; color: #1f2733; }
.pen__controls { display: flex; flex-wrap: wrap; gap: 10px; }
.seg { display: flex; }
.seg__btn {
  min-height: 48px;
  padding: 0 14px;
  font-family: var(--pixel);
  font-size: 16px;
  color: var(--paper);
  background: var(--wood);
  border: 3px solid var(--wood-dark);
  box-shadow: inset 0 3px 0 var(--wood-light);
  cursor: pointer;
}
.seg__btn + .seg__btn { border-left-width: 0; }
.seg__btn.is-on { background: var(--wood-dark); box-shadow: inset 0 3px 0 #5a3c22; }
.seg__btn:focus-visible { outline: 4px solid #1f2733; outline-offset: 3px; }
.seg__btn--solo { margin-left: auto; }

/* Thirty-three is a prime-ish count: a grid would leave the last row a hole, so the rows
   fill edge to edge and the short last row is centred. */
.herd {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
}
.herd > li { flex: 1 1 168px; max-width: 232px; display: flex; }
.stall-card {
  width: 100%;
  display: grid;
  grid-template-rows: 1fr auto;
  padding: 0;
  font: inherit;
  color: inherit;
  text-align: center;
  background: var(--paper-2);
  border: 3px solid var(--wood-dark);
  box-shadow: inset 0 0 0 3px #efe6cd;
  cursor: pointer;
}
.stall-card:focus-visible { outline: 4px solid var(--wood-dark); outline-offset: 3px; }
.stall-card:hover .stall-card__art img { transform: var(--pose) translateY(-4px); }
.stall-card__art {
  height: 148px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 8px 6px 0;
  overflow: hidden;
}
.stall-card__art img {
  max-width: 100%;
  height: auto;
  transform: var(--pose);
  transform-origin: bottom center;
  transition: transform .18s steps(3);
}
.stall-card.is-bones .stall-card__art img { filter: grayscale(.55) brightness(.82); }
.stall-card.is-asleep .stall-card__art img { filter: grayscale(.7) brightness(.72); }
.stall-card__plank {
  padding: 8px 6px 9px;
  background: var(--wood);
  border-top: 3px solid var(--wood-dark);
  box-shadow: inset 0 3px 0 var(--wood-light);
  display: grid;
  gap: 3px;
}
.stall-card__sym { font-family: var(--pixel); font-weight: 700; font-size: 18px; color: #fbf2d8; letter-spacing: .04em; }
.stall-card__word { font-family: var(--pixel); font-size: 16px; }
.stall-card__move { font-family: var(--pixel); font-size: 16px; color: #f4e9cc; }
.w-stuffed { color: #d3f08a; }
.w-fat     { color: #bede7e; }
.w-fine    { color: #efe6cd; }
.w-thin    { color: #f2b79a; }
.w-bones   { color: #f39b7c; }
.w-asleep  { color: #cfc6ad; }

@media (prefers-reduced-motion: no-preference) {
  .motion-on .stall-card__art img { animation: bob 1.4s steps(2) infinite; }
  .motion-on .stall-card.is-bones .stall-card__art img,
  .motion-on .stall-card.is-asleep .stall-card__art img { animation: none; }
}
@keyframes bob {
  0%, 100% { transform: var(--pose) translateY(0); }
  50%      { transform: var(--pose) translateY(-3px); }
}

/* ---------- the stall card ---------- */
.stall {
  width: min(460px, calc(100vw - 32px));
  padding: 20px;
  color: var(--ink);
  background: var(--paper);
  border: var(--bevel) solid var(--wood-dark);
  box-shadow: inset 0 0 0 var(--bevel) var(--paper-2);
}
.stall::backdrop { background: rgba(28, 22, 12, .72); }
.stall__close-form { display: flex; justify-content: flex-end; margin-bottom: 4px; }
.stall__close {
  min-height: 44px; padding: 0 14px;
  font-family: var(--pixel); font-size: 16px;
  color: var(--paper); background: var(--wood);
  border: 3px solid var(--wood-dark); box-shadow: inset 0 3px 0 var(--wood-light);
  cursor: pointer;
}
.stall__art { display: flex; justify-content: center; align-items: flex-end; height: 170px; }
.stall__art img { max-height: 100%; width: auto; }
.stall__title { font-size: 26px; text-align: center; margin-top: 10px; }
.stall__beast { margin: 2px 0 14px; text-align: center; font-size: 18px; color: var(--ink-soft); }
.stall__rows { margin: 0 0 16px; display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; }
.stall__rows dt { font-family: var(--pixel); font-size: 16px; color: var(--ink-soft); }
.stall__rows dd { margin: 0; font-family: var(--pixel); font-size: 16px; text-align: right; overflow-wrap: anywhere; }
.stall__acts { display: flex; flex-wrap: wrap; gap: 10px; }
.btn--take { flex: 1 1 200px; }
.stall__fine { margin: 12px 0 0; font-size: 16px; color: var(--ink-soft); }

/* ---------- the one you took ---------- */
.yours[hidden] { display: none; }
.yours {
  padding: 12px 16px;
  margin-bottom: 18px;
  background: var(--field);
  border: 3px solid var(--wood-dark);
  box-shadow: inset 0 0 0 3px var(--field-2);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  color: #1f2733;
}
.yours__head { margin: 0; font-family: var(--pixel); font-size: 16px; letter-spacing: .12em; }
.yours__body { display: flex; align-items: center; gap: 10px; flex: 1 1 260px; }
.yours__body img { width: 52px; height: auto; flex: 0 0 auto; }
.yours__text { font-family: var(--pixel); font-size: 16px; line-height: 1.5; }

@media (max-width: 720px) {
  .herd { gap: 10px; }
  .herd > li { flex: 1 1 150px; }
  .pen { padding: 12px; }
  .seg__btn--solo { margin-left: 0; }
}
@media (max-width: 380px) {
  .herd { gap: 8px; }
  .herd > li { flex: 1 1 calc(50% - 8px); max-width: none; }
  .stall-card__art { height: 124px; }
}
