/* =====================================================================
   app.css — Buku interaktif "Petualangan Bidak Catur"
   ===================================================================== */
:root {
  --ink: #2b2118;
  --soft: #6b5647;
  --brand: #8B4513;
  --brand2: #C1743B;
  --sand: #FBF5EA;
  --line: #E2CDB0;
  --paper: #ffffff;
  --bg: #EFE6D8;
  --lt: #F2E0C0;
  --dk: #B58863;
  --green: #2E7D32;
  --red: #C62828;
  --blue: #1565C0;
  --topbar-h: 58px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Charter", Georgia, "Times New Roman", serif;
  font-size: 16px;
  line-height: 1.6;
}

button, input, select { font-family: inherit; }

/* ------------------------------------------------------------- topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  background: linear-gradient(135deg, #7A3D11, #A85D24);
  color: #FFF6E9;
  box-shadow: 0 2px 12px rgba(0, 0, 0, .18);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { font-size: 27px; line-height: 1; }
.brand-txt { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-txt b { font-family: "Trebuchet MS", system-ui, sans-serif; font-size: 15px; }
.brand-txt small { font-size: 11px; opacity: .8; }

.modes { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.modes button {
  background: rgba(255, 255, 255, .13);
  border: 1px solid rgba(255, 255, 255, .28);
  color: #FFF6E9;
  border-radius: 20px;
  padding: 7px 14px;
  cursor: pointer;
  font-size: 13.5px;
  font-family: "Trebuchet MS", system-ui, sans-serif;
  transition: background .15s;
}
.modes button:hover { background: rgba(255, 255, 255, .24); }
.modes button.active { background: #FFF6E9; color: #7A3D11; font-weight: bold; }

.icon-btn {
  background: none; border: 0; color: #FFF6E9;
  font-size: 22px; cursor: pointer; display: none; padding: 4px 6px;
}

/* -------------------------------------------------------------- layout */
.layout { display: flex; align-items: flex-start; }

