/* ============================================================
   Widgets Interaktif — style Duolingo (chunky, cerah, playful)
   ============================================================ */
.widget {
  display: block;
  margin: 20px 0;
  padding: 18px;
  border: 3px solid #e5e7eb;
  border-radius: 20px;
  background: #ffffff;
  box-shadow: 0 4px 0 #e5e7eb;
}

/* panggung */
.w-stage { margin-bottom: 14px; }

/* kotak narasi */
.w-narasi {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: #f0f9ff;
  border: 2px solid #bae6fd;
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.5;
  color: #0c4a6e;
  min-height: 24px;
}
.w-narasi-icon { font-size: 18px; flex: 0 0 auto; }
.w-narasi-text b { color: #0369a1; }

/* kontrol tombol chunky 3D */
.w-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}
.w-btn {
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  background: #58cc02;
  border: none;
  border-radius: 14px;
  padding: 12px 18px;
  cursor: pointer;
  box-shadow: 0 4px 0 #46a302;
  transition: transform .06s ease, box-shadow .06s ease, background .15s;
  -webkit-tap-highlight-color: transparent;
}
.w-btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 0 0 #46a302; }
.w-btn-main { background: #1cb0f6; box-shadow: 0 4px 0 #1890c9; }
.w-btn-main:active:not(:disabled) { box-shadow: 0 0 0 #1890c9; }
.w-btn-ghost { background: #fff; color: #64748b; box-shadow: 0 4px 0 #e2e8f0; border: 2px solid #e2e8f0; }
.w-btn-ghost:active:not(:disabled) { box-shadow: 0 0 0 #e2e8f0; }
.w-btn:disabled { opacity: .45; cursor: not-allowed; }
.w-progress { margin-left: auto; font-weight: 800; color: #94a3b8; font-size: 14px; }

/* ---------- Coulomb Lab ---------- */
.cl-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px 16px;
  margin-bottom: 12px;
}
.cl-field { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: #475569; font-weight: 700; }
.cl-flabel b { color: #0f172a; }
.cl-range { width: 100%; accent-color: #1cb0f6; height: 22px; }

.cl-scene { text-align: center; background: #fafbfc; border-radius: 14px; padding: 6px; }
.cl-svg { width: 100%; max-width: 420px; height: auto; }
.cl-q1, .cl-q2 { transition: fill .2s; stroke: rgba(0,0,0,.12); stroke-width: 2; }
.cl-q1t, .cl-q2t { fill: #fff; font-weight: 800; font-size: 13px; }
.cl-rlbl { fill: #64748b; font-size: 12px; font-weight: 700; }
.cl-flbl1, .cl-flbl2 { fill: #e11d48; font-size: 14px; font-weight: 800; }
.cl-blink { animation: cl-blink .35s ease 2; }
@keyframes cl-blink { 50% { filter: brightness(1.6); r: 22px; } }

.cl-formula {
  margin-top: 12px;
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  color: #334155;
  font-family: "Georgia", serif;
}
.cl-fpart { padding: 2px 6px; border-radius: 8px; transition: background .2s, color .2s; }
.cl-fpart.hot { background: #fde68a; color: #92400e; }
.cl-frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; }
.cl-fbar { height: 2px; background: #334155; margin: 2px 0; }
.cl-result { color: #16a34a; margin-left: 8px; }

@media (max-width: 480px) {
  .cl-formula { font-size: 18px; }
  .widget { padding: 14px; }
}

/* ---------- Sorting Visualizer ---------- */
.sv-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 12px; font-weight: 700; color: #475569; font-size: 14px; }
.sv-algo { font-family: inherit; font-weight: 700; padding: 6px 10px; border: 2px solid #e2e8f0; border-radius: 10px; background: #fff; }
.sv-stats { margin-left: auto; color: #64748b; }
.sv-stats .sv-cmp, .sv-stats .sv-swp { font-weight: 800; color: #1cb0f6; }
.sv-bars { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding: 8px; background: #fafbfc; border-radius: 14px; }
.sv-bar {
  flex: 1; min-width: 0;
  background: #c7d2fe; border-radius: 8px 8px 0 0;
  display: flex; align-items: flex-start; justify-content: center;
  transition: background .2s, height .35s cubic-bezier(.34,1.56,.64,1);
  position: relative;
}
.sv-bar.cmp { background: #fbbf24; }
.sv-bar.ok { background: #58cc02; }
.sv-num { font-size: 12px; font-weight: 800; color: #1e293b; margin-top: 4px; }

/* ---------- Binary Search ---------- */
.bs-head { font-weight: 700; color: #475569; margin-bottom: 12px; font-size: 14px; }
.bs-target { width: 60px; font-family: inherit; font-weight: 800; padding: 6px 8px; border: 2px solid #e2e8f0; border-radius: 10px; text-align: center; }
.bs-cells { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; background: #fafbfc; border-radius: 14px; justify-content: center; }
.bs-cell {
  width: 38px; height: 38px; display: flex; align-items: center; justify-content: center;
  background: #e0f2fe; border: 2px solid #bae6fd; border-radius: 10px;
  font-weight: 800; color: #0369a1; font-size: 14px;
  transition: opacity .3s, background .2s, transform .2s;
}
.bs-cell.out { opacity: .2; }
.bs-cell.mid { background: #fbbf24; border-color: #f59e0b; color: #78350f; transform: translateY(-4px); }
.bs-cell.hit { background: #58cc02; border-color: #46a302; color: #fff; }

/* ---------- SQL Playground ---------- */
.sql-soal { padding: 12px 14px; background: #fef9c3; border: 2px solid #fde047; border-radius: 12px; margin-bottom: 12px; font-size: 14px; color: #713f12; }
.sql-editor {
  width: 100%; box-sizing: border-box; min-height: 84px; resize: vertical;
  font-family: "Menlo","Consolas",monospace; font-size: 14px; line-height: 1.5;
  padding: 12px 14px; border: 2px solid #cbd5e1; border-radius: 12px;
  background: #0f172a; color: #e2e8f0; margin-bottom: 12px;
}
.sql-editor:focus { outline: none; border-color: #1cb0f6; }
.sql-out { margin-top: 12px; overflow-x: auto; }
.sql-hint { color: #94a3b8; font-size: 14px; padding: 8px; }
.sql-err { color: #b91c1c; background: #fef2f2; border: 2px solid #fecaca; border-radius: 10px; padding: 10px 14px; font-family: monospace; font-size: 13px; }
.sql-ok { color: #166534; background: #dcfce7; border: 2px solid #86efac; border-radius: 10px; padding: 10px 14px; margin-bottom: 10px; }
.sql-warn { color: #92400e; background: #fef3c7; border: 2px solid #fcd34d; border-radius: 10px; padding: 10px 14px; margin-bottom: 10px; }
.sql-tbl { border-collapse: collapse; width: 100%; font-size: 14px; }
.sql-tbl th { background: #1cb0f6; color: #fff; padding: 8px 12px; text-align: left; font-weight: 800; }
.sql-tbl td { padding: 7px 12px; border-bottom: 1px solid #e2e8f0; }
.sql-tbl tr:nth-child(even) td { background: #f8fafc; }
.sql-count { margin-top: 6px; font-size: 12px; color: #94a3b8; font-weight: 700; }

/* ---------- Subnet Simulator ---------- */
.sn-head { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; margin-bottom: 14px; font-weight: 700; color: #475569; font-size: 14px; }
.sn-ip { font-family: monospace; font-weight: 800; padding: 6px 10px; border: 2px solid #e2e8f0; border-radius: 10px; width: 130px; }
.sn-cidrwrap { display: flex; align-items: center; gap: 8px; }
.sn-cidr { accent-color: #1cb0f6; }
.sn-cidrval { color: #1cb0f6; font-size: 16px; }
.sn-bits { display: flex; flex-wrap: wrap; gap: 3px; padding: 10px; background: #fafbfc; border-radius: 12px; justify-content: center; }
.sn-bit {
  width: 20px; height: 26px; display: flex; align-items: center; justify-content: center;
  font-family: monospace; font-weight: 800; font-size: 13px; border-radius: 5px;
  transition: background .25s, color .25s;
}
.sn-bit.net { background: #1cb0f6; color: #fff; }
.sn-bit.host { background: #e2e8f0; color: #64748b; }
.sn-bit.sn-oct { margin-left: 8px; }
.sn-legend { margin: 10px 0; font-size: 13px; font-weight: 700; display: flex; gap: 16px; }
.sn-lg.net { color: #1cb0f6; }
.sn-lg.host { color: #94a3b8; }
.sn-panel { display: grid; gap: 6px; }
.sn-row { display: flex; justify-content: space-between; padding: 8px 12px; background: #f8fafc; border-radius: 10px; font-size: 14px; }
.sn-row span { color: #64748b; font-weight: 600; }
.sn-row b { color: #0f172a; font-family: monospace; }

/* ---------- OSI Journey ---------- */
.osi-input { margin-bottom: 12px; }
.osi-msg { width: 100%; box-sizing: border-box; font-weight: 700; padding: 10px 14px; border: 2px solid #e2e8f0; border-radius: 12px; font-size: 15px; }
.osi-stack { display: flex; flex-direction: column; gap: 6px; }
.osi-layer {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 12px;
  background: #f1f5f9; border: 2px solid transparent;
  opacity: .5; transition: all .3s;
}
.osi-layer.active { opacity: 1; border-color: var(--lc); background: color-mix(in srgb, var(--lc) 10%, white); }
.osi-layer.done { opacity: 1; }
.osi-num { font-weight: 800; color: #fff; background: var(--lc); border-radius: 8px; padding: 3px 8px; font-size: 13px; flex: 0 0 auto; }
.osi-name { font-weight: 800; color: #334155; flex: 0 0 110px; font-size: 14px; }
.osi-pkt { font-family: monospace; font-size: 13px; color: #475569; opacity: 0; transform: translateX(-8px); transition: all .3s; }
.osi-pkt.show { opacity: 1; transform: translateX(0); }
@media (max-width: 480px) {
  .osi-name { flex-basis: 80px; font-size: 12px; }
  .sn-bit { width: 17px; }
}
