/* ==========================================================================
   trimSmithing.css — Smithing Calculator (smithing/, K1e): pengalih mode,
   Smithing Table bergaya GUI Minecraft, stepper, pohon bahan, daftar
   belanja. Token tema saja; ikon item tajam (pixelated).
   ========================================================================== */

/* ── Pengalih mode ───────────────────────────────────────────────────── */
.ks-modebar { margin: 0 0 14px; }
.ks-modebar__seg { width: 100%; max-width: 520px; }
.ks-modebar__seg .kit-seg__btn { flex: 1 1 0; min-width: 0; }
/* HP ~320px: label panjang ("Smithing Calculator") boleh turun baris,
   jangan meluber keluar segmen. */
@media (max-width: 360px) { .ks-modebar__seg .kit-seg__btn { white-space: normal; line-height: 1.2; padding-left: 6px; padding-right: 6px; } }
.ks-host[hidden], .kt-trims[hidden] { display: none !important; }
.ks [hidden] { display: none !important; }
.ks .kit-col--view { position: static; }

/* Urutan kartu di HP (kolom dilebur). */
.ks-table { order: 1; }
.ks-inputs { order: 2; }
.ks-owned { order: 3; }
.ks-trim { order: 4; }
.ks-shop { order: 5; }
.ks-tree { order: 6; }

