/* 养鸡场主题 — 像素农场风（移植自 Komari-Farmer, MIT, Tony Liu） */
@font-face {
  font-family: 'FusionPixel';
  src: url('../assets/fonts/fusion-pixel.woff2') format('woff2');
  font-display: swap;
}

:root {
  --wood-d: #5b3a1e;
  --wood: #8b5a2b;
  --wood-l: #c08a4a;
  --paper: #f6ead2;
  --paper-d: #e2cfa8;
  --ink: #3b2a18;
  --grass: #7cb342;
  --grass-d: #4e7a24;
  --sky: #a8dcf0;
  --ok: #3fa34d;
  --warn: #e0a020;
  --bad: #d0492b;
  --shadow: #2b1c0e;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: 'FusionPixel', 'PingFang SC', 'Microsoft YaHei', monospace;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink);
  background-color: var(--sky);
  background-image: linear-gradient(rgba(255, 255, 255, .38), rgba(255, 255, 255, .38)), url('../assets/bg/grass-flowers.png');
  background-size: auto, 320px;
  background-repeat: repeat, repeat;
  background-attachment: fixed, fixed;
  image-rendering: pixelated;
  -webkit-text-size-adjust: 100%;
}

img { image-rendering: pixelated; }

a { color: #2b5d8e; }

/* ---------- 顶部木牌 ---------- */
.sign {
  max-width: 1280px;
  margin: 14px auto 0;
  padding: 0 10px;
}

.sign-wood {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 12px;
  background: linear-gradient(180deg, var(--wood-l), var(--wood) 60%, var(--wood-d));
  border: 3px solid var(--shadow);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, .35), inset 0 -3px 0 rgba(0, 0, 0, .3);
  color: #fff8e6;
  text-shadow: 1px 1px 0 var(--shadow);
}

.sign-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sign-title img { width: 26px; height: 26px; }

.sign-sub { font-size: 11px; opacity: .85; }