#sidebar {
  width: 288px;
  flex: 0 0 288px;
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  background: #F7EFE2;
  border-right: 1px solid var(--line);
  padding: 14px 10px 40px;
}
#sidebar.hidden { display: none; }
.side-head {
  font-family: "Trebuchet MS", system-ui, sans-serif;
  font-weight: bold;
  color: var(--brand);
  font-size: 13px;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin: 0 6px 8px;
}
#tocSearch {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 10px;
  background: #fff;
  font-size: 13px;
}
.toc-item {
  display: block;
  padding: 5px 9px;
  border-radius: 7px;
  color: var(--soft);
  text-decoration: none;
  font-size: 13.5px;
  line-height: 1.35;
}
.toc-item:hover { background: #EFE2CE; }
.toc-item.part {
  font-family: "Trebuchet MS", system-ui, sans-serif;
  font-weight: bold;
  color: #fff;
  background: var(--brand2);
  margin: 12px 0 5px;
  font-size: 12.5px;
  letter-spacing: .03em;
}
.toc-item.active { background: var(--brand); color: #fff; }

#main { flex: 1 1 auto; min-width: 0; padding: 22px 26px 60px; }
.mode { display: none; }
.mode.active { display: block; }

/* -------------------------------------------------------------- reader */
.reader {
  background: var(--paper);
  border-radius: 12px;
  padding: 34px 42px 40px;
  max-width: 780px;
  margin: 0 auto;
  box-shadow: 0 4px 20px rgba(0, 0, 0, .07);
}
.reader h1 {
  font-family: "Trebuchet MS", system-ui, sans-serif;
  color: var(--brand);
  font-size: 26px;
  border-bottom: 3px solid var(--brand2);
  padding-bottom: 7px;
  margin-top: 0;
}
.reader h1.part-title {
  background: linear-gradient(135deg, #8B4513, #C1743B);
  color: #fff;
  border: 0;
  border-radius: 12px;
  padding: 24px 18px;
  text-align: center;
  letter-spacing: .05em;
}
.reader h1.part-title span { display: block; font-size: 16px; font-weight: 400; margin-top: 8px; }
.reader h2 {
  font-family: "Trebuchet MS", system-ui, sans-serif;
  color: var(--brand);
  font-size: 20px;
  border-left: 5px solid var(--brand2);
  padding-left: 11px;
  margin-top: 1.7em;
}
.reader h3 { font-family: "Trebuchet MS", system-ui, sans-serif; color: #A0522D; font-size: 17px; }
.reader h4 { font-family: "Trebuchet MS", system-ui, sans-serif; color: var(--soft); font-size: 15px; }
.reader strong { color: #7a3d0e; }
.reader code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: .87em;
  background: #F3E7D5;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  white-space: nowrap;
}
.reader table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 1em 0; }
.reader th, .reader td { border: 1px solid var(--line); padding: 6px 9px; text-align: left; }
.reader th { background: #F0E0C8; color: #7a3d0e; font-family: "Trebuchet MS", sans-serif; }
.reader tr:nth-child(even) td { background: #FDF8F0; }
.reader .cover { display: none; }
.reader .pagebreak { height: 0; }

.bfig { margin: 1.3em auto; text-align: center; position: relative; }
.bfig svg.cb { display: block; margin: 0 auto; max-width: 100%; height: auto; }
.bfig figcaption { font-size: 13px; color: var(--soft); margin-top: 6px; line-height: 1.4; }
.bfig figcaption b { color: var(--brand); }
.bcols { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.mover {
  display: inline-block; font-size: 12px; padding: 2px 10px;
  border-radius: 11px; margin-top: 5px;
  font-family: "Trebuchet MS", sans-serif;
}
.mover-w { background: #FFF6E0; border: 1px solid #D8B15E; color: #7a5a11; }
.mover-b { background: #EDE6DD; border: 1px solid #8b7355; color: #4a3928; }

.try-btn {
  display: block; margin: 6px auto 0;
  background: #fff; border: 1px solid var(--brand2); color: var(--brand);
  border-radius: 16px; padding: 3px 12px; font-size: 12px; cursor: pointer;
  font-family: "Trebuchet MS", sans-serif;
}
.try-btn:hover { background: var(--brand2); color: #fff; }

.callout {
  border-radius: 10px; padding: 13px 16px 6px;
  margin: 1.3em 0; border: 1px solid var(--line); background: var(--sand);
}
.co-head {
  font-family: "Trebuchet MS", system-ui, sans-serif;
  font-weight: bold; margin-bottom: 6px; color: var(--brand); font-size: 15px;
}
.co-ico { vertical-align: -2px; margin-right: 5px; }
.co-ayah { background: #FFF3E0; border-color: #F0C08A; }
.co-ayah .co-head { color: #B45309; }
.co-tip { background: #E9F6EC; border-color: #A8D8B4; }
.co-tip .co-head { color: var(--green); }
.co-warn { background: #FDECEA; border-color: #F3B6B1; }
.co-warn .co-head { color: var(--red); }
.co-cerita { background: #F1ECFB; border-color: #C9BDE8; }
.co-cerita .co-head { color: #5B3FA8; }
.co-fakta { background: #E8F2FD; border-color: #B3D4F5; }
.co-fakta .co-head { color: var(--blue); }
.co-latih { background: #FFF9E0; border-color: #EBD489; }
.co-latih .co-head { color: #9A7B0A; }
.co-ingat { background: #EFEAE3; border-color: #CBB79E; }

.pager {
  max-width: 780px; margin: 18px auto 0;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
#secLabel { font-size: 13px; color: var(--soft); }

/* ------------------------------------------------------------ trainer */
.trainer {
  display: grid;
  grid-template-columns: minmax(280px, 440px) 1fr;
  gap: 26px;
  align-items: start;
  max-width: 1080px;
  margin: 0 auto;
}
.tr-left, .tr-right {
  background: var(--paper);
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, .07);
}
.tr-head { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.chip {
  font-family: "Trebuchet MS", sans-serif; font-size: 12px;
  background: #F3E7D5; border: 1px solid var(--line);
  border-radius: 12px; padding: 2px 11px; color: var(--soft);
}
.chip-dark { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: bold; }

.tr-right h2 {
  font-family: "Trebuchet MS", system-ui, sans-serif;
  color: var(--brand); margin: 0 0 6px; font-size: 20px;
}
.muted { color: var(--soft); font-size: 14px; }

.feedback { margin: 12px 0; padding: 0; font-size: 14.5px; border-radius: 9px; }
.feedback.fb-ok, .feedback.fb-bad, .feedback.fb-done, .feedback.fb-hint {
  padding: 10px 13px;
}
.fb-ok { background: #E9F6EC; border: 1px solid #A8D8B4; color: #205C25; }
.fb-bad { background: #FDECEA; border: 1px solid #F3B6B1; color: #8E2019; }
.fb-done { background: #FFF6E0; border: 1px solid #D8B15E; color: #6F4E06; }
.fb-hint { background: #E8F2FD; border: 1px solid #B3D4F5; color: #0F4C87; }

.movelist { display: flex; flex-wrap: wrap; gap: 5px; margin: 10px 0; }
.movelist.tall { max-height: 220px; overflow-y: auto; align-content: flex-start; }
.mv-chip {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px; background: #F3E7D5; border: 1px solid var(--line);
  border-radius: 5px; padding: 2px 7px;
}
.mv-chip.reply { background: #EDE6DD; color: #4a3928; }

.tr-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.btn {
  background: var(--brand); color: #fff; border: 0; border-radius: 20px;
  padding: 9px 18px; cursor: pointer; font-size: 14px;
  font-family: "Trebuchet MS", system-ui, sans-serif;
}
.btn:hover { background: #6f370f; }
.btn.ghost { background: #fff; color: var(--brand); border: 1px solid var(--brand2); }
.btn.ghost:hover { background: #F3E7D5; }

.level-picker { margin: 12px 0 6px; font-size: 14px; color: var(--soft); }
.level-picker select {
  width: 100%; margin-top: 5px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 14px;
}
.score-strip {
  display: flex; gap: 16px; flex-wrap: wrap;
  font-size: 13px; color: var(--soft);
  border-top: 1px solid var(--line); padding-top: 10px; margin-top: 8px;
}
.score-strip b { color: var(--brand); font-size: 15px; }

.fen-label { display: block; font-size: 13px; color: var(--soft); margin-top: 10px; }
.fen-row { display: flex; gap: 7px; margin-top: 5px; }
.fen-row input {
  flex: 1 1 auto; min-width: 0; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px;
  font-family: ui-monospace, Menlo, monospace; font-size: 12px;
}

.mover-line { margin-top: 10px; text-align: center; }
.mv {
  display: inline-block; font-family: "Trebuchet MS", sans-serif;
  font-size: 13px; padding: 3px 12px; border-radius: 12px;
}
.mv-w { background: #FFF6E0; border: 1px solid #D8B15E; color: #7a5a11; }
.mv-b { background: #EDE6DD; border: 1px solid #8b7355; color: #4a3928; }
.mv-chk { background: #FDECEA; border: 1px solid #F3B6B1; color: #8E2019; font-weight: bold; }

/* --------------------------------------------------------- papan klik */
/* --cbd = tebal bingkai papan, --cco = lebar jalur koordinat.
   Keduanya dipakai bersama supaya huruf a–h dan angka 1–8 sejajar persis
   dengan petaknya, bukan dengan bingkai luar. */
.cboard { position: relative; padding: 0 18px 18px 0; --cbd: 3px; --cco: 18px; }
.cboard .grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  border: var(--cbd) solid #5A3A22;
  border-radius: 3px;
  overflow: hidden;
  width: 100%;
}
/* Setiap petak dipaksa persegi lewat padding-top:100% — persentase padding
   selalu dihitung dari LEBAR, jadi tinggi petak pasti sama dengan lebarnya.
   Cara ini tidak bergantung pada aspect-ratio maupun tinggi baris grid, yang
   sebelumnya membuat baris meregang mengikuti isinya dan papan jadi lonjong. */
.cboard .sq {
  position: relative;
  cursor: pointer;
  height: 0;
  padding-top: 100%;
  min-width: 0;
}
.cboard .sq.lt { background: var(--lt); }
.cboard .sq.dk { background: var(--dk); }
.cboard .sq.sel { box-shadow: inset 0 0 0 4px #F7D774; }
.cboard .sq.mk-hint { box-shadow: inset 0 0 0 4px #8FC5F5; }
.cboard .pc {
  position: absolute; inset: 0;
  width: 100%; height: 100%; display: block; pointer-events: none;
}
.cboard .dot { display: none; }
.cboard .sq.tgt .dot {
  display: block; position: absolute; inset: 0; margin: auto;
  width: 26%; height: 26%; border-radius: 50%;
  background: rgba(46, 125, 50, .55); pointer-events: none;
}
.cboard .sq.tgt:has(.pc) .dot {
  width: 100%; height: 100%; border-radius: 0; background: none;
  box-shadow: inset 0 0 0 5px rgba(198, 40, 40, .6);
}
.cboard .coords {
  position: absolute; display: flex;
  font-family: "Trebuchet MS", sans-serif; font-size: 11px;
  font-weight: bold; color: #6B4A2F;
}
.cboard .cf {
  left: var(--cbd); right: calc(var(--cco) + var(--cbd));
  bottom: 0; height: var(--cco);
}
.cboard .cf span {
  flex: 1 1 0; display: flex; align-items: center; justify-content: center;
}
.cboard .cr {
  top: var(--cbd); bottom: calc(var(--cco) + var(--cbd));
  right: 0; width: var(--cco); flex-direction: column;
}
.cboard .cr span {
  flex: 1 1 0; display: flex; align-items: center; justify-content: center;
}

/* ------------------------------------------------------------ kemajuan */
#mode-maju h1 {
  font-family: "Trebuchet MS", system-ui, sans-serif;
  color: var(--brand); border-bottom: 3px solid var(--brand2); padding-bottom: 7px;
}
#mode-maju h2 { font-family: "Trebuchet MS", system-ui, sans-serif; color: var(--brand); font-size: 19px; }
.prog-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(228px, 1fr));
  gap: 13px; margin: 18px 0 30px;
}
.prog-card {
  background: var(--paper); border-radius: 11px; padding: 14px 16px;
  box-shadow: 0 3px 14px rgba(0, 0, 0, .07);
}
.pc-title { font-family: "Trebuchet MS", sans-serif; font-weight: bold; color: var(--brand); }
.pc-sub { font-size: 12.5px; color: var(--soft); min-height: 2.4em; line-height: 1.25; }
.bar { height: 9px; background: #EFE2CE; border-radius: 5px; overflow: hidden; margin: 9px 0 6px; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, #C1743B, #2E7D32); }
.pc-num { font-size: 12px; color: var(--soft); }
.read-list { display: flex; flex-wrap: wrap; gap: 6px; }
.read-chip {
  font-size: 12.5px; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; padding: 3px 11px; color: var(--soft);
}
.read-chip.on { background: var(--green); border-color: var(--green); color: #fff; }

/* ---------------------------------------------------------------- footer */
.sitefoot {
  background: #4A2A10;
  color: #E8D9C4;
  margin-top: 40px;
  padding: 22px 26px 26px;
}
.foot-in {
  max-width: 1080px; margin: 0 auto;
  display: flex; flex-wrap: wrap; gap: 18px;
  align-items: center; justify-content: space-between;
}
.foot-brand { display: flex; align-items: center; gap: 12px; }
.foot-mark { font-size: 30px; line-height: 1; color: #E0A96D; }
.foot-brand b {
  font-family: "Trebuchet MS", system-ui, sans-serif;
  font-size: 15px; color: #FFF6E9;
}
.foot-brand small { font-size: 12px; opacity: .72; }
.foot-meta { text-align: right; font-size: 13px; }
.foot-meta p { margin: 0 0 3px; }
.foot-meta b { color: #FFF6E9; }
.foot-meta .tiny { font-size: 11px; opacity: .6; line-height: 1.45; max-width: 380px; }

/* --------------------------------------------------------------- kecil */
@media (max-width: 980px) {
  .trainer { grid-template-columns: 1fr; }
  .reader { padding: 22px 20px 28px; }
  .icon-btn { display: block; }
  #sidebar {
    position: fixed; left: 0; top: var(--topbar-h); z-index: 40;
    transform: translateX(-100%); transition: transform .2s;
    box-shadow: 4px 0 20px rgba(0, 0, 0, .18);
  }
  #sidebar.open { transform: none; }
  .brand-txt small { display: none; }
  .modes button { padding: 6px 10px; font-size: 12.5px; }
  #main { padding: 16px 12px 50px; }
  .foot-in { flex-direction: column; align-items: flex-start; }
  .foot-meta { text-align: left; }
}