.ks-icon { flex: 0 0 auto; image-rendering: pixelated; image-rendering: crisp-edges; }
.ks-group__title {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.ks-link {
  align-self: flex-start;
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.ks-link:hover { color: var(--text-primary); }
.ks-link:disabled { opacity: 0.45; cursor: default; }
.ks-link:focus-visible { outline: 2px solid var(--focus-outline); outline-offset: 2px; }
.ks-btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; }

/* ── Smithing Table ──────────────────────────────────────────────────── */
.ks-entries { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; scrollbar-width: thin; }
.ks-entry {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 4px 10px 4px 6px;
  border: 1px solid var(--wb-rule);
  border-radius: var(--radius-sm);
  background: var(--bg-surface-2);
  color: var(--text-secondary);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.ks-entry:hover { color: var(--text-primary); border-color: var(--border-strong); }
.ks-entry.is-active { color: var(--text-primary); border-color: var(--accent); background: var(--bg-active); }
.ks-entry:focus-visible { outline: 2px solid var(--focus-outline); outline-offset: 1px; }
.ks-entry__qty { color: var(--text-muted); font-weight: 700; }

.ks-gui {
  position: relative;
  max-width: 420px;
  margin: 0 auto;
  padding: 12px 16px 14px;
  background: var(--mc-gui-panel);
  border: 2px solid var(--mc-gui-edge);
  border-radius: 6px;
  box-shadow: inset 3px 3px 0 var(--mc-gui-light), inset -3px -3px 0 var(--mc-gui-shade);
}
.ks-gui__title { display: block; margin-bottom: 10px; font-size: 13px; font-weight: 700; color: var(--mc-slot-dark); }
.ks-gui__row { display: flex; align-items: flex-start; justify-content: center; gap: 6px; }
.ks-gui__cell { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.ks-gui__label { font-size: 10.5px; font-weight: 600; color: var(--mc-slot-dark); }
.ks-gui__arrow { display: flex; align-items: center; height: 44px; padding: 0 4px; color: var(--mc-gui-shade); }
.ks-slot {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: var(--mc-slot);
  box-shadow: inset 2px 2px 0 var(--mc-slot-dark), inset -2px -2px 0 var(--mc-gui-light);
}
.ks-slot--result { width: 52px; height: 52px; margin-top: -4px; }
.ks-slot .ks-icon { width: 32px; height: 32px; }
.ks-slot__count {
  position: absolute;
  right: 2px;
  bottom: 0;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--mc-gui-light);
  text-shadow: 1px 1px 0 var(--mc-slot-dark);
}
.ks-gui.is-empty .ks-slot { opacity: 0.75; }
.ks-gui__caption { max-width: 420px; margin: 10px auto 0; font-size: 12px; line-height: 1.5; color: var(--text-secondary); text-align: center; }

/* ── Stepper ─────────────────────────────────────────────────────────── */
.ks-step {
  display: inline-flex;
  align-items: stretch;
  flex: 0 0 auto;
  border: 1px solid var(--wb-rule);
  border-radius: var(--radius-sm);
  background: var(--bg-inset);
  overflow: hidden;
}
.ks-step__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  min-height: 36px;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  touch-action: manipulation;
}
.ks-step__btn:hover:not(:disabled) { color: var(--text-primary); background: var(--bg-hover); }
.ks-step__btn:disabled { opacity: 0.35; cursor: default; }
.ks-step__btn:focus-visible { outline: 2px solid var(--focus-outline); outline-offset: -2px; }
.ks-step__input {
  width: 48px;
  padding: 0 2px;
  border: 0;
  border-left: 1px solid var(--wb-rule);
  border-right: 1px solid var(--wb-rule);
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  -moz-appearance: textfield;
}
.ks-step__input::-webkit-outer-spin-button, .ks-step__input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.ks-step__input:focus { outline: 2px solid var(--focus-outline); outline-offset: -2px; }
.ks-step.is-zero .ks-step__input { color: var(--text-muted); font-weight: 500; }

/* ── Mau di-upgrade ──────────────────────────────────────────────────── */
.ks-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.ks-chip {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--wb-rule);
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.ks-chip:hover { color: var(--text-primary); border-color: var(--border-strong); }
.ks-chip:focus-visible { outline: 2px solid var(--focus-outline); outline-offset: 1px; }
.ks-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.ks-rows { display: flex; flex-direction: column; gap: 4px; }
.ks-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 5px 6px 5px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-2);
}
.ks-row.is-on { border-color: rgb(var(--accent-rgb) / 0.45); background: var(--bg-active); }
.ks-row__text { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; line-height: 1.3; }
.ks-row__name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.ks-row__sub { font-size: 11px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* HP ~320px: stepper 120px menyisakan <50px untuk nama ("Chestplate"
   meluber). Perkecil stepper & celah; nama panjang boleh dipenggal. */
@media (max-width: 360px) {
  .ks-row { gap: 6px; padding-left: 8px; }
  .ks-row .ks-step__btn { width: 30px; }
  .ks-row .ks-step__input { width: 38px; }
  .ks-row__name { overflow-wrap: anywhere; }
}

/* ── Sudah punya ─────────────────────────────────────────────────────── */
.ks-owned__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 8px 0 6px; }
.ks-owned__cell {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-2);
}
.ks-owned__head { display: flex; align-items: center; gap: 6px; min-width: 0; }
.ks-owned__label { font-size: 12px; font-weight: 600; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ks-owned__cell .ks-step { align-self: stretch; max-width: 240px; }
.ks-owned__cell .ks-step__input { flex: 1 1 auto; width: auto; min-width: 0; }

/* ── Trim dari viewer ────────────────────────────────────────────────── */
.ks-trim__pieces { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin: 10px 0; }
.ks-trim__chip { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 6px 8px; border-radius: var(--radius-sm); background: var(--bg-surface-2); }
.ks-trim__text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.ks-trim__name { font-size: 12.5px; font-weight: 600; color: var(--text-primary); }
.ks-trim__sub { font-size: 11px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ks-trim__mode { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.ks-trim__seg { width: 100%; }
.ks-trim__seg .kit-seg__btn { flex: 1 1 0; min-width: 0; }
.ks-trim__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 10px; }

/* ── Daftar belanja ──────────────────────────────────────────────────── */
.ks-totals { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.ks-total {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--wb-rule);
  border-radius: var(--radius-sm);
  background: var(--bg-inset);
}
.ks-total__num { font-family: var(--font-display); font-size: 22px; font-weight: 700; line-height: 1; color: var(--text-primary); }
.ks-total__label { display: flex; align-items: center; gap: 5px; min-width: 0; font-size: 11px; color: var(--text-muted); }
.ks-total__label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ks-total.is-zero .ks-total__num { color: var(--text-muted); }
.ks-shop__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.ks-shop__progress { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.ks-shop__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.ks-shop__row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-2);
  cursor: pointer;
}
.ks-shop__box { flex: 0 0 auto; width: 18px; height: 18px; margin: 0; cursor: pointer; }
.ks-shop__text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.ks-shop__name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.ks-shop__note { font-size: 11px; color: var(--text-muted); }
.ks-shop__item.is-done .ks-shop__name { color: var(--text-muted); text-decoration: line-through; }
.ks-shop__item.is-done .ks-icon { opacity: 0.45; }

/* ── Rantai bahan ────────────────────────────────────────────────────── */
.ks-tree__body { display: flex; flex-direction: column; gap: 14px; }
.ks-tree__group { display: flex; flex-direction: column; gap: 4px; }
.ks-node__kids { margin-left: 11px; padding-left: 12px; border-left: 1px dashed var(--border-strong); display: flex; flex-direction: column; gap: 2px; }
.ks-node__sum { list-style: none; cursor: pointer; border-radius: var(--radius-sm); }
.ks-node__sum::-webkit-details-marker { display: none; }
.ks-node__sum::before {
  content: "";
  float: left;
  width: 0;
  height: 0;
  margin: 13px 6px 0 2px;
  border-left: 5px solid var(--text-muted);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform var(--duration-fast) var(--ease-standard);
}
details[open] > .ks-node__sum::before { transform: rotate(90deg); }
.ks-node__sum:hover { background: var(--bg-hover); }
.ks-node__sum:focus-visible { outline: 2px solid var(--focus-outline); outline-offset: 1px; }
.ks-node--leaf { padding-left: 15px; }
.ks-node__line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 7px; min-height: 32px; padding: 3px 4px; }
.ks-node__count { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.ks-node__label { font-size: 13px; color: var(--text-primary); }
.ks-node__note { flex-basis: 100%; padding-left: 27px; margin-top: -3px; font-size: 11px; color: var(--text-muted); }
.ks-tag {
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  border: 1px solid var(--wb-rule);
  color: var(--text-secondary);
}
.ks-tag--have { color: var(--accent); border-color: rgb(var(--accent-rgb) / 0.5); }
.ks-tag--find { color: var(--accent-warning); border-color: var(--accent-warning); }
.ks-tag--craft { color: var(--accent-teal); border-color: var(--accent-teal); }
.ks-tag--smelt { color: var(--accent-danger); border-color: var(--accent-danger); }

.kt-cost__calc { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; margin-top: 10px; width: 100%; white-space: normal; text-align: center; line-height: 1.25; }

@media (max-width: 520px) {
  .ks-totals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ks-gui { padding: 10px 10px 12px; }
  .ks-gui__row { gap: 4px; }
  .ks-slot { width: 40px; height: 40px; }
  .ks-slot--result { width: 46px; height: 46px; }
  .ks-gui__arrow { height: 40px; padding: 0 1px; }
  .ks-trim__seg .kit-seg__btn span { font-size: 11.5px; }
}

/* Layar lebar: Smithing Table lebih besar, seperti GUI game. */
@media (min-width: 1000px) {
  .ks-gui { max-width: 480px; padding: 16px 22px 18px; }
  .ks-gui__row { gap: 10px; }
  .ks-slot { width: 56px; height: 56px; }
  .ks-slot--result { width: 64px; height: 64px; }
  .ks-slot .ks-icon { width: 40px; height: 40px; }
  .ks-gui__arrow { height: 56px; }
}

/* Salin daftar & Buka di viewer */
.ks-shop__tools { display: flex; align-items: center; gap: 12px; }
.ks-shop__copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 10px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-surface-2);
  border: 1px solid var(--wb-rule);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.ks-shop__copy:hover { color: var(--text-primary); border-color: var(--border-strong); background: var(--bg-hover); }
.ks-shop__copy:focus-visible { outline: 2px solid var(--focus-outline); outline-offset: 2px; }