.sign-live {
  margin-left: auto;
  font-size: 11px;
  padding: 3px 8px;
  background: rgba(0, 0, 0, .28);
  border: 2px solid rgba(0, 0, 0, .35);
  box-shadow: inset 1px 1px 0 rgba(255, 255, 255, .25);
}
.sign-live.on { background: #2f7d32; }
.sign-live.off { background: #8d3b22; }

/* ---------- 统计条 ---------- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.stat {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--paper);
  border: 3px solid var(--shadow);
  box-shadow: inset 0 2px 0 #fff, inset 0 -2px 0 var(--paper-d);
}

.stat img { width: 20px; height: 20px; }
.stat b { font-size: 15px; }
.stat span { font-size: 11px; color: #6d5a40; }
.stat.wide b { font-size: 14px; }

/* ---------- 分组标签 ---------- */
.tabs {
  max-width: 1280px;
  margin: 10px auto 0;
  padding: 0 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tab {
  font-family: inherit;
  font-size: 12px;
  padding: 5px 10px;
  cursor: pointer;
  color: var(--ink);
  background: linear-gradient(180deg, #fff6e2, var(--paper-d));
  border: 3px solid var(--shadow);
  box-shadow: inset 1px 1px 0 #fff, inset -1px -1px 0 #b99f78;
}

.tab.active {
  background: linear-gradient(180deg, var(--grass), var(--grass-d));
  color: #fff;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, .4);
}

.tab:active { transform: translateY(1px); }

/* ---------- 鸡舍网格 ---------- */
.farm {
  max-width: 1280px;
  margin: 12px auto 40px;
  padding: 0 10px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 12px;
}

.coop {
  background: var(--paper);
  border: 3px solid var(--shadow);
  box-shadow: inset 0 2px 0 #fff, inset 0 -3px 0 var(--paper-d), 3px 3px 0 rgba(0, 0, 0, .18);
  display: flex;
  flex-direction: column;
  cursor: pointer;
}

.coop.offline { filter: saturate(.55); }

.coop-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  background: linear-gradient(180deg, #cfae7c, #b08b55);
  border-bottom: 3px solid var(--shadow);
  color: #2b1c0e;
  text-shadow: 1px 1px 0 rgba(255, 255, 255, .35);
}

.coop-name {
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.coop-group { font-size: 11px; opacity: .75; margin-left: auto; white-space: nowrap; }

.badge {
  font-size: 11px;
  padding: 2px 6px;
  border: 2px solid var(--shadow);
  background: #ddd;
  white-space: nowrap;
}
.badge.online { background: var(--ok); color: #fff; text-shadow: 1px 1px 0 rgba(0,0,0,.35); }
.badge.offline { background: var(--bad); color: #fff; text-shadow: 1px 1px 0 rgba(0,0,0,.35); }

.coop-body { display: flex; gap: 8px; padding: 8px; }

.coop-yard {
  position: relative;
  width: 96px;
  flex: 0 0 96px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.coop-yard .barn { width: 96px; height: auto; }

.coop-yard .chicken {
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 42px;
  height: auto;
  transform: translateX(-58%);
  animation: bob 1.6s steps(2, end) infinite;
}

.coop.offline .chicken { animation: none; transform: translateX(-58%) rotate(-8deg); filter: grayscale(.7) brightness(.85); }

@keyframes bob {
  0% { transform: translateX(-58%) translateY(0); }
  50% { transform: translateX(-58%) translateY(-4px); }
  100% { transform: translateX(-58%) translateY(0); }
}

.coop .flag { position: absolute; top: 0; left: 0; width: 20px; height: 14px; border: 1px solid var(--shadow); }

.metrics { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }

.mrow { display: flex; align-items: center; gap: 5px; font-size: 12px; }
.mrow .ico { width: 16px; height: 16px; flex: 0 0 16px; }
.mrow .lbl { flex: 0 0 34px; color: #6d5a40; }

.bar {
  flex: 1;
  height: 12px;
  background: #4a3a24;
  border: 2px solid var(--shadow);
  box-shadow: inset 1px 1px 0 rgba(0, 0, 0, .5);
  overflow: hidden;
  display: flex;
}

.bar i {
  display: block;
  height: 100%;
  background-image: repeating-linear-gradient(90deg, var(--grass) 0 3px, transparent 3px 5px);
  transition: width .4s steps(6, end);
}
.bar i.warn { background-image: repeating-linear-gradient(90deg, var(--warn) 0 3px, transparent 3px 5px); }
.bar i.bad { background-image: repeating-linear-gradient(90deg, var(--bad) 0 3px, transparent 3px 5px); }

.mrow .val { flex: 0 0 52px; text-align: right; font-variant-numeric: tabular-nums; }

.coop-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-top: 3px solid var(--shadow);
  background: var(--paper-d);
  font-size: 11px;
}

.coop-foot .ico { width: 14px; height: 14px; }
.coop-foot .net { display: inline-flex; align-items: center; gap: 3px; }
.coop-foot .right { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.load-txt { font-size: 11px; color: #6d5a40; }

/* ---------- 详情页 ---------- */
.detail { max-width: 1280px; margin: 12px auto 40px; padding: 0 10px; }

.detail-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.btn {
  font-family: inherit;
  font-size: 12px;
  padding: 5px 10px;
  cursor: pointer;
  background: linear-gradient(180deg, #fff6e2, var(--paper-d));
  border: 3px solid var(--shadow);
  box-shadow: inset 1px 1px 0 #fff, inset -1px -1px 0 #b99f78;
  color: var(--ink);
}
.btn.active { background: linear-gradient(180deg, var(--grass), var(--grass-d)); color: #fff; }

.detail-hero {
  margin-top: 8px;
  padding: 10px;
  background: var(--paper);
  border: 3px solid var(--shadow);
  box-shadow: inset 0 2px 0 #fff, inset 0 -3px 0 var(--paper-d);
  display: flex;
  gap: 14px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.detail-hero .barn { width: 140px; }
.detail-hero .facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 4px 14px; font-size: 12px; }
.detail-hero .facts div { display: flex; gap: 6px; }
.detail-hero .facts b { font-weight: 400; color: #6d5a40; min-width: 62px; }

.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; margin-top: 12px; }

.chart {
  background: var(--paper);
  border: 3px solid var(--shadow);
  box-shadow: inset 0 2px 0 #fff, inset 0 -3px 0 var(--paper-d);
  padding: 8px;
}

.chart h3 { margin: 0 0 6px; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.chart h3 span { margin-left: auto; font-weight: 400; font-size: 12px; color: #6d5a40; }
.chart canvas { width: 100%; height: 120px; display: block; background: #2f2416; border: 2px solid var(--shadow); }

.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; margin-top: 12px; }

.mcard { background: var(--paper); border: 3px solid var(--shadow); box-shadow: inset 0 2px 0 #fff; padding: 6px 8px; }
.mcard .k { font-size: 11px; color: #6d5a40; display: flex; align-items: center; gap: 5px; }
.mcard .k img { width: 14px; height: 14px; }
.mcard .v { font-size: 15px; margin-top: 2px; }

.ping-row { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; }
.ping-row i { font-style: normal; }
.dot { display: inline-block; width: 8px; height: 8px; margin-right: 3px; border: 1px solid var(--shadow); }

/* ---------- 提示条 ---------- */
.notice {
  max-width: 1280px;
  margin: 10px auto 0;
  padding: 8px 12px;
  background: #ffe6a8;
  border: 3px solid var(--shadow);
  font-size: 12px;
}
.notice b { color: #8d3b22; }

/* ---------- 载入 / 页脚 ---------- */
#boot {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
#boot img { width: 64px; animation: bob 1.2s steps(2, end) infinite; }

.foot {
  max-width: 1280px;
  margin: 0 auto 20px;
  padding: 0 12px;
  font-size: 11px;
  color: #4c3a22;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.foot .grow { margin-left: auto; }

.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 30px;
  background: var(--paper);
  border: 3px dashed var(--shadow);
}

@media (max-width: 420px) {
  .coop-yard { width: 74px; flex: 0 0 74px; }
  .coop-yard .barn { width: 74px; }
  .farm { grid-template-columns: 1fr; }
}
