/* ============================================================
   Encyklopedia (js/encyclopedia.js): okno nad menu i grą, styl ciemnego drewna i pergaminu
   jak reszta interfejsu (css/style.css), skala interfejsu (--ui-scale), małe okna.
   ============================================================ */
.ency-overlay { position: fixed; inset: 0; z-index: 60; background: rgba(8, 6, 4, 0.72); display: flex; align-items: center; justify-content: center; }
.ency-box { zoom: var(--ui-scale, 1); width: min(1240px, calc(98vw / var(--ui-scale, 1))); height: min(900px, calc(96vh / var(--ui-scale, 1)));
  display: flex; flex-direction: column; background: linear-gradient(#2f281e, #1f1a14); border: 2px solid var(--edge); border-radius: 6px;
  box-shadow: 0 16px 60px #000d, inset 0 0 0 1px #000a; overflow: hidden; color: var(--text); user-select: text; }

/* ---------- pasek górny ---------- */
.ency-top { display: flex; align-items: center; gap: 8px; padding: 8px 12px; flex: none;
  background: linear-gradient(#4a3c28, #2e261b); border-bottom: 2px solid var(--edge); }
.ency-title { color: var(--gold); font-size: 22px; letter-spacing: 3px; text-shadow: 0 2px 0 #000; margin-right: 6px; white-space: nowrap; }
.ency-nav { min-width: 34px; font-size: 15px !important; }
.ency-nav:disabled { opacity: .35; cursor: default; }
.ency-search { flex: 1; min-width: 80px; font-size: 14px !important; padding: 6px 10px !important; }
.ency-close { white-space: nowrap; }
.ency-nats { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 5px 12px; flex: none; border-bottom: 1px solid var(--edge); background: #241e16; font-size: 13px; }
.ency-nats .ec-muted { margin-right: 4px; }
.ency-nat.on, .ency-pv-ctl .btn.on { border-color: var(--gold); color: var(--gold); background: linear-gradient(#6d5a3a, #4a3c27); }

/* ---------- układ: kategorie | lista | strona ---------- */
.ency-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 148px 236px minmax(0, 1fr); }
.ency-cats { display: flex; flex-direction: column; gap: 2px; padding: 8px 6px; overflow-y: auto; background: linear-gradient(90deg, #1b1610, #231d15); border-right: 1px solid var(--edge); }
.ency-cat { display: flex; align-items: center; gap: 8px; background: transparent; border: 1px solid transparent; border-radius: 4px; color: var(--muted);
  font-family: inherit; font-size: 13px; padding: 6px 6px; cursor: pointer; text-align: left; }
.ency-cat:hover { border-color: var(--edge); color: var(--text); }
.ency-cat.on { background: linear-gradient(#5a4a30, #3d3220); border-color: var(--gold); color: var(--gold); }
.ency-cat canvas { flex: none; }
.ency-list { overflow-y: auto; padding: 6px 4px 10px; border-right: 1px solid var(--edge); background: #1d1812; }
.ency-grp { color: var(--gold); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; margin: 10px 6px 3px; border-bottom: 1px solid #4a3e2c; padding-bottom: 2px; }
.ency-grp:first-child { margin-top: 2px; }
.ency-item { display: flex; align-items: center; gap: 7px; padding: 3px 6px; border-radius: 3px; cursor: pointer; font-size: 13px; color: var(--text); text-decoration: none; }
.ency-item:hover { background: #ffffff10; }
.ency-item.on { background: linear-gradient(90deg, #5a4a30, #3a3020); color: var(--gold); }
.ency-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ency-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--edge); flex: none; margin: 0 9px; }
.ency-page { overflow-y: auto; padding: 14px 22px 28px; background: linear-gradient(#2a241b, #231e16); line-height: 1.5; font-size: 14px; }

/* ---------- treść stron ---------- */
.ec-ico { display: inline-block; vertical-align: middle; flex: none; }
.ec-ico.empty { visibility: hidden; }
.ec-head { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--edge); }
.ec-head canvas { background: #1a1611; border: 1px solid var(--edge); border-radius: 4px; }
.ec-head h2 { margin: 0; color: var(--gold); font-size: 24px; font-weight: normal; text-align: left; }
.ec-sub { color: var(--muted); font-style: italic; font-size: 13px; }
.ec-desc { font-size: 14px; margin: 10px 0; color: #e8dcc0; }
.ec-note { font-size: 12px; color: var(--muted); font-style: italic; margin: 8px 0; }
.ec-muted { color: var(--muted); }
.ec-sec { margin-top: 14px; }
.ec-sec h3, .ec-tree h3, .ency-page > h3 { color: var(--gold); font-size: 15px; font-weight: normal; margin: 0 0 6px; padding-bottom: 3px; border-bottom: 1px solid #4a3e2c; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ec-sec h4 { color: var(--text); font-size: 13px; margin: 6px 0 4px; font-weight: normal; text-decoration: underline; text-decoration-color: var(--edge); }
.ec-ul { margin: 4px 0; padding-left: 20px; }
.ec-ul li { margin: 3px 0; }
.ec-link { color: var(--gold); cursor: pointer; text-decoration: none; border-bottom: 1px dotted #d8b45a80; }
.ec-link:hover { color: #ffe08a; }
.ec-chips { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.ec-chips.col { flex-direction: column; align-items: flex-start; gap: 4px; }
.ec-chip { display: inline-flex; align-items: center; gap: 5px; color: var(--text); cursor: pointer; text-decoration: none; padding: 1px 6px 1px 2px; border: 1px solid #4a3e2c; border-radius: 3px; background: #1d1812; }
.ec-chip:hover { border-color: var(--gold); color: var(--gold); }
.ec-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; }
.ec-res { display: inline-flex; align-items: center; gap: 4px; margin-right: 8px; white-space: nowrap; }
.ec-res i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; box-shadow: 0 0 0 1px #0008; }
.ec-pos { color: #9fd08a; }
.ec-neg { color: #e58a7a; }
.ec-zero { color: #6b5d48; text-align: center; }

/* karta jednostki / budynku */
.ec-unit { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.ec-unit-st { flex: 1; min-width: 260px; }
.ec-preview { flex: none; width: 236px; padding: 6px; background: radial-gradient(ellipse at 50% 70%, #3a3a26 0%, #1a1611 75%); border: 1px solid var(--edge); border-radius: 4px; text-align: center; }
.ency-pv-cv { display: block; margin: 0 auto; }
.ency-pv-ctl { display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; margin-top: 4px; }
.ency-pv-ctl .btn { padding: 2px 7px; font-size: 11px; }
.ec-bimg { flex: none; padding: 8px; background: radial-gradient(ellipse at 50% 70%, #3a3a26 0%, #1a1611 75%); border: 1px solid var(--edge); border-radius: 4px; }
.ec-stats { border-collapse: collapse; width: 100%; font-size: 13px; }
.ec-stats th { text-align: left; font-weight: normal; color: var(--muted); padding: 3px 12px 3px 0; white-space: nowrap; vertical-align: top; width: 1%; }
.ec-stats td { padding: 3px 0; border-bottom: 1px solid #3a3226; }

/* tabele */
.ec-tablewrap { overflow-x: auto; max-width: 100%; margin: 6px 0; }
.ec-table { border-collapse: collapse; font-size: 12.5px; min-width: 100%; }
.ec-table th { color: var(--gold); font-weight: normal; text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--edge); background: #241e16; position: sticky; top: 0; white-space: nowrap; }
.ec-table td { padding: 3px 6px; border-bottom: 1px solid #3a3226; white-space: nowrap; }
.ec-table tbody tr:hover td { background: #ffffff08; }
.ec-table small { color: var(--muted); }
.ec-table.ec-narrow { min-width: 0; }
.ec-sortable { cursor: pointer; }
.ec-sortable:hover, .ec-sortable.on { color: #ffe08a; text-decoration: underline; }
.ec-mx td { text-align: center; }
.ec-mx td:first-child { text-align: left; }
.ec-vert { vertical-align: bottom; height: 120px; padding: 4px 2px !important; }
.ec-vert span { writing-mode: vertical-rl; transform: rotate(180deg); display: inline-block; white-space: nowrap; font-size: 12px; }
.ec-eff td { font-size: 11.5px; min-width: 30px; }
.ec-eff td.ec-pos { background: #4a7a3a40; }
.ec-eff td.ec-neg { background: #8a3a3040; }
.ec-slots td { white-space: normal; vertical-align: top; min-width: 150px; }
.ec-slots td small { display: block; font-size: 11px; margin-top: 2px; }
.ec-slots th { position: static; }
.ec-keys { border-collapse: collapse; font-size: 13px; }
.ec-keys td { padding: 3px 10px 3px 0; vertical-align: top; }
.ec-keys td:first-child { white-space: nowrap; }

/* drzewo technologii */
.ec-tree { margin: 14px 0; }
.ec-tree-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ec-tree-col { background: #1d1812; border: 1px solid #3a3226; border-radius: 4px; padding: 4px; min-height: 40px; }
.ec-tree-age { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; text-align: center; margin-bottom: 4px; }
.ec-tcard { display: flex; gap: 6px; align-items: center; padding: 4px; margin: 3px 0; border: 1px solid #4a3e2c; border-radius: 3px; background: linear-gradient(#3a3022, #2a231a); cursor: pointer; color: var(--text); text-decoration: none; }
.ec-tcard:hover { border-color: var(--gold); }
.ec-tcard span { display: flex; flex-direction: column; min-width: 0; font-size: 12px; line-height: 1.3; }
.ec-tcard b { font-weight: normal; color: var(--gold); }
.ec-tcard em { color: #c9b98f; font-size: 11px; }
.ec-tcard small { color: var(--muted); font-size: 11px; }
.ec-guide p { margin: 0 0 10px; }

/* przycisk "?" w panelu zaznaczenia */
#selPanel { position: relative; }
.ency-q { position: absolute; left: 14px; top: 10px; width: 20px; height: 20px; padding: 0; border-radius: 50%; z-index: 2;
  background: linear-gradient(#6d5a3a, #3d3220); border: 1px solid var(--gold); color: var(--gold); font: bold 13px Georgia, serif; line-height: 18px; cursor: pointer; opacity: 0.85; }
.ency-q:hover { opacity: 1; color: #fff; }

/* ---------- małe okna ---------- */
@media (max-width: 980px) {
  .ency-body { grid-template-columns: 120px 190px minmax(0, 1fr); }
  .ec-tree-cols { grid-template-columns: 1fr; }
}
@media (max-width: 760px), (max-height: 520px) and (max-width: 1100px) {
  .ency-box { width: calc(100vw / var(--ui-scale, 1)); height: calc(100vh / var(--ui-scale, 1)); border-radius: 0; border-width: 0; }
  .ency-body { display: flex; flex-direction: column; }
  .ency-cats { flex-direction: row; flex: none; overflow-x: auto; overflow-y: hidden; border-right: 0; border-bottom: 1px solid var(--edge); padding: 4px; }
  .ency-cat { flex: none; padding: 4px 6px; }
  .ency-cat canvas { display: none; }
  .ency-list { flex: none; max-height: 28%; border-right: 0; border-bottom: 1px solid var(--edge); }
  .ency-page { flex: 1; min-height: 0; padding: 10px 12px 20px; }
  .ency-title { font-size: 16px; letter-spacing: 1px; }
  .ec-cols { grid-template-columns: 1fr; }
  .ec-preview { width: 100%; }
}
